/**
 * Antigravity Chess Platform - Master Stylesheet
 * Dark-mode modern theme, responsive grid, glassmorphism, animated brackets, and interactive widgets.
 */

:root {
    --bg-main: #121417;
    --bg-surface: #1a1e24;
    --bg-surface-elevated: #242a33;
    --bg-card: #202630;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.18);
    --accent-primary: #38bdf8;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-purple: #a855f7;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-surface-elevated);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ================= Top Navigation Header ================= */
.app-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.brand-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.05em;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Main Navigation Tabs */
.nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-main);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.nav-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
    background: var(--accent-primary);
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.action-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-surface-elevated);
}

/* ================= Main Container Layout ================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

.view-section {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.view-section.active {
    display: block;
}

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

/* ================= Chess Game Board Area ================= */
.play-layout {
    display: grid;
    grid-template-columns: minmax(auto, 620px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

.board-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chess-board-wrapper {
    display: flex;
    background: var(--bg-surface);
    padding: 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-main);
    gap: 10px;
}

/* Vertical Evaluation Bar */
.chess-eval-bar {
    width: 22px;
    background: #2b2b2b;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.eval-fill-black {
    background: #1e293b;
    width: 100%;
    transition: height 0.4s ease;
}

.eval-fill-white {
    background: #f8fafc;
    width: 100%;
    transition: height 0.4s ease;
}

.eval-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    font-size: 0.65rem;
    font-weight: 700;
    color: #475569;
    pointer-events: none;
    white-space: nowrap;
}

/* Main Board Grid */
.chess-board-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.player-avatar {
    font-size: 1.3rem;
}

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

.player-rating {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.captured-tray {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 0.5rem;
}

.tray-piece {
    width: 18px;
    height: 18px;
    display: inline-flex;
}

.tray-adv {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-left: 4px;
}

.player-clock {
    background: #0f172a;
    color: #e2e8f0;
    font-family: monospace;
    font-size: 1.15rem;
    font-weight: 700;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.player-clock.active-clock {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
    color: var(--accent-primary);
}

.player-clock.low-time {
    border-color: var(--accent-danger);
    color: var(--accent-danger);
    animation: pulseDanger 1s infinite;
}

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

/* 8x8 Board Grid */
.chess-board-grid {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    user-select: none;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
}

.board-square {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.coord-label {
    position: absolute;
    font-size: 0.65rem;
    font-weight: 700;
    pointer-events: none;
    line-height: 1;
}

.rank-label {
    top: 3px;
    left: 4px;
}

.file-label {
    bottom: 3px;
    right: 4px;
}

/* Pieces */
.board-piece {
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: grab;
    transition: transform 0.1s ease;
}

.board-piece:active {
    cursor: grabbing;
    transform: scale(1.08);
}

.chess-piece-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

/* Move Indicators */
.legal-dot {
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.55);
    pointer-events: none;
    z-index: 5;
    animation: scaleIn 0.15s ease;
}

.capture-ring {
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    border: 5px solid rgba(239, 68, 68, 0.7);
    pointer-events: none;
    z-index: 5;
    animation: scaleIn 0.15s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.check-square {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.9) 0%, rgba(239, 68, 68, 0.4) 60%, transparent 100%) !important;
    animation: pulseCheck 1s infinite;
}

@keyframes pulseCheck {
    0%, 100% { box-shadow: inset 0 0 12px #ef4444; }
    50% { box-shadow: inset 0 0 25px #ef4444; }
}

/* ================= Bottom Controls Bar ================= */
.board-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--bg-surface);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.control-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.control-btn:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.control-btn.primary {
    background: var(--accent-primary);
    color: #0f172a;
    border-color: var(--accent-primary);
}
.control-btn.primary:hover {
    filter: brightness(1.1);
    color: #0f172a;
}

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

/* ================= Sidebar Game Panels ================= */
.sidebar-panel {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 640px;
    box-shadow: var(--shadow-main);
}

.panel-header-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.panel-tab {
    flex: 1;
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-tab:hover {
    color: var(--text-primary);
}

.panel-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.05);
}

.panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem;
    position: relative;
}

.side-tab-content {
    display: none;
    flex-direction: column;
    gap: 0.85rem;
    height: 100%;
}

.side-tab-content.active {
    display: flex;
}

.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.side-selector-chips {
    display: flex;
    gap: 0.5rem;
}

.side-chip {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.side-chip:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.side-chip.active {
    background: var(--accent-primary);
    color: #0f172a;
    border-color: var(--accent-primary);
}

/* Moves Table */
.moves-table-container {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.moves-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.moves-table th {
    background: var(--bg-surface-elevated);
    padding: 0.4rem 0.6rem;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.moves-table td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
}

.moves-table tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

.move-num {
    color: var(--text-muted);
    width: 40px;
}

.move-white, .move-black {
    font-family: monospace;
    font-weight: 600;
}

/* AI Difficulty Selector Cards */
.difficulty-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tier-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tier-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.tier-card.selected {
    border-color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.08);
}

.tier-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.tier-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.tier-rating {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}

/* Hint / Coach Box */
.coach-box {
    background: var(--bg-card);
    border-left: 3px solid var(--accent-primary);
    padding: 0.75rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
    line-height: 1.4;
}

.coach-box h5 {
    color: var(--accent-primary);
    font-size: 0.8rem;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ================= Tournament Hub View ================= */
.tournament-hub {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hub-hero {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-main);
}

.hero-text h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-text p {
    color: var(--text-secondary);
    max-width: 550px;
    font-size: 0.95rem;
}

/* Tournament Preset Cards Grid */
.tournaments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.tourney-preset-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-main);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.tourney-preset-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.tourney-preset-card.beginner::before { background: #22c55e; }
.tourney-preset-card.advanced::before { background: #f59e0b; }
.tourney-preset-card.expert::before { background: #ef4444; }

.tourney-preset-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
}

.preset-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preset-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.preset-badge.beginner { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.preset-badge.advanced { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.preset-badge.expert { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.preset-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.preset-details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preset-details div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ================= Active Tournament Arena ================= */
.active-tournament-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tourney-header-banner {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.tourney-status-chips {
    display: flex;
    gap: 0.75rem;
}

.chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

/* Match Spotlight Card */
.spotlight-card {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(30, 41, 59, 0.4) 100%);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.15);
    flex-wrap: wrap;
    gap: 1rem;
}

.spotlight-match-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.spotlight-player {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.spotlight-vs {
    font-weight: 800;
    color: var(--accent-primary);
    font-size: 1.1rem;
}

/* Visual Tournament Bracket */
.bracket-visualizer-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    overflow-x: auto;
    box-shadow: var(--shadow-main);
}

.bracket-rounds-wrapper {
    display: flex;
    gap: 2rem;
    min-width: 700px;
}

.bracket-round-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    gap: 1.5rem;
}

.bracket-round-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 0.5rem;
}

.bracket-matchup-node {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.bracket-node-player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.bracket-node-player:last-child {
    border-bottom: none;
}

.bracket-node-player.winner {
    background: rgba(34, 197, 94, 0.15);
    font-weight: 700;
    color: #4ade80;
}

.bracket-node-player.user-player {
    border-left: 3px solid var(--accent-primary);
}

/* Standings Leaderboard Table */
.standings-table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-main);
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.standings-table th {
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.standings-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.standings-table tr.user-row {
    background: rgba(56, 189, 248, 0.08);
    font-weight: 600;
}

.medal-icon {
    font-size: 1.1rem;
    margin-right: 4px;
}

/* ================= Academy / Lessons View ================= */
.academy-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.academy-tier-nav {
    display: flex;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.tier-filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tier-filter-btn.active {
    background: var(--accent-primary);
    color: #0f172a;
    border-color: var(--accent-primary);
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.lesson-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-main);
    transition: all 0.2s ease;
}

.lesson-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.lesson-card.completed {
    border-color: rgba(34, 197, 94, 0.4);
}

.lesson-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lesson-type-tag {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-secondary);
}

/* ================= Promotion Modal ================= */
.promotion-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.promotion-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    text-align: center;
    box-shadow: var(--shadow-main);
    max-width: 380px;
    width: 90%;
    animation: scaleIn 0.2s ease;
}

.promotion-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.promotion-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.promotion-pieces {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.promo-piece-btn {
    aspect-ratio: 1 / 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: all 0.2s;
}

.promo-piece-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.08);
}

/* ================= Podium & Certificate ================= */
.podium-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-main);
}

.podium-stages {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    width: 100%;
    max-width: 500px;
}

.podium-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.podium-bar {
    width: 100%;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
}

.podium-col.first .podium-bar { height: 160px; background: linear-gradient(180deg, #facc15 0%, #eab308 100%); }
.podium-col.second .podium-bar { height: 120px; background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 100%); }
.podium-col.third .podium-bar { height: 90px; background: linear-gradient(180deg, #fdba74 0%, #d97706 100%); }

/* Certificate Canvas Modal */
.certificate-preview {
    background: #fff;
    color: #1e293b;
    border: 8px double #d97706;
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-align: center;
    max-width: 650px;
    width: 100%;
    box-shadow: var(--shadow-main);
    margin: 0 auto;
}

.cert-header {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #b45309;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.cert-sub {
    font-size: 0.95rem;
    color: #64748b;
    margin-bottom: 1.5rem;
}

.cert-name {
    font-size: 2rem;
    font-weight: 800;
    color: #0f172a;
    border-bottom: 2px solid #cbd5e1;
    display: inline-block;
    padding: 0 2rem 0.5rem;
    margin-bottom: 1.5rem;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
    .play-layout {
        grid-template-columns: 1fr;
    }
    .sidebar-panel {
        height: auto;
        min-height: 400px;
    }
}

@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    .nav-tabs {
        width: 100%;
        overflow-x: auto;
    }
    .nav-tab-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    .main-content {
        padding: 0.75rem;
    }
    .chess-board-wrapper {
        padding: 6px;
        gap: 6px;
    }
}

/* ================= Fullscreen Mode Styles ================= */
body.is-fullscreen {
    background-color: var(--bg-main);
    overflow: hidden;
}

body.is-fullscreen .app-header {
    padding: 0.4rem 1.25rem;
}

body.is-fullscreen .main-content {
    max-width: 100%;
    padding: 0.5rem 1.5rem;
    height: calc(100vh - 60px);
}

body.is-fullscreen .play-layout {
    height: 100%;
    grid-template-columns: minmax(auto, 680px) 1fr;
    align-items: stretch;
}

body.is-fullscreen .chess-board-wrapper {
    height: 100%;
    padding: 10px;
}

body.is-fullscreen .sidebar-panel {
    height: 100%;
}

