/* Lucky XO. Colors follow the Telegram theme when opened as a Mini App,
   with our own light/dark fallbacks in a regular browser. */

:root {
    --fallback-bg: #f2f3f7;
    --fallback-surface: #ffffff;
    --fallback-text: #151821;
    --fallback-hint: #858b99;
    --fallback-secondary-btn: #e7e9ef;

    --bg: var(--tg-theme-secondary-bg-color, var(--fallback-bg));
    --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fallback-surface)));
    --text: var(--tg-theme-text-color, var(--fallback-text));
    --muted: var(--tg-theme-hint-color, var(--fallback-hint));
    --secondary-btn: var(--fallback-secondary-btn);

    --accent: #16a35a;
    --accent-strong: #11894b;
    --accent-text: #ffffff;
    --opponent: #8b5cf6;
    --danger: #e5484d;

    --radius: 16px;
    --radius-small: 12px;
    --shadow: 0 1px 2px rgba(15, 20, 35, 0.06), 0 6px 20px rgba(15, 20, 35, 0.06);
    --edge: 0 0 0 0 transparent;
    --heat-cold: #2563eb;
    --heat-hot: #ea580c;
    --heat-tint: color-mix(in srgb, var(--heat-color) 14%, transparent);

    --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --edge: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
        --fallback-bg: #0f1116;
        --fallback-surface: #1a1d25;
        --fallback-text: #eef0f5;
        --fallback-hint: #8d93a3;
        --fallback-secondary-btn: #262a35;
        color-scheme: dark;
    }
}

/* Telegram dark theme (set by app.js from colorScheme) */
:root[data-theme="dark"] {
    --edge: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
    --fallback-secondary-btn: #262a35;
    --secondary-btn: color-mix(in srgb, var(--text) 10%, var(--surface));
    --heat-cold: #7daaff;
    --heat-hot: #ff9d4d;
    --heat-tint: color-mix(in srgb, var(--heat-color) 22%, transparent);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --heat-cold: #7daaff;
        --heat-hot: #ff9d4d;
        --heat-tint: color-mix(in srgb, var(--heat-color) 22%, transparent);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.4;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
}

button {
    font: inherit;
    color: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

h2 {
    font-size: 22px;
    line-height: 1.25;
}

.muted {
    color: var(--muted);
}

[hidden] {
    display: none !important;
}

/* ---------- Layout ---------- */

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: var(--tg-viewport-stable-height, 100dvh);
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    gap: 16px;
    min-height: var(--tg-viewport-stable-height, 100dvh);
    padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
    animation: screen-in 0.22s ease-out;
}

.screen.active {
    display: flex;
}

.screen-center {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.screen-title {
    margin-bottom: 4px;
}

.screen-bottom {
    margin-top: auto;
    align-self: stretch;
}

.screen-center .screen-bottom {
    margin-top: 24px;
}

@keyframes screen-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

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

.row > * {
    flex: 1;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--edge), var(--shadow);
    padding: 16px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 12px 18px;
    border-radius: var(--radius-small);
    font-weight: 600;
    font-size: 16px;
    transition: transform 0.08s ease, background-color 0.2s ease, opacity 0.2s ease;
    width: 100%;
}

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

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 6px 16px rgba(22, 163, 90, 0.28);
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-secondary {
    background: var(--secondary-btn);
}

.btn-ghost {
    color: var(--danger);
    background: transparent;
}

.btn-xl {
    min-height: 64px;
    font-size: 20px;
    border-radius: var(--radius);
}

.icon-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-radius: var(--radius-small);
    font-size: 13px;
    color: var(--muted);
}

.icon-btn span[aria-hidden],
.icon-btn #soundIcon {
    font-size: 22px;
}

.icon-btn-small {
    flex-direction: row;
    font-size: 14px;
    gap: 6px;
    background: var(--surface);
    padding: 8px 12px;
}

.icon-btn-small span[aria-hidden],
.icon-btn-small #gameSoundIcon {
    font-size: 16px;
}

.back-btn {
    align-self: flex-start;
    display: inline-flex;
    gap: 6px;
    padding: 6px 2px;
    color: var(--accent);
    font-weight: 600;
}

/* Platforms that draw their own Back button in the header (Telegram) */
.has-native-back .back-btn {
    display: none;
}

/* ---------- Home ---------- */

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 4px 4px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(22, 163, 90, 0.3);
}

.brand-name {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand-tagline {
    color: var(--muted);
    font-size: 14px;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    text-align: left;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--edge), var(--shadow);
}

.avatar {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    font-size: 30px;
    border-radius: 50%;
    background: var(--secondary-btn);
}

.profile-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.profile-name {
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-meta {
    color: var(--muted);
    font-size: 14px;
}

.profile-edit {
    color: var(--muted);
    font-size: 18px;
}

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    /* sits centred in the space between the profile card and the buttons */
    margin-block: auto;
    padding: 20px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--edge), var(--shadow);
}

.hero-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
}

/* One real board cell, animated by the same code as the game */
.hero-demo {
    width: 124px;
}

.hero-demo .cell {
    width: 100%;
}

.hero-text {
    text-align: center;
    color: var(--text);
    font-size: 14px;
    line-height: 1.35;
    /* room for three lines, so the card does not jump between demo steps */
    min-height: 57px;
    max-width: 280px;
}

.home-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-footer {
    display: flex;
    justify-content: space-around;
    padding-top: 4px;
}

/* ---------- Search ---------- */

.search-spinner {
    display: flex;
    gap: 14px;
    font-size: 40px;
    font-weight: 700;
    margin-bottom: 8px;
}

.search-spinner span {
    animation: bounce 1.2s ease-in-out infinite;
    color: var(--accent);
}

.search-spinner span:nth-child(2) {
    animation-delay: 0.15s;
    color: var(--opponent);
}

.search-spinner span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-12px); opacity: 1; }
}

.bot-offer {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    animation: screen-in 0.3s ease-out;
}

/* ---------- Friend mode ---------- */

.choice {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 18px 16px;
    text-align: left;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--edge), var(--shadow);
    transition: transform 0.08s ease;
}

.choice:active {
    transform: scale(0.98);
}

.choice-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    font-size: 24px;
    border-radius: 14px;
    background: var(--secondary-btn);
}

.choice-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.choice-title {
    font-weight: 700;
}

.choice-hint {
    color: var(--muted);
    font-size: 14px;
}

.invite-emoji {
    font-size: 56px;
}

.invite-code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 6px;
    padding: 14px 20px 14px 26px;
    margin: 8px 0;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--edge), var(--shadow);
    user-select: all;
    -webkit-user-select: all;
}

.waiting-dots {
    color: var(--muted);
    font-size: 14px;
    margin-top: 8px;
}

.waiting-dots::after {
    content: '';
    animation: dots 1.4s steps(4) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ---------- Inputs ---------- */

.input {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid transparent;
    border-radius: var(--radius-small);
    box-shadow: var(--edge), var(--shadow);
    outline: none;
    user-select: text;
    -webkit-user-select: text;
}

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

.input-code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 6px;
    text-align: center;
    text-transform: uppercase;
}

.input-code::placeholder {
    font-size: 16px;
    letter-spacing: 0;
    font-weight: 400;
}

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

.field-label {
    font-size: 14px;
    color: var(--muted);
}

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

.game-screen {
    gap: 12px;
}

.game-top {
    display: flex;
    justify-content: space-between;
}

.players {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.player {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
    transition: opacity 0.25s ease;
}

.player.waiting {
    opacity: 0.55;
}

.player-avatar {
    position: relative;
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
}

.player-emoji {
    font-size: 38px;
    transition: transform 0.25s ease;
}

.player.active .player-emoji {
    transform: scale(1.08);
}

.ring {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
}

.ring circle {
    fill: none;
    stroke-width: 4;
}

.ring-track {
    stroke: var(--secondary-btn);
}

.ring-progress {
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-dasharray: 182.2;
    stroke-dashoffset: 182.2;
}

#playerOpponent .ring-progress {
    stroke: var(--opponent);
}

.player.urgent .ring-progress {
    stroke: var(--danger);
}

.player-offline {
    position: absolute;
    right: -2px;
    bottom: -2px;
    font-size: 18px;
    display: none;
}

.player.offline .player-offline {
    display: block;
}

.player-name {
    font-weight: 600;
    font-size: 15px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-timer {
    font-size: 13px;
    color: var(--muted);
    min-height: 18px;
    font-variant-numeric: tabular-nums;
}

.player.urgent .player-timer {
    color: var(--danger);
    font-weight: 700;
}

.versus {
    color: var(--muted);
    font-weight: 700;
    font-size: 15px;
}

.status {
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    min-height: 26px;
}

.status.your-turn {
    color: var(--accent);
}

.status.notice {
    color: var(--muted);
    font-weight: 600;
    font-size: 15px;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}

.cell,
.hero-cell {
    /* 0 = coldest chance (30%), 100 = hottest (100%) */
    --heat: 0;
    --heat-color: color-mix(in oklch, var(--heat-hot) calc(var(--heat) * 1%), var(--heat-cold));
}

.cell {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--edge), var(--shadow);
    overflow: hidden;
    display: grid;
    place-items: center;
    transition: transform 0.12s ease, background-color 0.3s ease, box-shadow 0.2s ease;
    pointer-events: none;
}

.cell:not(.filled) {
    background:
        linear-gradient(var(--heat-tint), var(--heat-tint)),
        var(--surface);
}

/* Older webviews without color-mix still get a readable board */
@supports not (color: color-mix(in oklch, red 50%, blue)) {
    .cell,
    .hero-cell {
        --heat-color: var(--text);
    }
}

.board.interactive .cell:not(.filled) {
    pointer-events: auto;
}

.board.interactive .cell:not(.filled):active {
    transform: scale(0.94);
}

.board:not(.interactive) .cell:not(.filled):not(.rolling):not(.miss) {
    opacity: 0.75;
}

.cell-chance {
    font-size: clamp(22px, 7.5vw, 30px);
    font-weight: 800;
    color: var(--heat-color);
    font-variant-numeric: tabular-nums;
    transition: opacity 0.2s ease;
}

.cell-chance small {
    font-size: 0.55em;
    font-weight: 700;
}

.cell.filled .cell-chance,
.cell.rolling .cell-chance,
.cell.hit .cell-chance {
    opacity: 0;
    /* hide instantly, so the old number never shows under the rolling one */
    transition: none;
}

.cell-heat {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 12px;
    letter-spacing: -2px;
}

.cell.filled .cell-heat {
    display: none;
}

.cell-symbol {
    position: absolute;
    font-size: clamp(40px, 13vw, 54px);
    line-height: 1;
}

.cell.owner-you {
    box-shadow: inset 0 0 0 3px var(--accent), var(--shadow);
}

.cell.owner-opponent {
    box-shadow: inset 0 0 0 3px var(--opponent), var(--shadow);
}

/* Roll overlay */
.roll {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12%;
}

.cell.rolling .roll {
    display: flex;
}

.cell.rolling .cell-symbol {
    opacity: 0;
}

.roll-number {
    font-size: clamp(24px, 8vw, 32px);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.roll-track {
    position: relative;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--danger) 35%, transparent);
    background-color: rgba(229, 72, 77, 0.35);
}

.roll-zone {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 4px;
    background: var(--accent);
}

.roll-needle {
    position: absolute;
    top: -5px;
    width: 4px;
    height: 18px;
    margin-left: -2px;
    border-radius: 2px;
    background: var(--text);
}

.cell.hit .cell-symbol {
    animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.cell.hit {
    animation: flash-hit 0.6s ease-out;
}

.cell.miss .cell-symbol {
    animation: vanish 0.6s ease-in forwards;
}

.cell.miss {
    animation: shake 0.4s ease-in-out;
}

.cell.win {
    animation: win-glow 1s ease-in-out infinite alternate;
    z-index: 1;
}

.cell.win .cell-symbol {
    animation: pop 0.4s ease-out;
}

.cell.last:not(.rolling):not(.win)::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: calc(var(--radius) - 4px);
    border: 2px dashed color-mix(in srgb, var(--muted) 55%, transparent);
    pointer-events: none;
}

.cell-float {
    position: absolute;
    bottom: 10px;
    font-size: 14px;
    font-weight: 800;
    color: hsl(20 90% 55%);
    opacity: 0;
    pointer-events: none;
}

.cell-float.show {
    animation: float-up 1.1s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.3); }
    100% { transform: scale(1); }
}

@keyframes vanish {
    0% { opacity: 1; transform: scale(1); }
    40% { opacity: 0.9; transform: scale(1.05) rotate(-6deg); }
    100% { opacity: 0; transform: scale(0.6) rotate(12deg); }
}

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

@keyframes flash-hit {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 90, 0.6), var(--shadow); }
    100% { box-shadow: 0 0 0 14px rgba(22, 163, 90, 0), var(--shadow); }
}

@keyframes win-glow {
    from { transform: scale(1); box-shadow: 0 0 0 3px #f5b50b, 0 0 18px rgba(245, 181, 11, 0.5); }
    to { transform: scale(1.05); box-shadow: 0 0 0 3px #f5b50b, 0 0 28px rgba(245, 181, 11, 0.8); }
}

@keyframes float-up {
    0% { opacity: 0; transform: translateY(6px); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-26px); }
}

.last-roll {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    min-height: 20px;
    font-variant-numeric: tabular-nums;
}

.coach {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-small);
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    font-weight: 500;
    animation: screen-in 0.25s ease-out;
}

.coach span {
    flex: 1;
}

.coach-close {
    color: inherit;
    opacity: 0.7;
    font-size: 14px;
}

/* ---------- Sheets ---------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(8, 10, 16, 0.45);
    animation: fade-in 0.2s ease-out;
}

.sheet {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px 16px calc(20px + var(--safe-bottom));
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    animation: sheet-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: none; }
}

.result {
    text-align: center;
    align-items: stretch;
}

.result-emoji {
    font-size: 56px;
    line-height: 1;
}

.result-title {
    font-size: 30px;
    font-weight: 800;
}

.result-title.win {
    color: var(--accent);
}

.result-title.lose {
    color: var(--danger);
}

.result-stats {
    display: flex;
    gap: 10px;
}

.result-player {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px;
    border-radius: var(--radius-small);
    background: var(--bg);
    font-size: 14px;
}

.result-player-name {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-luckiest {
    font-weight: 600;
}

.rematch-status {
    min-height: 20px;
    color: var(--muted);
    font-size: 14px;
}

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

.segmented {
    display: flex;
    gap: 6px;
}

.segmented button {
    flex: 1;
    padding: 10px 8px;
    border-radius: 12px;
    background: var(--bg);
    border: 2px solid transparent;
    font-size: 15px;
    font-weight: 600;
}

.segmented button.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--bg));
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.emoji-option {
    aspect-ratio: 1;
    font-size: 26px;
    border-radius: 12px;
    background: var(--bg);
    border: 2px solid transparent;
}

.emoji-option.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--bg));
}

/* ---------- Linked platforms ---------- */

.link-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.link-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg);
    border: 2px solid transparent;
}

/* The platform the player is on right now cannot be unlinked from here: it is the one holding
   the session open, so the chip carries no remove button and says so by looking quieter */
.link-chip.current {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--bg));
}

.link-chip-remove {
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    color: var(--muted);
    background: none;
}

.link-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

/* Narrower than the invite code: this one shares a sheet with everything else */
.link-code {
    font-size: 26px;
    letter-spacing: 4px;
    margin: 0;
}

/* ---------- Stats & rules ---------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--edge), var(--shadow);
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat.wide {
    grid-column: span 2;
}

.stats-empty {
    text-align: center;
    padding: 24px 0;
}

.rules {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rules li {
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--edge), var(--shadow);
}

.rules strong {
    display: block;
    margin-bottom: 4px;
}

.rules p {
    color: var(--muted);
    font-size: 15px;
}

/* ---------- Toast & celebration ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--safe-bottom));
    z-index: 100;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 14px;
    background: var(--text);
    color: var(--bg);
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    opacity: 0;
    transform: translate(-50%, 16px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.celebration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    overflow: hidden;
}

.celebration span {
    position: absolute;
    left: 50%;
    top: 45%;
    font-size: 34px;
    animation: burst var(--duration, 0.9s) ease-out forwards;
}

@keyframes burst {
    0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1) rotate(var(--r)); opacity: 0; }
}

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