/* ═══════════════════════════════════════════════════════
   TONChess — Premium Dark Theme
   Mobile-first, Telegram Mini App optimized
   Inspired by Chess.com + crypto luxury aesthetics
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* Colors — Deep Space Dark */
    --bg-primary: #08080e;
    --bg-secondary: #0e0e18;
    --bg-card: rgba(18, 18, 35, 0.85);
    --bg-card-solid: #121223;
    --bg-card-hover: rgba(30, 30, 55, 0.9);
    --bg-elevated: #1a1a35;
    --bg-input: rgba(255, 255, 255, 0.04);

    --text-primary: #eaeaf0;
    --text-secondary: #7c7ca0;
    --text-muted: #4a4a6a;
    --text-bright: #ffffff;

    /* Accent — Electric Violet */
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-dark: #6d28d9;
    --accent-glow: rgba(139, 92, 246, 0.35);
    --accent-bg: rgba(139, 92, 246, 0.12);

    /* Semantic */
    --green: #22c55e;
    --green-light: #4ade80;
    --green-glow: rgba(34, 197, 94, 0.2);
    --green-bg: rgba(34, 197, 94, 0.1);
    --red: #ef4444;
    --red-light: #f87171;
    --red-glow: rgba(239, 68, 68, 0.2);
    --gold: #f59e0b;
    --gold-light: #fbbf24;
    --gold-glow: rgba(245, 158, 11, 0.2);
    --blue: #3b82f6;
    --cyan: #06b6d4;

    /* Board */
    --board-light: #e8dcc8;
    --board-dark: #b58863;
    --board-highlight: rgba(255, 255, 100, 0.42);
    --board-move-from: rgba(139, 92, 246, 0.42);
    --board-move-to: rgba(139, 92, 246, 0.42);
    --board-check: rgba(239, 68, 68, 0.55);

    /* Glass */
    --glass-bg: rgba(14, 14, 24, 0.75);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-blur: 16px;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Radius */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-2xl: 24px;
    --r-full: 50%;

    /* Font */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Safe areas */
    --safe-top: var(--tg-content-safe-area-inset-top, var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)));
    --safe-bottom: var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));

    /* Aliases for legacy/roadmap components */
    --rad-lg: 16px;
    --rad-md: 12px;
    --rad-sm: 8px;
    --border-light: rgba(255, 255, 255, 0.08);
    --text-main: #eaeaf0;
    --primary-main: #8b5cf6;
    --primary-light: #a78bfa;
}

/* ─── Reset ──────────────────────────────────────────── */

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

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    user-select: none;
    -webkit-user-select: none;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ─── Screens ────────────────────────────────────────── */

.screen {
    display: none;
    padding: var(--sp-3);
    padding-top: calc(var(--safe-top) + 70px);
    padding-bottom: calc(var(--safe-bottom) + 68px);
    position: relative;
    z-index: 1;
}

.screen.active {
    display: block;
    animation: screenIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ─── Game Screen Components ───────────────────────────── */

.board-container {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-card);
    margin: 0;
    position: relative;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.4), inset 0 0 10px rgba(139, 92, 246, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.5);
    overflow: hidden;
}

/* ─── Loading Screen ─────────────────────────────────── */

#loading-screen {
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

#loading-screen::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation: loadPulse 3s ease-in-out infinite;
}

@keyframes loadPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

.loading-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.logo-container {
    margin-bottom: var(--sp-8);
}

.logo-piece {
    font-size: 80px;
    animation: logoFloat 2.5s ease-in-out infinite;
    filter: drop-shadow(0 0 30px var(--accent-glow));
    line-height: 1;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(-2deg); }
    75% { transform: translateY(-6px) rotate(2deg); }
}

.logo-text {
    font-size: 36px;
    font-weight: 900;
    color: var(--text-bright);
    margin-top: var(--sp-3);
    letter-spacing: -1px;
}

.logo-text span {
    background: linear-gradient(135deg, var(--accent-light), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-bar {
    width: 180px;
    height: 3px;
    background: var(--bg-elevated);
    border-radius: 2px;
    margin: var(--sp-6) auto;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    border-radius: 2px;
    animation: loadBar 1.8s ease-in-out forwards;
}

@keyframes loadBar {
    0% { width: 0%; }
    40% { width: 55%; }
    100% { width: 100%; }
}

.loading-text {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ─── User Header ────────────────────────────────────── */

.user-header {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-xl);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-3);
    position: relative;
    overflow: hidden;
}

/* Subtle shine effect */
.user-header::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 200%; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.4), transparent);
    animation: headerShine 4s ease-in-out infinite;
}

@keyframes headerShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 2px 12px var(--accent-glow);
    flex-shrink: 0;
}

.user-details h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.2;
}

.user-stats {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: 2px;
}

.rating-badge {
    background: var(--accent-bg);
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-light);
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.rank-badge {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Inline Stats Row ───────────────────────────────── */

.inline-stats {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--r-sm);
    padding: 4px var(--sp-3);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.is-item {
    display: flex;
    align-items: center;
    gap: 2px;
}

.is-val {
    font-weight: 800;
    color: var(--text-bright);
}

.is-val.win { color: var(--green-light); }
.is-val.loss { color: var(--red-light); }
.is-val.draw { color: var(--text-muted); }

.is-divider {
    width: 1px;
    height: 12px;
    background: rgba(255, 255, 255, 0.08);
}

/* ─── Sections ───────────────────────────────────────── */

.section {
    margin-bottom: var(--sp-3);
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: var(--sp-2);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ─── Play Buttons — Hero Cards ─────────────────────── */

.play-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}

.play-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: var(--sp-3) var(--sp-3);
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font);
    position: relative;
    overflow: hidden;
}

.play-btn.primary {
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    color: white;
    box-shadow: 0 6px 24px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}

.play-btn.primary::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.08), transparent);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    pointer-events: none;
}

.play-btn.secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
}

.play-btn:active {
    transform: scale(0.95);
}

.play-icon { font-size: 22px; line-height: 1; }

.play-label {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.play-desc {
    font-size: 11px;
    opacity: 0.6;
    font-weight: 500;
}

/* ─── Stake Modal ────────────────────────────────────── */

.stake-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.stake-modal-content {
    background: var(--bg-secondary);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding: var(--sp-6) var(--sp-5);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 1px solid var(--glass-border);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.stake-modal-content h3 {
    text-align: center;
    margin-bottom: var(--sp-4);
    font-size: 18px;
    font-weight: 800;
    color: var(--text-bright);
}

.stake-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.stake-btn {
    padding: var(--sp-3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--r-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stake-btn.active {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent-light);
    box-shadow: 0 0 16px var(--accent-glow);
}

.stake-btn:active { transform: scale(0.95); }

.stake-currency-toggle {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-5);
}

.currency-btn {
    flex: 1;
    padding: var(--sp-3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--r-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.currency-btn.active {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent-light);
}

.btn-find-match {
    width: 100%;
    padding: var(--sp-4);
    border: none;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    margin-bottom: var(--sp-2);
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: all 0.2s ease;
}

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

.btn-cancel-stake {
    width: 100%;
    padding: var(--sp-3);
    border: none;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
}

/* ─── Lobby List ─────────────────────────────────────── */

.lobby-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-height: 200px;
    overflow-y: auto;
}

.lobby-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lobby-item:active { transform: scale(0.98); background: var(--bg-card-hover); }

.lobby-creator { display: flex; align-items: center; gap: var(--sp-2); }
.lobby-creator-name { font-weight: 600; font-size: 14px; }
.lobby-creator-rating { font-size: 12px; color: var(--accent-light); font-family: var(--font-mono); }
.lobby-details { text-align: right; }
.lobby-tc { font-size: 13px; color: var(--text-secondary); }
.lobby-stake { font-size: 14px; font-weight: 700; color: var(--gold-light); }

.lobby-empty {
    text-align: center;
    color: var(--text-muted);
    padding: var(--sp-5);
    font-size: 13px;
    font-weight: 500;
}

.btn-create-lobby {
    width: 100%;
    padding: var(--sp-3);
    margin-top: var(--sp-2);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-create-lobby:active {
    border-color: var(--accent);
    color: var(--accent-light);
}

/* ─── Bot Buttons ────────────────────────────────────── */

.bot-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
}

.bot-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--sp-4) var(--sp-2);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.bot-btn:active {
    transform: scale(0.95);
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.12);
}

.bot-emoji { font-size: 28px; line-height: 1; }

/* ─── Bottom Navigation ──────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-around;
    background: rgba(8, 8, 14, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: var(--sp-2) 0;
    padding-bottom: calc(var(--safe-bottom) + var(--sp-2));
    z-index: 50;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 16px;
    transition: color 0.2s ease;
    position: relative;
}

.nav-btn.active {
    color: var(--accent-light);
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%; transform: translateX(-50%);
    width: 20px; height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { letter-spacing: 0.3px; }

/* ─── Searching Screen ───────────────────────────────── */

#searching-screen {
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
}

.chess-piece-spin {
    font-size: 60px;
    animation: spin3d 2.5s ease-in-out infinite;
    filter: drop-shadow(0 0 24px var(--accent-glow));
}

@keyframes spin3d {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.08); }
    100% { transform: rotateY(360deg) scale(1); }
}

.searching-content h2 {
    margin-top: var(--sp-5);
    font-size: 20px;
    font-weight: 800;
    color: var(--text-bright);
}

.searching-content p {
    color: var(--text-secondary);
    margin-top: var(--sp-2);
    font-size: 14px;
    font-weight: 500;
}

.search-range {
    color: var(--text-muted) !important;
    font-size: 12px !important;
}

.search-timer {
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-light);
    margin-top: var(--sp-5);
    font-family: var(--font-mono);
}

.btn-cancel-search {
    margin-top: var(--sp-6);
    padding: var(--sp-3) var(--sp-8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* ─── Game Screen ────────────────────────────────────── */

#game-screen {
    padding: var(--sp-2) var(--sp-2);
    padding-top: calc(var(--safe-top) + var(--sp-2));
    padding-bottom: calc(var(--safe-bottom) + var(--sp-2));
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    justify-content: center;
    gap: 3px;
    position: relative;
}

/* Back button in game */
.game-back-btn {
    position: absolute;
    top: calc(var(--safe-top) + 8px);
    left: 8px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.game-back-btn:active {
    background: rgba(239, 68, 68, 0.3);
    color: var(--red-light);
    transform: scale(0.9);
}

.player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--glass-border);
}

.player-info {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.player-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-bright);
}

.player-rating-small {
    font-size: 11px;
    color: var(--accent-light);
    background: var(--accent-bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: 700;
}

/* game-clock styles are in the Enhanced section below */


/* ─── Chess Board ────────────────────────────────────── */

/* board-container and captured-pieces styles are in the Enhanced section below */


/* ─── Game Stake Info ────────────────────────────────── */

.game-stake-info {
    display: flex;
    justify-content: center;
    gap: var(--sp-5);
    padding: var(--sp-2);
    background: var(--gold-glow);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--gold-light);
    font-weight: 600;
}

.stake-win { color: var(--green-light); }

/* ─── Game Controls ──────────────────────────────────── */

.game-controls {
    display: flex;
    justify-content: center;
    gap: var(--sp-3);
    padding: 2px 0;
}

.game-btn {
    padding: 6px 18px;
    border: 1px solid var(--glass-border);
    border-radius: var(--r-sm);
    background: var(--bg-card);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-btn:active {
    transform: scale(0.95);
    background: var(--bg-card-hover);
}

/* move-list styles are in the Enhanced section below */


/* ─── Modals ─────────────────────────────────────────── */

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--r-2xl);
    padding: var(--sp-8) var(--sp-6);
    width: 90%;
    max-width: 340px;
    text-align: center;
    border: 1px solid var(--glass-border);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.game-over-content {
    animation: modalPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.game-result-icon {
    font-size: 52px;
    margin-bottom: var(--sp-2);
    line-height: 1;
}

.game-over-content h2 {
    font-size: 26px;
    font-weight: 900;
    color: var(--text-bright);
    margin-bottom: 2px;
}

#result-reason {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: var(--sp-4);
}

.rating-change {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    font-size: 16px;
    margin-bottom: var(--sp-4);
    font-weight: 600;
}

.rating-delta {
    font-weight: 900;
    font-size: 20px;
    font-family: var(--font-mono);
}

.rating-delta.positive { color: var(--green-light); }
.rating-delta.negative { color: var(--red-light); }

.payout-info { margin-bottom: var(--sp-4); }

.payout-amount {
    font-size: 30px;
    font-weight: 900;
    color: var(--gold-light);
    text-shadow: 0 0 24px var(--gold-glow);
    font-family: var(--font-mono);
}

.game-over-actions {
    display: flex;
    gap: var(--sp-2);
}

.btn-rematch, .btn-back-menu, .btn-view-board {
    flex: 1;
    padding: var(--sp-3);
    border: none;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-view-board {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-rematch {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-back-menu {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.modal-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
}

.btn-accept-draw, .btn-decline-draw {
    flex: 1;
    padding: var(--sp-3);
    border: none;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn-accept-draw { background: var(--green); color: white; }
.btn-decline-draw { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--glass-border); }

/* ─── Leaderboard ────────────────────────────────────── */

.screen-header { margin-bottom: var(--sp-4); }

.screen-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-bright);
    margin-bottom: var(--sp-3);
}

.tab-bar {
    display: flex;
    gap: var(--sp-2);
    background: var(--bg-input);
    border-radius: var(--r-md);
    padding: 3px;
}

.tab-btn {
    flex: 1;
    padding: var(--sp-2);
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--accent-bg);
    color: var(--accent-light);
    box-shadow: 0 1px 8px var(--accent-glow);
}

.leaderboard-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.lb-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--glass-border);
    transition: all 0.2s ease;
}

.lb-rank {
    font-size: 16px;
    font-weight: 900;
    min-width: 28px;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.lb-rank.gold { color: var(--gold-light); }
.lb-rank.silver { color: #d1d5db; }
.lb-rank.bronze { color: #d97706; }

.lb-info { flex: 1; }
.lb-name { font-weight: 700; font-size: 14px; color: var(--text-bright); }
.lb-stats { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 1px; }

.lb-value {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-light);
    font-family: var(--font-mono);
}

/* ─── History ────────────────────────────────────────── */

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--glass-border);
}

.history-result { font-size: 22px; min-width: 28px; }
.history-info { flex: 1; margin-left: var(--sp-2); }
.history-opponent { font-weight: 700; font-size: 14px; color: var(--text-bright); }
.history-details { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 1px; }

.history-rating-change {
    font-size: 15px;
    font-weight: 800;
    font-family: var(--font-mono);
}

.history-rating-change.win { color: var(--green-light); }
.history-rating-change.loss { color: var(--red-light); }
.history-rating-change.draw { color: var(--text-muted); }

/* ─── Wallet ─────────────────────────────────────────── */

.wallet-balances {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.wallet-card {
    padding: var(--sp-5);
    border-radius: var(--r-xl);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
}

.wallet-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 120px; height: 120px;
    border-radius: 50%;
    opacity: 0.08;
    pointer-events: none;
}

.ton-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
}
.ton-card::before { background: var(--blue); }

.usdt-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(6, 182, 212, 0.06));
}
.usdt-card::before { background: var(--green); }

.wallet-card-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}

.wallet-icon { font-size: 20px; }

.wallet-currency {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wallet-amount {
    font-size: 32px;
    font-weight: 900;
    color: var(--text-bright);
    font-family: var(--font-mono);
    letter-spacing: -1px;
}

.wallet-profit {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--sp-1);
    font-weight: 500;
}

.wallet-actions {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.wallet-btn {
    flex: 1;
    padding: var(--sp-4);
    border: none;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.deposit-btn {
    background: linear-gradient(135deg, var(--green), #15803d);
    color: white;
    box-shadow: 0 4px 16px var(--green-glow);
}

.withdraw-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

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

.wallet-notice {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}
.wallet-notice p { margin-bottom: 3px; }

/* ─── Toast Notifications ────────────────────────────── */

.toast-container {
    position: fixed;
    top: calc(var(--safe-top) + var(--sp-4));
    left: var(--sp-4); right: var(--sp-4);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    pointer-events: auto;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
}

.toast.success { background: rgba(34, 197, 94, 0.9); color: white; }
.toast.error { background: rgba(239, 68, 68, 0.9); color: white; }
.toast.info { background: rgba(139, 92, 246, 0.9); color: white; }

@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-8px); }
}

/* ─── Scrollbar ──────────────────────────────────────── */

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ─── Confetti Canvas (Game Over Win) ────────────────── */

#confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 250;
}

/* ─── Enhanced Game Over ────────────────────────────── */

.game-over-content.win-result {
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow:
        0 16px 64px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(245, 158, 11, 0.1);
}

.game-over-content.loss-result {
    animation: modalShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes modalShake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-3px); }
    30%, 70% { transform: translateX(3px); }
}

.rating-counter {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-bright);
    font-family: var(--font-mono);
    letter-spacing: -1px;
    transition: all 0.3s ease;
}

/* ─── Captured Pieces (Enhanced) ─────────────────────── */

.captured-pieces {
    min-height: 20px;
    font-size: 14px;
    padding: 1px var(--sp-2);
    display: flex;
    align-items: center;
    gap: 0px;
    color: var(--text-muted);
    letter-spacing: -2px;
    opacity: 0.85;
}

.captured-pieces .material-adv {
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0;
    margin-left: var(--sp-1);
    color: var(--text-secondary);
}

/* ─── Board Container Enhancement ────────────────────── */

.board-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1;
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.06),
        inset 0 0 0 1px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Board glow on hover/active */
.board-container::after {
    content: '';
    position: absolute;
    top: -1px; left: -1px; right: -1px; bottom: -1px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    transition: border-color 0.3s ease;
    pointer-events: none;
}

/* ─── Button Micro-interactions ──────────────────────── */

.play-btn, .bot-btn, .stake-btn, .wallet-btn, .game-btn,
.btn-rematch, .btn-back-menu, .btn-find-match {
    position: relative;
    overflow: hidden;
}

/* Ripple effect */
.play-btn::before, .bot-btn::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    pointer-events: none;
}

.play-btn:active::before, .bot-btn:active::before {
    width: 200%; height: 200%;
}

/* ─── Move List Enhanced ────────────────────────────── */

.move-list {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 3px var(--sp-2);
    max-height: 56px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    font-family: var(--font-mono);
    background: rgba(0,0,0,0.15);
    border-radius: var(--r-sm);
}

.move-item {
    background: rgba(255,255,255,0.04);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
}

.move-item:last-child {
    background: var(--accent-bg);
    color: var(--accent-light);
}

.move-number {
    color: var(--text-muted);
    margin-right: 2px;
    font-size: 9px;
}

/* ─── Game Clock Enhanced ───────────────────────────── */

.game-clock {
    font-size: 22px;
    font-weight: 900;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: var(--r-sm);
    min-width: 78px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    letter-spacing: -0.5px;
}

.game-clock.active {
    color: var(--text-bright);
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 20px var(--accent-glow);
}

.game-clock.low-time {
    color: var(--red-light);
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    animation: clockPulse 0.5s ease-in-out infinite;
    box-shadow: 0 0 20px var(--red-glow);
}

/* ─── Player Bar Enhanced ────────────────────────────── */

.player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
}

.player-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-bright);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Smooth Screen Transitions ─────────────────────── */

.screen.active {
    display: block;
    animation: screenFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Game screen specific (flex, not block) */
#game-screen.active {
    display: flex;
}

#searching-screen.active {
    display: flex;
}

#loading-screen.active {
    display: flex;
}

/* ─── Canvas Base ────────────────────────────────────── */

#chess-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ─── Turn Indicator ─────────────────────────────────── */

.turn-indicator {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 0;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.turn-indicator.your-turn {
    color: var(--green-light);
    animation: turnPulse 1.5s ease-in-out infinite;
}

.turn-indicator.opponent-turn {
    color: var(--text-muted);
}

@keyframes turnPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── Stats Card (Menu) ──────────────────────────────── */

.stats-card {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-2);
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    padding: var(--sp-3) var(--sp-2);
    margin-bottom: var(--sp-4);
    backdrop-filter: blur(var(--glass-blur));
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 900;
    color: var(--text-bright);
    font-family: var(--font-mono);
    line-height: 1;
}

.stat-value.win { color: var(--green-light); }
.stat-value.loss { color: var(--red-light); }
.stat-value.draw { color: var(--text-muted); }

.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ─── Quick Play Button ──────────────────────────────── */

.quick-play-btn {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    border: none;
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, #8b5cf6, #6d28d9, #4c1d95);
    color: white;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 0 #4c1d95, 0 15px 25px var(--accent-glow);
    margin-bottom: var(--sp-3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.quick-play-btn:active {
    transform: translateY(8px);
    box-shadow: 0 0px 0 #4c1d95, 0 5px 10px var(--accent-glow);
}

.quick-play-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 200%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    animation: btnShine 3s ease-in-out infinite;
}

@keyframes btnShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.quick-play-sub {
    display: block;
    font-size: 11px;
    font-weight: 500;
    opacity: 0.7;
    margin-top: 2px;
    letter-spacing: 0;
    text-transform: none;
}

/* ─── Menu Animated Background ───────────────────────── */

#menu-screen {
    position: relative;
}

#menu-screen::before {
    content: '';
    position: absolute;
    top: -200px; right: -200px;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.06) 0%, transparent 70%);
    animation: menuOrb1 8s ease-in-out infinite;
    pointer-events: none;
}

#menu-screen::after {
    content: '';
    position: absolute;
    bottom: -150px; left: -150px;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.05) 0%, transparent 70%);
    animation: menuOrb2 10s ease-in-out infinite;
    pointer-events: none;
}

@keyframes menuOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-30px, 20px) scale(1.05); }
    66% { transform: translate(20px, -15px) scale(0.95); }
}

@keyframes menuOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(25px, -20px) scale(1.1); }
}

/* ─── Searching Tips ────────────────────────────────── */

.search-tips {
    margin-top: var(--sp-5);
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    max-width: 250px;
    text-align: center;
    animation: tipFade 4s ease-in-out infinite;
}

@keyframes tipFade {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ─── Clock Pulse (fixed position) ───────────────────── */

@keyframes clockPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ─── Modals & Bottom Sheets (Roadmap 2.0) ───────────────── */

.modal-overlay, .sheet-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sheet-overlay {
    align-items: flex-end;
}

.promotion-dialog {
    background: var(--bg-card);
    padding: var(--sp-4);
    border-radius: var(--rad-lg);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid var(--border-light);
}

.promotion-dialog h3 {
    margin-top: 0;
    margin-bottom: var(--sp-3);
    font-size: 16px;
    font-weight: 600;
}

.promotion-pieces {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
}

.promotion-pieces button {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: var(--sp-3);
    font-size: 16px;
    font-weight: 500;
    border-radius: var(--rad-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.promotion-pieces button:active {
    transform: scale(0.95);
    background: var(--primary-main);
    border-color: var(--primary-light);
}

/* Bottom Sheet */

.bottom-sheet {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: var(--rad-lg) var(--rad-lg) 0 0;
    padding: var(--sp-4);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 1px solid var(--border-light);
}

.sheet-overlay.open .bottom-sheet {
    transform: translateY(0);
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
}

.sheet-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-sheet-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.lobby-controls {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.lobby-controls select {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    padding: var(--sp-3);
    border-radius: var(--rad-md);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

/* Chat */
.chat-trigger-btn {
    position: absolute;
    bottom: -30px;
    right: 10px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 20;
    cursor: pointer;
}

.chat-menu {
    position: absolute;
    bottom: 20px;
    right: 10px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 21;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.chat-emoji-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}
.chat-emoji-btn:active {
    transform: scale(0.9);
}

.chat-emoji-anim {
    position: absolute;
    font-size: 48px;
    z-index: 100;
    pointer-events: none;
    animation: floatUp 2s ease-out forwards;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    80% { transform: translateY(-80px) scale(1); opacity: 1; }
    100% { transform: translateY(-100px) scale(0.8); opacity: 0; }
}

/* ─── P2E Redesign Elements ──────────────────────────── */

/* Live Payout Ticker */
.payout-ticker {
    width: calc(100% + 32px);
    margin-left: -16px;
    margin-top: -16px;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    padding: 6px 0;
    margin-bottom: var(--sp-4);
    display: flex;
}

.payout-ticker-content {
    display: flex;
    white-space: nowrap;
    animation: ticker 20s linear infinite;
}

.ticker-item {
    font-size: 11px;
    font-weight: 600;
    color: var(--green-light);
    margin-right: 30px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

@keyframes ticker {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Sticky Wallet Header */
.p2e-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-5);
    backdrop-filter: blur(16px);
}

.user-profile-compact {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.user-info-small {
    display: flex;
    flex-direction: column;
}

.p2e-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.1;
}

.p2e-badges {
    display: flex;
    gap: 6px;
    font-size: 10px;
    color: var(--text-secondary);
}

.p2e-rating {
    color: var(--accent-light);
    font-weight: 700;
}

.wallet-compact {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.wallet-balance {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 800;
    color: var(--gold-light);
}

.btn-deposit-small {
    background: linear-gradient(135deg, var(--green), var(--green-light));
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 10px var(--green-glow);
    animation: pulseDeposit 2s infinite;
}

@keyframes pulseDeposit {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: var(--sp-5);
}

.hero-title {
    font-size: 32px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -1px;
    margin-bottom: var(--sp-2);
}

.hero-title .highlight {
    background: linear-gradient(135deg, var(--gold-light), #fef08a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Stake Cards */
.stake-cards-container {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
    overflow-x: auto;
    padding-top: 16px;
    padding-bottom: 10px;
    scrollbar-width: none;
}
.stake-cards-container::-webkit-scrollbar { display: none; }

.stake-card {
    min-width: 140px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-xl);
    padding: var(--sp-4);
    text-align: center;
    position: relative;
    flex: 1;
}

.stake-card.featured {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.1), var(--bg-card));
    transform: scale(1.05);
    z-index: 2;
    margin: 0 5px;
}

.stake-card.whale {
    border-color: var(--gold);
}

.stake-card-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    white-space: nowrap;
}

.stake-card-header {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: var(--sp-1);
}

.stake-card-pot {
    font-size: 16px;
    font-weight: 900;
    color: var(--gold-light);
    margin-bottom: var(--sp-2);
}

.stake-card-fee {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: var(--sp-4);
}

.btn-stake-play {
    width: 100%;
    padding: 8px 0;
    border-radius: var(--r-md);
    border: none;
    font-weight: 700;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
}

.btn-stake-play.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-stake-play.gold {
    background: linear-gradient(135deg, var(--gold), #ca8a04);
    box-shadow: 0 4px 12px var(--gold-glow);
}

.action-buttons-row {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

/* ─── Action Button (shared) ─────────────────────────── */

.action-btn {
    padding: var(--sp-3) var(--sp-4);
    border: none;
    border-radius: var(--r-md);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    border: none;
    box-shadow: 0 4px 16px var(--accent-glow);
}

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

/* Back button (referrals / other screens) */
.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    transition: color 0.2s;
}
.btn-back:active { color: var(--accent-light); }

/* Daily Quests */
.quest-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quest-info {
    flex: 1;
}

.quest-title {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 2px;
}

.quest-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.quest-desc .highlight {
    color: var(--gold-light);
    font-weight: 700;
}

.quest-action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    width: 80px;
}

.quest-progress {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.quest-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

.quest-status {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.btn-claim-quest {
    background: linear-gradient(135deg, var(--gold), #ca8a04);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
}

.btn-claim-quest:disabled {
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* ─── Desktop Responsive ────────────────────────────────── */
@media (min-width: 768px) {
    /* Menu constraints */
    #menu-screen {
        max-width: 600px;
        margin: 0 auto;
        border-left: 1px solid var(--border-light);
        border-right: 1px solid var(--border-light);
        min-height: 100vh;
        background: var(--bg-secondary);
        box-shadow: 0 0 50px rgba(139, 92, 246, 0.05);
    }
    
    #referrals-screen, #leaderboard-screen, #searching-screen, #admin-screen {
        max-width: 600px;
        margin: 0 auto;
        border-left: 1px solid var(--border-light);
        border-right: 1px solid var(--border-light);
        min-height: 100vh;
        background: var(--bg-secondary);
    }

    /* Desktop Game Layout */
    #game-screen {
        padding: var(--sp-6);
        max-width: 1200px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .desktop-layout {
        display: grid;
        grid-template-columns: min(70vh, 700px) 350px;
        gap: var(--sp-6);
        width: 100%;
        max-width: 1100px;
    }

    .board-column {
        display: flex;
        flex-direction: column;
        gap: var(--sp-4);
        justify-content: center;
    }

    .sidebar-column {
        background: var(--bg-card);
        border: 1px solid var(--border-light);
        border-radius: var(--r-xl);
        padding: var(--sp-5);
        display: flex;
        flex-direction: column;
        gap: var(--sp-3);
        box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    }

    .board-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    /* Reset absolute position of chat elements for grid layout */
    .chat-trigger-btn {
        position: relative;
        width: 100%;
        bottom: auto;
        right: auto;
        margin-top: auto;
        border-radius: var(--r-md);
        height: 48px;
    }

    .chat-menu {
        position: relative;
        bottom: auto;
        right: auto;
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        margin-bottom: var(--sp-2);
        padding: var(--sp-3);
    }

    .game-back-btn {
        position: relative;
        top: auto;
        left: auto;
        margin-bottom: var(--sp-2);
        align-self: flex-start;
    }

    .player-bar {
        background: rgba(255,255,255,0.02);
        border-radius: var(--r-md);
        padding: var(--sp-3);
    }
    
    .game-clock {
        font-size: 28px;
        padding: 8px 16px;
    }
}
