/* ========================================
   CSS Variables & Theme
   ======================================== */
:root {
    /* Colors - Dark theme with golden accent */
    --bg-dark: #0a0a1a;
    --bg-darker: #050510;
    --bg-card: rgba(20, 20, 40, 0.8);
    --bg-card-hover: rgba(30, 30, 60, 0.9);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent: #d4af37;
    --accent-light: #f0d060;
    --accent-dark: #b8960a;

    --success: #27ae60;
    --danger: #c0392b;
    --warning: #f39c12;

    /* Board colors */
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --board-highlight: rgba(255, 255, 100, 0.5);
    --board-selected: rgba(100, 200, 100, 0.6);
    --board-legal: rgba(100, 100, 100, 0.3);
    --board-capture: rgba(200, 50, 50, 0.5);
    --board-check: rgba(255, 0, 0, 0.5);

    /* Piece colors */
    --piece-white: #fff;
    --piece-black: #222;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========================================
   Reset & Base Styles
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at top, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(20, 20, 60, 0.3) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
    width: 100%;
    position: relative;
}

/* ========================================
   Screen System
   ======================================== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.screen.active {
    display: flex;
    opacity: 1;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: var(--space-lg);
    text-align: center;
}

/* ========================================
   Logo Section
   ======================================== */
.logo-section {
    margin-bottom: var(--space-xxl);
}

.logo-icon {
    font-size: 80px;
    margin-bottom: var(--space-md);
    animation: float 3s ease-in-out infinite;
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
}

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

.title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ========================================
   Buttons
   ======================================== */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: #ffffff;
    box-shadow: var(--shadow-md), 0 0 20px rgba(248, 113, 113, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(248, 113, 113, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-danger:hover {
    background: #e74c3c;
}

.btn-small {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
}

.btn-icon {
    font-size: 1.25rem;
}

.btn-back {
    position: absolute;
    top: var(--space-lg);
    left: var(--space-lg);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: var(--space-sm);
    transition: color var(--transition-fast);
}

.btn-back:hover {
    color: var(--text-primary);
}

/* ========================================
   Screen Titles
   ======================================== */
.screen-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.screen-subtitle {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

/* ========================================
   Invite Section
   ======================================== */
.invite-section.hidden {
    display: none;
}

.invite-code-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

#invite-code {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    font-family: monospace;
    color: var(--accent);
}

.btn-copy {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-sm);
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.btn-copy:hover {
    opacity: 1;
}

.invite-input-box {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

#invite-input {
    flex: 1;
    padding: var(--space-md);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
    text-transform: uppercase;
    font-family: monospace;
}

#invite-input:focus {
    outline: none;
    border-color: var(--accent);
}

#invite-input::placeholder {
    color: var(--text-muted);
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
}

.error-message.hidden {
    display: none;
}

/* ========================================
   Waiting Indicator
   ======================================== */
.waiting-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

.spinner.large {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

.spinner.small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

/* ========================================
   Matchmaking
   ======================================== */
.matchmaking-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xxl);
}

.matchmaking-status {
    color: var(--text-secondary);
}

.matchmaking-timer {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* ========================================
   Game Screen
   ======================================== */
#game-screen {
    padding: var(--space-md);
}

#game-screen.active {
    display: grid !important;
    grid-template-columns: 1fr minmax(auto, 600px) 320px 1fr;
    grid-template-areas: ". game ad .";
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-md);
    height: 100vh;
    overflow: hidden;
}

.game-container {
    grid-area: game;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    max-height: 100%;
}

/* ========================================
   Player Info
   ======================================== */
.player-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.player-info.active {
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.player-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--bg-darker);
    border-radius: var(--radius-sm);
}

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

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

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

.player-timer {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-darker);
    border-radius: var(--radius-sm);
    min-width: 70px;
    text-align: center;
}

.player-timer.warning {
    color: var(--warning);
}

.player-timer.danger {
    color: var(--danger);
    animation: pulse 0.5s ease-in-out infinite;
}

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

/* ========================================
   Captured Pieces
   ======================================== */
.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    min-height: 24px;
    width: 100%;
    padding: 0 var(--space-sm);
}

.captured-piece {
    font-size: 1rem;
    opacity: 0.7;
}

/* ========================================
   Chess Board
   ======================================== */
.board-container {
    position: relative;
    width: min(90vw, calc(100vh - 280px), 520px);
    aspect-ratio: 1;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.square.light {
    background-color: var(--board-light);
}

.square.dark {
    background-color: var(--board-dark);
}

.square.selected {
    background-color: var(--board-selected) !important;
}

.square.last-move {
    background-color: var(--board-highlight) !important;
}

.square.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: var(--board-legal);
    border-radius: var(--radius-full);
}

.square.legal-capture::after {
    content: '';
    position: absolute;
    width: 90%;
    height: 90%;
    border: 4px solid var(--board-capture);
    border-radius: var(--radius-full);
    background: transparent;
}

.square.check {
    background: var(--board-check) !important;
}

.square.can-move {
    animation: glow 1s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: inset 0 0 10px rgba(100, 200, 100, 0.5); }
    50% { box-shadow: inset 0 0 20px rgba(100, 200, 100, 0.8); }
}

/* Square labels */
.square .file-label {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    font-weight: 600;
    pointer-events: none;
}

.square .rank-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    font-weight: 600;
    pointer-events: none;
}

.square.light .file-label,
.square.light .rank-label {
    color: var(--board-dark);
}

.square.dark .file-label,
.square.dark .rank-label {
    color: var(--board-light);
}

/* ========================================
   Chess Pieces
   ======================================== */
.piece {
    font-size: calc(min(90vw, calc(100vh - 280px), 520px) / 9);
    line-height: 1;
    cursor: grab;
    user-select: none;
    z-index: 1;
    transition: transform var(--transition-normal);
    text-shadow:
        1px 1px 2px rgba(0, 0, 0, 0.5),
        -1px -1px 2px rgba(255, 255, 255, 0.3);
}

.piece.white {
    color: var(--piece-white);
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
}

.piece.black {
    color: var(--piece-black);
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.3));
}

.piece.dragging {
    cursor: grabbing;
    transform: scale(1.2);
    z-index: 100;
}

.piece.moving {
    transition: all var(--transition-normal);
}

.piece.captured {
    animation: capture 0.3s ease-out forwards;
}

@keyframes capture {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); }
    100% { transform: scale(0); opacity: 0; }
}

.piece.promoted {
    animation: promote 0.5s ease-out;
}

@keyframes promote {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); filter: drop-shadow(0 0 20px gold); }
    100% { transform: scale(1); }
}

/* ========================================
   Promotion Modal
   ======================================== */
.promotion-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    border-radius: var(--radius-sm);
}

.promotion-modal.hidden {
    display: none;
}

.promotion-pieces {
    display: flex;
    gap: var(--space-md);
    background: var(--bg-card);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
}

.promotion-piece {
    font-size: 3rem;
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.promotion-piece:hover {
    background: var(--bg-card-hover);
    transform: scale(1.1);
}

/* ========================================
   Game Controls
   ======================================== */
.game-controls {
    display: flex;
    gap: var(--space-md);
    width: 100%;
}

.game-controls .btn {
    flex: 1;
}

/* ========================================
   Game Status
   ======================================== */
.game-status {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease-out;
}

.game-status.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ========================================
   Result Screen
   ======================================== */
.result-box {
    margin-bottom: var(--space-xxl);
}

.result-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.result-title.victory {
    color: var(--accent);
}

.result-title.defeat {
    color: var(--danger);
}

.result-title.draw {
    color: var(--text-secondary);
}

.result-reason {
    color: var(--text-secondary);
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 90%;
    width: 320px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content h3 {
    margin-bottom: var(--space-md);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.modal-buttons {
    display: flex;
    gap: var(--space-md);
}

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

/* ========================================
   Connection Status
   ======================================== */
.connection-status {
    position: fixed;
    top: var(--space-md);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(200, 50, 50, 0.9);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    z-index: 1000;
}

.connection-status.hidden {
    display: none;
}

/* ========================================
   Footer Info
   ======================================== */
.footer-info {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 60px;
    }

    .container {
        padding: var(--space-md);
    }

    .player-info {
        padding: var(--space-xs) var(--space-sm);
    }

    .player-timer {
        font-size: 1rem;
        min-width: 60px;
    }

    .player-avatar {
        width: 32px;
        height: 32px;
        font-size: 1.25rem;
    }
}

@media (min-height: 800px) {
    .game-container {
        gap: var(--space-lg);
    }
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
    display: none !important;
}

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

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

/* ========================================
   Scrollbar Styling
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-card-hover);
}

/* ========================================
   Ad Containers
   ======================================== */
.ad-container {
    width: 100%;
    min-height: 100px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--space-md) 0;
    overflow: hidden;
}

.ad-container ins {
    width: 100%;
}

.ad-home, .ad-lobby, .ad-invite, .ad-result, .ad-friend {
    max-width: 100%;
}

.ad-game {
    grid-area: ad;
    position: static;
    width: 300px;
    min-height: 250px;
    max-height: 600px;
    align-self: center;
    border-radius: var(--radius-md);
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* No padding needed on desktop - ad is beside, not below */
#game-screen .game-container {
    padding-bottom: 0;
}

/* ========================================
   Footer
   ======================================== */
.home-footer {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent);
}

.home-footer p {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ========================================
   Site Header & Navigation
   ======================================== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--space-sm) var(--space-lg);
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--text-primary);
}

.nav-logo .logo-icon {
    font-size: 1.8rem;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    animation: none;
    line-height: 1;
    transform: translateY(3px);
}

.nav-logo .logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    list-style-type: none;
    margin: 0;
    padding: 0;
    gap: var(--space-lg);
}

.nav-links li {
    list-style: none;
    display: flex;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-fast);
}

.nav-links a:hover {
    color: var(--accent);
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0;
    line-height: 1.5;
}

.nav-dropdown-btn:hover {
    color: var(--accent);
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform var(--transition-fast);
}

.nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) 0;
    min-width: 140px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    list-style: none;
    z-index: 1000;
}

.nav-dropdown:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-menu li {
    list-style: none;
}

.nav-dropdown-menu a {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.nav-dropdown-menu a:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent);
}

/* ========================================
   Home Main & Hero Section
   ======================================== */
.home-main {
    padding-top: 60px;
    overflow-y: auto;
    min-height: 100%;
    width: 100%;
}

#home-screen.active {
    display: block !important;
    overflow-y: auto;
    justify-content: flex-start !important;
    align-items: stretch !important;
}

.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xxl);
    align-items: center;
    min-height: calc(100vh - 60px);
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xxl) var(--space-lg);
}

.hero-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 400px;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-md);
    width: 100%;
    max-width: 380px;
}

.hero-actions .btn {
    width: 100%;
    justify-content: center;
}

.btn-large {
    padding: var(--space-md) var(--space-xl);
    font-size: 1.1rem;
}

.hero-visual {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ========================================
   Animated Demo Board
   ======================================== */
.animated-board-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    perspective: 1000px;
}

.demo-board {
    display: grid;
    grid-template-columns: repeat(8, 12.5%);
    grid-template-rows: repeat(8, 12.5%);
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow:
        var(--shadow-lg),
        0 0 60px rgba(212, 175, 55, 0.2);
    transform: rotateX(5deg) rotateY(-5deg);
    transition: transform var(--transition-slow);
}

.demo-board:hover {
    transform: rotateX(0) rotateY(0);
}

.demo-square {
    position: relative;
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
}

.demo-square.light {
    background-color: var(--board-light);
}

.demo-square.dark {
    background-color: var(--board-dark);
}

.demo-piece {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(36px, 7vw, 64px);
    line-height: 1;
    transition: all 0.5s ease-in-out;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.demo-piece.white {
    color: var(--piece-white);
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
}

.demo-piece.black {
    color: var(--piece-black);
}

.demo-piece.moving {
    animation: pieceMove 0.5s ease-in-out;
}

@keyframes pieceMove {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.demo-square.highlight {
    background-color: rgba(212, 175, 55, 0.5) !important;
}

/* ========================================
   Ad Section
   ======================================== */
.ad-section {
    padding: var(--space-lg);
    max-width: 800px;
    margin: 0 auto;
}

/* ========================================
   Features Section
   ======================================== */
.features {
    padding: var(--space-xxl) var(--space-lg);
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: var(--space-xl);
    color: var(--text-primary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
}

.feature-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-normal);
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.feature-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: var(--space-md);
}

.feature-card h3 {
    font-size: 1.1rem;
    margin-bottom: var(--space-sm);
    color: var(--accent);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========================================
   FAQ Section
   ======================================== */
.faq {
    padding: var(--space-xxl) var(--space-lg);
    max-width: 800px;
    margin: 0 auto;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.faq-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.faq-item summary {
    padding: var(--space-lg);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.5rem;
    color: var(--accent);
    transition: transform var(--transition-fast);
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.faq-item p {
    padding: 0 var(--space-lg) var(--space-lg);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ========================================
   Site Footer (Enhanced)
   ======================================== */
.site-footer {
    background: var(--bg-darker);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-md);
}

.footer-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-fast);
}

.footer-nav a:hover {
    color: var(--accent);
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: var(--space-xs);
}

.footer-copyright {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ========================================
   Responsive Design for New Sections
   ======================================== */
@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        text-align: center;
        padding-top: var(--space-xl);
        min-height: auto;
    }

    .hero-content {
        align-items: center;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        max-width: 100%;
    }

    .hero-visual {
        order: -1;
        margin-bottom: var(--space-lg);
    }

    .animated-board-container {
        max-width: 300px;
    }

    .demo-board {
        transform: none;
    }

    /* Game screen mobile layout */
    #game-screen.active {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .game-container {
        max-width: 500px;
    }

    .ad-game {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-height: 60px;
        max-height: 90px;
        border-radius: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 100;
    }

    #game-screen .game-container {
        padding-bottom: 80px;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: var(--space-xs) var(--space-md);
    }

    .nav-logo .logo-text {
        display: none;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .btn-large {
        padding: var(--space-md) var(--space-lg);
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.5rem;
    }
}

/* ========================================
   Difficulty Selector
   ======================================== */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.difficulty-btn {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.difficulty-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateX(4px);
}

.difficulty-btn:active {
    transform: translateX(2px);
}

.diff-icon {
    font-size: 2rem;
    width: 50px;
    text-align: center;
}

.diff-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.diff-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 2px;
}

/* Difficulty level colors on hover */
.difficulty-btn[data-level="1"]:hover { border-color: #22c55e; }
.difficulty-btn[data-level="2"]:hover { border-color: #3b82f6; }
.difficulty-btn[data-level="3"]:hover { border-color: var(--accent); }
.difficulty-btn[data-level="4"]:hover { border-color: #f97316; }
.difficulty-btn[data-level="5"]:hover { border-color: #ef4444; }

@media (max-width: 480px) {
    .difficulty-btn {
        padding: var(--space-sm) var(--space-md);
    }

    .diff-icon {
        font-size: 1.5rem;
        width: 40px;
    }

    .diff-name {
        font-size: 1rem;
    }

    .diff-desc {
        font-size: 0.75rem;
    }
}

/* ========================================
   Puzzle ELO Slider
   ======================================== */
.elo-slider-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.elo-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

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

.elo-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 80px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.elo-slider {
    width: 100%;
    height: 8px;
    border-radius: var(--radius-sm);
    background: linear-gradient(to right,
        #22c55e 0%,
        #3b82f6 25%,
        #d4af37 50%,
        #f97316 75%,
        #ef4444 100%
    );
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.elo-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: 3px solid var(--accent);
    transition: transform var(--transition-fast);
}

.elo-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.elo-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: 3px solid var(--accent);
}

.elo-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ========================================
   Puzzle Info Preview
   ======================================== */
.puzzle-info-preview {
    margin-bottom: var(--space-xl);
}

.puzzle-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-card);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.badge-icon {
    font-size: 1.25rem;
}

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

/* ========================================
   Puzzle Game Screen
   ======================================== */
.puzzle-container {
    max-width: 520px;
}

.puzzle-header {
    width: 100%;
    margin-bottom: var(--space-md);
}

.puzzle-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    background: var(--bg-card);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
}

.puzzle-mate-in {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.puzzle-difficulty-badge {
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ========================================
   Puzzle Status
   ======================================== */
.puzzle-status {
    width: 100%;
    text-align: center;
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin: var(--space-md) 0;
    transition: all var(--transition-fast);
}

.puzzle-status.correct {
    background: rgba(39, 174, 96, 0.2);
    border: 1px solid var(--success);
}

.puzzle-status.wrong {
    background: rgba(192, 57, 43, 0.2);
    border: 1px solid var(--danger);
}

#puzzle-status-text {
    font-weight: 600;
    font-size: 1rem;
}

.puzzle-status.correct #puzzle-status-text {
    color: var(--success);
}

.puzzle-status.wrong #puzzle-status-text {
    color: var(--danger);
}

/* ========================================
   Puzzle Controls
   ======================================== */
.puzzle-controls {
    display: flex;
    gap: var(--space-md);
    width: 100%;
}

.puzzle-controls .btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
}

.puzzle-controls .btn-icon {
    font-size: 1rem;
    margin-right: var(--space-xs);
}

/* ========================================
   Puzzle Result Screen
   ======================================== */
.puzzle-result-box {
    margin-bottom: var(--space-xl);
}

.puzzle-result-box .result-icon {
    font-size: 5rem;
}

.puzzle-result-box .result-title {
    color: var(--success);
}

.puzzle-result-box.failed .result-title {
    color: var(--danger);
}

.puzzle-result-box.failed .result-icon::before {
    content: '😔';
}

.result-rating {
    color: var(--accent);
    font-size: 0.9rem;
    margin-top: var(--space-sm);
}

/* ========================================
   Puzzle Square Highlighting
   ======================================== */
.square.puzzle-hint {
    background-color: rgba(100, 200, 255, 0.5) !important;
    animation: hintPulse 1s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: inset 0 0 10px rgba(100, 200, 255, 0.5); }
    50% { box-shadow: inset 0 0 20px rgba(100, 200, 255, 0.8); }
}

.square.puzzle-correct {
    background-color: rgba(39, 174, 96, 0.5) !important;
}

.square.puzzle-wrong {
    background-color: rgba(192, 57, 43, 0.5) !important;
    animation: wrongShake 0.3s ease-in-out;
}

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

/* ========================================
   Puzzle Screen Layout
   ======================================== */
#puzzle-screen.active {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-md);
}

/* Mobile adjustments for puzzle */
@media (max-width: 480px) {
    .puzzle-info {
        gap: var(--space-md);
        padding: var(--space-sm) var(--space-md);
    }

    .puzzle-mate-in {
        font-size: 1rem;
    }

    .puzzle-controls {
        flex-wrap: wrap;
    }

    .puzzle-controls .btn {
        flex: 1 1 auto;
        min-width: calc(50% - var(--space-sm));
    }

    .elo-slider-container {
        padding: var(--space-lg);
    }

    .elo-value {
        font-size: 1.5rem;
    }
}
