/* ============================================================ tokens */
:root {
  --bg: #17113a;
  --bg-2: #211853;
  --surface: #261d5c;
  --surface-2: #31276f;
  --line: rgba(255, 255, 255, 0.1);
  --line-2: rgba(255, 255, 255, 0.18);
  --text: #f7f3ff;
  --muted: #b9afe0;
  --accent: #ffcf3f;
  --accent-ink: #2b1a00;
  --boost: #ff4d8d;
  --boost-2: #ff9a3c;
  --ok: #5ce1a1;
  --danger: #ff8a8a;
  --radius: 16px;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 70% at 50% -10%, #3a2a8a 0%, transparent 60%),
    radial-gradient(80% 60% at 100% 110%, #3b1550 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
[hidden] { display: none !important; }

/* ============================================================ layout */
.view { min-height: 100dvh; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
.bar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 20px; text-align: center; }
.bar-spacer { width: 44px; }
.scroll { flex: 1; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.bar-bottom {
  position: sticky; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: auto 1fr; gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-size: 18px; }
.panel h3 { font-size: 15px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head.sub { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--surface-2); font: 700 13px var(--font-body); vertical-align: 2px; }
.lede { color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0; }
.hint.center { text-align: center; }
.error { color: var(--danger); margin: 6px 0 0; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; border: 1.5px dashed var(--line-2); border-radius: var(--radius); }

/* ============================================================ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border-radius: 14px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  font-weight: 700; transition: transform .12s, background .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-dashed { background: transparent; border-style: dashed; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { min-height: 56px; font-size: 17px; }
.block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border-radius: 12px; border: 0; background: transparent; font-size: 20px; color: var(--text);
}
.icon-btn:active:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg-2); outline: none;
}
.input:focus { border-color: var(--accent); }
.input.big { font-size: 22px; text-align: center; }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 0 12px; min-height: 38px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset; }
.seg.wide { display: grid; grid-template-columns: repeat(3, 1fr); }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-row { display: grid; grid-template-columns: 36px 1fr auto 36px; gap: 8px; align-items: center; }
.player-row .icon-btn { width: 36px; height: 36px; font-size: 16px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: hsl(var(--h, 260) 70% 62%); color: #160d2e; font: 800 15px var(--font-display);
}
.avatar.big { width: 72px; height: 72px; font-size: 30px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px 0 10px;
  border-radius: 99px; border: 1px solid var(--line-2); background: var(--bg-2);
  font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s;
}
.chip-icon { font-size: 18px; }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); border-color: var(--accent); font-weight: 700; }

.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.summary.has-error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.summary-line { font-size: 15px; }
.summary-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

/* ============================================================ cards */
/* Themes: --c1 main, --c2 accent, --ink text on --c1, --paper light ground. */
.theme-sunset { --c1: #ff8a5b; --c2: #ffd36e; --ink: #3a1406; --paper: #fff3e6; }
.theme-ocean  { --c1: #3aa6ff; --c2: #a6ecff; --ink: #04223d; --paper: #eaf7ff; }
.theme-forest { --c1: #3fbf7f; --c2: #d0f58a; --ink: #062a17; --paper: #effbe9; }
.theme-berry  { --c1: #b84dff; --c2: #ffa3da; --ink: #fff;    --paper: #fbeefe; }
.theme-sand   { --c1: #e8b86b; --c2: #fff0c2; --ink: #3b2507; --paper: #fffaf0; }
.theme-night  { --c1: #5257e0; --c2: #9ad8ff; --ink: #fff;    --paper: #eef0ff; }
.theme-mint   { --c1: #47d6c4; --c2: #ecffa8; --ink: #053a33; --paper: #effffb; }
.theme-coral  { --c1: #ff5f7e; --c2: #ffc9b0; --ink: #3d0612; --paper: #fff0f3; }

.card {
  position: relative; container-type: inline-size;
  aspect-ratio: 5 / 7; width: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  padding: 0; border: 0; border-radius: 14px;
  background: var(--c1); color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 8px 18px -6px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .25);
  text-align: center;
  transition: transform .22s cubic-bezier(.3, 1.4, .5, 1), box-shadow .2s;
}
.card-art { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.card-label {
  position: relative; z-index: 1; display: block;
  padding: 3cqw 7cqw 8cqw;
  font: 700 12.5cqw/1.1 var(--font-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tag {
  position: absolute; z-index: 2; top: 5cqw; left: 6cqw;
  font-size: 12cqw; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25));
}
.art-emoji { font-size: 50cqw; line-height: 1; filter: drop-shadow(0 2cqw 2cqw rgba(0, 0, 0, .22)); }
.art-text {
  display: block; padding: 0 7cqw; max-width: 100%;
  font: 800 min(52cqw, calc(118cqw / (var(--len, 4) + 0.6)))/0.95 var(--font-display);
  letter-spacing: -0.02em; overflow-wrap: break-word;
}
.art-img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
.art-pattern { position: absolute; inset: 0; width: 100%; height: 100%; }

/* emoji styles */
.s-burst { background: radial-gradient(circle at 50% 40%, var(--c2) 0 24%, var(--c1) 72%); }
.s-burst .card-art::before {
  content: ''; position: absolute; inset: -30%;
  background: repeating-conic-gradient(from 0deg at 50% 46%, rgba(255, 255, 255, .22) 0 8deg, transparent 8deg 22deg);
}
.s-burst .art-emoji { position: relative; }
.s-sticker {
  background: radial-gradient(color-mix(in srgb, var(--c1) 35%, transparent) 1.4cqw, transparent 1.6cqw) 0 0 / 11cqw 11cqw, var(--paper);
  color: color-mix(in srgb, var(--c1) 45%, #111);
}
.s-sticker .art-emoji {
  width: 70cqw; height: 70cqw; display: grid; place-items: center; font-size: 42cqw;
  border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 2.5cqw var(--c1), 0 3cqw 6cqw rgba(0, 0, 0, .2);
  transform: rotate(-6deg); filter: none;
}
.s-poster { background: linear-gradient(162deg, var(--c1) 0 58%, var(--c2) 58% 100%); }
.s-poster .art-emoji { font-size: 60cqw; transform: rotate(-9deg) translateY(3cqw); }
.s-poster .card-label {
  margin: 0 7cqw 7cqw; padding: 2.5cqw 4cqw; border-radius: 99px;
  background: var(--ink); color: var(--c2);
  font-size: 11cqw; text-transform: uppercase; letter-spacing: .04em;
}
.s-glow {
  background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--c1) 55%, #0d0828) 0%, #0d0828 70%);
  color: var(--c2); box-shadow: 0 0 0 1.5px var(--c1) inset, 0 8px 18px -6px rgba(0, 0, 0, .55);
}
.s-glow .art-emoji { filter: drop-shadow(0 0 5cqw var(--c1)) drop-shadow(0 0 1.5cqw var(--c2)); }

/* image styles */
.f-image .card-art { width: 100%; }
.s-full .card-art { position: absolute; inset: 0; }
.s-full .card-label {
  margin-top: auto; padding-top: 14cqw; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
}
.s-polaroid { background: var(--paper); color: #2a2238; }
.s-polaroid .card-art { margin: 7cqw 7cqw 0; border-radius: 2cqw; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
.s-polaroid .card-label { font-weight: 500; font-style: italic; }
.s-round .art-img { width: 78cqw; height: 78cqw; border-radius: 50%; box-shadow: 0 0 0 3cqw var(--paper), 0 4cqw 8cqw rgba(0, 0, 0, .25); }
.s-round { background: radial-gradient(circle at 50% 40%, var(--c2), var(--c1) 70%); }
.s-tilt { background: repeating-linear-gradient(45deg, var(--c1) 0 6cqw, color-mix(in srgb, var(--c1) 80%, #fff) 6cqw 12cqw); }
.s-tilt .art-img { width: 80%; height: 82%; border: 3cqw solid #fff; border-radius: 3cqw; transform: rotate(-5deg); box-shadow: 0 4cqw 8cqw rgba(0, 0, 0, .3); }

.img-broken .art-img { display: none; }
.img-broken .card-art::after { content: '🖼️'; font-size: 40cqw; opacity: .8; }

/* text styles */
.s-bold { background: linear-gradient(180deg, var(--c1), color-mix(in srgb, var(--c1) 75%, #000)); }
.s-outline {
  background: repeating-linear-gradient(-45deg, var(--paper) 0 5cqw, color-mix(in srgb, var(--c2) 45%, var(--paper)) 5cqw 10cqw);
  color: color-mix(in srgb, var(--c1) 50%, #111);
}
.s-outline .art-text { color: transparent; -webkit-text-stroke: 1.6cqw var(--c1); paint-order: stroke; text-shadow: 1.6cqw 1.6cqw 0 color-mix(in srgb, var(--c1) 30%, transparent); }
.s-stamp { background: var(--c2); color: color-mix(in srgb, var(--c1) 40%, #111); }
.s-stamp .art-text {
  color: var(--c1); border: 1.6cqw dashed currentColor; border-radius: 4cqw;
  padding: 5cqw 6cqw; margin: 0 6cqw; transform: rotate(-7deg); font-size: min(40cqw, calc(88cqw / (var(--len, 4) + 0.6)));
}
.s-neon { background: #0d0828; color: var(--c2); box-shadow: 0 0 0 1.5px var(--c1) inset, 0 8px 18px -6px rgba(0, 0, 0, .55); }
.s-neon .art-text { color: #fff; text-shadow: 0 0 2cqw var(--c1), 0 0 6cqw var(--c1), 0 0 12cqw var(--c1); }

/* pattern styles */
.f-pattern .card-art { position: absolute; inset: 0; }
.f-pattern .card-label {
  margin: auto 7cqw 7cqw; padding: 2.5cqw 4cqw; border-radius: 99px;
  background: var(--paper); color: var(--ink); box-shadow: 0 2cqw 4cqw rgba(0, 0, 0, .2);
}
.theme-berry.f-pattern .card-label, .theme-night.f-pattern .card-label { color: #1d1440; }
.s-p1 .art-pattern { transform: scale(1.6) rotate(45deg); }
.s-p2 .art-pattern { transform: scale(1.3) rotate(90deg); }
.s-p3 .art-pattern { transform: scale(2.3); }

/* backs */
.card-back {
  display: block; aspect-ratio: 5 / 7; border-radius: 4px;
  background:
    radial-gradient(circle at 50% 50%, var(--accent) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, #5a3fd0 0 3px, #4430a8 3px 6px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25) inset;
}
.card-ghost { aspect-ratio: 5 / 7; border-radius: 14px; border: 1.5px dashed var(--line-2); display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.thumb { border-radius: 8px; }
.thumb .card-label { font-size: 14cqw; }

/* ============================================================ home */
.home-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: calc(32px + var(--safe-t)) 16px calc(32px + var(--safe-b)); text-align: center; }
.fan { position: relative; width: 260px; height: 190px; margin-bottom: 8px; }
.fan .card {
  position: absolute; left: 50%; bottom: 0; width: 108px; margin-left: -54px;
  transform-origin: 50% 120%;
  transform: rotate(calc((var(--i) - 1.5) * 14deg)) translateY(calc(var(--i) * 0px));
  animation: fan-in .7s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--i) * 80ms);
}
@keyframes fan-in { from { transform: rotate(0) translateY(40px); opacity: 0; } }
.logo {
  font: 800 clamp(64px, 20vw, 104px)/0.9 var(--font-display); letter-spacing: -0.04em;
  background: linear-gradient(100deg, var(--accent), var(--boost-2) 45%, var(--boost));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); margin: 0 0 14px; font-size: 17px; }
.home-actions { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }

/* ============================================================ table */
.table {
  position: relative; max-width: 640px; margin: 0 auto;
  min-height: 100dvh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.table-bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: calc(8px + var(--safe-t)) 12px 4px; }
.table-title { text-align: center; display: flex; flex-direction: column; line-height: 1.2; }
.table-title strong { font: 700 17px var(--font-display); }
.table-title span { color: var(--muted); font-size: 12.5px; }

.seats { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.seats::-webkit-scrollbar { display: none; }
.seat {
  position: relative; flex: 1 0 96px; max-width: 150px; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 8px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  transition: border-color .2s, background .2s;
}
.seat.is-to { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.seat-name { font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-name small { color: var(--muted); font-weight: 500; }
.mini-hand { display: flex; gap: 2px; }
.mini-hand .card-back { width: 13px; }
.seat-status { font-size: 12px; color: var(--muted); }
.seat.is-ready .seat-status { color: var(--ok); font-weight: 700; }
.seat.is-ready .seat-status::before { content: '✓ '; }
.seat-flag { font-size: 11px; color: var(--accent); font-weight: 700; }
.seat-flag.from { color: var(--muted); font-weight: 500; }

.felt { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; min-height: 92px; }
.status { margin: 0; font: 700 clamp(17px, 4.6vw, 20px)/1.25 var(--font-display); text-align: center; min-height: 1.25em; }
.meter { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.meter i { width: 22px; height: 6px; border-radius: 3px; background: var(--surface-2); transition: background .3s; }
.meter i.on { background: var(--accent); }
.meter span { margin-left: 4px; }
.table.is-eligible .meter i.on { background: var(--boost); }

/* Rounds left */
.rounds { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.rounds-bar { width: 100%; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.rounds-bar i { display: block; height: 100%; background: var(--muted); border-radius: inherit; transition: width .4s; }
.rounds-text { font-size: 13px; color: var(--muted); }
.rounds-text b { color: var(--text); }
.rounds.is-low .rounds-bar i { background: var(--accent); }
.rounds.is-low .rounds-text b { color: var(--accent); }
.rounds.is-last .rounds-bar i { background: var(--boost); }
.rounds.is-last .rounds-text b { color: var(--boost); }

/* The player your card goes to */
.next-up {
  display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 12px; border-radius: 99px;
  background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 6px 20px -10px color-mix(in srgb, var(--accent) 60%, transparent);
  max-width: 100%;
}
.next-arrow { font: 800 22px/1 var(--font-display); color: var(--accent); animation: nudge 1.4s ease-in-out infinite; }
.next-avatar { width: 48px; height: 48px; font-size: 21px; flex: none; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.next-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.next-text small { font-size: 12px; color: var(--muted); }
.next-text strong { font: 800 clamp(19px, 5.4vw, 24px)/1.1 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-text em { font-style: normal; font-size: 12px; color: var(--muted); }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }

/* Hard mode's turn clock */
.turn-timer { width: 100%; max-width: 260px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.turn-timer i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; border-radius: inherit;
  animation: drain var(--dur) linear forwards; animation-delay: var(--skip); }
@keyframes drain { 0% { transform: scaleX(1); background: var(--accent); } 70% { background: var(--accent); } 100% { transform: scaleX(0); background: var(--boost); } }

/* Points */
.pts { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.hand-name .pts { margin-left: 6px; }

/* Easy-mode hint */
.hand .card.is-hint { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 80%, transparent), 0 0 22px -2px color-mix(in srgb, var(--ok) 70%, transparent); }
.hand .card.is-hint::before {
  content: 'PASS?'; position: absolute; z-index: 3; top: 4cqw; left: 4cqw;
  padding: 1.5cqw 3.5cqw; border-radius: 99px; background: var(--ok); color: #10131a;
  font: 800 9cqw/1 var(--font-body); letter-spacing: .04em;
}

/* Scoreboard */
#board { width: 100%; max-width: 480px; }
.scoreboard { width: 100%; max-width: 480px; text-align: left; margin-top: 4px; }
.scoreboard h2 { font-size: 15px; color: var(--muted); }
.scoreboard ol { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.scoreboard li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.scoreboard li.is-gain { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.scoreboard .rank { width: 22px; color: var(--muted); font-weight: 700; }
.scoreboard .sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.scoreboard .sb-name small { color: var(--muted); font-weight: 500; }
.scoreboard b { font: 800 18px var(--font-display); }
.gain { color: var(--accent); font-weight: 800; }
.level-info b { color: inherit; }

.hand { padding: 0 12px 10px; }
.hand-name { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.hand-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 2vw, 14px); max-width: 560px; margin: 0 auto; padding-top: 16px; }
.hand .card { cursor: pointer; }
.hand .card:active:not(.is-locked) { transform: scale(.96); }
.hand .card.is-picked { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--accent), 0 14px 24px -8px rgba(0, 0, 0, .7); }
.hand .card.is-locked { cursor: default; }
.hand .card.is-leaving { animation: leave .5s cubic-bezier(.5, 0, .8, .4) forwards; }
@keyframes leave { to { transform: translate(60%, -140%) rotate(18deg) scale(.6); opacity: 0; } }
.hand .card.is-new::after {
  content: 'NEW'; position: absolute; z-index: 3; top: 4cqw; right: 4cqw;
  padding: 1.5cqw 3.5cqw; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  font: 800 9cqw/1 var(--font-body); letter-spacing: .04em;
}
.hand .card.anim-in { animation: arrive .5s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes arrive { from { transform: translate(-70%, -80%) rotate(-16deg) scale(.6); opacity: 0; } }
.table.is-eligible .hand .card { animation: boost-wiggle .9s ease-in-out infinite; }
.table.is-eligible .hand .card:nth-child(2) { animation-delay: .1s; }
.table.is-eligible .hand .card:nth-child(3) { animation-delay: .2s; }
.table.is-eligible .hand .card:nth-child(4) { animation-delay: .3s; }
@keyframes boost-wiggle { 50% { transform: translateY(-6px) rotate(1.5deg); } }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 16px 14px; }
.btn-pass { min-height: 56px; font-size: 16px; }
.btn-boost {
  min-height: 56px; border-radius: 14px; border: 0;
  font: 800 22px var(--font-display); letter-spacing: .06em;
  background: var(--surface); color: color-mix(in srgb, var(--text) 35%, transparent);
  box-shadow: 0 0 0 1px var(--line) inset;
  transition: transform .15s;
}
.btn-boost.is-live {
  color: #fff; background: linear-gradient(100deg, var(--boost-2), var(--boost));
  box-shadow: 0 0 0 0 rgba(255, 77, 141, .6), 0 8px 20px -6px var(--boost);
  animation: boost-pulse 1s ease-out infinite;
}
.btn-boost.is-live:active { transform: scale(.95); }
@keyframes boost-pulse { 70% { box-shadow: 0 0 0 14px rgba(255, 77, 141, 0), 0 8px 20px -6px var(--boost); } 100% { box-shadow: 0 0 0 0 rgba(255, 77, 141, 0), 0 8px 20px -6px var(--boost); } }

.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; }
.handoff { background: radial-gradient(circle at 50% 40%, #33267a, var(--bg) 70%); }
.handoff-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; max-width: 340px; }
.handoff-card h2 { font-size: 28px; }
.handoff-card p { color: var(--muted); margin: 0 0 10px; }
.splash { background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); text-align: center; }
.splash-word {
  font: 800 clamp(72px, 24vw, 140px)/1 var(--font-display); letter-spacing: -0.03em;
  background: linear-gradient(100deg, var(--accent), var(--boost-2), var(--boost));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: splash .7s cubic-bezier(.3, 1.6, .5, 1) both;
}
.splash.lose .splash-word { filter: saturate(.6); }
.splash p { font-size: 18px; margin: 8px 0 0; }
@keyframes splash { from { transform: scale(.2) rotate(-12deg); opacity: 0; } }

/* ============================================================ result */
.result-main { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: calc(32px + var(--safe-t)) 16px calc(24px + var(--safe-b)); text-align: center; position: relative; z-index: 1; }
.eyebrow { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.result-title { font-size: clamp(32px, 9vw, 48px); line-height: 1.05; }
.result-hand { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; max-width: 480px; margin: 8px 0; }
.flip-in { animation: flip .6s cubic-bezier(.3, 1.3, .5, 1) both; animation-delay: calc(var(--i) * 120ms + 150ms); }
@keyframes flip { from { transform: rotateY(90deg) translateY(20px); opacity: 0; } }
.others { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 8px; }
.others h2 { font-size: 15px; color: var(--muted); }
.other-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; }
.other-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.other-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 52px)); gap: 6px; }
.result-actions { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.confetti i {
  position: absolute; top: -20px; left: calc(var(--x) * 1%); width: 9px; height: 14px; border-radius: 2px;
  background: hsl(var(--h) 90% 65%);
  animation: fall 2.8s linear var(--d) infinite;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ============================================================ builder */
.deck-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.deck-item { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.deck-thumbs { display: flex; }
.deck-thumbs .card { width: 44px; }
.deck-thumbs .card + .card { margin-left: -22px; }
.deck-meta { display: flex; flex-direction: column; min-width: 0; }
.deck-meta span { color: var(--muted); font-size: 13px; }
.deck-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }

.group-edit { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.group-head { display: grid; grid-template-columns: 28px 1fr 44px; gap: 8px; align-items: center; }
.group-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 13px; }
.group-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot { padding: 0; border: 0; background: none; border-radius: 14px; }
.slot-empty {
  aspect-ratio: 5 / 7; border: 1.5px dashed var(--line-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); background: var(--bg-2);
}
.slot-empty span { font-size: 22px; }
.slot-empty small { font-size: 11px; }

/* ============================================================ modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(8, 5, 24, .6); animation: fade .18s ease both;
}
.modal-backdrop.is-closing { animation: fade .18s ease reverse both; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 22px 22px 0 0;
  animation: sheet .28s cubic-bezier(.2, .9, .3, 1) both;
}
.modal-wide { max-width: 720px; }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 8px 6px 20px; }
.modal-head h2 { font-size: 19px; }
.modal-body { overflow-y: auto; padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; }
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 22px; }
  .modal-foot { padding-bottom: 14px; }
}
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.preview-list { display: flex; flex-direction: column; gap: 16px; }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.preview-head span { color: var(--muted); font-size: 13px; }
.preview-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 3px; background: var(--bg); border-radius: 12px; }
.tab { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.slot-editor { display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: start; }
.slot-panel { display: flex; flex-direction: column; gap: 10px; }
.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.emoji-grid button { aspect-ratio: 1; border: 0; border-radius: 8px; background: var(--surface); font-size: 20px; }
.emoji-grid button:active { background: var(--surface-2); }
.upload { position: relative; display: grid; place-items: center; min-height: 64px; border-radius: 12px; border: 1.5px dashed var(--line-2); background: var(--surface); font-weight: 700; cursor: pointer; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
@media (max-width: 420px) {
  .slot-editor { grid-template-columns: 1fr; }
  .slot-preview { width: 120px; margin: 0 auto; }
  .group-fields { grid-template-columns: 1fr; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============================================================ online */
.home-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.center-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: calc(32px + var(--safe-t)) 24px calc(32px + var(--safe-b)); text-align: center; }
.msg-title { font-size: 28px; }
.panel.center { align-items: center; text-align: center; }
.bar-bottom.one { grid-template-columns: 1fr; }
.room-code { display: flex; justify-content: center; gap: 6px; margin: 4px 0; }
.room-code span {
  width: clamp(44px, 13vw, 56px); aspect-ratio: 4 / 5; display: grid; place-items: center;
  border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-2);
  font: 800 clamp(26px, 8vw, 34px)/1 var(--font-display); color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset;
}
.code-input { font: 800 26px var(--font-display); letter-spacing: .3em; text-align: center; text-transform: uppercase; }
.lobby-seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lobby-seat { display: grid; grid-template-columns: 36px 1fr auto 36px; gap: 10px; align-items: center; min-height: 44px; }
.lobby-seat .icon-btn { width: 36px; height: 36px; font-size: 16px; }
.lobby-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-name small { color: var(--muted); font-weight: 500; }
.lobby-tag { font-size: 12px; color: var(--muted); padding: 2px 8px; border-radius: 99px; background: var(--bg-2); }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 40% { transform: translateY(-6px); background: var(--accent); } }
