/* Sudoku — Telegram Mini App styles (Tailwind CDN handles most utility classes).
   Sections: 1 fonts & reset · 2 layout · 3 title, logo & splash · 4 board & cells ·
   5 game controls · 6 modals & effects · 7 calendar · 8 VIP & leaderboards ·
   9 shared animations · 10 dark mode (kept last so it overrides the rules above). */

/* =================================================================
   1. FONTS & RESET
   ================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Fredoka:wght@500;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
}

/* =================================================================
   2. LAYOUT
   ================================================================= */
/* One font on every phone (otherwise iOS uses SF and Android Roboto). The title keeps Fredoka,
   badges keep their engraved serif. */
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: -webkit-fill-available;
    overflow: hidden;
    position: fixed;
    background-color: #f0fff4;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    height: -webkit-fill-available;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

#app.hidden {
    display: none !important;
}

/* In Telegram full-screen mode the content runs under the status bar and Telegram's floating
   Back/menu buttons; the SDK exposes their heights as --tg-*-safe-area-inset-* variables. */
header {
    padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + 12px) !important;
    padding-left: 1rem;
    padding-right: 1rem;
    flex-shrink: 0;
}

#content {
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 1rem;
    padding-bottom: max(12px, env(safe-area-inset-bottom), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#content::-webkit-scrollbar {
    display: none;
}

/* Home is vertically centred when it fits, and scrolls (instead of being clipped) on short
   screens. Auto margins centre without cutting off the top like justify-content:center does. */
.view-home #content {
    display: flex;
    flex-direction: column;
}
.view-home #content > * {
    margin-top: auto;
    margin-bottom: auto;
}

#game-view {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
}

/* The board takes whatever height is left after the controls, so the number pad
   always stays on screen. */
#sudoku-board-container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =================================================================
   3. TITLE, LOGO & SPLASH SCREEN
   ================================================================= */
.app-title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0px 2px 0px rgba(13, 148, 136, 0.2));
    line-height: 1.1;
}

/* Header logo pieces */
[class^="logo-piece-"], [class^="logo-dot-"] {
    animation: scramble-down 4s cubic-bezier(0.25, 1, 0.5, 1) infinite;
    transform-origin: center;
}

.logo-piece-1 { animation-delay: 0s; }
.logo-piece-2 { animation-delay: 0.4s; }
.logo-piece-3 { animation-delay: 0.2s; }
.logo-dot-1   { animation-delay: 0.6s; }
.logo-dot-2   { animation-delay: 0.8s; }

@keyframes scramble-down {
    0% { transform: translateY(-120%) scale(0.5); opacity: 0; }
    15% { transform: translateY(0) scale(1.1); opacity: 1; }
    20% { transform: translateY(0) scale(1); }
    80% { transform: translateY(0) scale(1); opacity: 1; }
    90% { transform: translateY(20%) scale(0.8); opacity: 0; }
    100% { transform: translateY(-120%) scale(0.5); opacity: 0; }
}

/* Splash screen */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#splash-title {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 1))
            drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

#splash-logo {
    animation: board-glow 3s ease-in-out infinite;
}

[class^="splash-piece-"], [class^="splash-dot-"] {
    animation: splash-scramble 3s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    transform-origin: center;
}

.splash-piece-1 { animation-delay: 0.1s; }
.splash-piece-2 { animation-delay: 0.5s; }
.splash-piece-3 { animation-delay: 0.3s; }
.splash-piece-4 { animation-delay: 0.7s; }
.splash-dot-1   { animation-delay: 0.9s; }
.splash-dot-2   { animation-delay: 1.1s; }

@keyframes splash-scramble {
    0% { transform: translateY(-150px) scale(0) rotate(-45deg); opacity: 0; }
    20% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
    80% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translateY(150px) scale(0) rotate(45deg); opacity: 0; }
}

@keyframes board-glow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(252, 211, 77, 0.4)); }
    50% { filter: drop-shadow(0 0 25px rgba(252, 211, 77, 0.7)); }
}

/* =================================================================
   4. SUDOKU BOARD & CELLS
   ================================================================= */
/* The board's final size is set in JS (fitBoardToScreen) from the real viewport height;
   these width rules are the fallback. Container-query sizing collapsed the board to 0px
   inside Telegram's iOS/Android webviews, where the parent height isn't definite. */
.sudoku-grid {
    display: grid;
    /* minmax(0, 1fr): rows may shrink below the digit size, so a small board never clips row 9. */
    grid-template-columns: repeat(9, minmax(0, 1fr));
    grid-template-rows: repeat(9, minmax(0, 1fr));
    aspect-ratio: 1 / 1;
    border: 5px solid #0f766e;
    width: 100%;
    max-width: min(450px, 92vw);
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    position: relative; /* anchors the pause overlay to the board, not the whole app */
}

.sudoku-cell {
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: var(--cell-font, clamp(18px, 5.5vw, 26px)); /* --cell-font is set from the board size */
    font-weight: 600;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background-color: white;
    transition: all 0.2s ease;
}

/* Box separators after columns 3 and 6 only (3n also hit column 9, doubling the outer edge). */
.sudoku-cell:nth-child(9n+3),
.sudoku-cell:nth-child(9n+6) { border-right-width: 3px; border-right-color: #0d9488; }
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) { border-bottom-width: 3px; border-bottom-color: #0d9488; }

.selected {
    background-color: #2dd4bf !important;
    color: #ffffff !important;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1);
}

.highlighted {
    background-color: #a5f3eb;
}

.given-value {
    color: #0f766e;
    font-weight: 800;
}

.user-value {
    color: #2563eb;
    font-weight: 600;
}

.error-value {
    color: #e11d48;
    background-color: #fff1f2 !important;
    animation: shake 0.5s;
}

/* Pencil notes: a 3x3 mini grid inside the cell */
.note-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
    pointer-events: none;
}

.note-digit {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    line-height: 1;
    color: #0d9488;
    font-weight: 700;
}

/* Notes on the selected (teal) cell were teal-on-teal. */
.selected .note-digit,
html[data-theme="dark"] .selected .note-digit { color: #ffffff; }

.board-pause-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 118, 110, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

/* =================================================================
   5. GAME CONTROLS
   ================================================================= */
#timer-display {
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', monospace, sans-serif;
}

.control-btn {
    height: clamp(50px, 10vw, 70px);
    border-radius: 1rem;
    font-weight: 700;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #e0f2f1;
}

/* These must come after .control-btn so their heights win. */
.num-btn { background-color: white; color: #0f766e; font-size: 22px; height: 46px; }
.util-btn-game { background-color: #e0f2f1; color: #0f766e; }
.tool-btn { height: 56px; }

.notes-active-btn {
    background-color: #0d9488 !important;
    color: #ffffff !important;
    border-color: #0f766e !important;
    transform: translateY(2px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15) !important;
}

.pause-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background-color: #e0f2f1;
    color: #0f766e;
    border: 2px solid #ccfbf1;
    transition: all 0.15s ease;
}
.pause-pill.is-paused { background-color: #dcfce7; color: #15803d; border-color: #86efac; }

/* On short screens give the board more room by tightening the controls. */
@media (max-height: 640px) {
    .tool-btn { height: 48px; }
    .num-btn { height: 40px; font-size: 20px; }
    .game-stats-bar { padding-top: 0; padding-bottom: 0; }
}

/* =================================================================
   6. MODALS & GAME EFFECTS
   ================================================================= */
/* Toast: sits above the phone's home bar and above open modals, never wider than the screen. */
#toast {
    bottom: calc(16px + var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
    width: max-content;
    max-width: calc(100vw - 32px);
    text-align: center;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.3;
}
#toast.toast-error {
    background-color: #e11d48;
}
/* Win modal: forced with !important because Telegram's native webviews mis-render the
   Tailwind-only version. */
#winModal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
}

#winModal:not(.hidden) {
    display: flex !important;
}

#winModalContent {
    background: white !important;
    border-radius: 2rem !important;
    max-width: 90vw !important;
    width: 100% !important;
    margin: auto !important;
    position: relative !important;
    z-index: 9999 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

#game-end-modal {
    z-index: 9999 !important;
}

/* Confetti canvas sits above every modal */
canvas {
    z-index: 1000000 !important;
    position: fixed !important;
    pointer-events: none !important;
}

/* "+N" points that float up from a solved cell */
.floating-points-text {
    position: fixed;
    pointer-events: none;
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    color: #0d9488;
    font-size: 1.5rem;
    z-index: 1000;
    transform: translate(-50%, -50%);
    animation: point-fly-up 0.8s ease-out forwards;
}

.floating-points-gold {
    position: fixed;
    pointer-events: none;
    font-family: 'Fredoka', sans-serif;
    font-weight: 900;
    color: #d97706;
    font-size: 1.8rem;
    z-index: 1000;
    transform: translate(-50%, -50%);
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.6), 0 2px 4px rgba(0,0,0,0.2);
    animation: point-fly-up 0.8s ease-out forwards;
}

@keyframes point-fly-up {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -100%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -180%) scale(1); opacity: 0; }
}

/* Whole-app shake when the last life is lost */
.loss-animation {
    animation: red-flash-shake 0.8s ease-in-out;
}

@keyframes red-flash-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
    50% { background-color: rgba(239, 68, 68, 0.25); }
}

/* =================================================================
   7. DAILY CHALLENGE CALENDAR
   ================================================================= */
#master-trophy-container {
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.day-circle {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
}

.playable-day { background-color: #f0fdf4; color: #0d9488; border-color: #ccfbf1; }
.finished-day { background-color: #0ec4b4; color: white; box-shadow: 0 4px 6px -1px rgba(13, 148, 136, 0.3); }

.failed-day {
    background-color: #fab1b1 !important;
    border: 2px solid #c74a4a !important;
    color: #b91c1c !important;
    cursor: not-allowed;
    text-decoration: line-through;
}

.failed-day::after {
    content: '✕';
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.7rem;
    background: #ef4444;
    color: white;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    border: 1px solid white;
}

.in-progress-day {
    background-color: #fff7ed !important;
    color: #c2410c !important;
    border: 2px dashed #fb923c !important;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: #fb923c; }
    50% { border-color: transparent; }
}

.today-ring {
    box-shadow: 0 0 0 3px #f59e0b;
}

.locked-day {
    color: #94a3b8;
    opacity: 0.55;
    cursor: not-allowed;
}

/* Month progress bar when every day is solved */
.shimmer {
    background: linear-gradient(90deg, #f59e0b, #fcd34d, #f59e0b);
    background-size: 200% 100%;
    animation: shimmer-effect 1.5s infinite linear;
}

@keyframes shimmer-effect {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Locked trophy (overrides Tailwind's grayscale to also fade it) */
.grayscale {
    filter: grayscale(100%) opacity(40%);
}

/* =================================================================
   8. VIP & LEADERBOARDS
   ================================================================= */
.vip-avatar-frame {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 2px #fcd34d, 0 0 14px rgba(251, 191, 36, 0.75) !important;
}

.vip-infinity-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #d97706 100%);
}

/* VIP name: slow gold shimmer. Darker golds on light surfaces, brighter on dark ones. */
.vip-name {
    background-image: linear-gradient(90deg, #92400e 0%, #d97706 25%, #f59e0b 50%, #d97706 75%, #92400e 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    animation: vip-shimmer 4s linear infinite;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.vip-name.on-dark,
html[data-theme="dark"] .vip-name {
    background-image: linear-gradient(90deg, #f59e0b 0%, #fde68a 25%, #fff7d6 50%, #fde68a 75%, #f59e0b 100%);
}
@keyframes vip-shimmer {
    to { background-position: -200% center; }
}

.vip-pill {
    flex-shrink: 0;
    padding: 1px 5px;
    border-radius: 9999px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #451a03;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.05em;
    line-height: 1.4;
    -webkit-text-fill-color: #451a03;
}

/* Leaderboard rows of other VIP players (your own row keeps its teal highlight). */
.vip-row {
    background: linear-gradient(90deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.18);
}
html[data-theme="dark"] .vip-row {
    background: linear-gradient(90deg, rgba(120, 53, 15, 0.45) 0%, rgba(146, 64, 14, 0.25) 100%);
    border-color: #b45309;
}

/* Game Over: VIP Second Chance button */
.vip-resume-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #d97706 100%) !important;
    color: #451a03 !important;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45) !important;
}

/* Settings: VIP Style pickers */
.style-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 9999px;
    border: 2px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 12px;
    font-weight: 700;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.style-chip:active { transform: scale(0.95); }
.style-chip.is-active { border-color: #f59e0b; background: #fffbeb; color: #92400e; }
.style-chip-lock { font-size: 10px; opacity: 0.8; }
html[data-theme="dark"] .style-chip { background: #1f2937; border-color: #374151; color: #e5e7eb; }
html[data-theme="dark"] .style-chip.is-active { background: rgba(120, 53, 15, 0.4); border-color: #f59e0b; color: #fde68a; }

.theme-swatch {
    width: 16px;
    height: 16px;
    border-radius: 9999px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .vip-name { animation: none; }
}

/* Daily rankings date picker: the whole field opens the native picker */
#ranking-date-input {
    position: relative;
    min-width: 120px;
}

#ranking-date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    background: transparent;
    bottom: 0;
    color: transparent;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
}

/* =================================================================
   9. SHARED ANIMATIONS
   ================================================================= */
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-bounce-subtle {
    animation: bounce-subtle 3s infinite ease-in-out;
}

@keyframes bounce-subtle {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-15px) scale(1.1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.loader {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid #ccfbf1;
    border-top-color: #0d9488;
    animation: loader-spin 0.8s linear infinite;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

/* =================================================================
   10. DARK MODE (html[data-theme="dark"], set by applySavedTheme)
   ================================================================= */
html[data-theme="dark"] body {
    background-color: #111827;
    background-image: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: #e5e7eb;
}

/* Board: light digits on dark cells */
html[data-theme="dark"] .sudoku-grid { border-color: #14b8a6; }
html[data-theme="dark"] .sudoku-cell {
    background-color: #1f2937;
    border-color: #374151;
}
html[data-theme="dark"] .sudoku-cell:nth-child(9n+3),
html[data-theme="dark"] .sudoku-cell:nth-child(9n+6) { border-right-color: #14b8a6; }
html[data-theme="dark"] .sudoku-cell:nth-child(n+19):nth-child(-n+27),
html[data-theme="dark"] .sudoku-cell:nth-child(n+46):nth-child(-n+54) { border-bottom-color: #14b8a6; }
html[data-theme="dark"] .highlighted { background-color: #134e4a; }
html[data-theme="dark"] .given-value { color: #f3f4f6; }
html[data-theme="dark"] .user-value { color: #60a5fa; }
html[data-theme="dark"] .error-value { color: #fb7185; background-color: #4c0519 !important; }
html[data-theme="dark"] .note-digit { color: #5eead4; }

/* Controls */
html[data-theme="dark"] .num-btn { background-color: #1f2937; color: #5eead4; }
html[data-theme="dark"] .util-btn-game,
html[data-theme="dark"] .pause-pill { background-color: #134e4a; color: #99f6e4; }
html[data-theme="dark"] .control-btn,
html[data-theme="dark"] .pause-pill { border-color: #374151; }

/* Titles */
html[data-theme="dark"] .app-title,
html[data-theme="dark"] #splash-title {
    background-image: linear-gradient(135deg, #5eead4 0%, #2dd4bf 100%);
}

/* Calendar */
html[data-theme="dark"] .playable-day { background-color: #134e4a; color: #5eead4; border-color: #115e59; }
html[data-theme="dark"] .locked-day { color: #6b7280; }
html[data-theme="dark"] .failed-day {
    background-color: #450a0a !important;
    color: #f87171 !important;
    border-color: #7f1d1d !important;
}

/* Modals */
html[data-theme="dark"] #winModalContent { background: #1f2937 !important; }

/* Generic Tailwind surfaces/text used across screens */
html[data-theme="dark"] .bg-white { background-color: #1f2937; }
html[data-theme="dark"] .bg-white\/50,
html[data-theme="dark"] .bg-white\/80,
html[data-theme="dark"] .bg-white\/90 { background-color: rgba(31, 41, 55, 0.85); }
html[data-theme="dark"] .bg-gray-50 {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
}
html[data-theme="dark"] .bg-gray-100 { background-color: #374151; }
html[data-theme="dark"] .bg-teal-50,
html[data-theme="dark"] .bg-teal-100 { background-color: #134e4a; }
html[data-theme="dark"] .bg-teal-200 { background-color: #115e59; }
html[data-theme="dark"] .bg-teal-300 { background-color: #0f766e; }
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800 { color: #f3f4f6; }
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-600 { color: #d1d5db; }
html[data-theme="dark"] .text-gray-500 { color: #9ca3af; }
html[data-theme="dark"] .text-teal-900,
html[data-theme="dark"] .text-teal-800,
html[data-theme="dark"] .text-teal-700 { color: #5eead4; }
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-teal-100 { border-color: #374151; }

/* =================================================================
   11. VIP BOARD THEMES (html[data-board-theme], set by applySavedTheme)
   Each theme is a set of --b-* colours with a light and a dark variant; the rules below
   apply them to the board and number pad. Kept last so they win over dark mode.
   ================================================================= */
html[data-board-theme="ocean"] {
    --b-frame: #1e40af; --b-box: #3b82f6; --b-line: #dbeafe; --b-cell: #ffffff; --b-high: #dbeafe;
    --b-sel: #93c5fd; --b-sel-text: #1e3a8a; --b-given: #1e3a8a; --b-user: #0284c7; --b-note: #2563eb;
    --b-err: #e11d48; --b-err-bg: #ffe4e6; --b-num-bg: #ffffff; --b-num: #1e40af;
    --b-util-bg: #dbeafe; --b-util: #1e40af; --b-pause: rgba(30, 64, 175, 0.92);
}
html[data-theme="dark"][data-board-theme="ocean"] {
    --b-frame: #3b82f6; --b-box: #60a5fa; --b-line: #1e293b; --b-cell: #0f172a; --b-high: #1e3a5f;
    --b-sel: #1d4ed8; --b-sel-text: #ffffff; --b-given: #e0f2fe; --b-user: #38bdf8; --b-note: #7dd3fc;
    --b-err: #fb7185; --b-err-bg: #4c0519; --b-num-bg: #0f172a; --b-num: #93c5fd;
    --b-util-bg: #1e3a5f; --b-util: #bfdbfe;
}

html[data-board-theme="sakura"] {
    --b-frame: #be185d; --b-box: #ec4899; --b-line: #fce7f3; --b-cell: #fffafc; --b-high: #fce7f3;
    --b-sel: #f9a8d4; --b-sel-text: #831843; --b-given: #831843; --b-user: #c026d3; --b-note: #db2777;
    --b-err: #dc2626; --b-err-bg: #fee2e2; --b-num-bg: #ffffff; --b-num: #be185d;
    --b-util-bg: #fce7f3; --b-util: #9d174d; --b-pause: rgba(190, 24, 93, 0.92);
}
html[data-theme="dark"][data-board-theme="sakura"] {
    --b-frame: #ec4899; --b-box: #f472b6; --b-line: #3b1d2e; --b-cell: #24121c; --b-high: #4a1d38;
    --b-sel: #9d174d; --b-sel-text: #ffffff; --b-given: #fce7f3; --b-user: #f0abfc; --b-note: #f9a8d4;
    --b-err: #fb7185; --b-err-bg: #4c0519; --b-num-bg: #24121c; --b-num: #f9a8d4;
    --b-util-bg: #4a1d38; --b-util: #fbcfe8;
}

html[data-board-theme="forest"] {
    --b-frame: #166534; --b-box: #22c55e; --b-line: #dcfce7; --b-cell: #fbfef9; --b-high: #dcfce7;
    --b-sel: #86efac; --b-sel-text: #14532d; --b-given: #14532d; --b-user: #0e7490; --b-note: #16a34a;
    --b-err: #dc2626; --b-err-bg: #fee2e2; --b-num-bg: #ffffff; --b-num: #166534;
    --b-util-bg: #dcfce7; --b-util: #166534; --b-pause: rgba(22, 101, 52, 0.92);
}
html[data-theme="dark"][data-board-theme="forest"] {
    --b-frame: #22c55e; --b-box: #4ade80; --b-line: #1c2e22; --b-cell: #0f1d14; --b-high: #14532d;
    --b-sel: #15803d; --b-sel-text: #ffffff; --b-given: #dcfce7; --b-user: #67e8f9; --b-note: #86efac;
    --b-err: #fb7185; --b-err-bg: #4c0519; --b-num-bg: #0f1d14; --b-num: #86efac;
    --b-util-bg: #14532d; --b-util: #bbf7d0;
}

/* Midnight Gold is dark in both app modes. */
html[data-board-theme="midnight"] {
    --b-frame: #b45309; --b-box: #d97706; --b-line: #27272a; --b-cell: #18181b; --b-high: #292524;
    --b-sel: #f59e0b; --b-sel-text: #18181b; --b-given: #fafaf9; --b-user: #fbbf24; --b-note: #fcd34d;
    --b-err: #f87171; --b-err-bg: #450a0a; --b-num-bg: #18181b; --b-num: #fbbf24;
    --b-util-bg: #292524; --b-util: #fcd34d; --b-pause: rgba(24, 24, 27, 0.94);
}

/* Gradient themes: the colour blend sits behind see-through cells. Same look in both app modes. */
html[data-board-theme="peach"] {
    --b-scene: linear-gradient(135deg, #ffd6a5, #ffadad 55%, #fbc2eb);
    --b-frame: #fb7185; --b-box: #f43f5e; --b-line: rgba(244, 63, 94, 0.18); --b-cell: rgba(255, 255, 255, 0.6);
    --b-high: rgba(255, 255, 255, 0.85); --b-sel: #fb7185; --b-sel-text: #4c0519; --b-given: #881337; --b-user: #7c3aed;
    --b-note: #be123c; --b-err: #dc2626; --b-err-bg: rgba(254, 226, 226, 0.95); --b-num-bg: #ffffff; --b-num: #e11d48;
    --b-util-bg: #ffe4e6; --b-util: #9f1239; --b-pause: rgba(225, 29, 72, 0.9);
}
html[data-board-theme="candy"] {
    --b-scene: linear-gradient(135deg, #fbcfe8, #c7d2fe 55%, #bfdbfe);
    --b-frame: #a855f7; --b-box: #c084fc; --b-line: rgba(168, 85, 247, 0.18); --b-cell: rgba(255, 255, 255, 0.6);
    --b-high: rgba(255, 255, 255, 0.88); --b-sel: #f0abfc; --b-sel-text: #4a044e; --b-given: #581c87; --b-user: #db2777;
    --b-note: #9333ea; --b-err: #dc2626; --b-err-bg: rgba(254, 226, 226, 0.95); --b-num-bg: #ffffff; --b-num: #9333ea;
    --b-util-bg: #f3e8ff; --b-util: #6b21a8; --b-pause: rgba(126, 34, 206, 0.9);
}
html[data-board-theme="golden"] {
    --b-scene: linear-gradient(135deg, #fef08a, #fdba74 50%, #fb7185);
    --b-frame: #c2410c; --b-box: #ea580c; --b-line: rgba(194, 65, 12, 0.2); --b-cell: rgba(255, 255, 255, 0.62);
    --b-high: rgba(255, 255, 255, 0.88); --b-sel: #fb923c; --b-sel-text: #431407; --b-given: #7c2d12; --b-user: #be185d;
    --b-note: #c2410c; --b-err: #dc2626; --b-err-bg: rgba(254, 226, 226, 0.95); --b-num-bg: #ffffff; --b-num: #c2410c;
    --b-util-bg: #ffedd5; --b-util: #9a3412; --b-pause: rgba(194, 65, 12, 0.9);
}

/* Lemon: a solid tint, same look in both app modes. */
html[data-board-theme="lemon"] {
    --b-frame: #ca8a04; --b-box: #eab308; --b-line: #fef08a; --b-cell: #fefce8; --b-high: #fef9c3;
    --b-sel: #fde047; --b-sel-text: #422006; --b-given: #422006; --b-user: #2563eb; --b-note: #a16207;
    --b-err: #dc2626; --b-err-bg: #fee2e2; --b-num-bg: #ffffff; --b-num: #a16207;
    --b-util-bg: #fef9c3; --b-util: #713f12; --b-pause: rgba(161, 98, 7, 0.92);
}

html[data-board-theme] .sudoku-grid { border-color: var(--b-frame); background: var(--b-scene, none); }
html[data-board-theme] .sudoku-cell { background-color: var(--b-cell); border-color: var(--b-line); }
html[data-board-theme] .sudoku-cell:nth-child(9n+3),
html[data-board-theme] .sudoku-cell:nth-child(9n+6) { border-right-color: var(--b-box); }
html[data-board-theme] .sudoku-cell:nth-child(n+19):nth-child(-n+27),
html[data-board-theme] .sudoku-cell:nth-child(n+46):nth-child(-n+54) { border-bottom-color: var(--b-box); }
html[data-board-theme] .highlighted { background-color: var(--b-high); }
html[data-board-theme] .selected { background-color: var(--b-sel) !important; }
html[data-board-theme] .given-value { color: var(--b-given); }
html[data-board-theme] .user-value { color: var(--b-user); }
html[data-board-theme] .note-digit { color: var(--b-note); }
html[data-board-theme] .selected span:not(.error-value),
html[data-board-theme] .selected .note-digit { color: var(--b-sel-text) !important; }
/* After .selected so a wrong digit stays red even while its cell is selected. */
html[data-board-theme] .error-value { color: var(--b-err); background-color: var(--b-err-bg) !important; }
html[data-board-theme] .board-pause-overlay { background: var(--b-pause, rgba(15, 23, 42, 0.92)); }
html[data-board-theme] .num-btn { background-color: var(--b-num-bg); color: var(--b-num); border-color: var(--b-line); }
html[data-board-theme] .util-btn-game { background-color: var(--b-util-bg); color: var(--b-util); border-color: var(--b-line); }

/* =================================================================
   12. VIP THEMED GAME SCREEN (html.in-game[data-board-theme], set by syncScreenTheme)
   The board theme also colours the game screen around the board. --g-page is the background,
   --g-surface/--g-panel the bars and button panels. Other screens keep normal Light/Dark.
   ================================================================= */
html[data-board-theme="ocean"] {
    --g-page: linear-gradient(180deg, #eff6ff, #dbeafe); --g-surface: rgba(255, 255, 255, 0.75); --g-border: #bfdbfe;
    --g-label: #64748b; --g-accent: #1e40af; --g-pill-bg: #dbeafe; --g-pill: #1e40af; --g-panel: #ffffff;
}
html[data-theme="dark"][data-board-theme="ocean"] {
    --g-page: linear-gradient(180deg, #0b1222, #0f172a); --g-surface: #13203a; --g-border: #1e3a5f;
    --g-label: #93a4c3; --g-accent: #93c5fd; --g-pill-bg: #1e3a5f; --g-pill: #bfdbfe; --g-panel: #0f1a30;
}
html[data-board-theme="sakura"] {
    --g-page: linear-gradient(180deg, #fff1f6, #fce7f3); --g-surface: rgba(255, 255, 255, 0.75); --g-border: #fbcfe8;
    --g-label: #9d6b84; --g-accent: #be185d; --g-pill-bg: #fce7f3; --g-pill: #9d174d; --g-panel: #ffffff;
}
html[data-theme="dark"][data-board-theme="sakura"] {
    --g-page: linear-gradient(180deg, #1a0d14, #24121c); --g-surface: #2a1520; --g-border: #4a1d38;
    --g-label: #c79ab0; --g-accent: #f9a8d4; --g-pill-bg: #4a1d38; --g-pill: #fbcfe8; --g-panel: #2a1520;
}
html[data-board-theme="forest"] {
    --g-page: linear-gradient(180deg, #f0fdf4, #dcfce7); --g-surface: rgba(255, 255, 255, 0.75); --g-border: #bbf7d0;
    --g-label: #5f7f6a; --g-accent: #166534; --g-pill-bg: #dcfce7; --g-pill: #166534; --g-panel: #ffffff;
}
html[data-theme="dark"][data-board-theme="forest"] {
    --g-page: linear-gradient(180deg, #0b150e, #0f1d14); --g-surface: #13261a; --g-border: #14532d;
    --g-label: #8fb59b; --g-accent: #86efac; --g-pill-bg: #14532d; --g-pill: #bbf7d0; --g-panel: #13261a;
}
html[data-board-theme="midnight"] {
    --g-page: linear-gradient(180deg, #0c0c0e, #18181b); --g-surface: #1c1c20; --g-border: #3f3f46;
    --g-label: #a1a1aa; --g-accent: #fbbf24; --g-pill-bg: #292524; --g-pill: #fcd34d; --g-panel: #1c1c20;
}
html[data-board-theme="peach"] {
    --g-page: linear-gradient(160deg, #fff1e6, #ffe4e6 55%, #fdf2f8); --g-surface: rgba(255, 255, 255, 0.7); --g-border: #fecdd3;
    --g-label: #9f5b6b; --g-accent: #e11d48; --g-pill-bg: #ffe4e6; --g-pill: #9f1239; --g-panel: rgba(255, 255, 255, 0.85);
}
html[data-board-theme="candy"] {
    --g-page: linear-gradient(160deg, #fdf2f8, #eef2ff 55%, #eff6ff); --g-surface: rgba(255, 255, 255, 0.7); --g-border: #e9d5ff;
    --g-label: #7e6a9a; --g-accent: #9333ea; --g-pill-bg: #f3e8ff; --g-pill: #6b21a8; --g-panel: rgba(255, 255, 255, 0.85);
}
html[data-board-theme="golden"] {
    --g-page: linear-gradient(160deg, #fefce8, #fff7ed 50%, #fff1f2); --g-surface: rgba(255, 255, 255, 0.7); --g-border: #fed7aa;
    --g-label: #9a6b4f; --g-accent: #c2410c; --g-pill-bg: #ffedd5; --g-pill: #9a3412; --g-panel: rgba(255, 255, 255, 0.85);
}
html[data-board-theme="lemon"] {
    --g-page: linear-gradient(180deg, #fffef3, #fef9c3); --g-surface: rgba(255, 255, 255, 0.75); --g-border: #fde68a;
    --g-label: #8a7a3c; --g-accent: #a16207; --g-pill-bg: #fef9c3; --g-pill: #713f12; --g-panel: #ffffff;
}

html.in-game[data-board-theme] body { background: var(--g-page); }
html.in-game[data-board-theme] .app-title {
    background-image: none;
    -webkit-text-fill-color: var(--g-accent);
    color: var(--g-accent);
}
html.in-game[data-board-theme] #user-profile-badge { background: var(--g-surface); border-color: var(--g-border); }
html.in-game[data-board-theme] #header-username:not(.vip-name) { color: var(--g-accent); }
html.in-game[data-board-theme] .game-stats-bar { background: var(--g-surface); border-color: var(--g-border); }
html.in-game[data-board-theme] .game-stat-divider { border-color: var(--g-border); }
html.in-game[data-board-theme] .game-stat-label { color: var(--g-label); }
html.in-game[data-board-theme] .game-stat-value,
html.in-game[data-board-theme] .game-accent-text { color: var(--g-accent); }
html.in-game[data-board-theme] .pause-pill { background-color: var(--g-pill-bg); color: var(--g-pill); border-color: var(--g-border); }
html.in-game[data-board-theme] .game-panel { background: var(--g-panel); border: 1px solid var(--g-border); }
html.in-game[data-board-theme] .util-btn-game > span:last-child { color: var(--b-util); }
html.in-game[data-board-theme] header .bg-white { background: var(--g-surface); }

/* =================================================================
   13. CALENDAR STREAK BADGE (with the VIP Streak Freeze icon inside)
   ================================================================= */
.streak-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    background: #fff1f2;
    border: 1px solid #ffe4e6;
    color: #e11d48;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.streak-freeze { font-size: 12px; line-height: 1; }
.streak-freeze.is-used { opacity: 0.35; filter: grayscale(1); }
html[data-theme="dark"] .streak-pill { background: rgba(136, 19, 55, 0.3); border-color: #881337; color: #fda4af; }

/* Dark mode: no white outline on the month progress bar, and a visible locked trophy. */
html[data-theme="dark"] .calendar-progress { border-color: #374151; }
html[data-theme="dark"] .locked-trophy { filter: grayscale(100%) brightness(1.6); opacity: 0.3; }

/* =================================================================
   14. HOME STREAK CARD (renderHomeScreen)
   ================================================================= */
.home-hero {
    display: grid;
    gap: 0.85rem;
    padding: 1.25rem;
    border-radius: 1.5rem;
    background: linear-gradient(135deg, #f59e0b, #fbbf24 60%, #fcd34d);
    color: #451a03;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.3);
    text-align: left;
}
html[data-theme="dark"] .home-hero {
    background: linear-gradient(135deg, #b45309, #d97706 60%, #f59e0b);
    color: #fff7ed;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}
.home-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.home-streak { display: flex; align-items: baseline; gap: 0.4rem; }
.home-streak b { font-size: 2.75rem; font-weight: 900; line-height: 1; }
.home-streak span { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.2; }
.home-week { display: grid; grid-template-columns: repeat(7, 22px); gap: 4px; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; }
.home-day-col { display: grid; justify-items: center; gap: 2px; }
.home-day-col small { font-size: 9px; font-weight: 800; opacity: 0.8; }
.home-day {
    width: 22px; height: 22px; border-radius: 9999px;
    display: grid; place-items: center;
    font-size: 11px; font-style: normal; font-weight: 900;
    background: rgba(255, 255, 255, 0.45);
}
.home-day.is-solved { background: #ffffff; color: #b45309; }
.home-day.is-frozen { background: #e0f2fe; font-size: 10px; }
.home-day.is-today { box-shadow: 0 0 0 2px #ffffff; }
.home-day.is-today:not(.is-solved):not(.is-frozen) { background: transparent; }
.home-day.is-future { opacity: 0.5; }
.home-hero-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 0.75rem; font-size: 0.75rem; font-weight: 700; opacity: 0.95; }
.home-hero-link { background: none; border: 0; padding: 0; color: inherit; font-weight: 900; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.home-hero-btn {
    width: 100%; padding: 0.9rem; border: 0; border-radius: 0.9rem;
    background: #ffffff; color: #b45309;
    font-size: 1rem; font-weight: 900;
    box-shadow: 0 4px 12px rgba(120, 53, 15, 0.18);
    transition: transform 0.15s ease;
}
.home-hero-btn:active { transform: scale(0.97); }
.home-hero-btn.is-done { background: rgba(255, 255, 255, 0.35); color: inherit; box-shadow: none; }
.home-diff small { display: block; font-size: 10px; font-weight: 700; opacity: 0.8; margin-top: 2px; }
.home-icon-btn { display: grid; justify-items: center; gap: 2px; padding: 0.85rem 0.25rem; font-size: 0.8rem; font-weight: 800; }
.home-icon-btn span { font-size: 1.4rem; line-height: 1.2; }

/* =================================================================
   15. TOURNAMENTS
   ================================================================= */
.t-card {
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    border-radius: 1.5rem;
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
}
html[data-theme="dark"] .t-card { background: linear-gradient(135deg, #5b21b6, #4338ca); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35); }
.t-card-head { display: flex; align-items: center; justify-content: space-between; font-size: 1rem; font-weight: 900; }
.t-card-head span { font-size: 0.65rem; font-weight: 800; background: rgba(255, 255, 255, 0.22); padding: 2px 8px; border-radius: 9999px; }
.t-card-head span:empty { display: none; }
.t-card-items { display: grid; gap: 0.4rem; }
.t-card-item {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    width: 100%; padding: 0.55rem 0.75rem; border: 0; border-radius: 0.8rem;
    background: rgba(255, 255, 255, 0.16); color: #ffffff; font-size: 0.8rem; font-weight: 700; text-align: left;
}
.t-card-item.is-empty { justify-content: center; text-align: center; opacity: 0.9; font-weight: 600; }
.t-card-btn { padding: 0.7rem; border: 0; border-radius: 0.8rem; background: #ffffff; color: #5b21b6; font-weight: 900; font-size: 0.85rem; }
.t-card-btn.is-ghost { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
.t-card-btn:active, .t-card-item:active { transform: scale(0.97); }

.t-pill { flex-shrink: 0; font-size: 0.62rem; font-weight: 800; padding: 3px 8px; border-radius: 9999px; white-space: nowrap; }
.t-pill.is-play { background: #0d9488; color: #ffffff; }
.t-pill.is-wait { background: #fef3c7; color: #92400e; }
.t-pill.is-done { background: #ede9fe; color: #6d28d9; }
.t-pill.is-muted { background: #f3f4f6; color: #6b7280; }
.t-card .t-pill.is-wait, .t-card .t-pill.is-muted { background: rgba(255, 255, 255, 0.25); color: #ffffff; }
.t-card .t-pill.is-done { background: #ffffff; color: #5b21b6; }
html[data-theme="dark"] .t-pill.is-wait { background: rgba(146, 64, 14, 0.35); color: #fcd34d; }
html[data-theme="dark"] .t-pill.is-done { background: rgba(91, 33, 182, 0.35); color: #c4b5fd; }
html[data-theme="dark"] .t-pill.is-muted { background: #374151; color: #9ca3af; }

.t-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 0.9rem; background: #f1f5f9; }
.t-tabs button { padding: 0.55rem; border: 0; border-radius: 0.7rem; background: transparent; color: #6b7280; font-weight: 800; font-size: 0.85rem; }
.t-tabs button.is-on { background: #ffffff; color: #0f766e; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
html[data-theme="dark"] .t-tabs { background: #1f2937; }
html[data-theme="dark"] .t-tabs button.is-on { background: #374151; color: #5eead4; }

.t-item { display: grid; gap: 4px; width: 100%; padding: 0.75rem 0.9rem; border: 0; border-radius: 1rem; background: #ffffff; text-align: left; box-shadow: 0 4px 14px rgba(15, 118, 110, 0.08); }
html[data-theme="dark"] .t-item { background: #1f2937; box-shadow: none; border: 1px solid #374151; }
.t-item-l1 { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 0.9rem; color: #1f2937; min-width: 0; }
.t-item-l2 { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.72rem; font-weight: 700; color: #6b7280; }
html[data-theme="dark"] .t-item-l1 { color: #f3f4f6; }
html[data-theme="dark"] .t-item-l2 { color: #9ca3af; }
.t-progress { height: 5px; border-radius: 9999px; background: #f1f5f9; overflow: hidden; }
.t-progress i { display: block; height: 100%; background: #8b5cf6; border-radius: 9999px; }
html[data-theme="dark"] .t-progress { background: #374151; }

.t-field { display: grid; gap: 0.4rem; }
.t-field > span { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; }
.t-choices { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.4rem; }
.t-choice { position: relative; display: grid; gap: 1px; padding: 0.6rem 0.25rem; border: 2px solid #e5e7eb; border-radius: 0.75rem; background: transparent; color: #374151; font-weight: 800; font-size: 0.8rem; }
.t-choice small { font-size: 0.62rem; font-weight: 700; color: #9ca3af; }
.t-choice.is-on { border-color: #0d9488; background: #ccfbf1; color: #115e59; }
.t-choice.is-locked { color: #9ca3af; }
.t-choice.is-locked::after { content: "👑"; position: absolute; top: -9px; right: -4px; font-size: 0.7rem; }
html[data-theme="dark"] .t-choice { border-color: #374151; color: #e5e7eb; }
html[data-theme="dark"] .t-choice.is-on { border-color: #14b8a6; background: #134e4a; color: #99f6e4; }
.t-stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; text-align: center; border: 2px solid #e5e7eb; border-radius: 0.8rem; overflow: hidden; }
.t-stepper button { padding: 0.45rem 0; border: 0; background: transparent; color: #0f766e; font-size: 1.3rem; font-weight: 900; }
.t-stepper b { font-size: 1.1rem; font-weight: 900; }
.t-stepper small { font-size: 0.7rem; color: #9ca3af; font-weight: 700; }
html[data-theme="dark"] .t-stepper { border-color: #374151; }
html[data-theme="dark"] .t-stepper button { color: #5eead4; }
.t-hint { padding: 0.45rem 0.6rem; border-radius: 0.6rem; background: #fef3c7; color: #92400e; font-size: 0.7rem; font-weight: 700; }
html[data-theme="dark"] .t-hint { background: rgba(146, 64, 14, 0.35); color: #fcd34d; }

.t-invite { display: grid; justify-items: center; gap: 0.25rem; text-align: center; padding: 1rem; border-radius: 1.5rem; background: #ffffff; box-shadow: 0 8px 20px rgba(15, 118, 110, 0.1); }
html[data-theme="dark"] .t-invite { background: #1f2937; box-shadow: none; }
.t-invite h3 { margin: 0.15rem 0 0; font-size: 1.3rem; font-weight: 900; color: #0f766e; overflow-wrap: anywhere; }
html[data-theme="dark"] .t-invite h3 { color: #5eead4; }
.t-ava { width: 48px; height: 48px; border-radius: 9999px; display: grid; place-items: center; background: #0d9488; color: #ffffff; font-weight: 900; border: 2px solid #fbbf24; }
.t-facts { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 0.6rem 0.25rem; border-radius: 1rem; background: #ffffff; box-shadow: 0 4px 14px rgba(15, 118, 110, 0.08); }
html[data-theme="dark"] .t-facts { background: #1f2937; box-shadow: none; }
.t-facts b { display: block; font-size: 0.95rem; font-weight: 900; }
.t-facts small { font-size: 0.6rem; font-weight: 800; color: #9ca3af; text-transform: uppercase; }
.t-rules { margin: 0; padding: 0.9rem 1rem; list-style: none; display: grid; gap: 0.35rem; border-radius: 1rem; background: #ffffff; font-size: 0.78rem; font-weight: 700; color: #4b5563; }
html[data-theme="dark"] .t-rules { background: #1f2937; color: #d1d5db; }
.t-main-btn { width: 100%; padding: 0.95rem; border: 0; border-radius: 1rem; background: #0d9488; color: #ffffff; font-weight: 900; font-size: 1rem; box-shadow: 0 6px 16px rgba(13, 148, 136, 0.3); }
.t-second-btn { width: 100%; padding: 0.8rem; border: 2px solid #e5e7eb; border-radius: 1rem; background: transparent; color: #374151; font-weight: 800; }
html[data-theme="dark"] .t-second-btn { border-color: #374151; color: #e5e7eb; }
.t-main-btn:active, .t-second-btn:active, .t-item:active { transform: scale(0.97); }
.t-note { text-align: center; padding: 0.75rem; border-radius: 1rem; background: #f3f4f6; color: #6b7280; font-weight: 700; font-size: 0.85rem; }
html[data-theme="dark"] .t-note { background: #1f2937; color: #9ca3af; }
.t-banner { display: grid; justify-items: center; gap: 2px; padding: 0.9rem; border-radius: 1rem; background: #ede9fe; color: #6d28d9; font-weight: 800; }
.t-banner big { font-size: 2rem; line-height: 1; }
.t-banner small { font-size: 0.7rem; font-weight: 700; opacity: 0.8; }
html[data-theme="dark"] .t-banner { background: rgba(91, 33, 182, 0.35); color: #c4b5fd; }

.t-board { display: grid; gap: 0.4rem; }
.t-board h4 { margin: 0.5rem 0 0.1rem; font-size: 0.75rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; }
.t-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 0.5rem; padding: 0.6rem 0.75rem; border-radius: 0.9rem; background: #ffffff; font-size: 0.85rem; font-weight: 700; box-shadow: 0 2px 8px rgba(15, 118, 110, 0.06); }
html[data-theme="dark"] .t-row { background: #1f2937; box-shadow: none; }
.t-row.is-me { background: #ecfeff; outline: 2px solid #22d3ee; }
html[data-theme="dark"] .t-row.is-me { background: #164e63; }
.t-rank { text-align: center; font-weight: 900; }
.t-name { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; }
.t-time { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.t-time small { display: block; font-size: 0.6rem; font-weight: 700; color: #9ca3af; }
.t-dnf { color: #e11d48; }
.t-muted { color: #9ca3af; font-weight: 700; font-size: 0.75rem; }

.t-shelf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; text-align: center; }
.t-shelf div { padding: 0.4rem 0.2rem 0.45rem; border-radius: 0.8rem; background: #f8fafc; }
html[data-theme="dark"] .t-shelf div { background: #111827; }
.t-shelf big { display: block; font-size: 1.5rem; line-height: 1.15; }
.t-shelf .t-medal-art { display: block; width: 100%; max-width: 38px; margin: 0 auto 0.1rem; }
.t-medal-img { display: block; width: 100%; height: auto; }
.t-shelf b { font-size: 1rem; font-weight: 900; line-height: 1.2; }
.t-shelf small { display: block; font-size: 0.6rem; font-weight: 800; color: #9ca3af; text-transform: uppercase; }
html[data-theme="dark"] .t-card .t-pill.is-wait,
html[data-theme="dark"] .t-card .t-pill.is-muted { background: rgba(255, 255, 255, 0.25); color: #ffffff; }
html[data-theme="dark"] .t-card .t-pill.is-done { background: #ffffff; color: #5b21b6; }

/* Tournament invite code (tap to copy) */
.t-code {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    width: 100%; padding: 0.75rem 1rem; border: 2px dashed #a78bfa; border-radius: 1rem;
    background: #f5f3ff; color: #5b21b6; font-weight: 800; font-size: 0.8rem;
}
.t-code b { font-size: 1.25rem; font-weight: 900; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.t-code small { font-size: 0.7rem; font-weight: 800; opacity: 0.8; }
.t-code:active { transform: scale(0.98); }
html[data-theme="dark"] .t-code { background: rgba(91, 33, 182, 0.25); border-color: #7c3aed; color: #c4b5fd; }

/* =================================================================
   16. MY STATS TILES + ACHIEVEMENTS
   ================================================================= */
.stat-tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 0.9rem; background: #f1f5f9; }
.stat-tabs button { padding: 0.55rem; border: 0; border-radius: 0.7rem; background: transparent; color: #6b7280; font-weight: 800; font-size: 0.85rem; }
.stat-tabs button.is-on { background: #ffffff; color: #0f766e; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
html[data-theme="dark"] .stat-tabs { background: #1f2937; }
html[data-theme="dark"] .stat-tabs button.is-on { background: #374151; color: #5eead4; }
.stat-sec { display: grid; gap: 0.45rem; }
.stat-sec h6 { margin: 0 0.15rem; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.stat-tile { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.6rem; padding: 0.7rem 0.75rem; border-radius: 1rem; background: var(--tile-bg); }
.stat-ic { width: 38px; height: 38px; border-radius: 0.7rem; display: grid; place-items: center; background: #ffffff; font-size: 1.1rem; }
.stat-ic img { width: 26px; height: 26px; object-fit: contain; }
.stat-v { font-size: 1.35rem; font-weight: 900; line-height: 1.05; color: var(--tile-text); font-variant-numeric: tabular-nums; }
.stat-v.is-empty { color: #9ca3af; }
.stat-k { font-size: 0.72rem; font-weight: 700; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tone-teal { --tile-bg: #ccfbf1; --tile-text: #0f766e; }
.tone-rose { --tile-bg: #ffe4e6; --tile-text: #be123c; }
.tone-orange { --tile-bg: #ffedd5; --tile-text: #c2410c; }
.tone-amber { --tile-bg: #fef3c7; --tile-text: #b45309; }
.tone-green { --tile-bg: #dcfce7; --tile-text: #15803d; }
.tone-blue { --tile-bg: #dbeafe; --tile-text: #1d4ed8; }
.tone-gray { --tile-bg: #f1f5f9; --tile-text: #475569; }
html[data-theme="dark"] .stat-ic { background: #111827; }
html[data-theme="dark"] .stat-k, html[data-theme="dark"] .stat-sec h6 { color: #9ca3af; }
html[data-theme="dark"] .tone-teal { --tile-bg: rgba(13, 148, 136, 0.25); --tile-text: #5eead4; }
html[data-theme="dark"] .tone-rose { --tile-bg: rgba(190, 18, 60, 0.25); --tile-text: #fda4af; }
html[data-theme="dark"] .tone-orange { --tile-bg: rgba(194, 65, 12, 0.25); --tile-text: #fdba74; }
html[data-theme="dark"] .tone-amber { --tile-bg: rgba(180, 83, 9, 0.25); --tile-text: #fcd34d; }
html[data-theme="dark"] .tone-green { --tile-bg: rgba(21, 128, 61, 0.25); --tile-text: #86efac; }
html[data-theme="dark"] .tone-blue { --tile-bg: rgba(29, 78, 216, 0.25); --tile-text: #93c5fd; }
html[data-theme="dark"] .tone-gray { --tile-bg: rgba(71, 85, 105, 0.3); --tile-text: #cbd5e1; }

.badge-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; image-rendering: auto; }
.badge-strip { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.55rem 0.8rem; border: 0; border-radius: 1rem; background: linear-gradient(160deg, #1d2328, #14181b); color: #e9e4d8; font-weight: 800; font-size: 0.8rem; text-align: left; }
.badge-strip-art { display: flex; flex-shrink: 0; }
.badge-strip-art .badge-img { width: 34px; margin-left: -8px; }
.badge-strip-art .badge-img:first-child { margin-left: 0; }
.badge-strip-text { flex: 1; min-width: 0; }
.badge-strip-link { color: #fbbf24; flex-shrink: 0; }
.badge-next-row { display: grid; grid-template-columns: 2.6rem 1fr; align-items: center; column-gap: 0.7rem; row-gap: 0.35rem; width: 100%; margin-top: 0.15rem; padding: 0.6rem 0.75rem; border: 1px solid #f1f5f9; border-radius: 1rem; background: #f8fafc; text-align: left; }
.badge-next-art { grid-row: span 2; display: block; }
.badge-next-art .badge-img { width: 100%; }
.badge-next-text { display: grid; min-width: 0; line-height: 1.25; }
.badge-next-text small { font-size: 0.6rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: #0f766e; }
.badge-next-text b { font-size: 0.9rem; font-weight: 900; color: #1f2937; }
.badge-next-text em { font-style: normal; font-size: 0.72rem; font-weight: 700; color: #6b7280; }
.badge-next-prog { grid-column: 2; }
.badge-next-row:active { transform: scale(0.98); }
.badge-case { display: grid; gap: 1.2rem; padding: 1rem 0.8rem 1.2rem; border-radius: 1.5rem; background: #ffffff; box-shadow: 0 10px 25px rgba(15, 60, 55, 0.08); }
.badge-group h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0.3rem 0.6rem; padding-bottom: 0.4rem; border-bottom: 1px solid #f1f5f9; font: 700 0.72rem Georgia, "Times New Roman", serif; letter-spacing: 0.16em; text-transform: uppercase; color: #92702a; }
.badge-group h3 span { margin-left: auto; font-family: inherit; color: #9ca3af; letter-spacing: 0.05em; }
.badge-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem 0.35rem; }
.badge-cell { position: relative; display: grid; justify-items: center; gap: 0.2rem; padding: 0; border: 0; background: transparent; color: #1f2937; text-align: center; min-width: 0; }
.badge-cell .badge-img { width: 100%; max-width: 64px; }
.badge-cell b { font-size: 0.62rem; font-weight: 800; line-height: 1.2; }
.badge-cell.is-locked b { color: #9ca3af; }
.badge-cell.is-locked .badge-img { opacity: 0.75; }
html[data-theme="dark"] .badge-case { background: #1f2937; color: #f3f4f6; box-shadow: none; border: 1px solid #374151; }
html[data-theme="dark"] .badge-next-text em { color: #9ca3af; }
html[data-theme="dark"] .badge-next-row { background: #273244; border-color: #374151; }
html[data-theme="dark"] .badge-next-text b, html[data-theme="dark"] .badge-cell { color: #f3f4f6; }
html[data-theme="dark"] .badge-next-text small { color: #5eead4; }
html[data-theme="dark"] .badge-group h3 { color: #d6b86a; border-color: #374151; }
html[data-theme="dark"] .badge-cell.is-locked b { color: #6b7280; }
.badge-cell:active { transform: scale(0.95); }
.badge-prog { display: block; width: 42px; height: 3px; border-radius: 9px; background: #e5e7eb; overflow: hidden; }
html[data-theme="dark"] .badge-prog { background: #374151; }
.badge-prog.wide { width: 100%; height: 6px; background: #e5e7eb; }
.badge-prog i { display: block; height: 100%; background: linear-gradient(90deg, #d97706, #fbbf24); }
.badge-new { position: absolute; top: -2px; right: 4px; z-index: 1; padding: 1px 5px; border-radius: 9999px; background: #e11d48; color: #ffffff; font-size: 0.55rem; font-weight: 900; }
.badge-unlock { display: grid; justify-items: center; gap: 0.45rem; text-align: center; }
/* Glow is a background behind the image, not a filter on it, so the badge stays sharp. */
.badge-unlock-art { width: 132px; padding: 6px; border-radius: 50%; background: radial-gradient(circle, rgba(251, 191, 36, 0.35), rgba(251, 191, 36, 0) 70%); }
.badge-unlock h4 { margin: 0; font-size: 1.3rem; font-weight: 900; }
.badge-unlock p { margin: 0; font-size: 0.85rem; color: #6b7280; }
.badge-next b { color: #0f766e; }
.badge-tier { font: 700 0.65rem Georgia, 'Times New Roman', serif; letter-spacing: 0.16em; text-transform: uppercase; }
.tier-bronze { color: #b0703a; } .tier-silver { color: #8a95a1; } .tier-gold { color: #c88a10; } .tier-platinum { color: #5f8aa6; } .tier-diamond { color: #8b5cf6; }
.home-badge-btn { position: relative; }
.home-badge-art { width: 23px !important; height: auto; margin: 0 auto; display: block; }
.badge-dot { position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 9999px; background: #e11d48; box-shadow: 0 0 0 2px #ffffff; }
.profile-badges { display: grid; justify-items: center; gap: 0.3rem; margin: 0 0 1rem; }
.profile-badges small { font-size: 0.7rem; font-weight: 800; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.06em; }
.profile-badges div { display: flex; gap: 0.5rem; }
.profile-badges button { width: 54px; padding: 0; border: 0; background: transparent; }

/* Popup close button (✕ beside the title) */
.modal-close { flex-shrink: 0; width: 32px; height: 32px; border: 0; border-radius: 9999px; background: #f1f5f9; color: #475569; font-size: 0.9rem; font-weight: 900; line-height: 1; }
.modal-close:active { transform: scale(0.92); }
html[data-theme="dark"] .modal-close { background: #374151; color: #d1d5db; }

/* Season results popup */
.season-results { display: grid; justify-items: center; gap: 0.45rem; text-align: center; }
.season-kicker { font-size: 0.65rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; color: #0f766e; }
.season-results h4 { margin: 0; font-size: 1.3rem; font-weight: 900; }
.season-results p { margin: 0; font-size: 0.85rem; color: #6b7280; }
.season-res-list { width: 100%; display: grid; gap: 0.35rem; margin-top: 0.35rem; }
.season-res-list div { display: flex; justify-content: space-between; padding: 0.5rem 0.75rem; border-radius: 0.75rem; background: #f1f5f9; font-size: 0.82rem; }
.season-res-list span { font-weight: 700; color: #475569; }
.season-res-list b { font-weight: 900; color: #1f2937; }
html[data-theme="dark"] .season-res-list div { background: #374151; }
html[data-theme="dark"] .season-res-list span { color: #d1d5db; }
html[data-theme="dark"] .season-res-list b { color: #f9fafb; }
html[data-theme="dark"] .season-results p { color: #9ca3af; }
html[data-theme="dark"] .season-kicker { color: #5eead4; }

/* Hint-assisted win note (win modal) */
.assisted-note { display: grid; gap: 0.2rem; margin-bottom: 0.5rem; padding: 0.6rem 0.75rem; border-radius: 0.75rem; background: #fef3c7; border: 1px solid #fde68a; text-align: left; }
.assisted-note b { font-size: 0.85rem; font-weight: 900; color: #92400e; }
.assisted-note span { font-size: 0.75rem; font-weight: 600; line-height: 1.35; color: #78350f; }
html[data-theme="dark"] .assisted-note { background: rgba(180, 83, 9, 0.2); border-color: rgba(245, 158, 11, 0.4); }
html[data-theme="dark"] .assisted-note b, html[data-theme="dark"] .assisted-note span { color: #fcd34d; }
.t-medal-img.is-locked { opacity: 0.38; }

/* Rankings: one season card holding the board title, countdown and difficulty switch */
.season-card { display: grid; gap: 0.6rem; margin-bottom: 0.75rem; padding: 0.75rem; border-radius: 1.1rem; background: linear-gradient(135deg, #0f766e, #14b8a6); color: #ffffff; box-shadow: 0 8px 20px rgba(15, 118, 110, 0.2); }
.season-card.alltime { background: linear-gradient(135deg, #1d2328, #374151); box-shadow: 0 8px 20px rgba(17, 24, 39, 0.2); }
.season-card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.season-card-row b { display: block; font-size: 0.95rem; font-weight: 900; }
.season-card-row small { font-size: 0.7rem; font-weight: 700; opacity: 0.9; }
.season-pill { flex-shrink: 0; padding: 0.25rem 0.6rem; border-radius: 9999px; background: rgba(255, 255, 255, 0.18); font-size: 0.72rem; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.season-chips { display: flex; gap: 0.25rem; padding: 0.2rem; border-radius: 0.8rem; background: rgba(0, 0, 0, 0.16); }
.season-chips button { flex: 1; padding: 0.45rem 0; border: 0; border-radius: 0.6rem; background: transparent; color: rgba(255, 255, 255, 0.85); font-size: 0.8rem; font-weight: 800; }
.season-chips button.is-on { background: #ffffff; color: #0f766e; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.season-card.alltime .season-chips button.is-on { color: #1f2937; }
.season-chips button:active { transform: scale(0.97); }

/* Settings: every row the same height, padding and icon box */
.setting-row { min-height: 3.4rem; padding: 0.55rem 0.85rem; box-shadow: none; }
.setting-row img { width: 1.75rem; height: 1.75rem; }
.setting-ic { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; margin-right: 0.75rem; font-size: 1.35rem; line-height: 1; }
.style-row-swatch { width: 1.2rem; height: 1.2rem; border-radius: 9999px; border: 2px solid #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); flex-shrink: 0; }

/* Settings rows share one neutral surface; colour lives only in icons, toggles and pills. */
.setting-row { background: #f5faf9 !important; border: 1px solid #e2eeeb !important; color: #1f2937 !important; }
.setting-row > span:first-child, .setting-row > span:first-child * { color: #1f2937 !important; }
.setting-row:active { background: #eaf4f2 !important; }
html[data-theme="dark"] .setting-row { background: #263142 !important; border-color: #334155 !important; color: #e5e7eb !important; }
html[data-theme="dark"] .setting-row > span:first-child, html[data-theme="dark"] .setting-row > span:first-child * { color: #e5e7eb !important; }
html[data-theme="dark"] .setting-row:active { background: #2d3a4e !important; }
.badge-next-row.is-standalone { margin-top: 0; padding: 0.75rem 0.9rem; border: 0; border-radius: 1.25rem; background: #ffffff; box-shadow: 0 10px 25px rgba(15, 60, 55, 0.08); }
html[data-theme="dark"] .badge-next-row.is-standalone { background: #1f2937; border: 1px solid #374151; box-shadow: none; }

/* VIP offer: perks in one card, 2-column grid of equal tiles; tap one for its explanation */
.vip-perk-card { display: grid; gap: 0.5rem; padding: 0.65rem; border-radius: 1rem; background: #f5faf9; border: 1px solid #e2eeeb; text-align: left; }
.vip-perk-head { margin: 0; font-size: 0.62rem; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; color: #0f766e; }
.vip-perks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.vip-perk { display: flex; align-items: center; gap: 0.45rem; min-width: 0; min-height: 2.75rem; padding: 0.4rem 0.5rem; border-radius: 0.75rem; border: 1px solid #e2eeeb; background: #ffffff; color: #1f2937; font-size: 0.74rem; font-weight: 800; text-align: left; }
.vip-perk-ic { display: grid; place-items: center; flex-shrink: 0; width: 1.6rem; height: 1.6rem; border-radius: 0.5rem; background: #fef3c7; font-size: 0.85rem; line-height: 1; }
.vip-perk-name { min-width: 0; line-height: 1.15; overflow-wrap: anywhere; }
.vip-perk.is-on { border-color: #f59e0b; background: #fffbeb; color: #92400e; }
.vip-perk:active { transform: scale(0.97); }
.vip-perk-info { margin: 0; min-height: 2.4em; font-size: 0.72rem; font-weight: 600; line-height: 1.4; color: #6b7280; }
.vip-perk-info b { color: #1f2937; }
html[data-theme="dark"] .vip-perk-card { background: #1f2937; border-color: #334155; }
html[data-theme="dark"] .vip-perk-head { color: #5eead4; }
html[data-theme="dark"] .vip-perk { background: #263142; border-color: #334155; color: #e5e7eb; }
html[data-theme="dark"] .vip-perk-ic { background: rgba(245, 158, 11, 0.18); }
html[data-theme="dark"] .vip-perk.is-on { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; color: #fcd34d; }
html[data-theme="dark"] .vip-perk-info { color: #9ca3af; }
html[data-theme="dark"] .vip-perk-info b { color: #f3f4f6; }

/* Board & Celebration popup: cards with a 3-column grid of equal tiles (art on top, name below) */
.style-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.style-tile { position: relative; display: grid; justify-items: center; align-content: center; gap: 0.3rem; min-width: 0; min-height: 4.4rem; padding: 0.5rem 0.3rem; border-radius: 0.75rem; border: 1.5px solid #e2eeeb; background: #ffffff; color: #1f2937; font-size: 0.68rem; font-weight: 800; line-height: 1.15; text-align: center; }
.style-tile-art { width: 1.6rem; height: 1.6rem; }
.style-tile .theme-swatch { border: 2px solid #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); }
.style-tile-icon { display: grid; place-items: center; font-size: 1.2rem; line-height: 1; }
.style-tile-name { min-width: 0; overflow-wrap: anywhere; }
.style-tile .style-chip-lock { position: absolute; top: 0.25rem; right: 0.3rem; font-size: 0.6rem; }
.style-tile.is-active { border-color: #f59e0b; background: #fffbeb; color: #92400e; }
.style-tile:active { transform: scale(0.96); }
html[data-theme="dark"] .style-tile { background: #263142; border-color: #334155; color: #e5e7eb; }
html[data-theme="dark"] .style-tile .theme-swatch { border-color: #263142; }
html[data-theme="dark"] .style-tile.is-active { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; color: #fcd34d; }

/* =================================================================
   14. VIP THEME WASH ON OTHER SCREENS (html[data-board-theme]:not(.in-game))
   The theme tints the page background, header, selected tabs, Home shortcuts and the season
   card. Cards, text and the Daily / Tournaments cards keep their normal colours.
   --w-page background · --w-accent / --w-accent2 accent · --w-soft / --w-ink selected tab fill + text
   ================================================================= */
html[data-board-theme="ocean"]    { --w-page: linear-gradient(180deg, #d6e6ff 0%, #eff6ff 38%); --w-accent: #1d4ed8; --w-accent2: #3b82f6; --w-soft: #dbeafe; --w-ink: #1e3a8a; }
html[data-board-theme="sakura"]   { --w-page: linear-gradient(180deg, #ffd9ea 0%, #fff1f6 38%); --w-accent: #be185d; --w-accent2: #ec4899; --w-soft: #fce7f3; --w-ink: #9d174d; }
html[data-board-theme="forest"]   { --w-page: linear-gradient(180deg, #d3f8df 0%, #f0fdf4 38%); --w-accent: #15803d; --w-accent2: #22c55e; --w-soft: #dcfce7; --w-ink: #14532d; }
html[data-board-theme="midnight"] { --w-page: linear-gradient(180deg, #fdeec2 0%, #fffbeb 38%); --w-accent: #b45309; --w-accent2: #f59e0b; --w-soft: #fef3c7; --w-ink: #92400e; }
html[data-board-theme="peach"]    { --w-page: linear-gradient(180deg, #ffe0cc 0%, #fff1e6 38%); --w-accent: #e1543d; --w-accent2: #fb7185; --w-soft: #ffe4dc; --w-ink: #9a3412; }
html[data-board-theme="candy"]    { --w-page: linear-gradient(180deg, #f6dcff 0%, #fdf2f8 38%); --w-accent: #9333ea; --w-accent2: #ec4899; --w-soft: #f3e8ff; --w-ink: #6b21a8; }
html[data-board-theme="golden"]   { --w-page: linear-gradient(180deg, #ffe8b8 0%, #fefce8 38%); --w-accent: #c2410c; --w-accent2: #f59e0b; --w-soft: #ffedd5; --w-ink: #9a3412; }
html[data-board-theme="lemon"]    { --w-page: linear-gradient(180deg, #fdf6b3 0%, #fffef3 38%); --w-accent: #a16207; --w-accent2: #eab308; --w-soft: #fef9c3; --w-ink: #854d0e; }
html[data-theme="dark"][data-board-theme="ocean"]    { --w-page: linear-gradient(180deg, #0b1730 0%, #0b1222 38%); --w-accent: #3b82f6; --w-accent2: #1d4ed8; --w-soft: #1e3a8a; --w-ink: #bfdbfe; --w-text: #60a5fa; }
html[data-theme="dark"][data-board-theme="sakura"]   { --w-page: linear-gradient(180deg, #2a0f1e 0%, #1a0d14 38%); --w-accent: #ec4899; --w-accent2: #be185d; --w-soft: #831843; --w-ink: #fbcfe8; --w-text: #f472b6; }
html[data-theme="dark"][data-board-theme="forest"]   { --w-page: linear-gradient(180deg, #0f2416 0%, #0b150e 38%); --w-accent: #22c55e; --w-accent2: #15803d; --w-soft: #14532d; --w-ink: #bbf7d0; --w-text: #4ade80; }
html[data-theme="dark"][data-board-theme="midnight"] { --w-page: linear-gradient(180deg, #1c1609 0%, #0c0c0e 38%); --w-accent: #f59e0b; --w-accent2: #b45309; --w-soft: #3f2d07; --w-ink: #fcd34d; --w-text: #fbbf24; }
html[data-theme="dark"][data-board-theme="peach"]    { --w-page: linear-gradient(180deg, #26150f 0%, #1a1210 38%); --w-accent: #fb7185; --w-accent2: #e1543d; --w-soft: #4a2318; --w-ink: #fed7c3; --w-text: #fda4af; }
html[data-theme="dark"][data-board-theme="candy"]    { --w-page: linear-gradient(180deg, #211331 0%, #171223 38%); --w-accent: #c084fc; --w-accent2: #9333ea; --w-soft: #3b1d5c; --w-ink: #e9d5ff; --w-text: #d8b4fe; }
html[data-theme="dark"][data-board-theme="golden"]   { --w-page: linear-gradient(180deg, #25170a 0%, #18130a 38%); --w-accent: #f59e0b; --w-accent2: #c2410c; --w-soft: #4a2a0c; --w-ink: #fed7aa; --w-text: #fbbf24; }
html[data-theme="dark"][data-board-theme="lemon"]    { --w-page: linear-gradient(180deg, #211f08 0%, #15140a 38%); --w-accent: #eab308; --w-accent2: #a16207; --w-soft: #3f3a0a; --w-ink: #fef08a; --w-text: #facc15; }

html[data-board-theme]:not(.in-game) body { background: var(--w-page); }
html[data-board-theme]:not(.in-game) .app-title { background-image: none; -webkit-text-fill-color: var(--w-text, var(--w-accent)); color: var(--w-text, var(--w-accent)); }
html[data-board-theme]:not(.in-game) #user-profile-badge { border-color: var(--w-soft); }
html[data-board-theme]:not(.in-game) #header-username:not(.vip-name) { color: var(--w-text, var(--w-accent)); }
/* Screen titles, Back / Home links and accent numbers that use the app teal */
html[data-board-theme]:not(.in-game) #content .text-teal-600,
html[data-board-theme]:not(.in-game) #content .text-teal-700 { color: var(--w-text, var(--w-accent)); }
/* Home shortcut tiles */
html[data-board-theme]:not(.in-game) .home-icon-btn.bg-teal-100 { background: var(--w-soft); color: var(--w-ink); }
/* Selected tabs */
html[data-board-theme]:not(.in-game) .rank-tab.is-on,
html[data-board-theme]:not(.in-game) .stat-tabs button.is-on { background: var(--w-soft); color: var(--w-ink); }
/* Rankings season card (All Time keeps its charcoal) */
html[data-board-theme]:not(.in-game) .season-card:not(.alltime) { background: linear-gradient(135deg, var(--w-accent), var(--w-accent2)); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12); }
html[data-board-theme]:not(.in-game) .season-card:not(.alltime) .season-chips button.is-on { color: var(--w-accent); }

/* Stats tiles: one surface for every tile (colour only in the icons); numbers use the accent,
   which follows the VIP theme on themed screens. Overrides the per-tone colours above. */
.stat-tile[class*="tone-"] { --tile-bg: #ffffff; --tile-text: #0f766e; border: 1px solid #e2eeeb; box-shadow: 0 4px 12px rgba(15, 60, 55, 0.05); }
.stat-tile .stat-ic { background: #f5faf9; }
html[data-theme="dark"] .stat-tile[class*="tone-"] { --tile-bg: #1f2937; --tile-text: #5eead4; border-color: #334155; box-shadow: none; }
html[data-theme="dark"] .stat-tile .stat-ic { background: #263142; }
html[data-board-theme]:not(.in-game) .stat-tile[class*="tone-"] { --tile-text: var(--w-text, var(--w-accent)); }
