/* Royal Spades web — a one-for-one port of the native app's game table.
   Design tokens are the app's own (ui/theme/Color.kt, CosmeticRegistry):
   Royal Purple felt #38145E→#0F041D, Chevis cyan/violet gradient, gold
   only for currency/rewards/tier progression. Cinzel display, Inter body.
   Card faces/backs, placards, bidding panel and scoreboard are drawn from
   GameTableScreen.kt / CardView / CardBackView, not invented.
   Layout scales to fill the window: --card-w grows with the viewport
   (phone 360px → 72px cards, desktop → up to 150px), the fan spreads
   across the full width, the seats sit at the table edges — no fixed
   phone frame centered on a big empty page. One screen, no scroll. */
:root {
    /* App tokens (Color.kt) */
    --bg: #060a13;
    --bg-abyss: #04070d;
    --felt-1: #38145e;
    --felt-2: #0f041d;
    --gold-trim: #ffd700;
    --panel: #0c1424;
    --panel-2: #101c33;
    --surface-dark: #0a111f;
    --surface-elevated: #0d1526;
    --surface-2: #0b1322;
    --surface-3: #0a111f;
    --surface-deep: #060a13;
    --line: #1e2c47;
    --text: #f5f2eb;
    --muted: #8b99b5;
    --slate-100: #f1f5f9;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-900: #0f172a;
    --lavender: #9aa7bd;
    --cyan: #22d3ee;
    --violet: #8b5cf6;
    --sky: #38bdf8;
    --pink: #f472b6;
    --gold: #d4af37;
    --gold-primary: #e5a93c;
    --gold-metallic: #d4af37;
    --amber-400: #fbbf24;
    --amber-600: #d97706;
    --danger: #e53935;
    --red-600: #dc2626;
    --green: #34c759;
    --green-material: #4caf50;
    /* Red darkened for contrast: red ranks on white cards are 5.7:1
       (native pure red is 4.0:1). Kept from the Round-3 fix. */
    --red: #c81e2b;
    --brown-950: #3b1200;
    --brown-900: #3e1a04;
    --plum-950: #0a1220;
    --plum-void: #060a13;
    /* Card size scales with the window, but it is the HEIGHT that binds:
       the trick area (2.2 card-heights) plus the human area (placard +
       hand) must all fit one screen at any window size, windowed or
       fullscreen. 9vh keeps the whole table inside the viewport at
       700px tall and up (a phone with browser chrome); 19vw binds only
       on narrow phones (360px -> 68px, near the app's 72dp). Avatars
       track the card size. */
    --card-w: clamp(48px, min(19vw, 9vh), 140px);
    --card-h: calc(var(--card-w) * 1.5);
    --av: clamp(48px, calc(var(--card-w) * 0.85), 120px);
    --display: "Cinzel", "Times New Roman", serif;
    --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* Visible focus on EVERY interactive element — keyboard users must
   always see where they are. */
:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
    border-radius: 6px;
}
#hand .card:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 3px;
    transform: translateY(calc(var(--lift, 0px) - 50px)) scale(1.5) rotate(0deg);
}

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    height: 100%;
    overflow: hidden; /* the game never scrolls the page — see #app */
}

/* The whole screen IS the table (Royal Purple felt, Chevis ambience,
   navy vignette), exactly as the app's game screen. */
#app {
    position: relative;
    height: 100vh; height: 100dvh;
    overflow: hidden;
    display: flex; flex-direction: column;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    padding-top: calc(8px + env(safe-area-inset-top));
    background:
        radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(4, 7, 13, 0.52) 100%),
        linear-gradient(180deg, rgba(34, 211, 238, 0.05) 0%, transparent 30%, transparent 75%, rgba(139, 92, 246, 0.04) 100%),
        radial-gradient(120% 90% at 50% 40%, var(--felt-1), var(--felt-2) 78%);
}

/* ------------------------------------------------------------------ HUD */
#hud {
    position: relative; flex: 0 0 auto; height: 62px;
}
.hud-left, .hud-right { position: absolute; top: 0; display: flex; gap: 8px; align-items: center; height: 62px; }
.hud-left { left: 0; }
.hud-right { right: 0; }
.icon-btn {
    width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
    border: none; cursor: pointer; font-size: 20px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15, 23, 42, 0.5); color: #fff; padding: 0;
}
.icon-btn.history { background: rgba(6, 10, 19, 0.85); border: 1px solid rgba(34, 211, 238, 0.5); color: var(--cyan); font-size: 18px; }
/* Team score pill (Classic mode): vertical gradient, 2dp gradient
   border, US cyan / THEM pink, 24sp black scores. */
#scoreboard {
    position: absolute; left: 50%; top: 0; transform: translateX(-50%);
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(180deg, var(--surface-elevated), var(--bg-abyss));
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 8px; padding: 8px 24px;
    box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.0);
    outline: 2px solid transparent;
}
/* Gradient border via a wrapper outline trick: the pill uses a
   background-clip border (see .scoreboard-border below). */
#scoreboard::before {
    content: ''; position: absolute; inset: -2px; border-radius: 10px;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    z-index: -1;
}
.team-col { display: flex; flex-direction: column; align-items: center; position: relative; min-width: 52px; }
.team-col .team-name { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; }
.team-col.us .team-name { color: var(--cyan); }
.team-col.them .team-name { color: var(--pink); }
.team-col .team-score { font-size: clamp(20px, 6vw, 24px); font-weight: 900; color: var(--text); line-height: 1.1; display: inline-block; }
.team-col .team-score.score-pop { animation: score-pop 0.45s ease both; }
/* Floating "+37" / "−50" chip while the count-up runs (native
   ScoreDeltaAnimation: 18sp bold, green/red, slides in from +20,
   out to −50, lives 2.5s). */
.team-col .delta {
    position: absolute; top: -8px; right: -14px; font-size: 18px; font-weight: 800;
    pointer-events: none; opacity: 0;
}
.team-col .delta.show { animation: delta-rise 2.5s ease both; }
.team-col .delta.pos { color: var(--green-material); }
.team-col .delta.neg { color: var(--red-600); }
@keyframes delta-rise {
    0% { opacity: 0; transform: translateY(20px); }
    12% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-50px); }
}
#scoreboard .divider { width: 2px; height: 32px; background: var(--slate-700); }
/* Spades status pill (top-end): BROKEN amber on brown, LOCKED slate. */
#spades-pill {
    display: flex; align-items: center; gap: 4px; height: 32px;
    padding: 6px 10px; border-radius: 20px; border: 1px solid var(--slate-700);
    background: rgba(15, 23, 42, 0.75); color: var(--slate-400);
    font-size: 10.5px; font-weight: 900; letter-spacing: 0.05em; white-space: nowrap;
}
#spades-pill.broken { background: rgba(59, 18, 0, 0.85); border-color: rgba(251, 191, 36, 0.85); color: var(--amber-400); }
#spades-pill .spade { font-size: 12px; }

#phase-label {
    font-family: var(--display); font-weight: 900; text-align: center;
    font-size: 15px; letter-spacing: 0.14em; color: var(--gold);
    min-height: 20px; margin-top: 4px; flex: 0 0 auto;
    position: relative; z-index: 1;
}
#phase-label:empty { display: none; }

/* ------------------------------------------------------------------- table */
#table { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* The open table ABOVE the human area: it takes the remaining height
   (flex: 1), so the trick is centered in the space above the human's
   seat and the south placard can never drift up into the trick cards.
   The human area is a flex child at the bottom, not an overlay. */
#play-zone {
    position: relative; flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column; align-items: center;
}
/* System / game message chip: 18sp Cinzel bold, black 45% bg,
   12dp radius, top 84dp, 28dp side margins. Hidden while the human
   is bidding — the bidding panel title carries the message instead.
   z-index 61 sits above the fly layer (60) so swept cards never
   paint over the message text; Home (65) still covers it. */
#message {
    position: relative; z-index: 61; flex: 0 0 auto;
    width: calc(100% - 56px);
    font-family: var(--display); font-size: clamp(15px, 4.6vw, 18px); font-weight: 700;
    color: var(--text); text-align: center;
    background: rgba(0, 0, 0, 0.45); border-radius: 12px;
    padding: 6px 14px; min-height: 30px;
}
#message.hidden { display: none; }
#message .hint { font-family: var(--body); font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- placards */
.opp { position: absolute; display: flex; flex-direction: column; align-items: center; min-width: 0; z-index: 2; }
.opp.north { position: relative; left: auto; top: auto; transform: none; margin-top: 6px; flex: 0 0 auto; }
.opp.west { left: 16px; top: 50%; transform: translateY(-50%); }
.opp.east { right: 16px; top: 50%; transform: translateY(-50%); }
/* While the human bids, the side seats shift up out of the panel's way
   (native sideAiOffsetY −215dp, topAiOffsetY −15dp, scaled to the web). */
#app.bidding .opp.west { transform: translateY(calc(-50% - 150px)); }
#app.bidding .opp.east { transform: translateY(calc(-50% - 150px)); }
#app.bidding .opp.north { transform: translateY(-15px); }
.opp { transition: transform 0.35s cubic-bezier(0.2, 0, 0, 1); }
.opp .avatar-wrap {
    position: relative; width: var(--av); height: var(--av); border-radius: 50%;
    border: 2px solid var(--team-color, var(--sky));
    flex: 0 0 auto;
}
.opp.partner { --team-color: var(--sky); }
.opp.foe { --team-color: var(--pink); }
.opp .avatar-img {
    display: block; width: 100%; height: 100%; border-radius: 50%;
    object-fit: cover; position: relative; z-index: 2;
}
/* Turn: 88dp violet halo, pulsing cyan ring (1200ms, scale 1→1.4),
   4dp gradient border, cyan glow. */
.opp.turn .avatar-wrap { border: 4px solid transparent; background: linear-gradient(var(--surface-dark), var(--surface-dark)) padding-box, linear-gradient(90deg, var(--cyan), var(--violet)) border-box; box-shadow: 0 0 24px 4px rgba(34, 211, 238, 0.45), 0 0 48px rgba(139, 92, 246, 0.35); }
.opp.turn .avatar-wrap::before {
    content: ''; position: absolute; left: 50%; top: 50%; z-index: 0;
    width: calc(var(--av) * 1.16); height: calc(var(--av) * 1.16);
    transform: translate(-50%, -50%); border-radius: 50%;
    background: rgba(139, 92, 246, 0.5);
}
.opp.turn .avatar-wrap::after {
    content: ''; position: absolute; left: 50%; top: 50%; z-index: 1;
    width: var(--av); height: var(--av);
    border-radius: 50%; border: 12px solid rgba(34, 211, 238, 0.9);
    animation: pulse-ring 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}
@keyframes pulse-ring {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
}
/* Placard name: NEVER truncated (Patrick 16:13 CT — standing rule:
   nothing gets cut off). The native PlayerPlacard renders the full
   name with no max-width (GameTableScreen.kt, Text(player.name) 10sp).
   The web lets the name wrap to two lines (LVL on line 1, name on
   line 2) inside a 110px cap: the longest single-word name is 18
   chars (~99px at 10px) so it fits on one line, and 110px keeps a
   side placard clear of the trick area on a 360px phone. A long
   single word breaks across lines rather than overflowing. */
.opp .lvl-name { margin-top: 4px; font-size: 10px; max-width: 110px; overflow-wrap: break-word; line-height: 1.25; text-align: center; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.8); }
.opp .lvl-name .lvl { color: var(--team-color, var(--sky)); font-weight: 700; }
.opp .lvl-name .name { color: var(--text); }
.opp .bid-line { font-size: 12px; color: var(--lavender); white-space: nowrap; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.8); }
.opp .bid-line .nil { color: var(--gold); font-weight: 700; }
.opp .bid-line.bid-pop { animation: bid-pop 0.35s ease both; }
/* Reaction bubble: 48sp emoji, top-right +24/−24dp (mirrored on the
   right seat so it floats toward the table center). */
.opp .reaction {
    position: absolute; top: -24px; right: -24px; z-index: 5;
    font-size: clamp(32px, 12vw, 48px); line-height: 1; display: none;
    pointer-events: none;
}
.opp.east .reaction { right: auto; left: -24px; }
/* North: top-aligned beside the avatar, NOT above the placard —
   above would touch the message bar, and the placard must be the
   anchor (it was position:static, so the bubble anchored to
   #play-zone and landed at the screen's top-right corner). */
.opp.north .reaction { top: 0; }
.opp .reaction.show { display: block; animation: react-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes react-pop {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes bid-pop {
    0% { transform: scale(1.45); }
    100% { transform: scale(1); }
}
@keyframes score-pop {
    0% { transform: scale(1.3); color: var(--gold); }
    100% { transform: scale(1); }
}

/* -------------------------------------------------------------- trick area */
#trick-area {
    position: relative; flex: 0 0 auto; margin: auto 0;
    width: calc(var(--card-w) * 2.6); height: calc(var(--card-h) * 2.2);
    z-index: 1;
}
#trick-area .watermark {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--display); font-size: clamp(20px, 6.5vw, 28px); font-weight: 700;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    opacity: 0.13; pointer-events: none; text-align: center; white-space: nowrap;
}
.trick-slot {
    position: absolute; width: var(--card-w); height: var(--card-h);
    display: flex; align-items: center; justify-content: center;
}
.trick-slot.north { left: 50%; top: calc(50% - var(--card-w) * 0.55); transform: translate(-50%, -50%); }
.trick-slot.south { left: 50%; top: calc(50% + var(--card-w) * 0.55); transform: translate(-50%, -50%); }
.trick-slot.west { left: calc(50% - var(--card-w) * 0.55); top: 50%; transform: translate(-50%, -50%); }
.trick-slot.east { left: calc(50% + var(--card-w) * 0.55); top: 50%; transform: translate(-50%, -50%); }

/* Spades-broken banner: amber gradient border, radial plum/brown bg,
   "♠️ SPADES BROKEN!" 20sp black amber. Shows 1600ms. */
#spades-banner {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.65);
    z-index: 50; opacity: 0; pointer-events: none; text-align: center;
    border: 2px solid var(--amber-400); border-radius: 20px;
    background: radial-gradient(circle at 50% 40%, var(--brown-900), var(--plum-950), var(--plum-void));
    padding: 14px 24px; box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#spades-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#spades-banner .banner-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: clamp(17px, 5.4vw, 20px); font-weight: 900; color: var(--amber-400); letter-spacing: 0.05em; }
#spades-banner .banner-sub { font-size: 12px; font-weight: 600; color: rgba(245, 242, 235, 0.9); margin-top: 4px; }

/* -------------------------------------------------------------- human area */
#human-area {
    position: relative; z-index: 4; flex: 0 0 auto;
    display: flex; flex-direction: column; align-items: center;
    /* The native fan drops the edge cards 24dp and rotates them 20°,
       which puts their bottom corners below the fan's bottom edge (the
       app clips them slightly). The web keeps every card fully visible,
       so the bottom pad scales with the card size to clear that drop. */
    padding-bottom: calc(var(--card-w) * 0.55);
}
#your-turn {
    position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 5;
    transform: translate(-50%, 8px); white-space: nowrap;
    font-family: var(--display); font-size: clamp(17px, 5vw, 20px); font-weight: 900;
    color: var(--text); background: rgba(10, 17, 31, 0.92);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 12px; padding: 6px 16px;
    box-shadow: 0 8px 24px rgba(34, 211, 238, 0.35), 0 8px 24px rgba(139, 92, 246, 0.3);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#your-turn::before {
    content: ''; position: absolute; inset: -2px; border-radius: 14px;
    background: linear-gradient(90deg, var(--cyan), var(--violet)); z-index: -1;
}
#your-turn.show { opacity: 1; transform: translate(-50%, 0); }
#human-row { position: relative; display: flex; align-items: center; gap: 8px; }
#human-row .opp.you { position: relative; left: auto; top: auto; transform: none; }
/* Turn timer, anchored next to the human avatar (native offset −110dp). */
#turn-timer {
    position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%);
    color: var(--amber-400); font-size: 16px; font-weight: 700; white-space: nowrap;
    display: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.8);
}
#turn-timer.show { display: block; }
#turn-timer.urgent { font-size: 24px; animation: timer-flash 0.25s steps(2, start) infinite; }
@keyframes timer-flash {
    0% { color: var(--red-600); }
    50% { color: var(--amber-400); }
}
#btn-emote {
    width: 44px; height: 44px; min-width: 44px; border: none; background: none;
    font-size: 24px; cursor: pointer; padding: 0; line-height: 1;
}
#emote-tray {
    display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
    background: rgba(15, 23, 42, 0.8); border-radius: 16px; padding: 8px; width: 80%;
    margin-top: 8px;
}
#emote-tray button {
    min-width: 44px; min-height: 44px; font-size: 28px; line-height: 1;
    background: none; border: none; cursor: pointer; padding: 0;
}
#hand-label { width: 100%; font-size: 12px; color: var(--muted); margin: 8px 0 4px; display: flex; justify-content: space-between; padding: 0 4px; }
#hand-label b { color: var(--text); }
#hand { display: flex; justify-content: center; flex-wrap: nowrap; min-height: var(--card-h); padding: 4px 0 2px; width: 100%; }

/* ------------------------------------------------------------------- cards */
/* CardView: 72×108dp (1.5 ratio), 6dp radius, 0.5dp LightGray 50%
   border, 6dp shadow. Face: corner rank 15sp bold + suit 11sp, center
   suit 32sp, bottom-right corner rotated 180°. Red #FF0000 in the app;
   the web keeps the Round-3 darker red for contrast (see --red). */
.card {
    width: var(--card-w); height: var(--card-h); border-radius: 6px;
    background: linear-gradient(160deg, #ffffff, #e6e9f2);
    color: #101828; position: relative; flex: 0 0 auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
    border: 0.5px solid rgba(211, 211, 211, 0.5);
    user-select: none;
}
.card.red { color: var(--red); }
.card .corner { position: absolute; top: 4px; left: 5px; font-weight: 800; font-size: calc(var(--card-w) * 0.21); line-height: 1; text-align: center; }
.card .corner .s { display: block; font-size: calc(var(--card-w) * 0.15); }
.card .corner.br { top: auto; bottom: 4px; left: auto; right: 5px; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(var(--card-w) * 0.44); }
.card.trick-winner { outline: 3px solid var(--gold); outline-offset: 1px; animation: winner-pulse 1s ease-in-out infinite; }
/* Hidden while its flying clone travels; revealed when the flight lands. */
.card.flying-hidden { visibility: hidden; }
/* No landing scale pulse: a played card must land at exactly its
   settled size and angle. The flight (flyClone) already delivers it
   at final size, so the landing needs no accent of its own. */
/* CardBackDesign, "Default Blue": vertical gradient #1A237E→#0D47A1,
   2dp #E8EAF6 border, gold accent, crosshatch, center emblem circle. */
.card-back {
    width: var(--card-w); height: var(--card-h); border-radius: 8px;
    background:
        repeating-linear-gradient(115deg, rgba(255, 215, 0, 0.15) 0 1px, transparent 1px 16px),
        linear-gradient(180deg, #1a237e, #0d47a1);
    border: 2px solid #e8eaf6; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
    position: relative; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    user-select: none;
}
.card-back::before {
    content: ''; position: absolute; inset: 4px;
    border: 1px solid rgba(255, 215, 0, 0.6); border-radius: 5px;
    pointer-events: none;
}
.card-back .back-emblem {
    width: calc(var(--card-w) * 0.44); height: calc(var(--card-w) * 0.44);
    border-radius: 50%; background: rgba(0, 0, 0, 0.3);
    border: 1px solid #ffd700; color: #ffd700;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(var(--card-w) * 0.25); font-weight: 700; line-height: 1;
}
/* Staggered deal: cards arrive one at a time, at their FINAL landed
   size and fan angle for the whole flight — no smaller in-flight
   state, no size or angle snap on landing. The keyframes carry the
   card's own --lift/--rot so the `to` state is exactly the fan
   transform the card settles into. Fill is `backwards`: before its
   stagger turn the card sits invisible at its start offset. */
.card.deal-in, .card-back.deal-in { animation: deal-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
/* Reveal flip (native cardFlipY 400ms, 35ms stagger per index). The
   flip is a rotation only: the card keeps its landed size and fan
   angle throughout, so the reveal never shrinks or snaps. */
.card.flip-in, .card-back.flip-in { animation: flip-in 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) backwards; }
@keyframes deal-in {
    from { opacity: 0; transform: translateY(calc(var(--lift, 0px) - 18px)) rotate(var(--rot, 0deg)); }
    to { opacity: 1; transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg)); }
}
@keyframes flip-in {
    from { opacity: 0.4; transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg)) rotateY(90deg); }
    to { opacity: 1; transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg)) rotateY(0deg); }
}
@keyframes winner-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.55); }
    50% { box-shadow: 0 0 14px 3px rgba(212, 175, 55, 0.45); }
}
/* A played card's travelling clone. Transform-only motion (GPU-friendly). */
#fly-layer { position: absolute; inset: 0; pointer-events: none; z-index: 60; overflow: visible; }
.fly-card {
    position: absolute; left: 0; top: 0; margin: 0; z-index: 60;
    pointer-events: none; will-change: transform;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.6);
}
/* Hand fan (GameTableScreen.kt): rotation −20°..+20° across the hand,
   arc lift |index − center| × 4dp, overlap from the screen width
   (native formula, set as --overlap in app.js), focused card scale
   1.5× lift −50dp rotation 0. */
#hand .card, #hand .card-back {
    margin-left: calc(var(--overlap, 36px) * -1);
    transition: transform 0.12s ease;
    transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg));
}
#hand .card:first-child, #hand .card-back:first-child { margin-left: 0; }
#hand .card.playable:hover { transform: translateY(calc(var(--lift, 0px) - 12px)) rotate(var(--rot, 0deg)); }
/* Selection must be UNMISTAKABLE: the focused card rises high, big,
   thick cyan ring, glow (native focused scale 1.5 + lift −50dp). */
#hand .card.selected {
    transform: translateY(calc(var(--lift, 0px) - 50px)) scale(1.5) rotate(0deg);
    outline: 3px solid var(--cyan); outline-offset: 1px;
    box-shadow: 0 8px 18px rgba(34, 211, 238, 0.45);
    z-index: 100;
}
#hand .card.illegal { filter: brightness(0.55); cursor: not-allowed; }
#hand .card.legal-glow { outline: 2px solid rgba(34, 211, 238, 0.65); animation: glow-pulse 1.6s ease-in-out infinite; }
@keyframes glow-pulse {
    0%, 100% { outline-color: rgba(34, 211, 238, 0.35); }
    50% { outline-color: rgba(34, 211, 238, 0.9); }
}
/* Clear Play affordance: appears when a card is keyboard-selected
   (pointer users tap once to play, as in the app). */
#play-btn {
    display: none; width: 100%; min-height: 48px; margin-top: 6px;
    border: none; border-radius: 12px; cursor: pointer;
    font-family: var(--body); font-size: 16px; font-weight: 800; color: #06121f;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
}
#play-btn.show { display: block; animation: sheet-in 0.2s ease both; }
#play-btn:active { filter: brightness(1.15); }
@keyframes sheet-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --------------------------------------------------------------- bid panel */
/* BiddingPanel: a centered overlay over the table (native BIDDING MODAL
   OVERRIDE). The sheet is SurfaceDeep850 97%, 1.5dp gradient border,
   16dp radius, 92% width. */
#bid-panel {
    position: absolute; inset: 0; z-index: 80;
    display: none; align-items: center; justify-content: center;
}
#bid-panel.open { display: flex; }
.bid-sheet {
    width: 92%; max-width: 420px;
    /* Double-background gradient border (padding-box dark sheet over
       border-box gradient): the same border WITHOUT a ::before, because
       a z-index:-1 ::before paints OVER the sheet once the sheet keeps
       a transform from its entrance animation — that stacking-context
       bug turned the Round Complete panel into a full light gradient. */
    background:
        rgba(6, 10, 19, 0.97) padding-box,
        linear-gradient(90deg, var(--cyan), var(--violet)) border-box;
    border: 1.5px solid transparent;
    border-radius: 16px; padding: 12px 14px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55), 0 0 24px rgba(139, 92, 246, 0.35);
    position: relative; text-align: center;
}
.bid-sheet .title {
    font-family: var(--display); font-size: 18px; font-weight: 700; color: var(--text);
    text-shadow: 0 0 8px rgba(34, 211, 238, 0.35);
}
.bid-sheet .tip { font-size: 12px; color: var(--slate-300); margin-top: 2px; text-align: center; }
.bid-grid {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
    margin-top: 10px;
}
/* BidButton: 36dp circles (44px touch target on the web), recommended =
   ChevisGradient fill + sheen, white text, violet shadow; enabled =
   RoyalSurfaceElevated + cyan text + 1dp cyan 40% border. NIL is a
   DangerRed pill (44×36dp in the app, 44px tall here for touch). */
.bid-btn {
    min-height: 44px; aspect-ratio: 1; border-radius: 50%;
    border: 1px solid rgba(34, 211, 238, 0.4);
    background: var(--surface-elevated); color: var(--cyan);
    font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.1s ease; padding: 0;
}
.bid-btn:active { transform: scale(0.92); filter: brightness(1.2); }
.bid-btn.nil { background: var(--danger); border-radius: 999px; aspect-ratio: auto; color: #fff; border-color: rgba(212, 175, 55, 0.5); font-size: 12px; }
.bid-btn.recommended {
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    color: #fff; border-color: transparent;
    box-shadow: 0 6px 14px rgba(139, 92, 246, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.bid-btn.nil.recommended { border: 2px solid transparent; background: linear-gradient(var(--danger), var(--danger)) padding-box, linear-gradient(90deg, var(--cyan), var(--violet)) border-box; box-shadow: 0 6px 14px rgba(139, 92, 246, 0.5); }
.confirm-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 8px; }
.confirm-row[hidden] { display: none; }
#bid-chosen-label { color: #fff; font-size: 15px; font-weight: 700; }
.btn-outline {
    min-height: 44px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
    background: none; border: 1px solid var(--slate-600); color: var(--slate-300);
    font-size: 13px; font-family: inherit;
}
.btn-grad {
    min-height: 44px; padding: 6px 16px; border: none; border-radius: 20px; cursor: pointer;
    background: linear-gradient(90deg, var(--cyan), var(--violet)); color: #fff;
    font-size: 13px; font-weight: 700; font-family: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-amber {
    min-height: 48px; padding: 10px 18px; border: none; border-radius: 12px; cursor: pointer;
    background: var(--amber-600); color: #fff;
    font-size: 15px; font-weight: 700; font-family: inherit;
}

/* --------------------------------------------------------- modal dialogs */
#blind-nil-modal, #settings-dialog, #last-trick-dialog {
    position: absolute; inset: 0; z-index: 90;
    display: none; align-items: center; justify-content: center;
    background: rgba(3, 6, 12, 0.55); padding: 16px;
}
#blind-nil-modal:not([hidden]), #settings-dialog:not([hidden]), #last-trick-dialog:not([hidden]) { display: flex; }
.modal-row { display: flex; gap: 16px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }
.sheet.blind-nil { text-align: center; }
.sheet.blind-nil h2 { font-size: 24px; }
.sheet.blind-nil p { color: var(--slate-300); text-align: center; line-height: 1.6; margin: 16px 0 0; }
#last-trick-cards { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
#last-trick-cards .card, #last-trick-cards .card-back { flex: 0 0 auto; margin: 0; transform: none; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0; }
.set-row span { font-size: 15px; }
#motion-toggle {
    min-height: 44px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--panel); color: var(--muted);
    font-family: var(--body); font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---------------------------------------------------------------- ad slots */
.ad-slot { flex: 0 0 auto; }
/* No ad units configured yet: the slot takes no space at all. A dead
   dashed box between the table and the hand read as a broken game. */
.ad-slot:empty { display: none; }
.ad-slot:not(:empty) {
    margin: 8px 0; min-height: 48px; border: 1px dashed #2b3f63; border-radius: 10px;
    background: rgba(12, 20, 36, 0.6); display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 6px; text-align: center;
}
.ad-slot .ad-slot-label { font-size: 10px; letter-spacing: 0.22em; color: var(--muted); text-transform: uppercase; }
.ad-slot .ad-slot-note { font-size: 11px; color: var(--muted); margin-top: 3px; max-width: 420px; }
.ad-slot.interstitial-ad { min-height: 110px; margin: 12px 0; }
.ad-slot-error .ad-slot-label { color: var(--red); }

/* ---------------------------------------------------------------- overlays */
#overlay {
    position: fixed; inset: 0; background: rgba(3, 6, 12, 0.88);
    display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
#overlay.open { display: flex; }
/* Start screen: light backdrop so the dealt table stays visible behind
   the sheet — the first screen must read as the game itself. */
#overlay.light { background: rgba(3, 6, 12, 0.55); backdrop-filter: blur(2px); }
.sheet {
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    max-width: 480px; width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 20px;
    animation: sheet-in 0.28s ease both;
}
/* Round / match summary sheet (native RoundSummary): black 80% scrim,
   card 90% width, 24dp radius, gradient RoyalSurfaceElevated→
   SurfaceDeep850, 2dp gradient border, 24dp padding. The border is a
   double background (padding-box dark sheet over border-box gradient),
   NOT a ::before: the sheet's entrance animation ends on a transform
   with fill both, so the sheet stays a stacking context and a
   z-index:-1 ::before paints OVER the dark panel — that bug rendered
   the whole panel as a light cyan-to-violet gradient (Patrick's
   15:37 screenshot). */
.sheet.round-summary {
    background:
        linear-gradient(180deg, var(--surface-elevated), var(--surface-deep)) padding-box,
        linear-gradient(90deg, var(--cyan), var(--violet)) border-box;
    border: 2px solid transparent;
    border-radius: 24px; padding: 24px; position: relative;
}
.sheet h2 { margin: 0 0 4px; font-family: var(--display); font-size: 22px; font-weight: 900; letter-spacing: 0.06em; text-align: center; }
.sheet h2.fanfare { font-size: 24px; }
.sheet h2.round-title { font-size: 28px; font-weight: 900; color: var(--amber-400); letter-spacing: 0.07em; }
.sheet h2 .grad { background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sheet .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
/* Round summary subtitle + footer stay readable on the dark panel:
   Slate300 subtitle, Slate400 footer (the muted gray washed out). */
.sheet.round-summary .sub { color: var(--slate-300); }
.sheet.round-summary .fine { color: var(--slate-400); }
.sheet .gold { color: var(--gold); font-weight: 700; }
.stats { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.stats td, .stats th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; }
.stats td:first-child, .stats th:first-child { text-align: left; }
.stats th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
/* Team rows (native TeamSummaryRow): team name centered in Slate100,
   three stat columns spaced evenly, 1dp Slate divider between teams.
   No bordered cards, no cyan/pink team names — both washed out on the
   panel. Score diff takes the native green/red. */
.team-block { margin: 4px 0; padding: 0; border: none; text-align: center; }
.team-block .tname { display: block; font-size: 16px; font-weight: 700; color: var(--slate-100); margin-bottom: 8px; }
.stat-cols { display: flex; justify-content: space-evenly; }
.stat-col { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.stat-col .stat-label { font-size: 12px; color: var(--slate-400); }
.stat-col .stat-value { font-size: 20px; font-weight: 700; color: var(--slate-100); }
.team-block .verdict { display: block; font-size: 14px; font-weight: 900; margin-top: 4px; }
.team-block .verdict.set { color: var(--red-600); }
.team-block .verdict.made { color: var(--green); }
.team-block .bags-line { font-size: 12px; font-weight: 700; color: var(--amber-400); margin-top: 4px; }
.team-divider { height: 1px; background: var(--slate-600); margin: 16px 0; }
.score-diff.pos { color: var(--green); }
.score-diff.neg { color: var(--red-600); }
.row-in { animation: sheet-in 0.3s ease both; }
.progress-wrap { margin: 12px 0 4px; }
.progress-wrap .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.progress-wrap .lbl b { color: var(--gold); }
.progress { height: 10px; border-radius: 999px; background: #16233d; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); border-radius: 999px; }
.btn {
    display: block; width: 100%; min-height: 52px; margin-top: 12px; border: none; border-radius: 12px;
    font-size: 17px; font-weight: 800; font-family: inherit; cursor: pointer; color: #fff;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
}
/* Native GradientButton text is white 18sp Bold; the dark navy text
   on the gradient read as black and washed out at the cyan end. */
.btn.next-hand { width: 80%; margin-left: auto; margin-right: auto; min-height: 56px; border-radius: 28px; font-size: 18px; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn:active { filter: brightness(1.15); }
.fine { font-size: 11px; color: var(--muted); text-align: center; margin-top: 10px; line-height: 1.5; }
/* Tier select on the start sheet: compact 2-column grid. */
.tier-select { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.tier-pick {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    min-height: 64px; padding: 10px 12px; border-radius: 12px; text-align: left;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
    font-family: var(--body); cursor: pointer;
}
.tier-pick .tp-name { font-family: var(--display); font-weight: 900; font-size: 15px; letter-spacing: 0.04em; }
.tier-pick .tp-meta { font-size: 11px; color: var(--muted); }
.tier-pick .st { font-size: 11px; font-weight: 700; color: var(--cyan); }
.tier-pick .st.lock { color: var(--muted); font-weight: 600; }
.tier-pick.current { border-color: rgba(212, 175, 55, 0.7); background: linear-gradient(160deg, rgba(212, 175, 55, 0.14), var(--panel-2)); }
.tier-pick.current .st.cur { color: var(--gold); }
.tier-pick.locked { opacity: 0.55; cursor: not-allowed; }

/* Small toast above the hand (motion toggle feedback, tier picks). */
#toast {
    position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(8px);
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
    font-size: 13px; font-weight: 600; padding: 10px 16px; border-radius: 999px;
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 70; max-width: 90%; text-align: center;
    /* Toasts wrap instead of ellipsising: a long message (e.g. the
       Play with Friends Android-app note) must render in full, even
       on a phone, rather than being cut off mid-sentence. */
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Desktop / wide window: the table fills the window — cards are already
   scaled up by --card-w (up to 150px), the fan spans the full width,
   the seats sit at the edges. Only spacing grows here. */
@media (min-width: 768px) {
    #app { padding: 16px 28px calc(16px + env(safe-area-inset-bottom)); padding-top: calc(16px + env(safe-area-inset-top)); }
    #trick-area .watermark { font-size: 28px; }
    .opp.west { left: 28px; }
    .opp.east { right: 28px; }
}

/* Calm motion sheds DECORATION only — hover lift, glows, pulses, sheet
   entrances, reaction pops. Core motion (deal, card flight, trick sweep,
   score count-up, reveal flip) always plays, at every tier. */
body.reduced-motion #hand .card.playable:hover { transform: none; }
body.reduced-motion #hand .card.legal-glow { animation: none; }
body.reduced-motion .card.trick-winner { animation: none; }
body.reduced-motion .sheet { animation: none; }
body.reduced-motion #play-btn.show { animation: none; }
body.reduced-motion .opp.turn .avatar-wrap::after { animation: none; opacity: 0; }
body.reduced-motion .opp .reaction.show { animation: none; }
body.reduced-motion #spades-banner { transition: opacity 0.2s ease; }

/* ------------------------------------------------------------------- Home */
/* Home screen (native HomeScreen.kt): the first screen of the port.
   A fixed layer over the table (z 40, below the overlay z 50 and the
   dialogs z 90), Royal Purple felt + navy like #app, one screen with
   no page scroll. The match is dealt only when PLAY is tapped. */
#home {
    position: fixed; inset: 0; z-index: 65;
    background:
        radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(4, 7, 13, 0.52) 100%),
        linear-gradient(180deg, rgba(34, 211, 238, 0.05) 0%, transparent 30%, transparent 75%, rgba(139, 92, 246, 0.04) 100%),
        radial-gradient(120% 90% at 50% 40%, var(--felt-1), var(--felt-2) 78%);
    overflow-y: auto;
    padding: calc(10px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom));
}
#home[hidden] { display: none; }
.home-inner {
    min-height: 100%; max-width: 520px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 6px;
}
/* Top bar: logo left, profile chip + settings gear right. */
.home-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    flex: 0 0 auto; min-height: 48px;
}
.home-logo {
    font-family: var(--display); font-size: 22px; font-weight: 900; letter-spacing: 0.06em;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    white-space: nowrap;
}
.home-profile {
    display: flex; align-items: center; gap: 8px; min-width: 0;
    background: rgba(15, 23, 42, 0.6); border: 1px solid var(--line);
    border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer;
    font-family: var(--body); color: var(--text);
}
.home-profile img {
    width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--sky); flex: 0 0 auto;
}
/* Profile name wraps instead of forcing the pill wider than the
   screen: a long player name renders in full on a second line,
   never cut off (same standing rule as the placards). */
.home-profile .hp-name { font-size: 14px; font-weight: 700; min-width: 0; overflow-wrap: break-word; }
.home-profile .hp-level { font-size: 11px; color: var(--sky); font-weight: 700; white-space: nowrap; }
/* Hero table card (native hero): dark surface gradient, 2dp gradient
   border, 26px radius, ambient violet/cyan glows. */
.hero-card {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--surface-elevated), #0a1120, var(--surface-deep));
    border: 1px solid transparent;
    background-clip: padding-box;
    border-radius: 26px; padding: 14px 20px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.5);
}
.hero-card::before {
    content: ''; position: absolute; inset: -1px; border-radius: 27px;
    background: linear-gradient(90deg, var(--cyan), var(--violet)); z-index: -1;
}
.hero-card::after {
    content: ''; position: absolute; top: -70px; right: -60px; width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.10), transparent 70%);
    pointer-events: none;
}
.hero-change {
    align-self: flex-end; z-index: 2;
    display: flex; align-items: center; gap: 5px;
    background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px; padding: 5px 12px; cursor: pointer;
    color: var(--text); font-size: 11.5px; font-weight: 700; font-family: var(--body);
}
.hero-change .tune { color: var(--cyan); font-size: 13px; }
.hero-tier {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--display); font-size: 24px; font-weight: 900; letter-spacing: 0.03em;
    color: var(--text); margin-top: 4px;
}
/* Tier names wrap if they ever outgrow the card (never clip: the
   hero card hides overflow, so a nowrap name would be cut off). In
   practice every tier fits on one line at the phone size. */
.hero-format { font-size: 13px; color: var(--lavender); font-weight: 600; margin-top: 4px; }
.hero-tagline { font-size: 12px; color: var(--muted); margin-top: 2px; }
/* Native Play CTA: refined metallic champagne gold (iOS Luxury CTA),
   dark navy text, 56dp tall. Gold is reserved for currency/rewards,
   and the Play button is the match's reward moment. */
.btn-gold {
    display: block; width: 100%; min-height: 56px; margin-top: 10px;
    border: none; border-radius: 18px; cursor: pointer;
    background: linear-gradient(180deg, #f7dc6f, var(--gold-primary) 45%, #b8860b);
    color: #1a1206; font-family: var(--display); font-size: 18px; font-weight: 900;
    letter-spacing: 0.08em;
    box-shadow: 0 10px 20px rgba(212, 175, 55, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn-gold:active { filter: brightness(1.12); transform: scale(0.98); }
.hero-record { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.hero-record b { color: var(--gold); }
/* Feature tiles: 2x2 grid. Quests, wheel, pass, friends are items 4-6
   and platform-limited, so they carry a green ANDROID APP badge,
   never fake progress or rewards. */
.home-tiles {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 0 0 auto;
}
.home-tile {
    display: flex; flex-direction: column; gap: 2px; text-align: left;
    min-height: 84px; padding: 10px 14px; border-radius: 20px;
    background: linear-gradient(180deg, var(--panel-2), var(--surface-deep));
    border: 1px solid var(--line); color: var(--text);
    font-family: var(--body); cursor: pointer; position: relative;
}
.home-tile .tile-icon {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: rgba(139, 92, 246, 0.18); margin-bottom: 4px;
}
.home-tile .tile-icon.cyan { background: rgba(34, 211, 238, 0.18); }
.home-tile .tile-name { font-size: 15px; font-weight: 700; }
.home-tile .tile-sub { font-size: 12px; color: var(--muted); }
/* Android-app tile: Play Store-only, so it is full colour with a green
   ANDROID APP badge. */
.home-tile .android-badge {
    position: absolute; top: 10px; right: 10px;
    font-size: 10px; font-weight: 900; letter-spacing: 0.06em;
    color: #4ade80; background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.45); border-radius: 999px; padding: 3px 8px;
    white-space: nowrap;
}
/* Info dialog paragraphs (account / progress dialogs). */
.info-text { font-size: 14px; line-height: 1.55; color: var(--text); }
/* Inline text button (Account details link inside the avatar picker). */
.link-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--sky); font-size: inherit; font-weight: 700; font-family: var(--body);
    text-decoration: underline; text-underline-offset: 2px;
}
/* Avatar picker grid: 22 avatars, 4 across. Short labels, never
   clipped (no-cut-off rule); the selected avatar gets a gold ring
   and a checkmark. */
.avatar-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.avatar-pick {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 4px 8px; border-radius: 16px; cursor: pointer;
    background: rgba(15, 23, 42, 0.6); border: 1px solid var(--line);
    color: var(--text); font-family: var(--body); position: relative;
    min-width: 0;
}
.avatar-pick img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.avatar-pick .av-label { font-size: 11px; font-weight: 700; white-space: nowrap; }
.avatar-pick.selected { border-color: var(--amber-400); box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45); }
.avatar-pick .av-check {
    position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
    border-radius: 50%; background: var(--amber-400); color: #1a1205;
    font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center;
}
/* Bottom row: How to Play, Tour, Settings. */
.home-links {
    display: flex; gap: 8px; flex: 0 0 auto; margin-top: auto;
}
.home-link {
    flex: 1; min-height: 44px; border-radius: 12px; cursor: pointer;
    background: rgba(15, 23, 42, 0.6); border: 1px solid var(--line);
    color: var(--text); font-size: 13px; font-weight: 700; font-family: var(--body);
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.home-link:active { filter: brightness(1.2); }
.home-foot { text-align: center; font-size: 11px; color: var(--muted); line-height: 1.5; flex: 0 0 auto; }

/* ------------------------------------------- match setup / rules / tour */
/* Dialog shells: fixed overlay, black 82% scrim, centered sheet
   (native TableCustomizerDialog: 26dp radius, SurfaceLevel2, gradient
   border). The sheet scrolls internally; the sticky bottom action
   stays put. z 60-80, above Home (40) and the table. */
#match-setup-dialog, #rules-dialog, #tour-dialog, #avatar-dialog, #info-dialog {
    position: fixed; inset: 0; z-index: 60;
    display: none; align-items: center; justify-content: center;
    background: rgba(3, 6, 12, 0.82); padding: 16px;
}
#match-setup-dialog:not([hidden]), #rules-dialog:not([hidden]), #tour-dialog:not([hidden]), #avatar-dialog:not([hidden]), #info-dialog:not([hidden]) { display: flex; }
#tour-dialog { z-index: 70; }
.setup-sheet {
    background: var(--panel-2);
    border: 1px solid transparent;
    background-clip: padding-box;
    border-radius: 26px; width: 100%; max-width: 480px;
    max-height: 92vh; max-height: 92dvh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
    position: relative; animation: sheet-in 0.28s ease both;
}
.setup-sheet::before {
    content: ''; position: absolute; inset: -1px; border-radius: 27px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(139, 92, 246, 0.25), transparent 60%);
    z-index: -1;
}
.setup-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    padding: 16px 20px 12px; flex: 0 0 auto;
}
.setup-head h2 {
    margin: 0; font-family: var(--display); font-size: 15.5px; font-weight: 900;
    letter-spacing: 0.07em; color: var(--text); text-align: left;
}
.setup-head .setup-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.setup-close {
    flex: 0 0 auto; width: 36px; height: 36px; border: none; background: none;
    color: var(--slate-400); font-size: 18px; font-weight: 700; cursor: pointer; line-height: 1;
}
.setup-body {
    flex: 1 1 auto; overflow-y: auto; padding: 0 16px 14px;
    display: flex; flex-direction: column; gap: 16px;
}
.setup-divider { height: 1px; background: var(--line); flex: 0 0 auto; }
.setup-label {
    font-size: 11.5px; font-weight: 700; color: var(--lavender);
    letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px;
}
.setup-note { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.setup-note b { color: var(--text); font-weight: 600; }
/* Option grids: selected = ChevisGradient fill + white text + 1.5px
   white border; unselected = dark surface + ChevisText + 1px border.
   Android-app-only options are disabled, dimmed, and carry an
   ANDROID APP tag. */
.opt-row { display: flex; gap: 6px; }
.opt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.opt {
    flex: 1; min-height: 44px; padding: 9px 6px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
    color: var(--text); font-family: var(--body);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-align: center; position: relative;
}
.opt .opt-title { font-size: 11.5px; font-weight: 700; }
.opt .opt-sub { font-size: 10px; color: var(--muted); }
/* Option labels wrap rather than clip: the buttons are narrow on a
   phone, and a nowrap label would spill out of (or be cut by) the
   button. In practice the shortened labels fit on one line. */
.opt.selected {
    background: linear-gradient(180deg, var(--cyan), var(--violet));
    border: 1.5px solid rgba(255, 255, 255, 0.8); color: #fff;
}
.opt.selected .opt-sub { color: rgba(255, 255, 255, 0.85); }
.opt:disabled { opacity: 0.5; cursor: not-allowed; }
.opt .opt-android {
    position: absolute; top: 4px; right: 4px;
    font-size: 8.5px; font-weight: 900; letter-spacing: 0.06em;
    color: #4ade80;
}
.opt:active:not(:disabled) { filter: brightness(1.2); }
/* Table cards in match setup: one per tier, accent border per tier,
   lock state with progress. Selected card reports the effective
   setup; unselected cards advertise their native format. */
.tier-card {
    display: flex; flex-direction: column; gap: 2px; width: 100%;
    padding: 10px 12px; border-radius: 12px; cursor: pointer; text-align: left;
    border: 1.5px solid var(--line);
    background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
    color: var(--text); font-family: var(--body); margin-bottom: 6px;
}
.tier-card:last-child { margin-bottom: 0; }
.tier-card .tc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tier-card .tc-name { font-family: var(--display); font-size: 15px; font-weight: 900; letter-spacing: 0.03em; }
.tier-card .tc-meta { font-size: 11.5px; color: var(--muted); }
.tier-card .tc-tag { font-size: 11px; color: var(--lavender); font-style: italic; }
.tier-card .tc-lock { font-size: 11px; font-weight: 700; color: var(--muted); }
.tier-card.selected { border-color: rgba(255, 255, 255, 0.8); background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), var(--surface-2)); }
.tier-card.locked { opacity: 0.6; cursor: not-allowed; }
.tier-card[data-tier="royal_palace"].selected { border-color: var(--violet); }
.tier-card[data-tier="high_roller"].selected { border-color: var(--gold-primary); }
.tier-card[data-tier="silver_parlor"].selected { border-color: var(--slate-300); }
.tier-card[data-tier="rookie_lounge"].selected { border-color: var(--amber-600); }
/* Mode description callout (native variant explainer). */
.mode-callout {
    background: var(--surface-3); border: 1px solid rgba(34, 211, 238, 0.35);
    border-radius: 12px; padding: 10px 14px; margin-top: 8px;
}
.mode-callout .mc-title { font-size: 12.5px; font-weight: 700; color: var(--cyan); }
.mode-callout .mc-desc { font-size: 11.5px; color: var(--text); opacity: 0.9; line-height: 1.5; margin-top: 3px; }
/* Sticky bottom action: summary line + Apply & Start. */
.setup-foot {
    flex: 0 0 auto; padding: 12px 16px;
    border-top: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 8px;
}
.setup-summary {
    font-size: 12px; font-weight: 600; color: var(--muted); text-align: center;
}
.setup-summary b { color: var(--text); }
/* Rules dialog body: numbered rules, Slate400 text, Slate100 headings. */
.rules-list { display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.55; color: var(--slate-400); }
.rules-list b { color: var(--slate-100); }
.rules-list .rule-mode { padding-left: 16px; }
/* Tour dialog: centered slide, glowing icon, dots, Back/Next/Skip. */
.tour-slide { text-align: center; padding: 8px 4px 0; }
.tour-icon {
    width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center; font-size: 32px;
    background: rgba(34, 211, 238, 0.15); border: 1px solid rgba(34, 211, 238, 0.4);
    box-shadow: 0 0 24px rgba(34, 211, 238, 0.3);
}
.tour-slide h3 {
    margin: 0; font-family: var(--display); font-size: 20px; font-weight: 900;
    letter-spacing: 0.06em; color: var(--text);
}
.tour-slide .tour-sub { font-size: 13px; font-weight: 700; color: var(--cyan); margin-top: 4px; }
.tour-slide .tour-desc { font-size: 14px; color: var(--slate-300); line-height: 1.6; margin-top: 10px; }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin: 16px 0 4px; }
.tour-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--slate-700); border: none; padding: 0; cursor: pointer; }
.tour-dots .dot.active { background: var(--cyan); width: 24px; border-radius: 999px; }
.tour-nav { display: flex; gap: 8px; align-items: center; }
.tour-nav .spacer { flex: 1; }
.tour-skip { background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--body); min-height: 44px; padding: 0 8px; }

/* Desktop / wide window: Home centers at 520px with more air. */
@media (min-width: 768px) {
    #home { padding: 24px 28px; }
    .home-inner { gap: 16px; }
    .hero-tier { font-size: 28px; }
}
/* Very wide window: the Home column widens and the four feature tiles
   go four-across, so the desktop Home fills the window instead of
   floating as a narrow phone column in a sea of empty felt. Phone
   (<1024px) is untouched. */
@media (min-width: 1024px) {
    .home-inner { max-width: 780px; }
    .home-tiles { grid-template-columns: repeat(4, 1fr); }
}
/* Tall window: center the Home column vertically (only when the
   viewport is tall enough that the content fits — the inner already
   spans the full height, so this just centers its children). */
@media (min-width: 768px) and (min-height: 700px) {
    .home-inner { justify-content: center; }
}
/* Narrow phone: the top row (logo + profile + gear) is tight at 360px,
   so the profile name hides (avatar + level stay) and the logo shrinks
   — otherwise the gear is pushed off the right edge. */
@media (max-width: 400px) {
    .home-logo { font-size: 18px; letter-spacing: 0.04em; }
    .home-profile .hp-name { display: none; }
    .hero-tier { font-size: 21px; }
    .home-top { gap: 6px; }
}

/* CrazyGames variant: progression (XP bar on Home, match-end XP
   readout, locked avatars). Reuses the .progress bar. */
.xp-bar-wrap { margin: 10px 2px 2px; }
.xp-bar-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.xp-bar-top span:first-child { color: var(--gold); font-weight: 800; }
.xp-bar-sub { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; }
.xp-award { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--gold); border-radius: 12px; background: rgba(212, 175, 55, 0.08); }
.xp-head { font-size: 20px; font-weight: 800; color: var(--gold); text-align: center; }
.xp-head .level-up { display: block; font-size: 14px; margin-top: 4px; }
.xp-rows { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 6px 0; }
.xp-level { font-size: 12px; text-align: center; margin-bottom: 6px; }
.xp-streak { font-size: 12px; text-align: center; color: var(--muted); margin-top: 6px; }
.avatar-pick.locked { opacity: 0.45; filter: grayscale(1); }
.avatar-pick.locked .av-label::after { content: ' 🔒'; }
