:root {
    --bg-primary: #020617;
    --bg-secondary: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #22d3ee;
    --accent-glow: rgba(34, 211, 238, 0.4);
    --danger: #f43f5e;
    --canvas-width: 300px;
    --canvas-height: 500px;
}

/* Neon Theme */
html[data-theme="neon"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --accent: #00ffff;
    --accent-glow: rgba(0, 255, 255, 0.6);
    --danger: #ff00ff;
}

/* Retro Theme */
html[data-theme="retro"] {
    --bg-primary: #2d1b69;
    --bg-secondary: #4a2c7f;
    --bg-card: #6b46c1;
    --text-primary: #fef3c7;
    --text-secondary: #d1d5db;
    --accent: #fbbf24;
    --accent-glow: rgba(251, 191, 36, 0.4);
    --danger: #ef4444;
}

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

/* Keyboard Focus Indicators */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-glow);
}

html {
    touch-action: manipulation;
}

body {
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family:
        system-ui,
        -apple-system,
        sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

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

/* Splash Screen */
#screen-splash {
    cursor: pointer;
    user-select: none;
}

.splash-title {
    font-size: clamp(3rem, 12vw, 6rem);
    font-weight: 800;
    letter-spacing: 0.1em;
    background: linear-gradient(
        135deg,
        var(--accent) 0%,
        #a78bfa 50%,
        #f472b6 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px var(--accent-glow);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 20px var(--accent-glow));
    }
    to {
        filter: drop-shadow(0 0 40px var(--accent-glow));
    }
}

.splash-author {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.splash-author a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.2s;
}

.splash-author a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.splash-prompt {
    margin-top: 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Brand Header (shown on menu screens) */
.brand-header {
    font-size: clamp(1.8rem, 6vw, 2.5rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(
        135deg,
        var(--accent) 0%,
        #a78bfa 50%,
        #f472b6 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

/* Menu Screen */
.menu-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.menu-link {
    margin-top: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
}

.menu-link:hover {
    color: var(--accent);
}

/* Pro menu items in main menu */
.pro-menu-items {
    margin-top: 1rem;
}

/* Pro card styling - gradient accent */
.mode-card.pro-card {
    background: linear-gradient(
        135deg,
        rgba(168, 85, 247, 0.15),
        rgba(236, 72, 153, 0.1)
    );
    border: 2px solid rgba(168, 85, 247, 0.3);
}

.mode-card.pro-card:hover,
.mode-card.pro-card:focus {
    border-color: #a855f7;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(168, 85, 247, 0.4);
}

.mode-card.pro-card h3 {
    color: #a855f7;
}

.mode-card.pro-card::before {
    content: "PRO";
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 0.15rem 0.4rem;
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: white;
    border-radius: 4px;
}

.mode-card.pro-card {
    position: relative;
}

.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 400px;
}

.mode-card {
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.mode-card:hover,
.mode-card:focus {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        0 0 20px var(--accent-glow);
}

.mode-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.mode-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.mode-card.classic h3 {
    color: var(--accent);
}
.mode-card.daily h3 {
    color: #a78bfa;
}
.mode-card.hardcore h3 {
    color: var(--danger);
}

/* Game Screen */
#screen-game {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Desktop Game Navbar */
.game-navbar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    flex-shrink: 0;
}

.game-navbar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.05em;
}

/* 3-Column Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 180px 1fr 180px;
    gap: 1.5rem;
    flex: 1;
    padding: 1rem 1.5rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    align-items: start;
    overflow: hidden;
}

#screen-game.battle .game-layout {
    max-width: 1200px;
}

/* Sidebars */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-sidebar-left {
    justify-self: end;
}

.game-sidebar-right {
    justify-self: start;
}

.sidebar-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.sidebar-title {
    margin: 0 0 0.75rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.sidebar-title .hold-hint {
    color: var(--accent);
    font-size: 0.7rem;
}

/* Player Name Display */
.player-name-display {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    word-break: break-word;
}

/* Stats in Left Sidebar */
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item .stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stat-item .stat-value {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.high-score-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* Pro Section in Sidebar */
.pro-section-sidebar {
    display: none;
}

.pro-section-sidebar.active {
    display: block;
}

/* Sidebar Buttons */
.btn-sidebar {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.btn-sidebar:last-child {
    margin-bottom: 0;
}

.btn-sidebar:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sidebar.btn-menu {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.btn-sidebar.btn-menu:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Piece Preview Box */
.piece-preview-box {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 0.5rem;
}

.piece-preview-box canvas {
    width: 70px;
    height: 70px;
}

/* Game Center Area */
.game-center {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
}

.game-board-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game {
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow:
        0 0 60px rgba(0, 0, 0, 0.5),
        0 0 120px rgba(34, 211, 238, 0.1);
    width: var(--canvas-width);
    height: var(--canvas-height);
    border: 2px solid rgba(148, 163, 184, 0.1);
    display: none;
}

#screen-game.active #game {
    display: block;
}

/* Legacy panel - hidden on desktop, shown on mobile */
.panel {
    display: none;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.25rem;
    min-width: 180px;
    max-width: 200px;
}

.panel h3 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: var(--accent);
}

.panel h4 {
    margin: 1.25rem 0 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#stats {
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-line;
}

#next,
#hold {
    background: var(--bg-card);
    border-radius: 6px;
    width: 80px;
    height: 80px;
}

/* Tablet Layout (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 160px 1fr 160px;
        gap: 1rem;
        padding: 0.75rem 1rem;
    }

    .sidebar-section {
        padding: 0.75rem;
    }

    .btn-sidebar {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }

    .piece-preview-box canvas {
        width: 60px;
        height: 60px;
    }
}

/* Hide desktop layout on mobile */
@media (max-width: 767px) {
    .game-navbar {
        display: none;
    }

    .game-layout {
        display: none;
    }

    .panel {
        display: block;
        position: fixed;
        top: 0;
        right: -280px;
        width: 260px;
        max-width: 90vw;
        height: 100%;
        border-radius: 0;
        overflow-y: auto;
        z-index: 200;
        transition: right 0.3s ease;
    }

    .panel.open {
        right: 0;
    }
}

/* Show mobile header only on mobile */
.mobile-header {
    display: none;
}

@media (max-width: 767px) {
    .mobile-header {
        display: flex;
    }
}

/* Legacy game-container support for multiplayer opponent view */
.game-container {
    display: none;
}

.btn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 10px 14px;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn.secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: #334155;
    box-shadow: none;
}

.btn.back {
    width: auto;
    min-width: 120px;
    max-width: 200px;
    padding: 10px 24px;
    margin-top: 1.5rem;
}

/* Settings header layout */
.settings-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.settings-header .btn.back {
    margin: 0;
    padding: 0.25rem;
    min-width: auto;
    width: auto;
}

.settings-header .btn.back svg {
    width: 20px;
    height: 20px;
}

.settings-header .brand-header {
    margin: 0;
    flex: 1;
}

@media (max-width: 600px) {
    .settings-header {
        gap: 0.75rem;
    }

    .settings-header .btn.back {
        padding: 0.2rem;
    }

    .settings-header .btn.back svg {
        width: 18px;
        height: 18px;
    }

    .settings-header .brand-header {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }
}

@media (max-width: 400px) {
    .btn.back {
        min-width: 100px;
        padding: 10px 20px;
        font-size: 0.85rem;
    }
}

/* Help Overlay */
#overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 100;
    padding: 24px;
    overflow: auto;
    animation: fadeIn 0.2s ease-out;
}

#overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.overlay-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
}

.overlay-content h2 {
    margin: 0 0 1rem 0;
    color: var(--accent);
}

.overlay-content ul {
    padding-left: 1.5rem;
}

.overlay-content li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

/* Ranked Mode Button refinement */
#rankedModeBtn.btn.secondary {
    margin-left: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
}
#rankedModeBtn.btn.secondary:hover {
    border-color: rgba(148, 163, 184, 0.4);
}

/* Analytics Dashboard */
#analyticsDashboard {
    margin: 1rem 0 1.5rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.15);
}
#analyticsDashboard h3 {
    margin: 0 0 0.75rem 0;
    color: var(--accent);
    font-size: 1.1rem;
}
#analyticsDashboard h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.dashboard-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.dashboard-chart {
    background: var(--bg-primary);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    padding: 0.75rem;
}

.dashboard-chart canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.06);
    border: 1px dashed rgba(148, 163, 184, 0.15);
}

/* Responsive tweaks */
@media (max-width: 600px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

/* Store Sections */
#storeThemes,
#storeSkins,
#storeEmojis {
    margin: 1rem 0 1.5rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

#storeThemes h3,
#storeSkins h3,
#storeEmojis h3 {
    margin: 0 0 0.75rem 0;
    color: var(--accent);
    font-size: 1.1rem;
}

#storeThemes button,
#storeSkins button,
#storeEmojis button {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition:
        transform 0.05s ease,
        background 0.15s ease,
        border-color 0.15s ease;
}

#storeThemes button:hover,
#storeSkins button:hover,
#storeEmojis button:hover {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.35);
}

#storeThemes button:disabled,
#storeSkins button:disabled,
#storeEmojis button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Replay Viewer Overlay */
#replayViewer.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 110;
    padding: 24px;
    overflow: auto;
    animation: fadeIn 0.2s ease-out;
}

#replayViewer.overlay .overlay-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.25rem;
    max-width: 640px;
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

#replayViewer.overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

#replayViewer .replay-controls {
    display: grid;
    grid-template-columns: auto auto auto 1fr auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

#replayPlayBtn,
#replayPauseBtn,
#replayStopBtn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}

#replayPlayBtn:hover,
#replayPauseBtn:hover,
#replayStopBtn:hover {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.4);
}

#replaySeek {
    width: 100%;
    accent-color: var(--accent);
}

#replayProgressLabel {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Replay Timeline */
#replayTimeline {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0 0 0;
    max-height: 240px;
    overflow: auto;
    border-top: 1px dashed rgba(148, 163, 184, 0.2);
}

#replayTimeline li {
    padding: 0.4rem 0;
    color: var(--text-secondary);
    border-bottom: 1px dashed rgba(148, 163, 184, 0.1);
}

/* Panel Sections (common) */
.panel-section {
    margin: 1rem 0 1.5rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.panel-section h3 {
    margin: 0 0 0.75rem 0;
    color: var(--accent);
    font-size: 1.1rem;
}

/* Replay List Items */
#replayList .replay-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem 1rem;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
}

#replayList .replay-meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

#replayList .replay-title {
    color: var(--text-primary);
    font-weight: 600;
}

#replayList .replay-stats {
    display: flex;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#replayList .replay-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

#replayList .replay-actions .replay-play,
#replayList .replay-actions .replay-delete {
    padding: 0.4rem 0.6rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.05s ease;
}

#replayList .replay-actions .replay-play:hover,
#replayList .replay-actions .replay-delete:hover {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.35);
}

/* Analytics List Items */
#analyticsList .analytics-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem 1rem;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
}

#analyticsList .analytics-meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

#analyticsList .analytics-stats {
    display: flex;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ========================
   Analytics Dashboard Screen
   ======================== */

#screen-analytics {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    overflow-y: auto;
}

#screen-analytics .menu-title {
    margin-bottom: 1.5rem;
}

/* Grade Section */
.analytics-grade-section {
    margin-bottom: 2rem;
}

.grade-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.grade-card h3 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.grade-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

.grade-letter {
    display: block;
    font-size: 4rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.grade-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.grade-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.grade-stat {
    display: grid;
    grid-template-columns: 120px 1fr 50px;
    gap: 0.75rem;
    align-items: center;
}

.grade-stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.grade-bar {
    height: 8px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.grade-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.grade-stat-value {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: right;
}

/* Explanation Section */
.analytics-explanation {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.analytics-explanation h3 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.explanation-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.explanation-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.explanation-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.explanation-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.25rem;
}

.explanation-item p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Tips Section */
.analytics-tips {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.analytics-tips h3 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tip-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.75rem;
    background: rgba(148, 163, 184, 0.05);
    border-radius: 10px;
}

.tip-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.tip-item p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Charts Section */
.analytics-charts-section {
    margin-bottom: 2rem;
}

.analytics-charts-section h3 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.chart-card h4 {
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    font-weight: 500;
}

.chart-card canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* Recent Games */
.analytics-recent {
    margin-bottom: 2rem;
}

.analytics-recent h3 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.recent-games-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.recent-game-mode {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}

.recent-game-stats {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.recent-game-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

#screen-analytics .analytics-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    background: var(--bg-card);
    border-radius: 12px;
}

/* Analytics Dashboard Responsive */
@media (max-width: 600px) {
    .grade-stat {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .grade-stat-label {
        font-size: 0.8rem;
    }

    .grade-bar {
        order: 2;
    }

    .grade-stat-value {
        text-align: left;
        order: 1;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .explanation-item {
        flex-direction: column;
        gap: 0.5rem;
    }

    .explanation-icon {
        width: auto;
        text-align: left;
    }
}

/* Pro Overlay */
#pro-overlay.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 120;
    padding: 24px;
    overflow: auto;
    animation: fadeIn 0.2s ease-out;
}
#pro-overlay.overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
#pro-overlay .overlay-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.25rem;
    max-width: 560px;
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.15);
}
#pro-overlay .overlay-content h3 {
    margin: 0 0 0.75rem 0;
    color: var(--accent);
}
#pro-overlay .overlay-content p,
#pro-overlay .overlay-content li {
    color: var(--text-secondary);
}

/* Dev Pro Toggle Button */
[data-dev-pro-toggle] {
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}
[data-dev-pro-toggle]:hover {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.4);
}

/* Game Over Overlay */
#gameover-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 100;
    padding: 24px;
    overflow: auto;
}

#gameover-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.gameover-content h2 {
    color: var(--danger);
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.gameover-stats {
    margin-bottom: 1.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bg-card);
    font-size: 1.1rem;
}

.stat-row span:last-child {
    font-weight: 700;
    color: var(--accent);
}

.stat-row.secondary {
    font-size: 0.95rem;
    border-bottom: none;
    padding: 0.4rem 0;
}

.stat-row.secondary span:last-child {
    color: var(--text-secondary);
}

.seed-label {
    margin: 1rem 0 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.seed-display {
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-align: center;
    font-family: monospace;
    font-size: 1.1rem;
    color: #a78bfa;
    margin-bottom: 1rem;
}

#daily-seed-container {
    margin-bottom: 1rem;
}

/* Garbage Indicator */
.garbage-indicator {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 200px;
    background: var(--bg-card);
    border-radius: 4px;
    display: none;
    flex-direction: column-reverse;
    align-items: center;
    padding: 2px;
    z-index: 10;
}

#screen-game.active .garbage-indicator {
    display: flex;
}

.garbage-indicator.active {
    display: flex;
}

.garbage-bar {
    width: 100%;
    background: linear-gradient(to top, #f43f5e, #fb7185);
    border-radius: 2px;
    transition: height 0.3s ease;
}

.garbage-count {
    position: absolute;
    bottom: -20px;
    font-size: 0.75rem;
    color: #f43f5e;
    font-weight: 700;
}

/* Emoji Panel */
.emoji-panel {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100px;
}

.emoji-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--bg-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition:
        transform 0.15s,
        background 0.15s;
}

.emoji-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

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

/* Floating emoji animation */
.floating-emoji {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 1000;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

/* Rematch section */
.mp-rematch-section {
    margin-bottom: 1rem;
    text-align: center;
}

.rematch-status {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.rematch-status.waiting {
    color: #facc15;
}

/* Multiplayer Results Overlay */
#mp-results-overlay,
#royale-results-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 100;
    padding: 24px;
    overflow: auto;
}

#mp-results-overlay.active,
#royale-results-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.mp-results-content {
    max-width: 400px;
    width: 100%;
}

.mp-result-banner {
    text-align: center;
    margin-bottom: 1.5rem;
}

.mp-result-banner .result-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 0.5rem;
}

.mp-result-banner h2 {
    font-size: 2rem;
    margin: 0;
}

.mp-result-banner.win h2 {
    color: #4ade80;
}

.mp-result-banner.lose h2 {
    color: var(--danger);
}

.mp-result-banner.tie h2 {
    color: #facc15;
}

.mp-results-players {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.mp-player-result {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 2px solid #4ade80;
}

.mp-player-result.loser {
    border-color: var(--bg-secondary);
    opacity: 0.8;
}

.mp-player-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 50px;
}

.mp-player-result.loser .mp-player-rank {
    color: var(--text-secondary);
}

.mp-player-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.mp-player-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.mp-player-score {
    color: var(--accent);
    font-size: 1.25rem;
    font-weight: 700;
}

.mp-player-result.loser .mp-player-score {
    color: var(--text-secondary);
}

.mp-results-stats {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.mp-results-stats h4 {
    margin: 0 0 0.75rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Ranked Matchmaking Overlay */
#ranked-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

#ranked-overlay.active {
    display: flex;
}

.ranked-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.ranked-content h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #f59e0b, #eab308);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ranked-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.ranked-status-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    min-height: 80px;
}

.ranked-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-secondary);
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.ranked-spinner.active {
    display: block;
}

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

#rankedStatus {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.ranked-elo-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(
        135deg,
        rgba(245, 158, 11, 0.1),
        rgba(234, 179, 8, 0.1)
    );
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
}

.ranked-elo-display span {
    color: var(--text-secondary);
}

.elo-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #f59e0b !important;
}

.ranked-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.ranked-buttons .btn {
    min-width: 120px;
}

/* Bot mode card */
.mode-card.bot h3 {
    color: #06b6d4;
}

/* Bot select screen */
.menu-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    text-align: center;
}

.bot-cards {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.bot-card[data-bot="beginner"] h3 {
    color: #22c55e;
}

.bot-card[data-bot="easy"] h3 {
    color: #eab308;
}

.bot-card[data-bot="medium"] h3 {
    color: #f97316;
}

.bot-card[data-bot="hard"] h3 {
    color: #ef4444;
}

.bot-card[data-bot="expert"] h3 {
    color: #a855f7;
}

.bot-card[data-bot="master"] h3 {
    color: #6b7280;
}

.bot-card[data-bot="master"] {
    background: linear-gradient(
        135deg,
        rgba(107, 114, 128, 0.2),
        rgba(17, 24, 39, 0.3)
    );
    border: 1px solid rgba(107, 114, 128, 0.4);
}

.bot-card[data-bot="master"]:hover {
    border-color: #6b7280;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(107, 114, 128, 0.3);
}

/* Seed mode card */
.mode-card.seed h3 {
    color: #f472b6;
}

/* Multiplayer mode card */
.mode-card.multiplayer h3 {
    color: #4ade80;
}

/* Royale mode card */
.mode-card.royale h3 {
    color: #f59e0b;
}

/* Multiplayer screens */
.multiplayer-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

.or-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.join-room {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.room-info {
    text-align: center;
    margin-bottom: 2rem;
}

.room-code-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.room-code-display {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--accent);
    font-family: monospace;
}

.waiting-text {
    color: var(--text-secondary);
    margin-top: 1rem;
    animation: pulse 1.5s ease-in-out infinite;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    min-width: 200px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.player-name {
    font-weight: 600;
}

.player-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.player-status.ready {
    color: #4ade80;
}

.player-item.ready {
    border: 1px solid #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

/* Opponent board in game */
.opponent-container {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

#screen-game.active .opponent-container.active {
    display: flex;
}

.opponent-container.active {
    display: flex;
}

.opponent-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.opponent-score {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

#opponent-board {
    background: var(--bg-card);
    border-radius: 6px;
}

/* Seed Input Overlay */
#seed-overlay,
#name-overlay,
#wall-of-fame-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 100;
    padding: 24px;
    overflow: auto;
}

#seed-overlay.active,
#name-overlay.active,
#wall-of-fame-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

/* Wall of Fame Overlay Styles */
.wof-banner {
    text-align: center;
    margin-bottom: 1rem;
}

.wof-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.wof-banner h2 {
    color: var(--accent);
    margin: 0;
    font-size: 1.5rem;
}

.wof-message {
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.wof-stats {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.wof-stats .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    color: var(--text-secondary);
}

.wof-stats .stat-row span:last-child {
    color: var(--accent);
    font-weight: 600;
}

.wof-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    margin-bottom: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

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

.wof-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.wof-char-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: right;
    margin-bottom: 1.5rem;
}

#wof-char-current {
    color: var(--accent);
    font-weight: 600;
}

.name-input {
    display: block;
    width: 100%;
    min-width: 200px;
    padding: 12px 16px;
    font-size: 1.1rem;
    background: var(--bg-primary);
    border: 2px solid var(--bg-card);
    border-radius: 8px;
    color: var(--text-primary);
    text-align: center;
    margin: 0 auto 1rem auto;
    box-sizing: border-box;
}

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

.name-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.name-hint {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.name-preview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.name-preview span {
    color: var(--accent);
    font-weight: 600;
}

.seed-hint {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.seed-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

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

.seed-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Leaderboard Screen */
#screen-leaderboard {
    padding: 20px;
}

.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.leaderboard-tab {
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.leaderboard-tab:hover {
    border-color: var(--accent);
}

.leaderboard-tab.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.leaderboard-container {
    width: 100%;
    max-width: 500px;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 50px 1fr 100px;
    padding: 1rem;
    background: var(--bg-card);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 50px 1fr 100px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bg-card);
    align-items: center;
}

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

.leaderboard-row.highlight {
    background: rgba(34, 211, 238, 0.1);
}

.leaderboard-rank {
    font-weight: 700;
    color: var(--text-secondary);
}

.leaderboard-rank.gold {
    color: #fbbf24;
}

.leaderboard-rank.silver {
    color: #9ca3af;
}

.leaderboard-rank.bronze {
    color: #d97706;
}

.leaderboard-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    text-align: right;
    font-weight: 600;
    color: var(--accent);
}

.leaderboard-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.leaderboard-loading {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Royale Mode Styles */
.royale-player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 500px;
    margin-bottom: 1.5rem;
}

.royale-player-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.royale-player-card.ready {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.royale-player-card.you {
    border-color: var(--accent);
}

.royale-player-card .player-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.royale-player-card .player-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.royale-player-card.ready .player-status {
    color: #4ade80;
}

.royale-info {
    text-align: center;
    margin-bottom: 1rem;
}

.royale-info .player-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f59e0b;
}

.royale-info .player-count-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Mini boards grid for spectating */
.mini-boards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    max-width: 400px;
}

.mini-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.mini-board-container.eliminated {
    opacity: 0.4;
}

.mini-board-container .mini-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
}

.mini-board-container .mini-score {
    font-size: 0.65rem;
    color: var(--accent);
}

.mini-board {
    width: 60px;
    height: 100px;
    background: var(--bg-card);
    border-radius: 4px;
}

/* Elimination banner */
.elimination-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(244, 63, 94, 0.95);
    color: white;
    padding: 1.5rem 3rem;
    border-radius: 12px;
    text-align: center;
    z-index: 1000;
    animation: bannerPop 0.3s ease-out;
}

.elimination-banner.win {
    background: rgba(74, 222, 128, 0.95);
}

.elimination-banner h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
}

.elimination-banner p {
    margin: 0;
    opacity: 0.9;
}

@keyframes bannerPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Royale results overlay */
.royale-standings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.royale-standing-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.royale-standing-row.winner {
    border: 2px solid #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.royale-standing-row.you {
    border: 2px solid var(--accent);
}

.standing-rank {
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 40px;
    color: var(--text-secondary);
}

.royale-standing-row.winner .standing-rank {
    color: #4ade80;
}

.standing-name {
    flex: 1;
    font-weight: 500;
}

.standing-score {
    font-weight: 600;
    color: var(--accent);
}

/* Spectator mode indicator */
.spectator-indicator {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(245, 158, 11, 0.9);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 100;
}

/* Alive counter during game */
.alive-counter {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 100;
}

.alive-counter .count {
    color: #f59e0b;
    font-weight: 700;
}

/* Pause Overlay */
#pause-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 150;
    padding: 24px;
}

#pause-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.pause-content h2 {
    color: var(--accent);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.pause-hint {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Countdown Overlay */
#countdown-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.9);
    z-index: 200;
}

#countdown-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.countdown-number {
    font-size: 8rem;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 60px var(--accent-glow);
    animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Confirm Leave Dialog */
#confirm-leave-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 200;
    padding: 24px;
}

#confirm-leave-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.confirm-content {
    max-width: 350px;
    text-align: center;
}

.confirm-content h2 {
    color: var(--danger);
    margin-bottom: 0.5rem;
}

.confirm-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.confirm-buttons {
    display: flex;
    gap: 1rem;
}

.confirm-buttons .btn {
    flex: 1;
}

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

.btn.danger:hover {
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

/* High Score Display */
.high-score-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--bg-card);
}

.high-score-display .best-label {
    color: var(--text-secondary);
}

.high-score-display .best-value {
    color: #fbbf24;
    font-weight: 600;
}

.mobile-high-score {
    font-size: 0.7rem;
    color: #fbbf24;
    margin-top: 2px;
}

/* Settings Screen */
.settings-container {
    width: 100%;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.25rem;
}

.settings-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bg-card);
}

.setting-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-row:first-of-type {
    padding-top: 0;
}

.setting-label {
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Toggle Button */
.toggle-btn {
    width: 52px;
    height: 28px;
    background: var(--bg-card);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.toggle-btn[data-enabled="true"] {
    background: var(--accent);
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-btn[data-enabled="true"] .toggle-slider {
    transform: translateX(24px);
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 0.5rem;
}

.theme-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

/* Controls Info */
.controls-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
}

.control-row .key {
    min-width: 50px;
    padding: 0.25rem 0.5rem;
    background: var(--bg-primary);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent);
    text-align: center;
}

.control-row span:last-child {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    width: auto;
}

/* Hold Piece Display */
#hold {
    background: var(--bg-card);
    border-radius: 6px;
    width: 80px;
    height: 80px;
}

#hold.used {
    opacity: 0.5;
}

.hold-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: normal;
}

/* Mobile Pieces (Hold & Next) */
.mobile-pieces {
    display: flex;
    gap: 0.5rem;
}

.mobile-piece-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.mobile-piece-box .piece-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.mobile-piece-box canvas {
    background: var(--bg-card);
    border-radius: 4px;
}

/* Action Indicator (Combo/T-Spin) */
.action-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    display: none;
}

#screen-game.active .action-indicator {
    display: block;
}

.action-indicator.show {
    animation: actionPop 1.5s ease-out forwards;
}

.action-text {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    text-shadow: 0 0 20px currentColor;
}

.action-text.combo {
    color: #fbbf24;
}

.action-text.tetris {
    color: #22d3ee;
    font-size: 2.5rem;
}

.action-text.tspin {
    color: #a78bfa;
}

.action-text.back-to-back {
    color: #f472b6;
}

@keyframes actionPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -60%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -70%) scale(0.8);
    }
}

/* Tutorial Overlay */
#tutorial-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.98);
    z-index: 250;
    padding: 24px;
}

#tutorial-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.tutorial-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tutorial-step {
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 600;
}

.tutorial-skip {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem;
}

.tutorial-skip:hover {
    color: var(--text-primary);
}

.tutorial-body {
    text-align: center;
    margin-bottom: 2rem;
}

.tutorial-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.tutorial-body h2 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.tutorial-body p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tutorial-nav {
    display: flex;
    gap: 1rem;
}

.tutorial-nav .btn {
    flex: 1;
}

/* Top row controls layout */
.controls-row.top-row {
    gap: 40px;
}

/* Mobile Header */
.mobile-header {
    display: none;
    width: 100%;
    padding: 8px 12px;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 5px;
}

.mobile-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#mobile-score {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.mobile-stats-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

#next-mobile {
    background: var(--bg-card);
    border-radius: 6px;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.panel-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

/* Mobile Touch Controls */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px;
    width: 100%;
    max-width: 280px;
    margin-top: 5px;
}

.controls-row {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    background: var(--accent);
    color: var(--bg-primary);
    transform: scale(0.95);
}

.control-btn svg {
    width: 28px;
    height: 28px;
}

.control-btn.large {
    width: 72px;
    height: 72px;
}

.control-btn.large svg {
    width: 34px;
    height: 34px;
}

/* Responsive */
@media (max-width: 767px) {
    :root {
        /* Canvas width must be multiple of 10 (COLS) for cells to fill width */
        /* 300px / 10 = 30px cells, height = 600px for 20 rows */
        --canvas-width: 300px;
        --canvas-height: 600px;
    }

    /* Smaller board when opponent is visible (multiplayer)
       NOTE: Removed the `:has()` rule to avoid reserving horizontal space on mobile
       when no opponent is present. Opponent visibility and any dynamic resizing
       should be handled via the `.opponent-container.active` class (and/or JS)
       rather than the parent `:has()` selector so mobile layouts don't keep
       space for a missing opponent. */

    #screen-game {
        padding: 5px;
        justify-content: flex-start;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .mobile-header {
        display: flex;
        flex-shrink: 0;
        margin-bottom: 5px;
    }

    .mobile-controls {
        display: flex;
        flex-shrink: 0;
        margin-top: auto;
        padding: 8px;
        gap: 6px;
    }

    .control-btn {
        width: 60px;
        height: 60px;
    }

    .control-btn.large {
        width: 68px;
        height: 68px;
    }

    /* Mobile game screen layout */
    #screen-game {
        padding: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* Mobile game uses the game-center for the canvas */
    .game-center {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        padding: 5px;
        flex: 1;
        gap: 8px;
        min-height: 0;
        overflow: hidden;
    }

    .game-board-wrapper {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
    }

    #game {
        width: var(--canvas-width);
        height: var(--canvas-height);
        max-height: 100%;
        object-fit: contain;
    }

    /* When opponent is visible (multiplayer/bot), constrain the board
       NOTE: Removed the `:has()`-based rule to prevent the main board from
       shrinking/allocating space when there is no opponent on mobile.
       If needed, apply opponent-driven sizing via the `.opponent-container.active`
       element or via JS that toggles an explicit class on `.game-center`. */

    /* Hide sidebars on mobile */
    .game-sidebar {
        display: none !important;
    }

    .game-layout {
        display: flex;
        flex-direction: column;
        flex: 1;
        padding: 0;
    }

    /* Opponent board on mobile - smaller and beside main board */
    .opponent-container {
        order: 2;
    }

    .opponent-container.active {
        display: flex;
    }

    #opponent-board {
        width: 90px;
        height: 150px;
    }

    .opponent-name {
        font-size: 0.75rem;
    }

    .opponent-score {
        font-size: 0.9rem;
    }

    .panel {
        display: none;
        position: fixed;
        top: 0;
        right: -280px;
        bottom: 0;
        width: 260px;
        max-width: 90vw;
        border-radius: 0;
        z-index: 200;
        overflow-y: auto;
        transition: right 0.3s ease;
    }

    .panel.open {
        display: block;
        right: 0;
    }

    /* Opponent container on mobile */
    .opponent-container {
        order: 2;
    }

    .opponent-container.active {
        display: flex;
    }

    #opponent-board {
        width: 90px;
        height: 150px;
    }

    .opponent-name {
        font-size: 0.75rem;
    }

    .opponent-score {
        font-size: 0.9rem;
    }

    /* Multiplayer lobby responsive */
    .multiplayer-options {
        max-width: 100%;
        padding: 0 1rem;
    }

    .join-room {
        flex-direction: column;
    }

    /* Waiting room responsive */
    .room-code-display {
        font-size: 2rem;
        letter-spacing: 0.3em;
    }

    .players-list {
        min-width: 100%;
        padding: 0 1rem;
    }

    /* Multiplayer results responsive */
    .mp-results-content {
        max-width: 100%;
        padding: 0 1rem;
    }

    /* Garbage indicator mobile */
    .garbage-indicator {
        left: 2px;
        width: 16px;
        height: 150px;
    }

    .garbage-count {
        font-size: 0.65rem;
    }

    /* Emoji panel mobile */
    .emoji-panel {
        max-width: 80px;
    }

    .emoji-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .mp-result-banner .result-icon {
        font-size: 3rem;
    }

    .mp-result-banner h2 {
        font-size: 1.5rem;
    }

    .mp-player-result {
        padding: 0.75rem;
    }

    .mp-player-rank {
        font-size: 1.2rem;
        min-width: 40px;
    }

    .mp-player-name {
        font-size: 1rem;
    }

    .mp-player-score {
        font-size: 1.1rem;
    }

    .mp-results-stats {
        padding: 0.75rem;
    }

    /* Overlay content responsive */
    .overlay-content {
        max-width: 100%;
        padding: 1.5rem;
        margin: 0 1rem;
    }

    .gameover-content {
        max-width: 100%;
    }

    .panel-close {
        display: block;
    }

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

    .panel-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 199;
    }

    .panel-overlay.open {
        display: block;
    }

    .mode-cards {
        padding: 0 10px;
    }

    /* Hide desktop next piece on mobile */
    .panel #next {
        display: none;
    }

    .panel h4:nth-of-type(1) {
        display: none;
    }
}

@media (min-width: 601px) and (max-width: 900px) {
    :root {
        --canvas-width: 360px;
        --canvas-height: 600px;
    }

    .panel {
        max-width: 220px;
    }
}

@media (min-width: 901px) {
    :root {
        --canvas-width: 400px;
        --canvas-height: 667px;
    }

    .panel {
        max-width: 250px;
    }
}

/* ========================
   Update Banner
   ======================== */

.update-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: var(--bg-primary);
    padding: 1rem 1.5rem;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    display: none;
    animation: slideUp 0.3s ease-out;
}

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

.update-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.update-icon {
    font-size: 2rem;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.update-text {
    flex: 1;
}

.update-text strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.update-text p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.update-btn,
.update-dismiss {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.update-btn {
    background: white;
    color: var(--accent);
}

.update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.update-dismiss {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.update-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 600px) {
    .update-content {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .update-text {
        width: 100%;
    }

    .update-btn,
    .update-dismiss {
        flex: 1;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* ========================
   Tournament Screens
   ======================== */

.tournament-container,
.tournament-create-form,
.tournament-bracket-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tournament-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tournament-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    background: var(--bg-card);
    border-radius: 12px;
}

.tournament-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.tournament-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.tournament-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.tournament-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tournament-status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.tournament-status-badge.waiting {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.tournament-status-badge.in_progress {
    background: rgba(34, 211, 238, 0.2);
    color: var(--accent);
}

.tournament-status-badge.completed {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.tournament-item-details {
    display: flex;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tournament-item-details span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Tournament Form */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-input,
.form-select {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.tournament-type-selector {
    display: flex;
    gap: 0.5rem;
}

.tournament-type-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tournament-type-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* Tournament Bracket */
.tournament-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
}

.tournament-round {
    font-weight: 700;
    color: var(--accent);
}

.tournament-players-remaining {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tournament-matches {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tournament-match {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    border: 2px solid transparent;
}

.tournament-match.pending {
    border-color: var(--accent);
}

.tournament-match.completed {
    opacity: 0.7;
}

.tournament-match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.tournament-match-number {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.tournament-match-status {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--accent);
}

.tournament-match-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tournament-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 6px;
}

.tournament-player.winner {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid #4ade80;
}

.tournament-player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.tournament-player-score {
    font-weight: 700;
    color: var(--accent);
}

.tournament-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.tournament-actions .btn {
    flex: 1;
    min-width: 150px;
}

@media (max-width: 600px) {
    .tournament-item-details {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tournament-type-selector {
        flex-direction: column;
    }

    .tournament-status {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .tournament-actions {
        flex-direction: column;
    }

    .tournament-actions .btn {
        width: 100%;
    }
}

/* ========================
   Tournament Enhanced Styles
   ======================== */

/* Tournament screen title styling */
#screen-tournament .menu-title,
#screen-create-tournament .menu-title,
#screen-tournament-bracket .menu-title {
    color: #f59e0b;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

/* Tournament card hover glow effect */
.tournament-item {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.tournament-item:hover {
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(245, 158, 11, 0.2);
}

/* Bracket visualization - connecting lines */
.tournament-matches {
    position: relative;
}

.tournament-match {
    position: relative;
    transition: all 0.2s ease;
}

.tournament-match:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Match connector lines (for bracket feel) */
.tournament-match::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    width: 12px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent));
    opacity: 0.5;
}

.tournament-match:first-child::before {
    display: none;
}

/* Round indicator badge */
.tournament-round {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.1rem;
}

/* Winner styling */
.tournament-player.winner {
    animation: winnerPulse 2s ease-in-out infinite;
}

@keyframes winnerPulse {
    0%,
    100% {
        box-shadow: 0 0 5px rgba(74, 222, 128, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(74, 222, 128, 0.5);
    }
}

.tournament-player.winner .tournament-player-name {
    color: #4ade80;
}

.tournament-player.winner .tournament-player-score {
    color: #4ade80;
}

/* Eliminated player styling */
.tournament-player.eliminated {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Trophy/Winner celebration */
.tournament-winner-banner {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(
        135deg,
        rgba(245, 158, 11, 0.15),
        rgba(234, 179, 8, 0.1)
    );
    border: 2px solid rgba(245, 158, 11, 0.4);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    animation: winnerBannerGlow 3s ease-in-out infinite;
}

@keyframes winnerBannerGlow {
    0%,
    100% {
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
    }
    50% {
        box-shadow: 0 0 40px rgba(245, 158, 11, 0.4);
    }
}

.tournament-winner-banner .trophy-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: trophyBounce 1s ease-in-out infinite;
}

@keyframes trophyBounce {
    0%,
    100% {
        transform: translateY(0) rotate(-5deg);
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

.tournament-winner-banner h3 {
    color: #f59e0b;
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
}

.tournament-winner-banner .winner-name {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status badge animations */
.tournament-status-badge.in_progress {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Match status colors */
.tournament-match.in_progress {
    border-color: #f59e0b;
    background: linear-gradient(
        135deg,
        var(--bg-card),
        rgba(245, 158, 11, 0.05)
    );
}

.tournament-match.in_progress .tournament-match-status {
    color: #f59e0b;
}

/* VS indicator between players */
.tournament-match-players {
    position: relative;
}

.tournament-vs {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    z-index: 1;
}

/* Create tournament form enhancements */
.tournament-create-form .form-group {
    animation: formSlideIn 0.3s ease-out;
    animation-fill-mode: both;
}

.tournament-create-form .form-group:nth-child(1) {
    animation-delay: 0.05s;
}
.tournament-create-form .form-group:nth-child(2) {
    animation-delay: 0.1s;
}
.tournament-create-form .form-group:nth-child(3) {
    animation-delay: 0.15s;
}

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

/* Tournament type button icons */
.tournament-type-btn[data-type="single_elimination"]::before {
    content: "🏆 ";
}

.tournament-type-btn[data-type="round_robin"]::before {
    content: "🔄 ";
}

/* Loading skeleton for tournament list */
.tournament-skeleton {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.tournament-skeleton-line {
    height: 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.tournament-skeleton-line:last-child {
    margin-bottom: 0;
    width: 60%;
}

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

/* Bracket round headers */
.tournament-round-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--bg-card);
}

.tournament-round-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.tournament-round-header .round-badge {
    background: var(--accent);
    color: var(--bg-primary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Final match highlight */
.tournament-match.final {
    border: 2px solid #f59e0b;
    background: linear-gradient(
        135deg,
        var(--bg-card),
        rgba(245, 158, 11, 0.08)
    );
}

.tournament-match.final::after {
    content: "FINAL";
    position: absolute;
    top: -10px;
    right: 1rem;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* Standings table */
.tournament-standings {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.standings-header,
.standings-row {
    display: grid;
    grid-template-columns: 50px 1fr 60px 60px 80px;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    align-items: center;
}

.standings-header {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.standings-row {
    border-bottom: 1px solid var(--bg-secondary);
    transition: background 0.15s;
}

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

.standings-row:hover {
    background: var(--bg-secondary);
}

.standings-rank {
    font-weight: 700;
    color: var(--accent);
}

.standings-rank.gold {
    color: #f59e0b;
}
.standings-rank.silver {
    color: #94a3b8;
}
.standings-rank.bronze {
    color: #cd7f32;
}

.standings-name {
    font-weight: 600;
}

.standings-name.eliminated {
    opacity: 0.5;
    text-decoration: line-through;
}

.standings-wins {
    color: #4ade80;
    font-weight: 600;
}

.standings-losses {
    color: var(--danger);
    font-weight: 600;
}

.standings-score {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Standings overlay */
#standings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    z-index: 100;
    padding: 24px;
    overflow: auto;
}

#standings-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

/* Mobile bracket view improvements */
@media (max-width: 600px) {
    .tournament-match::before {
        display: none;
    }

    .tournament-winner-banner {
        padding: 1.5rem 1rem;
    }

    .tournament-winner-banner .trophy-icon {
        font-size: 3rem;
    }

    .tournament-winner-banner .winner-name {
        font-size: 1.5rem;
    }

    .standings-header,
    .standings-row {
        grid-template-columns: 40px 1fr 50px 50px;
        font-size: 0.85rem;
    }

    .standings-score {
        display: none;
    }
}
