:root {
  --bg: #0a1612;
  --bg-elevated: #12241c;
  --surface: rgba(255, 250, 240, 0.07);
  --surface-strong: rgba(255, 250, 240, 0.11);
  --ink: #fff8ec;
  --ink-soft: #d8cbb3;
  --mist: #8fa89a;
  --label: #7d9588;
  --separator: rgba(232, 196, 120, 0.16);
  --fill: rgba(255, 250, 240, 0.08);
  --fill-strong: rgba(255, 250, 240, 0.16);
  --gold: #f0d18a;
  --gold-bright: #ffe7a8;
  --gold-deep: #c9a04a;
  --jade: #3aa87a;
  --tint: var(--gold-bright);
  --green: #5ee0a0;
  --red: #ff8f7a;
  --zero: #c5b89f;
  --radius: 16px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Cormorant Garamond", "Noto Serif SC", "Songti SC", serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 0 0 env(safe-area-inset-bottom, 36px);
  position: relative;
  overflow-x: hidden;
}

.ambiance {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(1000px 580px at 50% -10%, rgba(255, 231, 168, 0.34), transparent 58%),
    radial-gradient(760px 520px at 108% 28%, rgba(47, 143, 104, 0.42), transparent 55%),
    radial-gradient(640px 460px at -8% 78%, rgba(201, 160, 74, 0.22), transparent 50%),
    radial-gradient(520px 420px at 50% 110%, rgba(94, 224, 160, 0.12), transparent 55%),
    linear-gradient(165deg, #123024 0%, #0a1612 48%, #050d0a 100%);
}

.ambiance::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    conic-gradient(from 120deg at 50% 40%, transparent 0 60%, rgba(232, 196, 120, 0.08), transparent 75%),
    conic-gradient(from 300deg at 40% 70%, transparent 0 55%, rgba(58, 168, 122, 0.08), transparent 72%);
  animation: auroraSpin 22s linear infinite;
  opacity: 0.85;
}

.ambiance::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.48;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at center, #000 12%, transparent 72%);
  animation: gridDrift 22s linear infinite;
}

.spark-field {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255, 231, 168, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 78% 18%, rgba(94, 224, 160, 0.65), transparent),
    radial-gradient(1px 1px at 34% 64%, rgba(255, 248, 236, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 88% 72%, rgba(232, 196, 120, 0.55), transparent),
    radial-gradient(1px 1px at 55% 40%, rgba(255, 231, 168, 0.5), transparent),
    radial-gradient(1px 1px at 22% 82%, rgba(94, 224, 160, 0.45), transparent);
  animation: sparkTwinkle 3.8s ease-in-out infinite;
  opacity: 0.85;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.65;
  animation: orbFloat 10s ease-in-out infinite;
  mix-blend-mode: screen;
}

.orb-a {
  width: 260px;
  height: 260px;
  left: -50px;
  top: 10%;
  background: rgba(58, 168, 122, 0.55);
}

.orb-b {
  width: 320px;
  height: 320px;
  right: -100px;
  top: 34%;
  background: rgba(232, 196, 120, 0.36);
  animation-delay: -4s;
}

.orb-c {
  width: 210px;
  height: 210px;
  left: 28%;
  bottom: 6%;
  background: rgba(94, 224, 160, 0.28);
  animation-delay: -7s;
}

body.fx-boom .ambiance {
  animation: boomFlash 0.7s ease;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

/* —— Nav —— */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 48px;
  padding: 8px 0 4px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(10, 22, 18, 0.72);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid transparent;
}

body[data-view="room"] .top {
  border-bottom-color: var(--separator);
}

.top .brand {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 52vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff8ec, var(--gold-bright) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(232, 196, 120, 0.28));
}

.top .nav-link:first-child { justify-self: start; }
.top #btn-share { justify-self: end; }

body[data-view="home"] .top {
  display: none;
}

.nav-link {
  border: 0;
  background: transparent;
  color: var(--jade);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.nav-link:active { opacity: 0.55; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Home hero —— */
.home {
  padding-top: 56px;
  animation: rise 0.7s ease both;
}

.home-hero {
  position: relative;
  text-align: center;
  margin-bottom: 40px;
  padding: 36px 12px 12px;
  animation: rise 0.75s ease 0.05s both;
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 0 6% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 231, 168, 0.85), transparent);
  box-shadow: 0 0 18px rgba(232, 196, 120, 0.55);
}

.home-hero::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  width: 92px;
  height: 92px;
  transform: translateX(-50%);
  border: 1px solid rgba(232, 196, 120, 0.4);
  border-radius: 50%;
  box-shadow:
    0 0 0 12px rgba(232, 196, 120, 0.04),
    0 0 40px rgba(232, 196, 120, 0.18);
  animation: ringPulse 2.8s ease-in-out infinite;
}

.home-mark {
  position: relative;
  z-index: 1;
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  color: var(--jade);
  margin-bottom: 14px;
  text-shadow: 0 0 20px rgba(58, 168, 122, 0.45);
  animation: markPulse 2.4s ease-in-out infinite;
}

.home-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.9rem, 12vw, 3.55rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1.1;
  background: linear-gradient(120deg, #fffdf5 8%, var(--gold-bright) 28%, #fff 46%, var(--gold) 62%, var(--gold-deep) 88%, #fff8ec 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleShine 3.6s linear infinite;
  filter: drop-shadow(0 10px 28px rgba(201, 160, 74, 0.42));
}

.home-sub {
  position: relative;
  z-index: 1;
  margin: 16px 0 0;
  color: var(--mist);
  font-size: 0.95rem;
  letter-spacing: 0.28em;
}

.home .primary {
  margin-bottom: 22px;
  animation: rise 0.7s ease 0.12s both;
}

#form-join {
  animation: rise 0.7s ease 0.18s both;
}

#host-banner,
.recent {
  animation: rise 0.7s ease 0.24s both;
}

/* —— Surfaces —— */
.group {
  background:
    linear-gradient(165deg, rgba(255, 250, 240, 0.1), rgba(255, 250, 240, 0.04) 55%),
    var(--surface);
  border: 1px solid rgba(232, 196, 120, 0.22);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.cell {
  padding: 13px 16px;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.inline-cell { gap: 10px; }
.inline-cell input { flex: 1; }

input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  padding: 0;
  outline: none;
  letter-spacing: 0.02em;
  caret-color: var(--gold-bright);
}

input::placeholder { color: var(--mist); }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
}

.primary {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 20px;
  padding: 16px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 231, 168, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 236, 190, 0.28), transparent 42%),
    linear-gradient(135deg, #ffe7a8 0%, #e8c478 40%, #c9a04a 75%, #a88432 100%);
  color: #1a1408;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  box-shadow:
    0 0 0 1px rgba(232, 196, 120, 0.2),
    0 12px 36px rgba(201, 160, 74, 0.38),
    0 0 40px rgba(232, 196, 120, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  overflow: hidden;
  animation: goldPulse 2.8s ease-in-out infinite;
}

.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: sheen 3.8s ease-in-out infinite;
  pointer-events: none;
}

.primary:active {
  transform: translateY(1px) scale(0.995);
  filter: brightness(0.96);
}

.text-btn {
  background: transparent;
  color: var(--gold-bright);
  font-size: 16px;
  font-weight: 700;
  padding: 0;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.text-btn:active { opacity: 0.55; }

.ghost-danger {
  background: transparent;
  color: var(--red);
  font-size: 15px;
  padding: 12px 10px;
  border-radius: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.row.actions { margin-top: 4px; }
.grow { flex: 1; }

body.is-viewer .host-only { display: none !important; }

/* —— Scoreboard —— */
.board {
  margin-bottom: 18px;
  min-height: 0;
  animation: rise 0.55s ease both;
}

.board-live {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.board-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--mist);
  font-size: 15px;
  letter-spacing: 0.12em;
  background:
    linear-gradient(160deg, rgba(232, 196, 120, 0.08), transparent 50%),
    var(--surface);
  border: 1px dashed rgba(232, 196, 120, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.score-grid:has(.score-card:only-child) {
  grid-template-columns: 1fr;
}

.score-card.flash .total {
  animation: scorePop 0.55s ease;
}

.score-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 14px 14px;
  min-height: 118px;
  border-radius: 18px;
  border: 1px solid rgba(232, 196, 120, 0.2);
  background:
    linear-gradient(165deg, rgba(255, 250, 240, 0.12), rgba(255, 250, 240, 0.03) 45%),
    rgba(12, 28, 22, 0.72);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  animation: cardIn 0.55s ease both;
  animation-delay: calc(var(--i, 0) * 0.06s);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.score-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% -20%;
  height: 70%;
  background: radial-gradient(circle, rgba(232, 196, 120, 0.16), transparent 65%);
  pointer-events: none;
}

.score-card.pos::before {
  background: radial-gradient(circle, rgba(94, 224, 160, 0.22), transparent 65%);
}

.score-card.neg::before {
  background: radial-gradient(circle, rgba(255, 143, 122, 0.2), transparent 65%);
}

.score-card.rank-1 {
  border-color: rgba(255, 231, 168, 0.7);
  background:
    linear-gradient(165deg, rgba(255, 231, 168, 0.26), rgba(255, 250, 240, 0.03) 50%),
    rgba(16, 32, 24, 0.78);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.36),
    0 0 36px rgba(232, 196, 120, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: cardIn 0.55s ease both, crownGlow 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.06s), 0.55s;
}

.score-card.rank-1::after {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 231, 168, 1), transparent);
  box-shadow: 0 0 16px rgba(255, 231, 168, 0.7);
}

.score-card.rank-2 {
  border-color: rgba(180, 210, 220, 0.35);
}

.score-card.rank-3 {
  border-color: rgba(201, 140, 90, 0.35);
}

.score-card.me {
  border-color: rgba(94, 224, 160, 0.45);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.34),
    0 0 26px rgba(58, 168, 122, 0.25);
}

.score-card.me.rank-1 {
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.36),
    0 0 30px rgba(232, 196, 120, 0.28),
    0 0 22px rgba(58, 168, 122, 0.3);
}

.score-card .rank {
  position: relative;
  z-index: 1;
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--gold);
  opacity: 0.85;
}

.score-card.rank-1 .rank {
  color: var(--gold-bright);
  text-shadow: 0 0 12px rgba(255, 231, 168, 0.45);
}

.score-card .name {
  position: relative;
  z-index: 1;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.score-card.me .name {
  color: var(--gold-bright);
  font-weight: 700;
}

.score-card .you {
  margin-left: 6px;
  font-size: 11px;
  color: var(--jade);
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(58, 168, 122, 0.18);
  border: 1px solid rgba(94, 224, 160, 0.28);
}

.score-card .total {
  position: relative;
  z-index: 1;
  margin-top: auto;
  font-family: var(--display);
  font-size: 2.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--zero);
}

.score-card .total.pos {
  color: var(--green);
  text-shadow:
    0 0 12px rgba(94, 224, 160, 0.55),
    0 0 28px rgba(94, 224, 160, 0.35);
}

.score-card .total.neg {
  color: var(--red);
  text-shadow:
    0 0 12px rgba(255, 143, 122, 0.5),
    0 0 28px rgba(255, 143, 122, 0.28);
}

.score-card.flash {
  animation: cardShake 0.55s ease;
}

.score-card .card-del {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: var(--mist);
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  border: 1px solid var(--separator);
}

.score-card .card-del:active { background: var(--fill-strong); }

/* —— Folds —— */
.group-fold {
  background:
    linear-gradient(165deg, rgba(255, 250, 240, 0.1), rgba(255, 250, 240, 0.04) 55%),
    var(--surface);
  border: 1px solid rgba(232, 196, 120, 0.22);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.group-fold summary {
  list-style: none;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  cursor: pointer;
  user-select: none;
  position: relative;
  text-shadow: 0 0 16px rgba(232, 196, 120, 0.25);
}

.group-fold summary::-webkit-details-marker { display: none; }

.group-fold summary::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid rgba(232, 196, 120, 0.55);
  border-bottom: 2px solid rgba(232, 196, 120, 0.55);
  transform: translateY(-60%) rotate(45deg);
  transition: transform 0.2s ease;
}

.group-fold[open] summary::after {
  transform: translateY(-20%) rotate(225deg);
}

.group-fold .fold-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--separator);
}

.group-fold .fold-body .group {
  margin: 12px 0;
  box-shadow: none;
}

.group-fold .fold-body .primary {
  margin-bottom: 0;
}

.lan-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--jade);
  margin: 10px 0;
  line-height: 1.45;
}

.qr-box {
  width: 168px;
  margin: 10px auto 4px;
  padding: 10px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(232, 196, 120, 0.35);
}

.qr-box img, .qr-box canvas {
  display: block;
  width: 148px !important;
  height: 148px !important;
  margin: 0 auto;
}

/* —— Lists —— */
.list { margin: 0; padding: 0; list-style: none; }

.recent { margin-top: 8px; }

.recent li,
.history li,
.player-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  position: relative;
  min-height: 48px;
}

.recent li + li::before,
.history li + li::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--separator);
}

.recent a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 16px;
  letter-spacing: 0.06em;
}

.recent a code {
  margin-left: 8px;
  color: var(--gold-bright);
  font-size: 14px;
  font-weight: 600;
}

.recent .ghost,
.recent button.ghost {
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 20px;
  padding: 4px 8px;
  cursor: pointer;
}

.sum {
  margin: 8px 4px 12px;
  font-size: 13px;
  color: var(--label);
  text-align: center;
  min-height: 1.2em;
}

.sign-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 12px 0 10px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(232, 196, 120, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.sign-option {
  margin: 0;
  cursor: pointer;
}

.sign-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sign-option span {
  display: block;
  text-align: center;
  padding: 11px 0;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--mist);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.sign-option input:checked + span {
  color: #1a1408;
  background: linear-gradient(135deg, #e8c478, #c9a04a);
  transform: translateY(-1px);
}

.sign-option:nth-child(1) input:checked + span {
  background: linear-gradient(135deg, #7ae0b0, #3aa87a);
  color: #062216;
  box-shadow: 0 6px 18px rgba(58, 168, 122, 0.35);
}

.sign-option:nth-child(2) input:checked + span {
  background: linear-gradient(135deg, #ff9f8c, #e06a58);
  color: #2a0d08;
  box-shadow: 0 6px 18px rgba(224, 106, 88, 0.35);
}

.sign-option:nth-child(3) input:checked + span {
  background: rgba(255, 250, 240, 0.16);
  color: var(--ink-soft);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

#my-score:disabled {
  opacity: 0.35;
}

.pending-list { margin-top: 12px; }

.pending-board {
  margin-bottom: 8px;
  border-color: rgba(232, 196, 120, 0.28);
}

.pending-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  font-size: 16px;
  position: relative;
  color: var(--ink-soft);
}

.pending-row + .pending-row::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(232, 196, 120, 0.28), transparent 85%);
}

.pending-row.me {
  color: var(--gold-bright);
  font-weight: 700;
  background: linear-gradient(90deg, rgba(232, 196, 120, 0.12), transparent 70%);
}

.pending-row.done {
  background: linear-gradient(90deg, rgba(94, 224, 160, 0.06), transparent 65%);
}

.pending-val {
  font-family: var(--display);
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--zero);
}

.pending-val.pos {
  color: var(--green);
  text-shadow: 0 0 14px rgba(94, 224, 160, 0.35);
}

.pending-val.neg {
  color: var(--red);
  text-shadow: 0 0 14px rgba(255, 143, 122, 0.3);
}

.pending-wait {
  color: var(--mist);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px dashed rgba(143, 168, 154, 0.45);
}

.pending-tip {
  margin: 8px 4px 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--mist);
  text-align: center;
  line-height: 1.45;
  letter-spacing: 0.04em;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid transparent;
}

.pending-tip.warn {
  color: var(--red);
  font-weight: 700;
  border-color: rgba(255, 143, 122, 0.35);
  background: rgba(224, 106, 88, 0.1);
  animation: tipPulse 1.4s ease-in-out infinite;
}

.pending-tip.ok {
  color: var(--green);
  font-weight: 700;
  border-color: rgba(94, 224, 160, 0.4);
  background: rgba(58, 168, 122, 0.12);
  box-shadow: 0 0 22px rgba(94, 224, 160, 0.18);
  animation: tipPulse 1.2s ease-in-out infinite;
}

.pending-host-actions {
  margin: 8px 0 4px;
  justify-content: center;
}

.undo-actions {
  margin-top: 8px;
  justify-content: center;
  gap: 16px;
}

.history {
  padding: 0;
}

.history .round-card {
  display: block;
  padding: 14px 16px 12px;
  min-height: 0;
  align-items: stretch;
}

.history .round-card + .round-card::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(232, 196, 120, 0.28), transparent 85%);
}

.history .meta {
  color: var(--jade);
  font-size: 12px;
  margin-bottom: 8px;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.history .round-rows {
  display: grid;
  gap: 2px;
}

.history .round-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 15px;
}

.history .round-row.me {
  background: linear-gradient(90deg, rgba(232, 196, 120, 0.14), transparent 75%);
  color: var(--gold-bright);
  font-weight: 700;
}

.history .round-name .you {
  margin-left: 6px;
  font-size: 11px;
  color: var(--jade);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.history .round-val {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--zero);
}

.history .round-val.pos {
  color: var(--green);
  text-shadow: 0 0 12px rgba(94, 224, 160, 0.28);
}

.history .round-val.neg {
  color: var(--red);
  text-shadow: 0 0 12px rgba(255, 143, 122, 0.24);
}

.history .round-card:first-child {
  background: linear-gradient(180deg, rgba(232, 196, 120, 0.1), transparent 70%);
}

.fold-hint {
  margin: 10px 0 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--mist);
  letter-spacing: 0.04em;
}

.secondary-action {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(232, 196, 120, 0.28);
  background:
    linear-gradient(165deg, rgba(255, 250, 240, 0.1), transparent 60%),
    var(--fill);
  color: var(--gold-bright);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: center;
}

.secondary-action:active {
  background: var(--fill-strong);
}

.host-manage {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--separator);
}

.section { margin: 0; }
.player-list { display: none; }

/* —— Share sheet —— */
.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.share-sheet.open {
  opacity: 1;
  pointer-events: auto;
}

.share-sheet[hidden] {
  display: none !important;
}

.share-sheet.open[hidden] {
  display: flex !important;
}

.share-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(3, 10, 8, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.share-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  max-height: min(92vh, 720px);
  overflow: auto;
  margin: 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  border: 1px solid rgba(232, 196, 120, 0.28);
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.12), transparent 28%),
    linear-gradient(165deg, #163428 0%, #0c1c16 100%);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
  transform: translateY(24px);
  transition: transform 0.28s cubic-bezier(0.16, 0.84, 0.28, 1);
}

.share-sheet.open .share-panel {
  transform: translateY(0);
}

.share-handle {
  width: 42px;
  height: 4px;
  margin: 4px auto 14px;
  border-radius: 999px;
  background: rgba(232, 196, 120, 0.35);
}

.share-title {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(232, 196, 120, 0.3);
}

.share-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mist);
  letter-spacing: 0.04em;
}

.share-code {
  margin: 18px auto 8px;
  text-align: center;
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  margin-right: -0.28em;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(94, 224, 160, 0.28);
}

.share-qr {
  width: 188px;
  margin: 12px auto;
  padding: 10px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(232, 196, 120, 0.4);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 28px rgba(232, 196, 120, 0.16);
}

.share-qr img,
.share-qr canvas {
  display: block;
  width: 168px !important;
  height: 168px !important;
  margin: 0 auto;
}

.share-qr-fallback {
  padding: 28px 12px;
  text-align: center;
  color: #333;
  font-size: 13px;
}

.share-url {
  margin: 4px 0 14px;
  padding: 0 6px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
  color: var(--jade);
}

.share-actions {
  display: grid;
  gap: 10px;
}

.share-actions .primary {
  margin: 0;
  animation: none;
}

.share-close {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  text-align: center;
  color: var(--mist);
}

/* —— Toast —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(12px);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.1), transparent 50%),
    linear-gradient(180deg, #24352c, #15231c);
  color: var(--ink);
  border: 1px solid rgba(232, 196, 120, 0.45);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  z-index: 20;
  max-width: 86vw;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(232, 196, 120, 0.12);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Celebrate / FX —— */
#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}

.fx-bit {
  position: absolute;
  width: var(--s, 6px);
  height: var(--s, 6px);
  border-radius: 2px;
  background: var(--c, #ffe7a8);
  box-shadow: 0 0 10px var(--c, #ffe7a8);
  animation: fxFly var(--d, 0.9s) cubic-bezier(0.12, 0.7, 0.2, 1) forwards;
}

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.celebrate.show {
  opacity: 1;
}

.celebrate[hidden] {
  display: none !important;
}

.celebrate.show[hidden] {
  display: grid !important;
}

.celebrate-glow {
  position: absolute;
  width: min(78vw, 340px);
  height: min(78vw, 340px);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 231, 168, 0.45), rgba(58, 168, 122, 0.12) 45%, transparent 70%);
  filter: blur(8px);
  animation: celeGlow 1.5s ease-out both;
}

.celebrate-title,
.celebrate-sub {
  position: relative;
  z-index: 1;
  text-align: center;
}

.celebrate-title {
  font-family: var(--display);
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  font-weight: 600;
  letter-spacing: 0.28em;
  margin-left: 0.28em;
  background: linear-gradient(180deg, #fffdf5, #ffe7a8 45%, #c9a04a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 28px rgba(232, 196, 120, 0.55));
  animation: celeTitle 1.45s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.celebrate-sub {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--jade);
  text-shadow: 0 0 18px rgba(94, 224, 160, 0.45);
  animation: celeTitle 1.45s cubic-bezier(0.16, 0.84, 0.28, 1) 0.08s both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sheen {
  0%, 55%, 100% { transform: translateX(-120%); }
  72% { transform: translateX(120%); }
}

@keyframes titleShine {
  to { background-position: 200% center; }
}

@keyframes ringPulse {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.45; }
  50% { transform: translateX(-50%) scale(1.18); opacity: 0.15; }
}

@keyframes orbFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(18px, -22px, 0) scale(1.08); }
}

@keyframes gridDrift {
  to { background-position: 42px 42px; }
}

@keyframes goldPulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(232, 196, 120, 0.25),
      0 12px 36px rgba(201, 160, 74, 0.42),
      0 0 34px rgba(232, 196, 120, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 231, 168, 0.55),
      0 16px 44px rgba(201, 160, 74, 0.58),
      0 0 64px rgba(255, 231, 168, 0.42),
      inset 0 1px 0 rgba(255, 255, 255, 0.55);
  }
}

@keyframes markPulse {
  0%, 100% { opacity: 0.75; letter-spacing: 0.42em; }
  50% { opacity: 1; letter-spacing: 0.5em; text-shadow: 0 0 28px rgba(94, 224, 160, 0.7); }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scorePop {
  0% { transform: scale(1); }
  35% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes tipPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(94, 224, 160, 0); }
  50% { box-shadow: 0 0 18px rgba(94, 224, 160, 0.22); }
}

@keyframes auroraSpin {
  to { transform: rotate(360deg); }
}

@keyframes sparkTwinkle {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.03); }
}

@keyframes boomFlash {
  0% { filter: brightness(1); }
  30% { filter: brightness(1.35) saturate(1.25); }
  100% { filter: brightness(1); }
}

@keyframes crownGlow {
  0%, 100% {
    box-shadow:
      0 16px 40px rgba(0, 0, 0, 0.36),
      0 0 28px rgba(232, 196, 120, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
  50% {
    box-shadow:
      0 18px 44px rgba(0, 0, 0, 0.38),
      0 0 48px rgba(255, 231, 168, 0.42),
      inset 0 1px 0 rgba(255, 255, 255, 0.18);
  }
}

@keyframes cardShake {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-3px) scale(1.03); }
  55% { transform: translateY(1px) scale(0.99); }
}

@keyframes fxFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.2);
  }
}

@keyframes celeGlow {
  0% { opacity: 0; transform: scale(0.55); }
  35% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.35); }
}

@keyframes celeTitle {
  0% { opacity: 0; transform: translateY(18px) scale(0.88); letter-spacing: 0.5em; }
  45% { opacity: 1; transform: translateY(0) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#view-room {
  animation: rise 0.55s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .home, .home-hero, .home .primary, #form-join, #host-banner, .recent, .board,
  .primary, .primary::after, .home-title, .home-mark, .orb, .ambiance::before, .ambiance::after,
  .home-hero::after, .score-card, .score-card.rank-1, #view-room,
  .pending-tip.warn, .pending-tip.ok, .score-card.flash .total,
  .spark-field, .celebrate-glow, .celebrate-title, .celebrate-sub, body.fx-boom .ambiance {
    animation: none !important;
  }
  .toast { transition: none; }
  .fx-bit { display: none !important; }
}
