/* ============================================================
   Trading Fight — Main Stylesheet
   Estilo futurista crypto: verde, rojo, negro
   ============================================================ */

/* ============================================================
   CSS VARIABLES (Design Tokens)
   ============================================================ */
:root {
    /* Primary Colors */
    --color-bg:            #0a0e17;
    --color-bg-secondary:  #111827;
    --color-bg-card:       #1a1f2e;
    --color-bg-card-hover: #222840;
    --color-bg-modal:      #151a28;

    /* Accent Colors */
    --color-green:         #00ff88;
    --color-green-dim:     #00cc6a;
    --color-green-glow:    rgba(0, 255, 136, 0.3);
    --color-red:           #ff3366;
    --color-red-dim:       #cc2952;
    --color-red-glow:      rgba(255, 51, 102, 0.3);
    --color-accent:        #00d4ff;
    --color-accent-dim:    #00a8cc;
    --color-accent-glow:   rgba(0, 212, 255, 0.3);
    --color-yellow:        #ffd700;
    --color-purple:        #8b5cf6;
    --color-orange:        #ff6b35;

    /* Text */
    --color-text:          #e2e8f0;
    --color-text-secondary:#94a3b8;
    --color-text-muted:    #64748b;

    /* Borders */
    --color-border:        #1e293b;
    --color-border-active: #334155;

    /* Fonts */
    --font-display:        'Orbitron', sans-serif;
    --font-body:           'Rajdhani', sans-serif;
    --font-mono:           'Share Tech Mono', monospace;

    /* Sizes */
    --header-height:       64px;
    --border-radius:       8px;
    --border-radius-lg:    12px;
    --border-radius-xl:    16px;

    /* Shadows */
    --shadow-sm:           0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md:           0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg:           0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow-green:   0 0 20px var(--color-green-glow), 0 0 40px var(--color-green-glow);
    --shadow-glow-red:     0 0 20px var(--color-red-glow), 0 0 40px var(--color-red-glow);
    --shadow-glow-accent:  0 0 20px var(--color-accent-glow), 0 0 40px var(--color-accent-glow);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    /* Background pattern */
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(0, 255, 136, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(255, 51, 102, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 0%, rgba(0, 212, 255, 0.03) 0%, transparent 50%);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
    background: var(--color-border-active);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent-dim);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.5px;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

.text-accent { color: var(--color-accent); }
.text-green { color: var(--color-green); }
.text-red { color: var(--color-red); }
.text-muted { color: var(--color-text-muted); font-size: 0.9rem; }
.text-mono { font-family: var(--font-mono); }

/* ============================================================
   LOADING SCREEN
   ============================================================ */
.loading-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}
.loading-content {
    text-align: center;
}
.loading-logo {
    margin-bottom: 2rem;
}
.loading-logo .logo-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: pulse 1.5s infinite;
}
.loading-logo .logo-text {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-text);
}
.loading-bar {
    width: 200px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 1rem auto;
    overflow: hidden;
}
.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-green), var(--color-accent));
    border-radius: 2px;
    animation: loadingFill 2s ease-in-out forwards;
}
.loading-text {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    text-decoration: none;
}
.logo .logo-icon {
    font-size: 1.5rem;
}
.logo .logo-text {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: 1px;
}

.header-nav {
    display: flex;
    gap: 0.25rem;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}
.nav-btn:hover {
    color: var(--color-text);
    background: var(--color-bg-card);
}
.nav-btn.active {
    color: var(--color-accent);
    background: rgba(0, 212, 255, 0.1);
}
.nav-icon { font-size: 1.1rem; }

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-balance {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--color-bg-card);
    padding: 0.4rem 0.8rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
}
.balance-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-green);
}

.header-avatar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: var(--border-radius);
    transition: background 0.2s;
}
.header-avatar:hover {
    background: var(--color-bg-card);
}
.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--color-accent);
}
.avatar-nickname {
    font-weight: 600;
    font-size: 0.9rem;
}
.avatar-rank {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}
.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    transition: all 0.3s;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-green-dim), var(--color-green));
    color: #000;
    border-color: var(--color-green);
}
.btn-primary:hover {
    background: var(--color-green);
    box-shadow: var(--shadow-glow-green);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-text);
    border-color: var(--color-border-active);
}
.btn-secondary:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-accent);
}

.btn-accent {
    background: linear-gradient(135deg, var(--color-accent-dim), var(--color-accent));
    color: #000;
    border-color: var(--color-accent);
}
.btn-accent:hover {
    box-shadow: var(--shadow-glow-accent);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-red-dim), var(--color-red));
    color: #fff;
}

.btn-large {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    border-radius: var(--border-radius-lg);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
}

.btn-glow {
    animation: glowPulse 2s infinite;
}

.btn-disabled, .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-icon { font-size: 1.2rem; }

/* ============================================================
   APP CONTENT
   ============================================================ */
.app-content {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 1rem 1.5rem;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.page {
    display: none;
}
.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ============================================================
   LIVE STATS BAR
   ============================================================ */
.live-stats-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.8rem 1.2rem;
    background: var(--color-bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: fit-content;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
}

.price-ticker .stat-value {
    font-size: 0.9rem;
}

/* ============================================================
   LOBBY
   ============================================================ */
.lobby-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.section-header h2 {
    font-size: 1.3rem;
}

.badge {
    background: var(--color-accent);
    color: #000;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-family: var(--font-mono);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* Game card in lobby */
.game-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.game-card:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.game-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-green), var(--color-accent));
}
.game-card.status-playing::before {
    background: linear-gradient(90deg, var(--color-red), var(--color-orange));
    animation: glowBar 1.5s infinite;
}

.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}
.game-card-pair {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
}
.game-card-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-waiting {
    background: rgba(0, 255, 136, 0.15);
    color: var(--color-green);
    border: 1px solid var(--color-green-dim);
}
.status-playing {
    background: rgba(255, 51, 102, 0.15);
    color: var(--color-red);
    border: 1px solid var(--color-red-dim);
}
.status-countdown {
    background: rgba(255, 215, 0, 0.15);
    color: var(--color-yellow);
    border: 1px solid #b8960f;
}

.game-card-players {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}
.game-card-player {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.game-card-player img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}
.game-card-player-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.game-card-vs {
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-weight: 700;
}

.game-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-border);
}
.game-card-bet {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-yellow);
}
.game-card-timeframe {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.game-card-join {
    padding: 0.3rem 0.8rem;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}
.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* ============================================================
   GAME PAGE
   ============================================================ */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--color-bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--color-border);
    margin-bottom: 0;
}

.game-player {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.game-player-right {
    flex-direction: row-reverse;
    text-align: right;
}
.game-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-accent);
}
.game-player-name {
    display: block;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
}
.game-player-rank {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.game-player-elo {
    display: block;
    font-size: 0.75rem;
    color: var(--color-accent);
    font-family: var(--font-mono);
}

.game-vs {
    text-align: center;
}
.vs-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-red);
    text-shadow: 0 0 10px var(--color-red-glow);
}
.game-timer {
    margin-bottom: 0.3rem;
}
.timer-label {
    display: block;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.timer-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-green);
    transition: color 0.3s, text-shadow 0.3s;
}
.timer-value.timer-urgent {
    color: var(--color-yellow);
    text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
    animation: pulse 1s ease infinite;
}
.timer-value.timer-critical {
    color: var(--color-red) !important;
    text-shadow: 0 0 15px var(--color-red-glow) !important;
    animation: pulse 0.5s ease infinite !important;
    font-size: 1.6rem;
}
.game-pair {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 0.2rem;
}

/* Game progress bar */
.game-progress-container {
    width: 100%;
    height: 4px;
    background: var(--color-bg-secondary);
    border-radius: 2px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.game-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-green), var(--color-accent));
    border-radius: 2px;
    transition: width 2s linear;
}
.game-progress-bar.progress-urgent {
    background: linear-gradient(90deg, var(--color-yellow), var(--color-red));
    animation: glowPulse 0.5s ease infinite;
}

/* Winning indicator */
.winning-indicator {
    text-align: center;
    padding: 0.5rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}
.winning-indicator.ahead {
    background: rgba(0, 255, 127, 0.1);
    color: var(--color-green);
    border: 1px solid rgba(0, 255, 127, 0.3);
    text-shadow: 0 0 10px rgba(0, 255, 127, 0.3);
    animation: pulse 2s ease infinite;
}
.winning-indicator.behind {
    background: rgba(255, 59, 48, 0.1);
    color: var(--color-red);
    border: 1px solid rgba(255, 59, 48, 0.3);
    text-shadow: 0 0 10px rgba(255, 59, 48, 0.3);
}
.winning-indicator.tied {
    background: rgba(255, 193, 7, 0.1);
    color: var(--color-yellow);
    border: 1px solid rgba(255, 193, 7, 0.3);
}

/* Countdown overlay */
.countdown-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.countdown-overlay.countdown-active {
    backdrop-filter: blur(10px);
}
.countdown-number, .countdown-num {
    font-family: var(--font-display);
    font-size: 10rem;
    font-weight: 900;
    color: var(--color-accent);
    text-shadow: 0 0 60px var(--color-accent-glow), 0 0 120px var(--color-accent-glow);
}
.countdown-num.countdown-urgent {
    color: var(--color-red);
    text-shadow: 0 0 60px var(--color-red-glow), 0 0 120px var(--color-red-glow);
}
.countdown-num.countdown-go {
    font-size: 6rem;
    color: var(--color-green) !important;
    text-shadow: 0 0 80px var(--color-green-glow) !important;
}
.countdown-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    letter-spacing: 3px;
    margin-top: 1rem;
}

/* Chart */
.game-chart-container {
    position: relative;
    background: var(--color-bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.3s ease;
}
.game-chart-container.glow-green {
    box-shadow: 0 0 20px rgba(0, 255, 127, 0.15);
}
.game-chart-container.glow-red {
    box-shadow: 0 0 20px rgba(255, 59, 48, 0.15);
}
.game-chart {
    width: 100%;
    height: 350px;
    display: block;
}

/* Race track — below chart */
.race-track {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    position: relative;
}
.race-track.race-track-enter {
    animation: slideUp 0.5s ease;
}
.race-lane {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    position: relative;
    margin-bottom: 0.3rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius);
    padding: 0 0.5rem;
}
.race-lane:last-child {
    margin-bottom: 0;
}
.race-name {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 40px;
    color: var(--color-text-secondary);
}
.race-runner {
    position: absolute;
    transition: left 1s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.2rem;
    z-index: 2;
}
.race-runner.race-bounce {
    animation: raceBounce 0.3s ease;
}
.race-runner.race-leading {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
    font-size: 1.4rem;
}
.race-diff {
    position: absolute;
    right: 0.5rem;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
}
.race-finish-line {
    position: absolute;
    right: 10%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(0deg, var(--color-text-muted) 0, var(--color-text-muted) 4px, transparent 4px, transparent 8px);
    opacity: 0.3;
}

/* Live score container */
.live-score-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}
.live-score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 1.2rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
}
.live-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}
.live-score {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-accent);
}
.live-score-vs {
    font-size: 1.5rem;
}

/* Prediction panel */
.prediction-panel {
    background: var(--color-bg-card);
    border: 2px solid var(--color-accent);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-glow-accent);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.prediction-panel.pulse-urgent {
    border-color: var(--color-red);
    animation: borderGlow 0.5s ease infinite;
    box-shadow: 0 0 20px rgba(255, 59, 48, 0.2);
}
.prediction-panel h3 {
    margin-bottom: 0.5rem;
}
.prediction-info {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}
.prediction-input-group {
    display: flex;
    align-items: center;
    max-width: 300px;
    margin: 0 auto 1rem;
}
.prediction-currency {
    background: var(--color-bg-secondary);
    padding: 0.7rem 1rem;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    border: 1px solid var(--color-border);
    border-right: none;
    color: var(--color-accent);
    font-size: 1.1rem;
    font-weight: 700;
}
.prediction-input {
    flex: 1;
    padding: 0.7rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    outline: none;
}
.prediction-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 10px var(--color-accent-glow);
}
.prediction-helpers {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.prediction-timer {
    color: var(--color-text-muted);
    margin-top: 0.8rem;
    font-family: var(--font-mono);
}
.prediction-confirmed {
    padding: 1rem;
}
.pred-check-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
.prediction-price-big {
    font-size: 1.8rem;
    color: var(--color-green);
    margin: 0.5rem 0;
}
.waiting-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
}
.waiting-dots span {
    animation: blink 1.4s ease-in-out infinite;
    font-size: 2rem;
    color: var(--color-accent);
}
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Game info bar */
.game-info-bar {
    display: flex;
    justify-content: space-around;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 0.6rem;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.info-item {
    text-align: center;
    min-width: 70px;
}
.info-item-price {
    position: relative;
}
.info-label {
    display: block;
    font-size: 0.65rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
}
.info-value {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
}
.price-display {
    color: var(--color-green);
}
.price-display.price-live {
    animation: pulse 2s ease infinite;
}
.price-change-badge {
    font-size: 0.65rem;
    font-family: var(--font-mono);
}
.price-up { color: var(--color-green); }
.price-down { color: var(--color-red); }

/* Price flash animations */
.price-flash-up {
    animation: priceFlashUp 0.5s ease;
}
.price-flash-down {
    animation: priceFlashDown 0.5s ease;
}

@keyframes priceFlashUp {
    0% { color: var(--color-green); text-shadow: 0 0 15px var(--color-green-glow); transform: scale(1.1); }
    100% { text-shadow: none; transform: scale(1); }
}
@keyframes priceFlashDown {
    0% { color: var(--color-red); text-shadow: 0 0 15px var(--color-red-glow); transform: scale(1.1); }
    100% { text-shadow: none; transform: scale(1); }
}

/* ============================================================
   RANKINGS PAGE
   ============================================================ */
.rankings-header {
    text-align: center;
    margin-bottom: 2rem;
}

.rank-tiers-display {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.rank-tier {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 1rem;
    background: var(--color-bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
    min-width: 80px;
    transition: all 0.2s;
}
.rank-tier:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
}
.tier-icon { font-size: 1.5rem; }
.tier-name {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 0.2rem;
}
.tier-elo {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-text-muted);
}

.leaderboard-container {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}
.leaderboard-table th {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.leaderboard-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}
.leaderboard-table tr:hover td {
    background: var(--color-bg-card);
}
.leaderboard-table .player-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.leaderboard-table .player-cell img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}
.leaderboard-table .rank-cell {
    font-family: var(--font-mono);
    font-weight: 700;
}
.leaderboard-table .elo-cell {
    font-family: var(--font-mono);
    color: var(--color-accent);
}
.leaderboard-table .position-1 td {
    color: var(--color-yellow);
}
.leaderboard-table .position-2 td {
    color: #C0C0C0;
}
.leaderboard-table .position-3 td {
    color: #CD7F32;
}

/* ============================================================
   TRAINING PAGE
   ============================================================ */
.training-header {
    text-align: center;
    margin-bottom: 2rem;
}

.training-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.training-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 1.2rem;
    transition: all 0.2s;
}
.training-card:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
}
.training-card.locked {
    opacity: 0.5;
}
.training-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}
.training-icon {
    font-size: 2rem;
}
.training-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
}
.badge-free {
    background: rgba(0, 255, 136, 0.15);
    color: var(--color-green);
}
.badge-soon {
    background: rgba(255, 215, 0, 0.15);
    color: var(--color-yellow);
}
.badge-premium {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-purple);
}
.training-card h3 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}
.training-card p {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
}
.training-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}
.difficulty {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}
.difficulty.beginner { background: rgba(0,255,136,0.1); color: var(--color-green); }
.difficulty.intermediate { background: rgba(255,215,0,0.1); color: var(--color-yellow); }
.difficulty.advanced { background: rgba(255,51,102,0.1); color: var(--color-red); }
.duration {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ============================================================
   PROFILE PAGE
   ============================================================ */
.profile-container {
    max-width: 700px;
    margin: 0 auto;
}

.profile-header-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.profile-avatar-large {
    position: relative;
}
.profile-avatar-large img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--color-accent);
}
.rank-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    font-size: 1.5rem;
    background: var(--color-bg);
    border-radius: 50%;
    padding: 2px;
}
.profile-info {
    flex: 1;
}
.profile-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}
.profile-rank-display {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}
.rank-name {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--color-accent);
}
.elo-display {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.profile-elo-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}
.elo-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-green), var(--color-accent));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.profile-stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1rem;
    text-align: center;
}
.stat-icon { font-size: 1.5rem; display: block; margin-bottom: 0.3rem; }
.stat-number {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    display: block;
}
.stat-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.profile-wallets {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 1.2rem;
}
.profile-wallets h3 {
    margin-bottom: 0.8rem;
}
.wallets-list {
    margin-bottom: 0.8rem;
}
.wallet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.wallet-address {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}
.wallet-chain-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: rgba(0, 212, 255, 0.1);
    color: var(--color-accent);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.hidden {
    display: none;
}
.modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: var(--color-bg-modal);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-xl);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}
.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
}
.modal-close:hover {
    color: var(--color-text);
}

/* Login Modal */
.wallet-options {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1.5rem;
}
.wallet-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
}
.wallet-btn:hover {
    border-color: var(--color-accent);
    background: var(--color-bg-card-hover);
}
.wallet-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.wallet-icon {
    width: 32px;
    height: 32px;
}
.wallet-icon-emoji {
    font-size: 1.5rem;
    width: 32px;
    text-align: center;
}
.wallet-chain {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.nickname-form {
    margin: 1.5rem 0;
}
.input-field {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s;
}
.input-field:focus {
    border-color: var(--color-accent);
}
.nickname-status {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.85rem;
}

.avatar-preview {
    text-align: center;
    margin: 1.5rem 0;
}
.avatar-preview-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--color-accent);
    margin-bottom: 0.5rem;
}

/* Create Room Modal */
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.radio-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.radio-card {
    flex: 1;
    min-width: 70px;
    text-align: center;
    padding: 0.6rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.9rem;
}
.radio-card input {
    display: none;
}
.radio-card:hover {
    border-color: var(--color-accent);
}
.radio-card.active,
.radio-card:has(input:checked) {
    border-color: var(--color-accent);
    background: rgba(0, 212, 255, 0.1);
    color: var(--color-accent);
}
.radio-card.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.radio-icon {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}
.bet-amount {
    font-family: var(--font-mono);
    font-weight: 700;
}

/* Result Modal — Full Redesign */
.modal-result-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-result-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
}
.modal-result-content {
    position: relative;
    text-align: center;
    max-width: 440px;
    width: 90%;
    background: var(--color-bg-card);
    border-radius: var(--border-radius-lg);
    padding: 2rem 1.5rem;
    border: 2px solid var(--color-border);
    animation: modalIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1;
}
.result-victory .modal-result-content {
    border-color: var(--color-green);
    box-shadow: 0 0 40px rgba(0, 255, 127, 0.2), 0 0 80px rgba(0, 255, 127, 0.1);
}
.result-defeat .modal-result-content {
    border-color: var(--color-red);
    box-shadow: 0 0 40px rgba(255, 59, 48, 0.2);
}
.result-draw .modal-result-content {
    border-color: var(--color-yellow);
    box-shadow: 0 0 40px rgba(255, 193, 7, 0.2);
}
.result-animation {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}
.result-big-icon {
    font-size: 4rem;
    position: relative;
}
.icon-trophy {
    animation: trophyReveal 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: inline-block;
}
.icon-skull {
    animation: defeatShake 0.6s ease;
    display: inline-block;
}
.icon-bounce {
    animation: raceBounce 0.6s ease;
    display: inline-block;
}
.victory-ring {
    position: absolute;
    top: 50%; left: 50%;
    width: 100px; height: 100px;
    border: 3px solid var(--color-green);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ringExpand 0.8s ease-out 0.3s forwards;
    opacity: 0.5;
}
@keyframes ringExpand {
    to { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}
.result-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
}
.victory-title {
    color: var(--color-green);
    text-shadow: 0 0 20px var(--color-green-glow);
}
.defeat-title {
    color: var(--color-red);
    text-shadow: 0 0 20px var(--color-red-glow);
}
.draw-title {
    color: var(--color-yellow);
    text-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}
.result-details {
    margin-bottom: 0;
}

/* Result comparison card */
.result-comparison {
    margin-bottom: 1rem;
}
.result-vs {
    display: flex;
    align-items: stretch;
    gap: 0;
}
.result-player {
    flex: 1;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius);
}
.result-player.you {
    border-right: none;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}
.result-player.opp {
    border-left: none;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
.result-player-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 0.3rem;
    font-weight: 700;
}
.result-player-pred {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text);
    margin-bottom: 0.2rem;
}
.result-player-diff {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
}
.winner-diff {
    color: var(--color-green) !important;
    font-weight: 700;
}
.result-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
}
.vs-badge {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 900;
    color: var(--color-red);
    margin-bottom: 0.3rem;
}
.final-price-label {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
}
.final-price-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-accent);
}

/* ELO change card */
.elo-change-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.8rem;
    animation: slideUp 0.5s ease 0.3s backwards;
}
.elo-change-card.elo-positive {
    background: rgba(0, 255, 127, 0.1);
    border: 1px solid rgba(0, 255, 127, 0.3);
}
.elo-change-card.elo-negative {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
}
.elo-icon { font-size: 1.2rem; }
.elo-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
}
.elo-positive .elo-value { color: var(--color-green); }
.elo-negative .elo-value { color: var(--color-red); }
.elo-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
}

/* Prize card */
.prize-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    animation: slideUp 0.5s ease 0.5s backwards;
}
.prize-icon { font-size: 1.2rem; }
.prize-amount {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-yellow);
}
.prize-card.prize-reveal {
    animation: prizeReveal 0.6s ease 0.5s backwards;
}
@keyframes prizeReveal {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Result actions */
.result-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    margin-top: 1rem;
}
.result-actions .btn {
    flex: 1;
    max-width: 180px;
}

/* Screen effects */
.screen-shake {
    animation: defeatShake 0.6s ease !important;
}
.screen-pulse {
    animation: screenPulse 0.3s ease;
}
@keyframes screenPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.1); }
}
.screen-flash {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 9999;
    animation: flashFade 0.5s ease forwards;
}
@keyframes flashFade {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Fireworks */
.firework {
    position: fixed;
    pointer-events: none;
    z-index: 7000;
}
.firework-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: fireworkBurst 0.8s ease-out forwards;
}
@keyframes fireworkBurst {
    0% { transform: translate(0, 0); opacity: 1; }
    100% {
        transform: translate(
            calc(cos(var(--angle)) * var(--dist)),
            calc(sin(var(--angle)) * var(--dist))
        );
        opacity: 0;
    }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    right: 1rem;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 350px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1.2rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    cursor: pointer;
}
.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}
.toast-icon { font-size: 1.2rem; }
.toast-message {
    flex: 1;
    font-size: 0.9rem;
}
.toast.toast-victory {
    border-color: var(--color-green);
    box-shadow: var(--shadow-glow-green);
}
.toast.toast-defeat {
    border-color: var(--color-red);
    box-shadow: var(--shadow-glow-red);
}
.toast.toast-info {
    border-color: var(--color-accent);
}
.toast.toast-warning {
    border-color: var(--color-yellow);
}

/* ============================================================
   MATCHMAKING OVERLAY
   ============================================================ */
.matchmaking-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}
.matchmaking-content {
    text-align: center;
}
.matchmaking-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-accent);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}
.matchmaking-content h3 {
    margin-bottom: 0.5rem;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
