/* Tehilat Olam – Main Styles
   Single-file: variables + animations + components (no @import needed)
   ─────────────────────────────────────────────────────────────────── */

/* ── Google Font (Inter) loaded via <link> in index.html ── */

/* ── CSS Variables ── */
:root {
    /* Backgrounds */
    --bg-page:      #0a0a14;
    --bg-primary:   #0f0f1a;
    --bg-secondary: #141428;
    --bg-tertiary:  #16213e;

    /* Surfaces */
    --surface:        rgba(255,255,255,0.05);
    --surface-hover:  rgba(255,255,255,0.09);
    --surface-border: rgba(78,205,196,0.14);
    --surface-card:   rgba(20,20,44,0.92);

    /* Accent / brand */
    --accent:     #4ecdc4;
    --accent-dim: #3ba89f;
    --accent-glow: rgba(78,205,196,0.35);

    /* Game colors */
    --coral:      #ff6b6b;
    --coral-dim:  #e05555;
    --gold:       #ffd93d;
    --gold-dim:   #e6c235;

    /* Felt (card table green) */
    --felt:       #1a3d2b;
    --felt-light: #1e4a33;

    /* Text */
    --text-primary:   #f0f0f8;
    --text-secondary: #a0a0b8;
    --text-muted:     #55556a;

    /* Suit colors */
    --suit-red:   #e84040;
    --suit-black: #d0d0e0;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --r-xl: 24px;

    /* Shadows */
    --shadow-sm:  0 2px 8px  rgba(0,0,0,0.4);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:  0 8px 40px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 24px var(--accent-glow);

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    height: 100%;
    /* Lock the page — no outer scroll ever */
    overflow: hidden;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

/* ── Body — subtle dark felt texture ── */
body {
    font-family: var(--font);
    background-color: var(--bg-page);
    background-image:
        repeating-linear-gradient(
            45deg,
            rgba(255,255,255,0.012) 0px,
            rgba(255,255,255,0.012) 1px,
            transparent 1px,
            transparent 8px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(255,255,255,0.008) 0px,
            rgba(255,255,255,0.008) 1px,
            transparent 1px,
            transparent 8px
        );
    color: var(--text-primary);
    /* Exact viewport height — no scroll */
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ── Container — exact viewport fit on mobile ── */
.container {
    width: 100%;
    /* Exact height match — prevents any overflow scroll */
    height: 100vh;
    height: 100dvh;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: manipulation;
}

/* ── Desktop: centered framed panel ── */
@media (min-width: 560px) {
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        /* body can scroll on desktop if window is very short */
        height: auto;
        overflow: auto;
        padding: 24px 16px;
    }

    .container {
        width: 500px;
        max-width: 500px;
        /* Fixed height panel — same size regardless of state */
        height: 620px;
        max-height: calc(100dvh - 48px);
        /* Override mobile height/overflow */
        overflow: hidden;
        border-radius: var(--r-xl);
        border: 1px solid rgba(78,205,196,0.12);
        background: linear-gradient(160deg, rgba(15,15,26,0.98) 0%, rgba(20,20,40,0.98) 100%);
        box-shadow:
            0 0 0 1px rgba(255,255,255,0.04),
            0 24px 80px rgba(0,0,0,0.7),
            0 0 80px rgba(78,205,196,0.04);
        padding: 24px;
    }
}

@media (min-width: 768px) {
    .container { width: 560px; max-width: 560px; height: 640px; padding: 28px 32px; }
}

@media (min-width: 1024px) {
    .container { width: 620px; max-width: 620px; height: 660px; }
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 10px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--coral) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    user-select: none;
}

/* Stage progress row — shown only in-game, centered below header */
.stage-progress {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 2px 0 12px;
    flex-shrink: 0;
}

[data-state="ingame"] .stage-progress { display: flex; }

.stage-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: all 0.3s;
    flex-shrink: 0;
}

.stage-dot.done {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
}

.stage-dot.current {
    background: var(--coral);
    width: 14px; height: 14px;
    box-shadow: 0 0 10px rgba(255,107,107,0.6);
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    width: 44px; height: 44px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover  { color: var(--accent); border-color: var(--accent); }
.icon-btn.active { color: var(--accent); background: rgba(78,205,196,0.12); border-color: var(--accent); }

/* ── Score Display ── */
.score-display {
    text-align: center;
    padding: 2px 0 4px;
    flex-shrink: 0;
}

.score-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.score-value {
    font-size: clamp(22px, 5vw, 32px);
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 24px rgba(255,217,61,0.25);
    font-variant-numeric: tabular-nums;
}

/* ── Probability Bar ── */
.prob-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.04);
    border-radius: 2px;
    margin: 2px 0 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.prob-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Live Odds Display ── */
.live-odds {
    display: none; /* hidden in pregame */
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    margin: 2px 0 6px;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.3s;
}

.live-odds:hover { opacity: 1; }

.live-odds-label {
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.live-odds-value {
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* Show only during in-game state */
[data-state="ingame"] .live-odds { display: flex; }

/* ── Tabs (pregame mode selector) ── */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 3px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.tab {
    flex: 1;
    padding: 10px 4px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border: none;
    background: transparent;
    border-radius: calc(var(--r-md) - 2px);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
    background: rgba(78,205,196,0.14);
    color: var(--accent);
    box-shadow: inset 0 1px 0 rgba(78,205,196,0.2);
}

/* ── Card Table (felt area) ── */
.table-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 8px;
    border-radius: var(--r-lg);
    background:
        radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 60%, rgba(10,18,14,0.8) 100%);
    margin: 0;
    flex-shrink: 0;
    position: relative;
}

.cards-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}


/* ── 3D Card Flip ──
   JS (animations.js) creates: .card.card-flip-container > .card-inner > .card-back + .card-front
   Perspective lives on .card-flip-container; the inner div rotates.            ── */

.card-flip-container {
    perspective: 700px;
    flex-shrink: 0;
}

/* The rotating layer */
.card-flip-container .card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-flip-container .card-inner.flipped {
    transform: rotateY(180deg);
}

/* Shared face styles */
.card-back,
.card-front {
    position: absolute;
    inset: 0;
    border-radius: var(--r-sm);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}

/* Card BACK — uses gray_back.png card image */
.card-back {
    background-color: #1a237e;
    background-image: url('/static/cards/gray_back.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid rgba(100,120,220,0.4);
}

/* Card FRONT — white, reveals image; rotated 180deg so it's hidden until flip */
.card-front {
    transform: rotateY(180deg);
    background: #ffffff;
    background-size: 90%;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid var(--surface-border);
}

/* Deal-in animation */
.card-deal {
    animation: dealCard 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dimmed reveal after loss — shows what cards would have been */
.card-peek {
    opacity: 0.4;
    filter: saturate(0.5) brightness(0.85);
    transition: opacity 0.7s ease, filter 0.7s ease;
}

.card-peek .card-inner {
    transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Base card size */
.card,
.card-flip-container {
    width: 56px;
    height: 80px;
    flex-shrink: 0;
}

/* Static already-revealed card (restored games) */
.card:not(.card-flip-container) {
    border-radius: var(--r-sm);
    border: 2px solid var(--surface-border);
    overflow: hidden;
    background: #fff;
    background-size: 90%;
    background-repeat: no-repeat;
    background-position: center;
}

.card-slot {
    width: 56px; height: 80px;
    border-radius: var(--r-sm);
    border: 2px dashed rgba(255,255,255,0.08);
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

/* Subtle shimmer on placeholder slots */
.card-slot::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent 40%,
        rgba(255,255,255,0.04) 50%,
        transparent 60%
    );
}

/* ── Game Area ── */
.game-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    position: relative;
    padding: 20px 0 4px;
    overflow: hidden;
    touch-action: manipulation;
}

.prompt {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    padding: 0 8px;
    line-height: 1.4;
}

/* ── Game Buttons — glassmorphism ── */
.buttons {
    display: grid;
    gap: 8px;
    padding: 0 4px;
}

.buttons.grid-2 { grid-template-columns: 1fr 1fr; }
.buttons.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.buttons.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.game-btn {
    /* Glassmorphism base */
    background: rgba(78,205,196,0.10);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(78,205,196,0.28);
    color: var(--accent);
    font-family: var(--font);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 14px 8px;
    min-height: 52px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    overflow: hidden;
    /* Eliminate 300ms tap delay on mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Sheen effect */
.game-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.game-btn:hover:not(:disabled) {
    background: rgba(78,205,196,0.20);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px rgba(78,205,196,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
    transform: translateY(-2px);
}

.game-btn:active:not(:disabled) {
    transform: scale(0.96) translateY(0);
    box-shadow: none;
}

.game-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    transform: none;
}

.game-btn .btn-label { font-size: 13px; }
.game-btn .btn-pct  { font-size: 11px; opacity: 0.65; font-weight: 500; }

/* Suit buttons */
.game-btn.suit-btn {
    min-height: 68px;
    font-size: 28px;
}

.game-btn.red-suit {
    background: rgba(232,64,64,0.12);
    border-color: rgba(232,64,64,0.40);
    color: var(--suit-red);
}

.game-btn.red-suit:hover:not(:disabled) {
    background: rgba(232,64,64,0.22);
    border-color: var(--suit-red);
    color: #ff8888;
    box-shadow: 0 0 20px rgba(232,64,64,0.25);
}

.game-btn.black-suit {
    background: rgba(200,200,220,0.08);
    border-color: rgba(200,200,220,0.25);
    color: var(--suit-black);
}

.game-btn.black-suit:hover:not(:disabled) {
    background: rgba(200,200,220,0.15);
    border-color: var(--suit-black);
    box-shadow: 0 0 16px rgba(200,200,220,0.15);
}

/* ── Stage 5 Picker ── */
.stage5-picker { display: flex; flex-direction: column; gap: 12px; }

.suit-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.value-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.value-btn {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    font-family: var(--font);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 4px;
    min-height: 44px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.value-btn:hover  { border-color: var(--accent); background: rgba(78,205,196,0.10); color: var(--accent); }
.value-btn:disabled { opacity: 0.2; cursor: not-allowed; }

.back-btn {
    grid-column: 1 / -1;
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.18s;
}

.back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Compact inline back button used at the top of the value picker */
.back-btn-inline {
    grid-column: unset;
    padding: 10px 14px;
    min-height: 40px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Pregame ── */
.pregame-section {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 8px 0 12px;
    flex: 1;
    min-height: 0;        /* critical: lets flex child shrink below its content size */
    justify-content: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Hero start button */
.start-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
    border: none;
    color: var(--bg-primary);
    font-family: var(--font);
    font-weight: 800;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 15px 44px;
    border-radius: var(--r-xl);
    cursor: pointer;
    transition: all 0.22s ease;
    box-shadow: var(--shadow-glow), 0 4px 16px rgba(0,0,0,0.4);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.start-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 40px var(--accent-glow), 0 8px 24px rgba(0,0,0,0.5);
}

.start-btn:active { transform: scale(0.97); }

/* Pregame stat mini-cards */
.pregame-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 100%;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 10px 8px;
    text-align: center;
    transition: border-color 0.2s;
}

.stat-card:hover { border-color: rgba(78,205,196,0.3); }

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Streak display */
.streak-display {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.streak-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.streak-item .streak-icon { font-size: 18px; }
.streak-item .streak-count { font-weight: 700; color: var(--gold); }

/* Daily info in pregame tab */
.daily-info { text-align: center; padding: 12px 0; }
.daily-number { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); }
.daily-status { font-size: 14px; color: var(--text-secondary); margin-top: 6px; }

/* Challenge section in pregame tab */
.challenge-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.challenge-code {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--accent);
    font-family: monospace;
    text-shadow: var(--shadow-glow);
}

.challenge-input {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    color: var(--text-primary);
    font-size: 20px;
    text-align: center;
    letter-spacing: 5px;
    font-weight: 700;
    padding: 14px;
    width: min(200px, 80vw);
    text-transform: uppercase;
    font-family: monospace;
    transition: border-color 0.2s;
}

.challenge-input::placeholder { color: var(--text-muted); letter-spacing: 3px; font-size: 14px; }
.challenge-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78,205,196,0.12); }

/* ── Generic action button (used in pregame panels) ── */
.action-btn {
    background: rgba(78,205,196,0.10);
    border: 1px solid rgba(78,205,196,0.30);
    color: var(--accent);
    font-family: var(--font);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 24px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all 0.18s;
}

.action-btn:hover {
    background: rgba(78,205,196,0.20);
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(78,205,196,0.2);
}

.action-btn.danger {
    background: rgba(255,107,107,0.10);
    border-color: rgba(255,107,107,0.30);
    color: var(--coral);
}

/* ── Modal overlay ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show { display: flex; }

.modal-content {
    background: linear-gradient(160deg, var(--bg-secondary) 0%, rgba(20,20,44,0.98) 100%);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-lg);
    padding: 28px 24px;
    width: min(400px, calc(100vw - 32px));
    max-height: 90dvh;
    overflow-y: auto;
    text-align: center;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.04);
    animation: slideUp 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-content.win  { border-color: rgba(78,205,196,0.4); box-shadow: var(--shadow-lg), 0 0 40px rgba(78,205,196,0.08); }
.modal-content.lose { border-color: rgba(255,107,107,0.4); box-shadow: var(--shadow-lg), 0 0 40px rgba(255,107,107,0.08); }

.modal-title { font-size: 26px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.5px; }
.modal-title.win  { color: var(--accent); }
.modal-title.lose { color: var(--coral); }

.modal-score {
    font-size: 40px;
    font-weight: 800;
    color: var(--gold);
    margin: 12px 0;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 30px rgba(255,217,61,0.3);
}

.modal-score .score-unit { font-size: 14px; color: var(--text-muted); font-weight: 500; }

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.5;
}

.modal-cards {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 14px 0;
}

.modal-card {
    width: 44px; height: 62px;
    border-radius: 6px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #fff;
    border: 1px solid var(--surface-border);
}

.modal-card.wrong {
    border-color: var(--coral);
    box-shadow: 0 0 10px rgba(255,107,107,0.4);
}

.modal-guess-detail {
    font-size: 13px;
    color: var(--text-muted);
    margin: 10px 0;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--r-sm);
    line-height: 1.6;
}

.modal-stage-results {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 10px 0;
    font-size: 22px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}

.modal-btn {
    padding: 16px;
    min-height: 48px;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    position: relative;
    overflow: hidden;
}

.modal-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.10) 0%, transparent 60%);
    pointer-events: none;
}

.modal-btn.primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
    color: var(--bg-primary);
    box-shadow: 0 4px 16px rgba(78,205,196,0.2);
}

.modal-btn.primary:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

.modal-btn.secondary {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
}

.modal-btn.secondary:hover { border-color: var(--accent); color: var(--accent); }

.modal-btn.share {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
    color: var(--bg-primary);
    box-shadow: 0 4px 16px rgba(255,217,61,0.2);
}

.modal-btn.share:hover { box-shadow: 0 0 24px rgba(255,217,61,0.35); transform: translateY(-1px); }
.modal-btn:active { transform: scale(0.97) !important; }

/* ── Toast notifications ── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 280px;
    animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: auto;
}

.toast.removing { animation: toastOut 0.25s ease forwards; }
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-text { line-height: 1.4; }

/* Achievement toast — gold border */
.toast.achievement {
    border-color: var(--gold);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(255,217,61,0.15);
}

/* ── Odds Info Modal ── */
.odds-modal {
    text-align: left;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    padding: 20px 20px 20px;
}

.odds-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.odds-intro {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
}

.odds-intro strong { color: var(--text-primary); }

.odds-table {
    width: 100%;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--surface-border);
    margin-bottom: 14px;
}

.odds-row {
    display: grid;
    grid-template-columns: 36px 1fr 80px;
    align-items: center;
    padding: 9px 12px;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
}

.odds-row:last-child { border-bottom: none; }

.odds-row-header {
    background: rgba(255,255,255,0.04);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 7px 12px;
}

.odds-stage-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}

.odds-pct {
    font-weight: 700;
    font-size: 13px;
    text-align: right;
}
.odds-pct strong { font-weight: 800; }
.odds-good  { color: #4ecdc4; }
.odds-ok    { color: #a8e6cf; }
.odds-warn  { color: var(--gold); }
.odds-bad   { color: var(--coral); }

.odds-formula {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.odds-formula small { color: var(--text-muted); font-size: 11px; }

.odds-result {
    background: linear-gradient(135deg, rgba(78,205,196,0.08), rgba(255,217,61,0.06));
    border: 1px solid rgba(78,205,196,0.2);
    border-radius: var(--r-md);
    padding: 14px 16px;
    text-align: center;
    margin-bottom: 12px;
}

.odds-result-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.odds-result-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255,217,61,0.3);
}

.odds-tip {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--r-sm);
    border-left: 3px solid var(--accent);
}
.odds-tip strong { color: var(--text-secondary); }

.odds-math-box {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    margin-top: 14px;
    font-size: 13px;
}

.odds-math-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.odds-math-line {
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.6;
}
.odds-math-line strong { color: var(--text-primary); }

.odds-math-result {
    font-size: 16px;
    font-weight: 800;
    color: var(--gold);
    margin: 10px 0 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.odds-math-note {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.6;
    font-style: italic;
    margin-top: 8px;
}

/* Derivation blocks (advanced view) */
.odds-deriv-block {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 10px;
}

.odds-deriv-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.odds-deriv-eq {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    flex-wrap: wrap;
}

.odds-deriv-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 7px;
    line-height: 1.5;
    font-style: italic;
}

/* Inline fraction rendering */
.odds-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    font-size: 11px;
    line-height: 1.25;
    margin: 0 2px;
}

.odds-frac span:first-child {
    border-bottom: 1px solid var(--text-secondary);
    padding-bottom: 1px;
    white-space: nowrap;
}

.odds-frac span:last-child {
    padding-top: 1px;
    white-space: nowrap;
}

.odds-frac-lg {
    font-size: 14px;
}

.odds-highlight {
    color: var(--accent);
    font-weight: 700;
}

/* ── Game Over — fairness reveal strip ── */
.modal-fairness {
    background: rgba(78,205,196,0.06);
    border: 1px solid rgba(78,205,196,0.2);
    border-radius: var(--r-md);
    padding: 10px 12px;
    margin: 10px 0 4px;
    text-align: left;
}

.modal-fairness-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-fairness-icon { font-size: 14px; }

.modal-fairness-label {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.modal-fairness-verify {
    background: none;
    border: 1px solid var(--accent);
    border-radius: 20px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.modal-fairness-verify:hover { background: rgba(78,205,196,0.12); }

.modal-fairness-seed {
    margin-top: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.5;
}

/* ── Provably Fair Modal ── */
.fairness-modal {
    text-align: left;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    padding: 20px 20px 24px;
    max-width: 460px;
}

.fairness-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.fairness-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* ── Fairness tab bar (pill style like the reference) ── */
.fairness-tabs {
    display: flex;
    background: rgba(255,255,255,0.06);
    border-radius: 50px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 18px;
    flex-shrink: 0;
}

.fairness-tab {
    flex: 1;
    padding: 9px 8px;
    border: none;
    background: transparent;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.fairness-tab.active {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

.fairness-tab:hover:not(.active) { color: var(--text-secondary); }

/* ── Overview tab ── */
.fair-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.fair-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 10px;
}

.fair-body strong { color: var(--text-primary); }

.fair-formula {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: var(--accent);
    text-align: center;
    letter-spacing: 0.3px;
    margin: 4px 0 8px;
}

.fair-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fair-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.fair-step-num {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.fair-step-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.fair-step-text strong { color: var(--text-primary); }
.fair-step-text code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    background: rgba(255,255,255,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--accent);
}

/* ── Seeds tab ── */
.fair-field {
    margin-bottom: 12px;
}

.fair-field-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 5px;
}

.fair-hint {
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 10px;
}

.fair-field-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fair-input {
    flex: 1;
    width: 100%;          /* fills container whether inside flex or not */
    box-sizing: border-box;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.fair-input:focus { border-color: var(--accent); }
.fair-input[readonly] { color: var(--text-secondary); cursor: default; }
.fair-mono-sm { font-family: 'Courier New', Courier, monospace; font-size: 11px; }

.fair-copy-btn {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    padding: 0 10px;
    height: 38px;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.fair-copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.fair-change-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--r-sm);
    color: #000;
    padding: 0 16px;
    height: 38px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.fair-change-btn:hover { background: var(--accent-dim); }

/* Full-width rotate button — sits below the client seed input */
.fair-rotate-full-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 11px 0;
    background: var(--accent);
    border: none;
    border-radius: var(--r-sm);
    color: #000;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    letter-spacing: 0.3px;
}
.fair-rotate-full-btn:hover  { background: var(--accent-dim); }
.fair-rotate-full-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Seed input meta row: rules hint left, char counter right */
.fair-seed-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
    font-size: 11px;
}
.fair-seed-rules  { color: var(--text-muted); }
.fair-char-counter { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.fair-rotate-box {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 14px;
    margin-top: 14px;
}

.fair-rotate-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.fair-rotate-note {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 10px;
    font-style: italic;
}

/* ── Verify tab ── */

/* Input fields — all same height, same font size */
.vfy-fields { display: flex; flex-direction: column; gap: 10px; }

.vfy-field { display: flex; flex-direction: column; gap: 4px; }

.vfy-row { display: flex; gap: 10px; }

.vfy-field-nonce { width: 120px; }

.vfy-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
}

.vfy-hint {
    font-size: 10px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    margin-left: 4px;
}

.vfy-input {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.vfy-input:focus { border-color: var(--accent); }

/* Monospace inputs — same height, just different font */
.vfy-mono {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    letter-spacing: 0.3px;
}

/* Verify button */
.fair-verify-btn {
    width: 100%;
    height: 42px;
    background: var(--accent);
    border: none;
    border-radius: var(--r-md);
    color: #000;
    font-family: var(--font);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    margin: 14px 0 0;
    transition: background 0.2s;
    letter-spacing: 0.5px;
}
.fair-verify-btn:hover { background: var(--accent-dim); }

/* Result area — only visible after clicking Verify */
#fair-verify-result { margin-top: 14px; }

.vfy-status {
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    margin-bottom: 8px;
}
.vfy-status.ok   { background: rgba(78,205,196,0.1);  color: var(--accent); border: 1px solid rgba(78,205,196,0.25); }
.vfy-status.warn { background: rgba(255,217,61,0.08); color: var(--gold);   border: 1px solid rgba(255,217,61,0.25); }

.vfy-hash-line {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.vfy-mono-sm {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: var(--text-secondary);
}

.vfy-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

/* 5-card row */
.vfy-cards {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.vfy-card {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 8px 4px 6px;
    text-align: center;
}

.vfy-card-val  { font-size: 15px; font-weight: 800; line-height: 1; }
.vfy-card-suit { font-size: 13px; line-height: 1.2; }
.vfy-card-stage { font-size: 9px; color: var(--text-muted); margin-top: 4px; letter-spacing: 0.3px; }

/* Collapsible full deck */
.vfy-full-deck {
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    overflow: hidden;
}

.vfy-full-deck summary {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: color 0.2s;
}
.vfy-full-deck summary:hover { color: var(--text-secondary); }
.vfy-full-deck summary::before { content: '▶'; font-size: 9px; transition: transform 0.2s; }
.vfy-full-deck[open] summary::before { transform: rotate(90deg); }

.vfy-full-list {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.9;
    padding: 8px 12px 10px;
    border-top: 1px solid var(--surface-border);
    word-break: break-word;
}

/* Utility states */
.vfy-error     { font-size: 13px; color: var(--coral); margin: 8px 0; }
.vfy-computing { font-size: 13px; color: var(--text-muted); margin: 8px 0; }

.vfy-note {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
    line-height: 1.5;
}

.fair-loading {
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

/* ── Stats Panel (slide-in drawer) ── */
.stats-panel {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 300px;
    max-width: 90vw;
    background: linear-gradient(160deg, var(--bg-secondary) 0%, rgba(14,14,28,0.99) 100%);
    border-left: 1px solid var(--surface-border);
    z-index: 500;
    padding: 20px 16px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s cubic-bezier(0.4,0,0.2,1);
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.stats-panel::-webkit-scrollbar { width: 4px; }
.stats-panel::-webkit-scrollbar-track { background: transparent; }
.stats-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
.stats-panel::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.stats-panel.show { display: block; }

/* ── Stats panel top tabs (Stats | History) ── */
.stats-panel-tabs {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: 50px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 16px;
}

.stats-panel-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.stats-panel-tab.active {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

.stats-panel-tab:hover:not(.active) { color: var(--text-secondary); }

/* ── History list ── */
.history-loading {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 32px 0;
}

.history-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 32px 0;
    line-height: 1.6;
}

.history-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    margin-bottom: 10px;
    overflow: hidden;
}

.history-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.history-item-header:hover { background: rgba(255,255,255,0.04); }

.history-result-icon { font-size: 18px; flex-shrink: 0; }

.history-meta { flex: 1; min-width: 0; }

.history-meta-top {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.history-mode-badge {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    background: rgba(255,255,255,0.07);
    color: var(--text-muted);
}

.history-mode-badge.daily  { background: rgba(78,205,196,0.15); color: var(--accent); }
.history-mode-badge.challenge { background: rgba(255,217,61,0.15); color: var(--gold); }

.history-result-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.history-result-text.won  { color: var(--accent); }
.history-result-text.lost { color: var(--coral); }

.history-date {
    font-size: 11px;
    color: var(--text-muted);
}

.history-score {
    font-size: 13px;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
}

.history-chevron {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.history-item.expanded .history-chevron { transform: rotate(180deg); }

/* Seed detail section */
.history-seeds {
    display: none;
    border-top: 1px solid var(--surface-border);
    padding: 12px;
    background: rgba(0,0,0,0.15);
}

.history-item.expanded .history-seeds { display: block; }

.history-seed-row {
    margin-bottom: 10px;
}

.history-seed-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.history-seed-value-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.history-seed-value {
    flex: 1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: var(--text-secondary);
    word-break: break-all;
    line-height: 1.5;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    padding: 6px 8px;
}

.history-copy-btn {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    width: 28px; height: 28px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.history-copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.history-verify-btn {
    width: 100%;
    margin-top: 10px;
    padding: 9px;
    background: rgba(78,205,196,0.1);
    border: 1px solid rgba(78,205,196,0.25);
    border-radius: var(--r-sm);
    color: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.history-verify-btn:hover { background: rgba(78,205,196,0.18); }

.stats-panel h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 20px 0 10px;
}

.stats-panel h3:first-of-type { margin-top: 4px; }

.stats-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stats-panel-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.close-panel-btn {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-muted);
    width: 44px; height: 44px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.close-panel-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* Re-enable selection for all inputs */
input, textarea {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
}

/* Name input row */
.name-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.name-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 12px;
    transition: border-color 0.2s;
}

.name-input::placeholder { color: var(--text-muted); font-weight: 400; }
.name-input:focus { outline: none; border-color: var(--accent); }

.name-save-btn {
    background: rgba(78,205,196,0.12);
    border: 1px solid rgba(78,205,196,0.3);
    color: var(--accent);
    font-family: var(--font);
    font-weight: 700;
    font-size: 12px;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
}

.name-save-btn:hover { background: rgba(78,205,196,0.22); border-color: var(--accent); }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.stats-grid .stat-card { padding: 12px 8px; }
.stats-grid .stat-card .stat-value { font-size: 20px; }

/* Loss breakdown bars */
.loss-breakdown { margin-top: 4px; }

.loss-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.loss-bar-label {
    width: 58px;
    text-align: right;
    color: var(--text-muted);
    flex-shrink: 0;
}

.loss-bar-track {
    flex: 1;
    height: 14px;
    background: rgba(255,255,255,0.04);
    border-radius: 3px;
    overflow: hidden;
}

.loss-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--coral-dim), var(--coral));
    border-radius: 3px;
    min-width: 2px;
    transition: width 0.6s ease;
}

.loss-bar-count { color: var(--text-secondary); font-size: 11px; flex-shrink: 0; }

/* ── Achievements Grid ── */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.achievement-badge {
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.achievement-badge.locked { opacity: 0.25; filter: grayscale(1); }

.achievement-badge:hover { transform: scale(1.12); border-color: var(--accent); z-index: 1; }

.achievement-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    padding: 7px 10px;
    font-size: 11px;
    white-space: normal;
    max-width: min(200px, 80vw);
    z-index: 10;
    color: var(--text-primary);
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.achievement-badge:hover .achievement-tooltip { display: block; }

/* ── Leaderboard ── */
.leaderboard { margin-top: 4px; }

.leaderboard-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
}

.lb-tab {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--surface);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.lb-tab:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.lb-tab:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.lb-tab.active { color: var(--accent); background: rgba(78,205,196,0.12); }

.lb-entry {
    display: flex;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
}

.lb-entry.me { background: rgba(78,205,196,0.05); border-radius: var(--r-sm); padding: 7px 6px; margin: 0 -6px; }

.lb-rank          { width: 28px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
.lb-rank.gold     { color: var(--gold); }
.lb-rank.silver   { color: #c0c0c0; }
.lb-rank.bronze   { color: #cd7f32; }
.lb-name          { flex: 1; color: var(--text-primary); }
.lb-score         { font-weight: 700; color: var(--accent); }

/* ── Score popup animation ── */
.score-popup {
    position: absolute;
    font-size: 18px;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255,217,61,0.5);
    pointer-events: none;
    z-index: 100;
    animation: scoreFloat 1.2s cubic-bezier(0.4,0,0.2,1) forwards;
}

/* ── State visibility ── */
[data-state="pregame"] .table-area,
[data-state="pregame"] .game-area,
[data-state="pregame"] .score-display,
[data-state="pregame"] .prob-bar { display: none !important; }

[data-state="pregame"] .pregame-section { display: flex; }

[data-state="ingame"] .pregame-section,
[data-state="ingame"] .tabs { display: none !important; }

[data-state="ingame"] .table-area { display: flex; }
[data-state="ingame"] .game-area  { display: flex; }
[data-state="ingame"] .score-display { display: block; }
[data-state="ingame"] .prob-bar { display: block; }

/* ── Responsive — tablet / framed ── */
@media (min-width: 560px) {
    .card, .card-flip-container, .card-slot { width: 68px; height: 95px; }
    .cards-row { gap: 10px; }
    .logo { font-size: 24px; }
    .score-value { font-size: 34px; }
    .prompt { font-size: 17px; }
    .game-btn { min-height: 54px; font-size: 14px; }
    .game-btn.suit-btn { min-height: 60px; font-size: 26px; }
    .game-area { padding-top: 4px; overflow-y: auto; }
    .modal-card { width: 52px; height: 72px; }
}

/* ── Responsive — desktop ── */
@media (min-width: 768px) {
    .card, .card-flip-container, .card-slot { width: 82px; height: 115px; }
    .cards-row { gap: 12px; }
    .logo { font-size: 26px; }
    .prompt { font-size: 18px; }
    .game-btn { min-height: 58px; padding: 16px 12px; }
    .game-btn.suit-btn { min-height: 62px; font-size: 28px; }
    .modal-card { width: 56px; height: 78px; }
}

/* ── Landscape small screen ── */
@media (max-height: 500px) and (orientation: landscape) {
    .container { padding: 8px 16px; }
    .card, .card-flip-container, .card-slot { width: 46px; height: 64px; }
    .header { padding: 2px 0 8px; }
    .prompt { font-size: 13px; }
    .score-value { font-size: 22px; }
    .pregame-section { padding: 8px 0; gap: 12px; }
    .game-btn { min-height: 42px; padding: 10px 6px; }
    .table-area { padding: 8px 0 4px; }
}

/* ── Touch / hover states ── */
@media (hover: hover) {
    .game-btn:hover:not(:disabled)  { transform: translateY(-2px); }
    .start-btn:hover                 { transform: translateY(-3px); }
    .modal-btn.primary:hover         { transform: translateY(-1px); }
    .modal-btn.share:hover           { transform: translateY(-1px); }
}

/* ── Keyframe animations ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(32px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px) scale(0.92); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(24px); }
}

@keyframes scoreFloat {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    60%  { opacity: 1; transform: translateY(-40px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-70px) scale(0.9); }
}

@keyframes dealCard {
    from { opacity: 0; transform: translateY(-24px) scale(0.9) rotate(-3deg); }
    to   { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-6px); }
    80%       { transform: translateX(6px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.06); }
}

/* Utility classes */
.deal-anim { animation: dealCard 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.shake-anim { animation: shake 0.45s ease; }
.pulse-anim { animation: pulse 0.5s ease; }

/* ── Stats skeleton loading ─────────────────────────────────────────────────── */
.skeleton-val {
    display: inline-block;
    width: 60px;
    height: 1em;
    border-radius: 4px;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.06) 25%,
        rgba(255,255,255,0.12) 50%,
        rgba(255,255,255,0.06) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    vertical-align: middle;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Leaderboard empty state ─────────────────────────────────────────────────── */
.leaderboard-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 28px 16px;
    font-size: 0.88rem;
    line-height: 1.7;
}
.leaderboard-empty span {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 10px;
}

/* ── History: Copy All Seeds + Load More ─────────────────────────────────────── */
.history-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.history-copy-all-btn {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--surface-border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.history-copy-all-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.history-load-more {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--r-sm);
    border: 1px dashed var(--surface-border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.history-load-more:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* ── Google SSO ──────────────────────────────────────────────────────────────── */
.account-section {
    margin-bottom: 4px;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
    padding: 10px 16px;
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    justify-content: center;
}
.google-signin-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 6px rgba(0,0,0,0.2);
}

.google-signin-note {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin: 6px 0 0;
}

.google-account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
}
.google-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}
.google-account-info {
    flex: 1;
    min-width: 0;
}
.google-account-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.google-account-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.google-signout-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--surface-border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}
.google-signout-btn:hover { color: var(--coral); border-color: var(--coral); }

/* ── Danger zone (delete account) ────────────────────────────────────────── */
.danger-zone {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.delete-account-btn {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(255, 80, 80, 0.3);
    border-radius: var(--r-sm);
    color: rgba(255, 100, 100, 0.7);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 36px;
}
.delete-account-btn:hover {
    background: rgba(255, 80, 80, 0.1);
    border-color: rgba(255, 80, 80, 0.6);
    color: #ff6464;
}

/* ── Onboarding Modal ─────────────────────────────────────────────────────── */
.onboarding-modal {
    max-width: 380px;
    padding: 28px 24px 24px;
    text-align: center;
}
.onboarding-header {
    margin-bottom: 20px;
}
.onboarding-logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.onboarding-sub {
    font-size: 13px;
    color: var(--text-muted);
}
.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
    text-align: left;
}
.onboarding-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 10px 12px;
}
.step-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.onboarding-step-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}
.onboarding-step-text strong {
    color: var(--text);
    display: block;
    margin-bottom: 2px;
}
.onboarding-tip {
    font-size: 12px;
    color: var(--accent);
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ── Leaderboard empty state ──────────────────────────────────────────────── */
.lb-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}
.lb-empty span {
    display: block;
    font-size: 28px;
    margin-bottom: 10px;
}

/* ── Stats error / retry ──────────────────────────────────────────────────── */
.stats-error {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
    grid-column: 1 / -1;
}
.retry-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 18px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s;
}
.retry-btn:hover { background: rgba(255,255,255,0.12); }

/* ── Daily countdown timer ────────────────────────────────────────────────── */
.daily-countdown {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 16px;
    text-align: center;
}

/* ── Leaderboard reset countdown ─────────────────────────────────────────── */
.lb-reset-countdown {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding: 4px 0 2px;
    min-height: 18px;
}

/* ── Leaderboard: your rank row ───────────────────────────────────────────── */
.lb-your-rank {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 10px 14px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 10px;
    font-size: 13px;
}
.lb-your-rank-label {
    color: var(--text-muted);
    flex: 1;
}
.lb-your-rank-num {
    font-weight: 700;
    color: var(--accent);
}
.lb-your-rank-score {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ── Data export button ───────────────────────────────────────────────────── */
.export-data-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    min-height: 36px;
    margin-bottom: 8px;
}
.export-data-btn:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.22);
    color: var(--text-secondary);
}

/* ── Fairness: hint label ────────────────────────────────────────────────────── */
.fair-hint {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

/* ── Stats Panel: scrollable body wrapper ─────────────────────────────────── */
.stats-panel-body {
    /* panel itself handles scroll; this just groups the content */
}

/* ── Profile Panel ────────────────────────────────────────────────────────── */
.profile-panel {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 300px;
    max-width: 90vw;
    background: linear-gradient(160deg, var(--bg-secondary) 0%, rgba(14,14,28,0.99) 100%);
    border-left: 1px solid var(--surface-border);
    z-index: 500;
    padding: 20px 16px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s cubic-bezier(0.4,0,0.2,1);
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.profile-panel::-webkit-scrollbar { width: 4px; }
.profile-panel::-webkit-scrollbar-track { background: transparent; }
.profile-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
.profile-panel::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.profile-panel.show { display: block; }

.profile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.profile-panel-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

/* ── Profile panel tabs ───────────────────────────────────────────────────── */
.profile-tabs {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: 50px;
    padding: 3px;
    gap: 2px;
    margin: 16px 0 12px;
}

.profile-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.profile-tab.active {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

.profile-tab:hover:not(.active) { color: var(--text-secondary); }

.profile-tab-content { /* shown/hidden by JS */ }

/* ── Profile panel: Fairness section ─────────────────────────────────────── */
.fairness-profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 24px 8px;
}

.fairness-profile-icon {
    font-size: 3rem;
    line-height: 1;
}

.fairness-profile-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.fairness-profile-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 240px;
}

.fairness-profile-open-btn {
    padding: 12px 24px;
    border-radius: var(--r-md);
    border: none;
    background: var(--accent);
    color: var(--bg-primary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.fairness-profile-open-btn:hover { background: var(--accent-dim); }
.fairness-profile-open-btn:active { transform: scale(0.97); }

.fairness-profile-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    width: 100%;
    text-align: left;
}

/* ── Header: profile / avatar button ─────────────────────────────────────── */
.profile-icon-btn {
    position: relative;
    overflow: hidden;
}

.header-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    display: block;
}

.header-avatar-fallback {
    font-size: 16px;
    line-height: 1;
}

/* ── Leaderboard: anonymous sign-in prompt ────────────────────────────────── */
.leaderboard-anon-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 16px 12px;
    margin-bottom: 12px;
    background: rgba(78,205,196,0.06);
    border: 1px solid rgba(78,205,196,0.2);
    border-radius: var(--r-md);
}

.leaderboard-anon-icon {
    font-size: 1.6rem;
}

.leaderboard-anon-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.leaderboard-anon-btn {
    padding: 8px 18px;
    border-radius: var(--r-sm);
    border: none;
    background: var(--accent);
    color: var(--bg-primary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.leaderboard-anon-btn:hover { background: var(--accent-dim); }

/* ── Game Over Modal: score breakdown ────────────────────────────────────── */
.modal-score-breakdown {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--surface-border);
    border-radius: var(--r-md);
    padding: 10px 14px;
    margin: 10px 0 0;
}

.score-breakdown-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.score-breakdown-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
}

.score-breakdown-stage {
    color: var(--text-muted);
    width: 48px;
    flex-shrink: 0;
}

.score-breakdown-prob {
    flex: 1;
    color: var(--text-secondary);
}

.score-breakdown-pts {
    font-weight: 700;
    color: var(--gold);
}

/* ── Game Over Modal: rank nudge ─────────────────────────────────────────── */
.modal-rank-nudge {
    width: 100%;
    background: linear-gradient(135deg, rgba(78,205,196,0.08) 0%, rgba(78,205,196,0.03) 100%);
    border: 1px solid rgba(78,205,196,0.25);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin: 10px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.rank-nudge-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.rank-nudge-btn {
    padding: 9px 20px;
    border-radius: var(--r-sm);
    border: none;
    background: var(--accent);
    color: var(--bg-primary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.rank-nudge-btn:hover { background: var(--accent-dim); }
.rank-nudge-btn:active { transform: scale(0.97); }

/* ── Panel Backdrop ─────────────────────────────────────────────────────────── */
#panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 490;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
#panel-backdrop.show { display: block; }

/* ── Stage 3 mobile single-column ───────────────────────────────────────────── */
@media (max-width: 767px) {
    .buttons.grid-3 { grid-template-columns: 1fr; }
}

/* ── Very small screen stat cards ───────────────────────────────────────────── */
@media (max-width: 360px) {
    .pregame-stats { gap: 6px; }
    .stat-card { padding: 8px 10px; }
    .stat-card .stat-value { font-size: 18px; }
}

/* ── How to Play button (pregame) ───────────────────────────────────────────── */
.how-to-play-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    padding: 4px 12px;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.how-to-play-btn:hover { opacity: 1; color: var(--text-secondary); }
