/* Setback: portrait-first card table. Cards are drawn in CSS (original artwork, no branded deck). */

:root {
    --bg: #0d2419;
    --ink: #f3efe4;
    --ink-muted: #b9c4ba;
    --panel: #fbfaf6;
    --panel-ink: #1d1d1f;
    --panel-muted: #5f6368;
    --felt-light: #237a51;
    --felt-dark: #0f4a30;
    --gold: #f5c542;
    --card-face: #fffdf8;
    --card-edge: #d6d1c4;
    --red: #c8102e;
    --black: #1b1b1b;
    --joker: #6b2fa3;
    /* Team 1 is always blue and Team 2 always orange, whichever team you are on. */
    --team1: #4f8ef7;
    --team1-ink: #1e4fd8;
    --team2: #f08a3c;
    --team2-ink: #a8490c;
    --danger: #c8102e;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 700; }

.muted { color: var(--ink-muted); }
.small { font-size: .85rem; }
.link { color: var(--gold); }

.loading {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    font-family: Georgia, serif;
    font-size: 1.2rem;
    color: var(--ink-muted);
}

/* ---------- Buttons ---------- */

button {
    font: inherit;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    min-height: 44px;
    cursor: pointer;
    touch-action: manipulation;
}
button:disabled { cursor: default; opacity: .35; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.primary { background: var(--gold); color: #1d1d1f; font-weight: 700; }
.secondary { background: rgba(255, 255, 255, .12); color: var(--ink); }
.panel .secondary { background: #ebe7dc; color: var(--panel-ink); }
.wide { width: 100%; }
.icon-button {
    background: rgba(255, 255, 255, .1);
    color: var(--ink);
    min-width: 44px;
    padding: 8px;
    font-size: 1.2rem;
}
.icon-button.small { min-width: 36px; min-height: 36px; font-size: .8rem; }

/* ---------- Cards ---------- */

.card {
    --w: var(--card-w, 60px);
    position: relative;
    flex: none;
    width: var(--w);
    height: calc(var(--w) * 1.42);
    padding: 0;
    min-height: 0;
    border-radius: calc(var(--w) * .1);
    background: var(--card-face);
    border: 1px solid var(--card-edge);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
    color: var(--suit-colour, var(--black));
    font-weight: 700;
    user-select: none;
    -webkit-user-select: none;
}
.card .corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: .95;
    font-size: calc(var(--w) * .25);
}
.card .corner.top { top: 5%; left: 7%; }
.card .corner.bottom { bottom: 5%; right: 7%; transform: rotate(180deg); }
.card .corner .pip { font-size: .85em; }
.card .centre {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--w) * .5);
}
.card.joker { --suit-colour: var(--joker); }
.card.joker .centre {
    font-size: calc(var(--w) * .17);
    letter-spacing: .06em;
    text-transform: uppercase;
    writing-mode: vertical-rl;
}
.card.highlight { box-shadow: 0 0 0 3px var(--gold), 0 4px 12px rgba(0, 0, 0, .45); }
.card.mini { --card-w: 30px; }
.card.mini .corner.bottom, .card.mini .centre { display: none; }

.suit-hearts, .suit-diamonds { --suit-colour: var(--red); }
.suit-spades, .suit-clubs { --suit-colour: var(--black); }
.four-colour .suit-diamonds { --suit-colour: #1f5fbf; }
.four-colour .suit-clubs { --suit-colour: #1d7a3a; }
.suit-text { color: var(--suit-colour); }

.card-back {
    width: 40px;
    height: 57px;
    margin: 0 auto 4px;
    border-radius: 5px;
    border: 3px solid var(--card-face);
    background: repeating-linear-gradient(45deg, #7a1f2b 0 5px, #932c3a 5px 10px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

/* ---------- Table layout ---------- */

.table-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 760px;
    margin: 0 auto;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
}

.team-1 { --team: var(--team1); --team-ink: var(--team1-ink); }
.team-2 { --team: var(--team2); --team-ink: var(--team2-ink); }

.scorebar {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 6px;
}
.score-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    border-radius: 10px;
    border-top: 4px solid var(--team);
    background: rgba(255, 255, 255, .06);
    line-height: 1.1;
}
.score-team .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--team); font-weight: 700; }
.score-team .score { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hole { font-size: .7rem; color: #ff9b9b; }
.score-meta { text-align: center; font-size: .8rem; }

.infobar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 0 12px 6px;
    min-height: 30px;
}
.info-chip {
    font-size: .8rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    border-left: 3px solid var(--team, transparent);
}
.info-chip.trump { background: var(--card-face); color: var(--panel-ink); font-weight: 600; }

.felt {
    position: relative;
    flex: 1 1 auto;
    min-height: 230px;
    margin: 0 8px;
    border-radius: 28px;
    background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt-dark) 75%);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, .45), 0 0 0 4px #5a3a1e, 0 0 0 7px #3e2814;
    --card-w: 54px;
}

/* ---------- Seats ---------- */

.seat {
    position: absolute;
    z-index: 2;
    max-width: 104px;
    padding: 4px 8px;
    border-radius: 10px;
    border-left: 4px solid var(--team);
    background: rgba(0, 0, 0, .38);
    font-size: .8rem;
    transition: box-shadow .2s;
}
.seat-top { top: 10px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 8px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 8px; top: 50%; transform: translateY(-50%); }
.seat-bottom {
    position: static;
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    width: fit-content;
}
.seat.turn { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(245, 197, 66, .6); animation: pulse 1.6s ease-in-out infinite; }
.seat-name { display: flex; gap: 4px; align-items: center; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.seat-bottom .seat-chips { margin-top: 0; }
.chip {
    font-size: .7rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .15);
    white-space: nowrap;
}
.chip.dealer { background: var(--card-face); color: var(--panel-ink); font-weight: 800; }
.chip.bid.winning { background: var(--gold); color: #1d1d1f; font-weight: 700; }
.chip.drew { background: rgba(245, 197, 66, .25); }
.offline { font-size: .65rem; color: #ff9b9b; }

/* ---------- Trick ---------- */

.trick { position: absolute; inset: 0; }
.trick-slot { position: absolute; left: 50%; top: 50%; z-index: 1; }
.slot-bottom { transform: translate(-50%, 8%); }
.slot-top { transform: translate(-50%, -108%); }
.slot-left { transform: translate(-128%, -50%); }
.slot-right { transform: translate(28%, -50%); }

.enter-bottom { animation: enter-bottom .25s ease-out; }
.enter-top { animation: enter-top .25s ease-out; }
.enter-left { animation: enter-left .25s ease-out; }
.enter-right { animation: enter-right .25s ease-out; }
@keyframes enter-bottom { from { transform: translateY(60px); opacity: 0; } }
@keyframes enter-top { from { transform: translateY(-60px); opacity: 0; } }
@keyframes enter-left { from { transform: translateX(-60px); opacity: 0; } }
@keyframes enter-right { from { transform: translateX(60px); opacity: 0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--gold), 0 0 4px rgba(245, 197, 66, .3); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } }

.widow-pile {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: .75rem;
    color: var(--ink-muted);
}

.discard-strip {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .7rem;
    white-space: nowrap;
}

.last-trick-button {
    position: absolute;
    right: 10px;
    bottom: 8px;
    min-height: 32px;
    padding: 4px 10px;
    font-size: .75rem;
    background: rgba(0, 0, 0, .35);
    color: var(--ink);
}

/* ---------- Status and actions ---------- */

.status {
    margin: 8px 12px 0;
    padding: 8px 12px;
    min-height: 38px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: .95rem;
}
.status.mine { background: var(--gold); color: #1d1d1f; animation: fade-in .2s ease-out; }
.status.error { background: var(--danger); color: white; }

.action-panel { padding: 6px 12px 0; }
.action-panel:empty { display: none; }
.hint { margin: 4px 0 8px; font-size: .85rem; color: var(--ink-muted); text-align: center; }

.bid-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bid-button { background: var(--card-face); color: var(--panel-ink); font-weight: 700; padding: 8px 4px; }
.bid-button.take-it { grid-column: span 2; background: var(--gold); }
.bid-button.moon { grid-column: span 3; background: #2b2350; color: #f1e9ff; }
.bid-button.pass { grid-column: span 2; background: rgba(255, 255, 255, .15); color: var(--ink); }

.bid-history { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; font-size: .8rem; }
.bid-history span { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); border-left: 3px solid var(--team); }

.suit-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.suit-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    background: var(--card-face);
    color: var(--panel-ink);
    font-size: .8rem;
}
.suit-button .suit-symbol { font-size: 1.6rem; line-height: 1; color: var(--suit-colour); }
.suit-button .muted { color: var(--panel-muted); }

/* ---------- Hand ---------- */

.my-area { padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); }
.hand {
    --card-w: min(72px, calc((min(100vw, 760px) - 32px) / 5.2));
    display: flex;
    justify-content: center;
    padding: 18px 0 4px;
}
.hand .card {
    /* The whole fan spans about 15 degrees, however many cards are held. */
    --rot: calc((var(--i) - (var(--count) - 1) / 2) * 15deg / var(--count));
    transform-origin: 50% 130%;
    transform: rotate(var(--rot));
    transition: transform .15s ease-out, filter .15s;
}
.hand .card + .card {
    margin-left: clamp(calc(var(--card-w) * -0.62), calc((min(100vw, 760px) - 32px - var(--count) * var(--card-w)) / (var(--count) - 1)), 6px);
}
.hand .card.selected { transform: rotate(var(--rot)) translateY(-18px); box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0, 0, 0, .5); }
.hand .card.unplayable { filter: brightness(.55) saturate(.5); opacity: 1; }
@media (hover: hover) {
    .hand button.card:not(:disabled):not(.selected):hover { transform: rotate(var(--rot)) translateY(-8px); }
}
/* Top-left, because each card in the fan overlaps the right-hand side of the one before it. */
.card.from-widow::after {
    content: "★";
    position: absolute;
    top: -9px;
    left: -4px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold);
    color: #1d1d1f;
    font-size: 11px;
}
.hand-hint { text-align: center; font-size: .8rem; color: var(--ink-muted); margin-top: 4px; }

/* ---------- Overlays ---------- */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, .55);
    animation: fade-in .2s ease-out;
}
.panel {
    width: min(440px, 100%);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    padding: 18px;
    border-radius: 16px;
    background: var(--panel);
    color: var(--panel-ink);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.panel h2 { margin: 0 0 4px; text-align: center; }
.panel .muted { color: var(--panel-muted); }
.panel .card { --card-w: 52px; }

.team-text { color: var(--team-ink); font-weight: 700; }
.panel .suit-text { font-weight: 700; }
.summary-bid { text-align: center; margin: 0; }
.made { color: #1d7a3a; }
.set { color: var(--danger); }

.points { width: 100%; border-collapse: collapse; font-size: .9rem; }
.points th { text-align: left; font-weight: 500; padding: 4px 0; }
.points td { padding: 4px 0 4px 8px; }
.points tr + tr { border-top: 1px solid #ebe7dc; }
.points .value { text-align: right; font-variant-numeric: tabular-nums; color: var(--panel-muted); }
.counts { font-size: .85rem; margin: 0; text-align: center; }

.summary-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0; }
.summary-team {
    padding: 8px;
    border-radius: 10px;
    border-top: 4px solid var(--team);
    background: #f1eee5;
    text-align: center;
    line-height: 1.25;
}
.summary-team .label { color: var(--team-ink); font-weight: 800; text-transform: uppercase; font-size: .8rem; letter-spacing: .06em; }
.summary-team .captured { font-size: .8rem; color: var(--panel-muted); }
.summary-team .change { font-weight: 700; }
.summary-team .total { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary-team .hole { color: var(--danger); }

.last-trick-cards { display: flex; justify-content: center; gap: 8px; }
.last-trick-play { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .8rem; }
.last-trick p, .game-over p { text-align: center; margin: 4px 0; }

/* ---------- Home and settings ---------- */

.home, .settings {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.home { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
.home-hero { text-align: center; }
.home-hero h1 { font-size: 3rem; margin: 12px 0 4px; letter-spacing: .02em; }
.home-cards, .setback-icon { display: flex; justify-content: center; --card-w: 64px; }
.home-cards .card + .card, .setback-icon .card + .card { margin-left: calc(var(--card-w) * -0.22); }
.home-cards .tilt-left, .setback-icon .tilt-left { transform: rotate(-10deg) translateY(6px); }
.home-cards .tilt-right, .setback-icon .tilt-right { transform: rotate(10deg) translateY(6px); }
.holdem-icon { width: 170px; height: auto; display: block; margin: 0 auto; }
/* New Market's picture: the four sevens in a row, with cards built above and below some of them. */
.newmarket-icon { display: flex; justify-content: center; gap: 4px; --card-w: 34px; }
.newmarket-icon .nm-icon-column { display: flex; flex-direction: column; }
.newmarket-icon .card + .card { margin-top: calc(var(--card-w) * -0.9); }
.newmarket-icon .nm-icon-gap { height: calc(var(--card-w) * 0.52); }
.home-actions { display: flex; flex-direction: column; gap: 10px; text-align: center; }

.settings-header { display: flex; align-items: center; gap: 12px; }
.settings-header h1 { margin: 0; }
.settings section { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.settings h2 { margin: 0; font-size: 1.2rem; }
.settings h3 { margin: 8px 0 0; font-size: 1rem; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--gold); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--ink-muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field input, .field select {
    font: inherit;
    font-size: 1rem;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .08);
    color: var(--ink);
}
.field.inline input { width: 80px; }
.field select option { color: var(--panel-ink); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.trump-order { margin: 0; padding-left: 28px; display: flex; flex-direction: column; gap: 4px; }
.trump-order li { display: flex; align-items: center; gap: 6px; }
.trump-order li span { flex: 1; }
.settings-actions { margin-top: 24px; }
.settings-logout { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 28px; }
.error-text { color: #ff9b9b; }

/* ---------- Polish: dealing, drawing, collecting tricks, score changes ---------- */

/* Cards slide into the hand when dealt or drawn. Uses the separate "translate" property so it doesn't fight
   the fan's rotation. Only new card elements animate, so re-sorting the hand doesn't replay it. */
.hand .card {
    animation: deal-in .35s ease-out both;
    animation-delay: calc(var(--i) * 45ms);
}
@keyframes deal-in { from { translate: 0 70px; opacity: 0; } }

.hand .card.drawn { box-shadow: 0 0 0 3px #4ade80, 0 4px 12px rgba(0, 0, 0, .4); }

/* Floats over the bottom of the table so it never pushes the hand off screen, then fades away. */
.refill-note {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: 44px;
    translate: -50% 0;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .55);
    font-size: .8rem;
    text-align: center;
    animation: fade-in .25s ease-out, fade-away .6s ease-in 4.2s forwards;
}
.refill-cards { display: flex; justify-content: center; gap: 3px; margin-top: 4px; }
.refill-cards .card.mini { --card-w: 22px; }
@keyframes fade-away { to { opacity: 0; } }

/* A finished trick pauses, then slides towards whoever took it. */
.trick.collect .trick-slot { animation: collect .45s ease-in .7s forwards; }
.trick.collect-top .trick-slot { --to-x: 0; --to-y: -170px; }
.trick.collect-bottom .trick-slot { --to-x: 0; --to-y: 170px; }
.trick.collect-left .trick-slot { --to-x: -150px; --to-y: 0; }
.trick.collect-right .trick-slot { --to-x: 150px; --to-y: 0; }
@keyframes collect { to { translate: var(--to-x) var(--to-y); scale: .55; opacity: 0; } }

.score-team { position: relative; }
.score.bump { animation: bump .5s ease-out; }
@keyframes bump { 40% { scale: 1.25; } }
.score-delta {
    position: absolute;
    right: -4px;
    top: -10px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--bg);
    font-weight: 800;
    font-size: .9rem;
    animation: float-up 2.5s ease-out forwards;
}
.score-delta.up { color: #4ade80; }
.score-delta.down { color: #ff8a8a; }
@keyframes float-up {
    0% { opacity: 0; translate: 0 8px; }
    15% { opacity: 1; translate: 0 0; }
    70% { opacity: 1; }
    100% { opacity: 0; translate: 0 -10px; }
}

button.score-meta {
    background: none;
    color: var(--ink);
    padding: 4px 6px;
    min-height: 0;
    font-size: .8rem;
    text-decoration: underline dotted rgba(255, 255, 255, .35);
    text-underline-offset: 3px;
}

.score-sheet table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.score-sheet th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; padding: 4px 4px 6px; }
.score-sheet td { padding: 5px 4px; border-top: 1px solid #ebe7dc; vertical-align: top; }
.score-sheet .num { text-align: right; }
.score-sheet .total { display: block; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-sheet .total.negative { color: var(--danger); }
.score-sheet .change { display: block; font-size: .75rem; color: var(--panel-muted); }
.score-sheet .record { text-align: center; margin: 0; }

.sound-test { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Fireworks (or rain for the losers) fill the dimmed backdrop behind the game-over panel. */
.game-over-effect { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sad-title { color: #4a5563; }
.sad-face { display: inline-block; animation: droop 2.4s ease-in-out 0.4s both; }
@keyframes droop {
    0% { rotate: 0deg; translate: 0 0; }
    60% { rotate: 18deg; translate: 0 6px; }
    100% { rotate: 12deg; translate: 0 4px; }
}
.game-over { position: relative; z-index: 1; }

/* ---------- Game chooser ---------- */

/* A back button pinned to the top-left of a centred page. */
.home { position: relative; }
.page-back { position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 16px; }


.chooser { justify-content: flex-start; gap: 20px; }
.chooser-title { text-align: center; }
.chooser-title h1 { font-size: 2.3rem; margin: 8px 0 2px; }
.chooser-title p { margin: 0; }
.game-tiles { display: flex; flex-direction: column; gap: 14px; }
.game-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 128px;
    padding: 14px 14px 14px 8px;
    border-radius: 20px;
    background: radial-gradient(ellipse at 25% 40%, var(--felt-light) 0%, var(--felt-dark) 85%);
    box-shadow: inset 0 0 24px rgba(0, 0, 0, .35), 0 0 0 3px #5a3a1e, 0 8px 18px rgba(0, 0, 0, .35);
    color: var(--ink);
    text-align: left;
    transition: transform .15s ease-out;
}
.game-tile:not(:disabled):active { transform: scale(.98); }
@media (hover: hover) {
    .game-tile:not(:disabled):hover { transform: translateY(-2px); }
}
.game-tile:disabled { opacity: 1; }
.game-tile-picture { flex: none; width: 128px; display: grid; place-items: center; }
.game-tile .setback-icon { --card-w: 42px; }
.game-tile .holdem-icon { width: 128px; }
.game-tile .newmarket-icon { --card-w: 30px; gap: 2px; }
.game-tile-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.game-tile-name { font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; font-weight: 700; }
.game-tile-tagline { font-size: .85rem; line-height: 1.3; }
.game-tile-players { font-size: .75rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .04em; }
.game-tile.coming-soon .game-tile-picture, .game-tile.coming-soon .game-tile-text { opacity: .55; }
.game-tile-badge {
    position: absolute;
    top: -12px;
    right: 18px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--gold);
    color: #1d1d1f;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

/* ---------- Language picker ---------- */

.language-picker { display: flex; justify-content: center; gap: 6px; }
.field .language-picker { justify-content: flex-start; margin-top: 4px; }
.language-choice {
    min-height: 36px;
    padding: 6px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    color: var(--ink);
    font-size: .9rem;
}
.language-choice.chosen { background: var(--gold); color: #1d1d1f; font-weight: 700; }

/* ---------- Multiplayer: forms, lobby, seats ---------- */

.form-page { justify-content: flex-start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }

.lobby {
    max-width: 520px;
    margin: 0 auto;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.lobby h1, .lobby h2 { margin: 0; }
.lobby h2 { font-size: 1.2rem; }
.lobby-header { display: flex; justify-content: space-between; align-items: center; }
.room-code { font-family: ui-monospace, Menlo, monospace; font-size: 2.2rem; font-weight: 800; letter-spacing: .18em; }

.invite {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .06);
}
.qr { flex: none; background: white; border-radius: 8px; padding: 6px; }
.invite-text { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.invite-text p { margin: 0; }
.share-link {
    width: 100%;
    font: inherit;
    font-size: .85rem;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(0, 0, 0, .25);
    color: var(--ink);
}
@media (max-width: 420px) {
    .invite { flex-direction: column; text-align: center; }
}

.small-button { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.secondary.small-button, .small-button:not(.primary) { background: rgba(255, 255, 255, .14); color: var(--ink); }
.panel .small-button:not(.primary) { background: #ebe7dc; color: var(--panel-ink); }
.small-select { font: inherit; font-size: .85rem; min-height: 36px; border-radius: 8px; padding: 4px 8px; }

.seat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "top top" "left right" "bottom bottom";
    gap: 8px;
}
.seat-card {
    padding: 10px;
    border-radius: 12px;
    border-left: 5px solid var(--team);
    background: rgba(255, 255, 255, .07);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.panel .seat-card { background: #f1eee5; }
.seat-card.at-top { grid-area: top; justify-self: center; width: min(100%, 260px); }
.seat-card.at-left { grid-area: left; }
.seat-card.at-right { grid-area: right; }
.seat-card.at-bottom { grid-area: bottom; justify-self: center; width: min(100%, 260px); }
.seat-card.empty { border-left-style: dashed; }
.seat-card.moving { box-shadow: 0 0 0 2px var(--gold); }
.seat-card-name { display: flex; align-items: center; gap: 6px; font-weight: 700; flex-wrap: wrap; }
.seat-card-team { font-size: .75rem; color: var(--team); font-weight: 600; }
.panel .seat-card-team { color: var(--team-ink); }
.seat-card-note { font-size: .75rem; }
.seat-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.presence { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.presence.online { background: #4ade80; }
.presence.offline { background: #f87171; }
.chip.host { background: var(--gold); color: #1d1d1f; font-weight: 700; }
.unseated { margin: 8px 0 0; }
.lobby-footer { display: flex; flex-direction: column; gap: 8px; }
.lobby-footer p { margin: 0; }
.players-panel { width: min(520px, 100%); }

.connection-banner {
    margin: 6px 12px 0;
    padding: 6px 12px;
    border-radius: 10px;
    background: var(--danger);
    color: white;
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
}
.status-extras {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 12px 0;
    font-size: .85rem;
}
.notice {
    margin: 6px 12px 0;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(245, 197, 66, .2);
    border: 1px solid var(--gold);
    text-align: center;
    font-size: .85rem;
    animation: fade-in .2s ease-out;
}

/* ---------- Texas Hold'em ---------- */

/* Games without teams: seats listed in order, with a neutral edge instead of a team colour. */
.seat-grid.no-teams { grid-template-areas: none; }
.seat-card.no-team { --team: rgba(255, 255, 255, .3); --team-ink: var(--panel-muted); }
.lobby .randomise { align-self: flex-start; margin-top: 8px; }

.holdem-bar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 6px;
}
.blinds-now { font-weight: 800; font-size: 1.05rem; }
button.hand-number {
    background: none;
    color: var(--ink);
    min-height: 0;
    padding: 4px 6px;
    font-size: .85rem;
    text-decoration: underline dotted rgba(255, 255, 255, .35);
    text-underline-offset: 3px;
}

.holdem-felt { min-height: 280px; margin-top: 4px; }

/* Seats round the felt. Positions are named, so more seats only need more names. */
.pk-seat {
    position: absolute;
    z-index: 2;
    width: 104px;
    padding: 4px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .4);
    font-size: .78rem;
    text-align: center;
    transition: box-shadow .2s, opacity .2s;
}
.pk-seat.pos-top { top: 8px; left: 50%; translate: -50% 0; }
.pk-seat.pos-top-left { top: 8px; left: 10%; }
.pk-seat.pos-top-right { top: 8px; right: 10%; }
.pk-seat.pos-left { left: 6px; top: 24%; }
.pk-seat.pos-right { right: 6px; top: 24%; }
.pk-seat.pos-bottom { bottom: 8px; left: 50%; translate: -50% 0; }
.pk-seat.turn, .pk-me.turn .pk-me-plate { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(245, 197, 66, .6); animation: pulse 1.6s ease-in-out infinite; }
.pk-seat.folded { opacity: .55; }
.pk-seat.out { opacity: .45; }
.pk-seat.winner { box-shadow: 0 0 0 2px #4ade80, 0 0 16px rgba(74, 222, 128, .5); }
.pk-name { display: flex; justify-content: center; align-items: center; gap: 3px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-stack { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); }
.pk-markers { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 2px; min-height: 18px; }
.chip.pk-blind { background: rgba(255, 255, 255, .28); }
.chip.pk-all-in { background: var(--danger); color: white; font-weight: 700; }
.chip.pk-action { background: rgba(245, 197, 66, .3); }
.pk-cards { display: flex; justify-content: center; gap: 3px; margin-top: 4px; min-height: 0; }
.pk-cards:empty { display: none; }
.pk-cards .card.mini { --card-w: 30px; }
.pk-back {
    width: 22px;
    height: 31px;
    border-radius: 3px;
    border: 2px solid var(--card-face);
    background: repeating-linear-gradient(45deg, #7a1f2b 0 4px, #932c3a 4px 8px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.pk-hand-name { margin-top: 3px; font-size: .7rem; font-weight: 600; line-height: 1.2; }

/* Chips bet this round sit between each seat and the middle. */
.pk-bet {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 3px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .45);
    font-size: .8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    animation: fade-in .2s ease-out;
}
.pk-chip {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--danger);
    border: 3px dashed var(--card-face);
}
.bet-top { top: 112px; left: 50%; translate: -50% 0; }
.bet-top-left { top: 112px; left: 16%; }
.bet-top-right { top: 112px; right: 16%; }
.bet-left { left: 22px; top: calc(24% + 112px); }
.bet-right { right: 22px; top: calc(24% + 112px); }
.bet-bottom { bottom: 10px; left: 50%; translate: -50% 0; }
/* A watcher sees the bottom seat on the felt, with its bet above it. */
.pk-seat.pos-bottom + .bet-bottom { bottom: 120px; }

.pk-centre {
    position: absolute;
    left: 50%;
    top: 58%;
    translate: -50% -50%;
    width: calc(100% - 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.pk-pot { font-weight: 800; font-size: 1rem; padding: 2px 12px; border-radius: 999px; background: rgba(0, 0, 0, .3); }
.pk-side-pots { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; font-size: .75rem; color: var(--ink-muted); }
.pk-board { display: flex; justify-content: center; gap: 4px; --card-w: min(54px, calc((min(100vw, 760px) - 64px) / 5.4)); }
.pk-board .card { animation: deal-in .3s ease-out both; }
.pk-slot {
    width: var(--card-w);
    height: calc(var(--card-w) * 1.42);
    border-radius: calc(var(--card-w) * .1);
    border: 2px dashed rgba(255, 255, 255, .18);
}
.pk-to-call { font-size: .85rem; font-weight: 700; color: var(--gold); }
.pk-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .45);
    font-size: .85rem;
    font-weight: 600;
    text-align: center;
    animation: fade-in .25s ease-out;
}

.pk-log-strip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-height: 0;
    margin: 4px 12px 0;
    padding: 2px 8px;
    background: none;
    color: var(--ink-muted);
    font-size: .8rem;
    line-height: 1.35;
}
.pk-log-strip span:last-child { color: var(--ink); }

/* This player's own seat: name plate, hole cards and the hand-strength helper. */
.pk-me { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px 0; }
.pk-me.folded .pk-hole { opacity: .5; }
.pk-me-plate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .3);
    font-size: .85rem;
}
.pk-me-plate .pk-markers { margin-top: 0; min-height: 0; }
.pk-hole { display: flex; gap: 6px; --card-w: 64px; }
.pk-hole:empty { display: none; }
.pk-hole .card { animation: deal-in .35s ease-out both; }
.pk-hole .card + .card { animation-delay: 60ms; rotate: 4deg; }
.pk-hole .card:first-child { rotate: -4deg; }
.pk-helper { font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: rgba(245, 197, 66, .2); }

.pk-controls { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.pk-controls:empty { display: none; }
.pk-actions { display: flex; gap: 8px; }
.pk-actions > button { flex: 1; min-height: 52px; font-weight: 700; font-size: 1rem; }
.pk-fold { background: rgba(200, 16, 46, .85); color: white; }
.pk-quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.pk-quick-button { padding: 6px 2px; min-height: 40px; font-size: .8rem; background: var(--card-face); color: var(--panel-ink); font-weight: 700; }
.pk-slider { display: flex; align-items: center; gap: 6px; }
.pk-slider input[type="range"] { flex: 1; min-width: 0; accent-color: var(--gold); height: 32px; }
.pk-amount {
    width: 84px;
    font: inherit;
    font-weight: 700;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .25);
    background: rgba(0, 0, 0, .25);
    color: var(--ink);
    text-align: right;
}

.pk-standings { margin: 4px 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.pk-standings li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: #f1eee5; }
.pk-standings li.me { box-shadow: inset 0 0 0 2px var(--gold); }
.pk-standings .pk-place { font-weight: 800; }
.pk-log-panel h3 { margin: 8px 0 0; font-size: .95rem; }
.pk-log { margin: 0; padding-left: 18px; font-size: .9rem; display: flex; flex-direction: column; gap: 2px; }

@media (min-width: 600px) {
    .pk-seat { width: 130px; font-size: .85rem; }
    .pk-hole { --card-w: 76px; }
}

/* ---------- Texas Hold'em: animations, history, scoreboard, landscape ---------- */

/* The status, cards and controls follow the table in portrait; in landscape they become a column beside it. */
.pk-side { display: contents; }

/* A finished betting round's bets slide into the pot. */
.pk-bet.collecting { animation: collect-bet .5s ease-in forwards; }
.pk-bet.collecting.bet-top { --to-x: 0; --to-y: 120px; }
.pk-bet.collecting.bet-top-left { --to-x: 70px; --to-y: 120px; }
.pk-bet.collecting.bet-top-right { --to-x: -70px; --to-y: 120px; }
.pk-bet.collecting.bet-left { --to-x: 110px; --to-y: 30px; }
.pk-bet.collecting.bet-right { --to-x: -110px; --to-y: 30px; }
.pk-bet.collecting.bet-bottom { --to-x: 0; --to-y: -110px; }
@keyframes collect-bet { to { transform: translate(var(--to-x), var(--to-y)); opacity: 0; } }

/* The pot slides from the middle to each winner. */
.pk-win-chips {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 46%;
    translate: -50% -50%;
    display: flex;
    gap: 2px;
    pointer-events: none;
    animation: win-chips 1s ease-in-out .3s both;
}
.pk-win-chips .pk-chip { width: 20px; height: 20px; background: var(--gold); border-color: #fff8de; }
.pk-win-chips.to-top { --to-x: 0; --to-y: -170px; }
.pk-win-chips.to-top-left { --to-x: -100px; --to-y: -170px; }
.pk-win-chips.to-top-right { --to-x: 100px; --to-y: -170px; }
.pk-win-chips.to-left { --to-x: -130px; --to-y: -70px; }
.pk-win-chips.to-right { --to-x: 130px; --to-y: -70px; }
.pk-win-chips.to-bottom { --to-x: 0; --to-y: 260px; }
@keyframes win-chips {
    0% { transform: scale(.6); opacity: 0; }
    25% { transform: scale(1.15); opacity: 1; }
    85% { opacity: 1; }
    100% { transform: translate(var(--to-x), var(--to-y)) scale(.7); opacity: 0; }
}

/* An all-in run-out deals the missing streets one at a time (each card's delay is set on it). */
.pk-board .card.runout { animation: run-out .45s ease-out both; }
@keyframes run-out {
    from { transform: rotateY(90deg) translateY(-12px); opacity: 0; }
    60% { opacity: 1; }
}
.holdem-felt.result .pk-results { animation: fade-in .3s ease-out; }

/* Hand history: one fold-out section per hand, newest first. */
.pk-history { width: min(520px, 100%); }
.pk-hand { border-top: 1px solid #ebe7dc; padding: 6px 0; }
.pk-hand summary { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; cursor: pointer; padding: 4px 0; }
.pk-hand-title { font-weight: 800; }
.pk-hand summary .muted { font-size: .85rem; }
.pk-hand-board, .pk-shown { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.pk-hand-board .card.mini, .pk-shown .card.mini { --card-w: 30px; }
.pk-shown-name { min-width: 72px; font-weight: 700; font-size: .85rem; }
.pk-shown .muted { font-size: .8rem; }
.pk-history .pk-log { margin-top: 4px; }

/* Session scoreboard and final standings. */
.pk-scoreboard table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.pk-scoreboard th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; padding: 4px; }
.pk-scoreboard td { padding: 6px 4px; border-top: 1px solid #ebe7dc; }
.pk-scoreboard .num { text-align: right; font-variant-numeric: tabular-nums; }
.pk-scoreboard tr.me td { background: rgba(245, 197, 66, .18); }
.pk-scoreboard .pk-place { font-weight: 800; width: 40px; }
.pk-scoreboard p { margin: 0; text-align: center; }
.pk-standing-name { display: flex; flex-direction: column; line-height: 1.2; }

/* Landscape phones: the table on the left, everything else in a column on the right. */
@media (orientation: landscape) and (max-height: 560px) {
    .table-screen.holdem {
        display: grid;
        grid-template-columns: minmax(0, 1.45fr) minmax(250px, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas: "bar side" "felt side";
        max-width: none;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .holdem .holdem-bar { grid-area: bar; padding-bottom: 2px; }
    .holdem .holdem-felt { grid-area: felt; min-height: 0; margin: 4px 8px 8px; }
    .holdem .pk-side {
        grid-area: side;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        min-height: 0;
        overflow-y: auto;
        padding-top: env(safe-area-inset-top);
    }
    .holdem .pk-seat { width: 96px; padding: 3px 5px; }
    .holdem .pk-seat.pos-left, .holdem .pk-seat.pos-right { top: 30%; }
    .holdem .pk-centre { top: 60%; }
    .holdem .pk-board { --card-w: 42px; }
    .holdem .bet-top, .holdem .bet-top-left, .holdem .bet-top-right { top: 104px; }
    .holdem .bet-left { top: calc(30% + 104px); }
    .holdem .bet-right { top: calc(30% + 104px); }
    .holdem .pk-hole { --card-w: 52px; }
    .holdem .pk-actions > button { min-height: 46px; }
    /* This player's seat is in the column on the right. */
    .holdem .pk-win-chips.to-bottom { --to-x: 300px; --to-y: 120px; }
}

/* ---------- New Market ---------- */

/* Up to eight players and two rows of cards can be taller than a phone, so this table scrolls. */
.table-screen.newmarket { height: auto; min-height: 100dvh; overflow: visible; padding-bottom: env(safe-area-inset-bottom); }

.nm-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px 6px; }
.nm-round { font-weight: 800; font-size: 1.05rem; }

/* The other players, clockwise from you, as compact tiles. */
.nm-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; padding: 0 10px 8px; }
.nm-player {
    padding: 4px 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .07);
    font-size: .78rem;
    text-align: center;
    min-width: 0;
}
.nm-player.turn, .nm-me.turn .nm-me-plate { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(245, 197, 66, .6); animation: pulse 1.6s ease-in-out infinite; }
.nm-player.out { opacity: .6; }
.nm-name { display: flex; justify-content: center; align-items: center; gap: 3px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 2px; }
.nm-score { font-size: .7rem; }
.chip.nm-place { background: var(--gold); color: #1d1d1f; font-weight: 800; }
.chip.nm-passed { background: rgba(255, 255, 255, .28); font-style: italic; }

/* The layout: the sevens in a row, each column growing up and down from its seven, every card showing its
   corner. --y is a card's row: 0 at the top, the sevens on row --above. */
.nm-felt {
    flex: 0 0 auto;
    min-height: 0;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    --card-w: min(52px, calc((min(100vw, 760px) - 44px) / var(--cols) - 6px));
    --step: calc(var(--card-w) * 0.5);
}
.nm-layout { display: flex; justify-content: center; gap: 6px; }
.nm-column { position: relative; width: var(--card-w); height: calc((var(--above) + var(--below)) * var(--step) + var(--card-w) * 1.42); }
.nm-column .card, .nm-slot { position: absolute; left: 0; top: calc(var(--y) * var(--step)); }
.nm-slot {
    width: var(--card-w);
    height: calc(var(--card-w) * 1.42);
    border-radius: calc(var(--card-w) * .1);
    border: 2px dashed rgba(255, 255, 255, .16);
}
.nm-slot.open { border-color: rgba(245, 197, 66, .8); }
.nm-slot.target { border: 2px solid var(--gold); background: rgba(245, 197, 66, .25); box-shadow: 0 0 12px rgba(245, 197, 66, .7); }
.nm-result-banner { padding: 4px 14px; border-radius: 999px; background: rgba(0, 0, 0, .45); font-weight: 700; animation: fade-in .25s ease-out; }

.nm-log-strip { display: flex; flex-direction: column; align-items: center; margin: 4px 12px 0; font-size: .8rem; color: var(--ink-muted); line-height: 1.35; }
.nm-log-strip span:last-child { color: var(--ink); }

/* Your cards, a row for each suit; the rows overlap so every card's corner shows. */
.nm-me { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 8px 0; }
.nm-me-plate { display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 10px; background: rgba(0, 0, 0, .3); font-size: .85rem; }
.nm-why { margin: 0; }
.nm-hand { --card-w: min(52px, calc((min(100vw, 760px) - 32px) / 7.8)); display: flex; flex-direction: column; align-items: center; padding-top: 10px; }
.nm-hand-row { display: flex; }
.nm-hand-row + .nm-hand-row { margin-top: calc(var(--card-w) * -0.62); }
.nm-hand-row .card + .card { margin-left: calc(var(--card-w) * -0.4); }
.nm-hand .card { transition: translate .15s ease-out; }
.nm-hand .card.selected { translate: 0 -12px; box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0, 0, 0, .5); z-index: 1; }
.card.nm-waiting { filter: brightness(.55) saturate(.5); }
.nm-controls { padding: 10px 12px; }
.nm-controls:empty { display: none; }

.nm-order { margin: 4px 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.nm-order li { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: #f1eee5; }
.nm-order li.me { box-shadow: inset 0 0 0 2px var(--gold); }
.nm-order-place { font-weight: 800; }
.nm-order-name { display: flex; flex-direction: column; gap: 4px; }
.nm-order-score { text-align: right; font-weight: 700; display: flex; flex-direction: column; }
.nm-left-with { display: flex; flex-wrap: wrap; gap: 2px; }
.nm-left-with .card.mini { --card-w: 24px; }
.nm-totals { text-align: center; margin: 4px 0; }

/* Passing: a stamp pops up on the player's tile, and the player who had to pass gets a banner. */
.nm-player, .nm-me-plate { position: relative; }
.nm-pass-pop {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    padding: 2px 10px;
    border: 3px solid var(--danger);
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    color: var(--danger);
    font-weight: 900;
    letter-spacing: .12em;
    pointer-events: none;
    animation: pass-stamp 1.8s ease-out forwards;
}
@keyframes pass-stamp {
    0% { opacity: 0; scale: 2.2; rotate: -18deg; }
    18% { opacity: 1; scale: 1; rotate: -10deg; }
    75% { opacity: 1; }
    100% { opacity: 0; scale: .9; rotate: -10deg; }
}
.chip.nm-stuck { background: var(--danger); color: white; font-weight: 700; animation: pulse 1s ease-in-out infinite; }
.nm-pass-banner {
    position: fixed;
    z-index: 15;
    left: 50%;
    top: 38%;
    translate: -50% -50%;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 20px;
    border-radius: 999px;
    border: 2px solid var(--danger);
    background: rgba(20, 10, 14, .9);
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    pointer-events: none;
    animation: pass-banner 1.8s ease-out forwards;
}
.nm-pass-icon { font-size: 1.5rem; }
@keyframes pass-banner {
    0% { opacity: 0; scale: .6; }
    15% { opacity: 1; scale: 1.05; }
    25% { scale: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; translate: -50% -70%; }
}

/* The round summary. */
.nm-result-trophy { font-size: 2.6rem; text-align: center; line-height: 1; animation: bump .6s ease-out; }
.nm-result-round { text-align: center; margin: -4px 0 4px; }
.nm-order li.first { background: #fbefc7; }
.nm-order-place { font-size: 1.15rem; }
.nm-result-subtitle { margin: 8px 0 0; font-size: .95rem; text-align: center; }
/* With many players the result scrolls; its button stays in reach at the bottom. */
.nm-result > button.wide:last-child { position: sticky; bottom: 0; box-shadow: 0 -10px 14px var(--panel); }
.nm-standings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nm-standings li { display: flex; justify-content: space-between; align-items: center; padding: 3px 10px; border-radius: 8px; }
.nm-standings li.me { background: rgba(245, 197, 66, .18); }
.nm-stars span { color: #d6d1c4; font-size: 1.05rem; }
.nm-stars span.won { color: #e0a800; }
.nm-points { font-weight: 700; }

/* The help page's example layout. */
.nm-help ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.nm-help p { margin: 0; line-height: 1.45; }
.nm-example { margin: 4px auto; padding: 14px 24px; --card-w: 52px; }

/* ---------- Shed ---------- */

/* Shed's picture: three face-down cards with a face-up card laid on each. */
.shed-icon { display: flex; justify-content: center; gap: 8px; --card-w: 34px; }
.game-tile .shed-icon { --card-w: 30px; gap: 6px; }
.shed-icon-stack { position: relative; width: calc(var(--card-w) + 4px); height: calc(var(--card-w) * 1.42 + 10px); }
.shed-icon-stack .card { position: absolute; left: 4px; top: 10px; rotate: 4deg; }
.shed-icon-back, .card-back.sh-back {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--card-w);
    height: calc(var(--card-w) * 1.42);
    margin: 0;
    padding: 0;
    min-height: 0;
    border-width: 2px;
}

/* The centre of the table: draw pile, play pile and discards, and what the next card must be. */
.sh-felt { flex: 0 0 auto; min-height: 0; padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; --card-w: 60px; }
.sh-choosing { margin: 18px 0; text-align: center; color: var(--ink-muted); }
.sh-centre { display: flex; justify-content: center; align-items: flex-end; gap: 22px; }
.sh-heap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sh-heap .card-back.sh-back, .sh-heap .sh-slot { position: relative; }
.sh-slot { width: var(--card-w); height: calc(var(--card-w) * 1.42); border-radius: calc(var(--card-w) * .1); border: 2px dashed rgba(255, 255, 255, .2); }
.sh-play-pile { --card-w: 74px; }
.sh-play-pile .card { animation: deal-in .25s ease-out both; }
.sh-heap-label { font-size: .75rem; font-weight: 700; color: var(--ink-muted); }
.sh-discards {
    width: calc(var(--card-w) * .7);
    height: calc(var(--card-w) * 1);
    border-radius: 6px;
    background: repeating-linear-gradient(-30deg, rgba(0, 0, 0, .35) 0 4px, rgba(0, 0, 0, .15) 4px 8px);
    border: 2px solid rgba(255, 255, 255, .15);
}
.sh-needs { padding: 3px 12px; border-radius: 999px; background: rgba(0, 0, 0, .35); font-size: .85rem; font-weight: 700; color: var(--gold); }
.sh-pending { padding: 4px 12px; border-radius: 10px; background: rgba(200, 16, 46, .85); color: white; font-weight: 700; animation: fade-in .2s ease-out; }
.sh-burn {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 40%;
    translate: -50% -50%;
    padding: 4px 12px;
    border-radius: 999px;
    background: linear-gradient(#ffb03b, #e2401c);
    color: white;
    font-weight: 900;
    letter-spacing: .08em;
    white-space: nowrap;
    pointer-events: none;
    animation: pass-stamp 1.8s ease-out forwards;
}
.sh-play-pile.burning .card { animation: burn-away .6s ease-in forwards; }
@keyframes burn-away { to { filter: brightness(2) sepia(1) saturate(4); opacity: .2; scale: .85; } }

/* Your hand, wrapping onto more rows after a big pickup, with a badge on each special card. */
.sh-hand {
    --card-w: min(54px, calc((min(100vw, 760px) - 40px) / 6.2));
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    padding: 12px calc(var(--card-w) * .45) 0 0;
}
.sh-card-wrap { position: relative; margin-right: calc(var(--card-w) * -0.45); transition: translate .15s ease-out; }
.sh-card-wrap.selected { translate: 0 -12px; z-index: 1; }
.sh-card-wrap .card.selected { box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0, 0, 0, .5); }
.sh-badge {
    position: absolute;
    left: 2px;
    bottom: 2px;
    padding: 0 4px;
    border-radius: 6px;
    background: var(--danger);
    color: white;
    font-size: .58rem;
    font-weight: 800;
    pointer-events: none;
}

/* Your face-down cards, each with its face-up card laid on it. */
.sh-table-cards { display: flex; justify-content: center; gap: 12px; padding-top: 8px; --card-w: 46px; }
.sh-stack { position: relative; width: calc(var(--card-w) + 6px); height: calc(var(--card-w) * 1.42 + 12px); }
.sh-stack .sh-slot { position: absolute; left: 0; top: 0; border-width: 1px; }
.sh-stack .card.sh-face-up { position: absolute; left: 6px; top: 12px; }
button.card-back.sh-back { cursor: default; }
button.card-back.sh-back:disabled { opacity: 1; }
button.card-back.sh-back.playable { cursor: pointer; box-shadow: 0 0 0 3px var(--gold), 0 0 12px rgba(245, 197, 66, .6); animation: pulse 1.6s ease-in-out infinite; }
button.card-back.sh-back.selected { translate: 0 -10px; box-shadow: 0 0 0 3px white, 0 6px 14px rgba(0, 0, 0, .5); }

/* The players' tiles: their face-up cards, and a back for each face-down card. */
.sh-tile-cards { display: flex; justify-content: center; align-items: center; gap: 2px; margin-top: 4px; }
.sh-tile-cards .card.mini { --card-w: 20px; }
.sh-tile-cards .card.mini .corner { font-size: 7px; }
.sh-mini-back { width: 12px; height: 17px; border-radius: 2px; border: 1px solid var(--card-face); background: #932c3a; }
.nm-pass-pop.sh-stamp-pickup { border-color: var(--danger); color: var(--danger); }
.nm-pass-pop.sh-stamp-three { border-color: #6b2fa3; color: #6b2fa3; }
.nm-order li.shedhead { background: #eadfd6; }
.sh-standing { display: flex; align-items: center; gap: 8px; }

.sh-targets .sh-target { display: flex; justify-content: space-between; align-items: center; }
.sh-targets .sh-target.chosen { box-shadow: inset 0 0 0 2px var(--gold); background: #fbefc7; }

/* The help page's special cards. */
.sh-specials { display: flex; flex-direction: column; gap: 10px; --card-w: 44px; }
.sh-special { display: flex; align-items: center; gap: 12px; }
.sh-example { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }

/* ---------- Shoot the moon ---------- */

/* A night sky with a rocket over the whole screen, which taps go straight through. */
.moon-shot { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.moon-shot-sky { position: absolute; inset: 0; width: 100%; height: 100%; }
/* At the top, over the scores, so the bidder can still see the trump buttons and their cards. */
.moon-shot-title {
    position: absolute;
    left: 50%;
    top: calc(env(safe-area-inset-top) + 7%);
    translate: -50% -50%;
    display: flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 8px 18px;
    border-radius: 999px;
    border: 2px solid var(--gold);
    background: rgba(10, 14, 40, .8);
    color: var(--gold);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    animation: moon-title 7.4s ease-in-out both;
}
@keyframes moon-title {
    0% { opacity: 0; scale: .8; }
    6% { opacity: 1; scale: 1; }
    88% { opacity: 1; }
    100% { opacity: 0; }
}
.moon-shot.still .moon-shot-title { top: 40%; animation-duration: 3.5s; }

/* ---------- Larger screens ---------- */

@media (min-width: 600px) {
    .felt { --card-w: 68px; }
    .seat { max-width: 140px; font-size: .9rem; }
    .slot-left { transform: translate(-135%, -50%); }
    .slot-right { transform: translate(35%, -50%); }
}

/* ---------- Motion ---------- */

.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after {
    animation: none !important;
    transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Blazor error bar ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 16px;
    background: #fff3cd;
    color: #1d1d1f;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, .3);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }
