/* ========================================
   ChessMaster - Premium Chess PWA Styles
   Water-themed UI with glassmorphism
   ======================================== */

/* CSS Variables / Design Tokens */
:root {
    /* Core Colors */
    --bg-primary: #060b18;
    --bg-secondary: #0d1529;
    --bg-card: rgba(13, 21, 41, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);

    /* Water Theme Colors */
    --water-100: #caf0f8;
    --water-200: #90e0ef;
    --water-300: #00b4d8;
    --water-400: #0096c7;
    --water-500: #0077b6;
    --water-600: #023e8a;
    --water-700: #03045e;

    /* Accent Colors */
    --accent-cyan: #22d3ee;
    --accent-teal: #2dd4bf;
    --accent-blue: #3b82f6;
    --accent-purple: #a855f7;
    --accent-gold: #fbbf24;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-green: #22c55e;

    /* Text Colors */
    --text-primary: #f0f6ff;
    --text-secondary: #8899b8;
    --text-muted: #4a5e82;
    --text-accent: #22d3ee;

    /* Board Themes */
    --board-light: #b8d4e8;
    --board-dark: #4a7fa5;
    --board-highlight: rgba(34, 211, 238, 0.35);
    --board-selected: rgba(251, 191, 36, 0.45);
    --board-move-dot: rgba(34, 211, 238, 0.7);
    --board-last-move: rgba(168, 85, 247, 0.25);
    --board-check: rgba(239, 68, 68, 0.5);

    /* Sizing */
    --board-size: min(92vw, 420px);
    --square-size: calc(var(--board-size) / 8);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 30px;
    --radius-full: 999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(34, 211, 238, 0.15);
    --shadow-glow-strong: 0 0 50px rgba(34, 211, 238, 0.25);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(0, 119, 182, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(3, 4, 94, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(0, 180, 216, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1;
}

.screen.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.35s ease;
}

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

/* ===== SPLASH SCREEN ===== */
#splash-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #03045e 0%, #0a0e1a 50%, #023e8a 100%);
    z-index: 1000;
}

.splash-content {
    text-align: center;
    z-index: 2;
}

.chess-icon-animated {
    font-size: 80px;
    animation: floatPiece 3s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(34, 211, 238, 0.5));
}

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

.splash-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 900;
    color: var(--text-primary);
    margin-top: 12px;
    letter-spacing: 3px;
}

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

.splash-loader {
    margin-top: 50px;
}

.loader-wave {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.loader-wave span {
    display: inline-block;
    width: 6px;
    height: 30px;
    background: linear-gradient(to top, var(--water-500), var(--accent-cyan));
    border-radius: 3px;
    animation: wave 1.2s ease-in-out infinite;
}

.loader-wave span:nth-child(2) { animation-delay: 0.1s; }
.loader-wave span:nth-child(3) { animation-delay: 0.2s; }
.loader-wave span:nth-child(4) { animation-delay: 0.3s; }
.loader-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 40%, 100% { transform: scaleY(0.4); }
    20% { transform: scaleY(1); }
}

.splash-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 16px;
    letter-spacing: 1px;
}

/* Water Background Animation */
.water-bg-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.bubble {
    position: absolute;
    bottom: -50px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(34, 211, 238, 0.2), rgba(0, 119, 182, 0.08));
    border: 1px solid rgba(34, 211, 238, 0.1);
    animation: bubbleFloat linear infinite;
}

.bubble:nth-child(1) { width: 40px; height: 40px; left: 10%; animation-duration: 8s; animation-delay: 0s; }
.bubble:nth-child(2) { width: 25px; height: 25px; left: 25%; animation-duration: 10s; animation-delay: 1s; }
.bubble:nth-child(3) { width: 55px; height: 55px; left: 40%; animation-duration: 7s; animation-delay: 2s; }
.bubble:nth-child(4) { width: 35px; height: 35px; left: 55%; animation-duration: 9s; animation-delay: 3s; }
.bubble:nth-child(5) { width: 20px; height: 20px; left: 70%; animation-duration: 11s; animation-delay: 1.5s; }
.bubble:nth-child(6) { width: 45px; height: 45px; left: 85%; animation-duration: 8.5s; animation-delay: 2.5s; }
.bubble:nth-child(7) { width: 30px; height: 30px; left: 15%; animation-duration: 9.5s; animation-delay: 4s; }
.bubble:nth-child(8) { width: 50px; height: 50px; left: 65%; animation-duration: 7.5s; animation-delay: 0.5s; }

@keyframes bubbleFloat {
    0% { transform: translateY(0) scale(1); opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { transform: translateY(-110vh) scale(0.4); opacity: 0; }
}

/* ===== WATER BUTTON STYLES ===== */
.water-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    border: none;
    background: linear-gradient(135deg, var(--water-500), var(--water-300), var(--accent-cyan));
    background-size: 200% 200%;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow:
        0 4px 15px rgba(0, 119, 182, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    z-index: 1;
    isolation: isolate;
    gap: 8px;
}

.water-btn:hover {
    background-position: 100% 50%;
    transform: translateY(-2px);
    box-shadow:
        0 8px 30px rgba(0, 180, 216, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 20px rgba(34, 211, 238, 0.2);
}

.water-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow:
        0 2px 10px rgba(0, 119, 182, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Water ripple effect */
.water-effect {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    z-index: -1;
}

.water-effect::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 65%);
    animation: waterShimmer 4s ease-in-out infinite;
}

.water-effect::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 300%;
    height: 15px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120'%3E%3Cpath d='M0,60 C150,90 350,0 600,60 C850,120 1050,30 1200,60 L1200,120 L0,120 Z' fill='rgba(255,255,255,0.08)'/%3E%3C/svg%3E") repeat-x;
    animation: waveMove 3s linear infinite;
}

@keyframes waterShimmer {
    0%, 100% { transform: translate(0, 0) rotate(0deg); opacity: 0.5; }
    33% { transform: translate(15px, -10px) rotate(2deg); opacity: 0.8; }
    66% { transform: translate(-10px, 5px) rotate(-1deg); opacity: 0.6; }
}

@keyframes waveMove {
    from { background-position-x: 0; }
    to { background-position-x: 200px; }
}

/* Ripple click effect */
.ripple-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: rippleExpand 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleExpand {
    to { transform: scale(4); opacity: 0; }
}

/* Water Button Variants */
.water-btn-secondary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.water-btn-secondary:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.water-btn-danger {
    background: linear-gradient(135deg, #b91c1c, #ef4444, #f97316);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.water-btn-danger:hover {
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
}

.water-btn-play {
    width: 100%;
    margin-top: 12px;
    padding: 12px 24px;
    font-size: 13px;
}

/* ===== ICON BUTTON ===== */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--bg-glass);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.icon-btn:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(34, 211, 238, 0.2);
}

.icon-btn:active {
    transform: scale(0.92);
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 10px 20px;
    transition: var(--transition-normal);
}

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

/* ===== HOME SCREEN ===== */
.home-container {
    padding: 16px 20px 30px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 24px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 36px;
    filter: drop-shadow(0 0 15px rgba(34, 211, 238, 0.4));
}

.logo-text h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 2px;
}

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

.tagline {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 2px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: 1px;
}

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

/* ===== MODE CARDS ===== */
.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 32px;
}

.mode-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(34, 211, 238, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mode-card:hover::before {
    opacity: 1;
}

.mode-card:hover {
    border-color: rgba(34, 211, 238, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.mode-card:active {
    transform: translateY(0) scale(0.99);
}

.card-glow {
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.06), transparent 70%);
    pointer-events: none;
}

.card-content {
    position: relative;
    z-index: 1;
}

.mode-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.mode-card h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.mode-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}

.difficulty-badges {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.easy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge.medium {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge.hard {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.feature-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 12px;
    background: rgba(0, 180, 216, 0.12);
    color: var(--water-300);
    border: 1px solid rgba(0, 180, 216, 0.2);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== LEARN CARDS ===== */
.learn-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}

.learn-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.learn-card:hover {
    border-color: rgba(34, 211, 238, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.learn-card:active {
    transform: scale(0.97);
}

.learn-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.learn-card h4 {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.learn-card p {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== STATS BAR ===== */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-cyan), var(--water-200));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal.show {
    display: flex;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: 30px 24px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    animation: modalSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from { transform: translateY(20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 24px;
}

.difficulty-options, .color-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.difficulty-btn, .color-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    text-align: left;
    justify-content: flex-start;
}

.diff-icon, .color-piece {
    font-size: 28px;
}

.dark-piece {
    filter: brightness(0.4);
}

.diff-name, .color-name {
    font-size: 15px;
    font-weight: 700;
    display: block;
}

.diff-desc, .color-desc {
    font-size: 11px;
    opacity: 0.7;
    display: block;
    margin-top: 2px;
}

/* ===== GAME SCREEN ===== */
.game-container {
    padding: 8px 12px 20px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 12px;
}

.game-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
}

.game-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: rgba(34, 211, 238, 0.15);
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Game Menu */
.game-menu {
    position: absolute;
    top: 60px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease;
}

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

.game-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.game-menu button:hover {
    background: var(--bg-glass-hover);
}

/* Player Info */
.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    margin: 6px 0;
}

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

.player-details {
    flex: 1;
}

.player-name {
    font-weight: 600;
    font-size: 14px;
    display: block;
}

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

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    font-size: 14px;
    max-width: 120px;
}

.player-timer {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-cyan);
    min-width: 55px;
    text-align: right;
}

.player-info.active-turn {
    border-color: rgba(34, 211, 238, 0.3);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}

/* ===== CHESS BOARD ===== */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 6px 0;
}

.board-with-coords {
    display: flex;
    align-items: stretch;
}

.board-coordinates-top, .board-coordinates-bottom {
    display: flex;
    justify-content: space-around;
    width: var(--board-size);
    padding: 0 2px;
    margin: 0 auto;
}

.board-coordinates-top span, .board-coordinates-bottom span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--square-size);
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

.board-coordinates-left, .board-coordinates-right {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 16px;
}

.board-coordinates-left span, .board-coordinates-right span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--square-size);
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

.chess-board {
    width: var(--board-size);
    height: var(--board-size);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow:
        var(--shadow-lg),
        0 0 0 2px rgba(255, 255, 255, 0.05);
}

.square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--square-size) * 0.7);
    cursor: pointer;
    position: relative;
    transition: background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

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

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

.square .piece {
    position: relative;
    z-index: 2;
    transition: transform 0.1s ease;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
    line-height: 1;
    pointer-events: none;
}

.square.selected {
    background: var(--board-selected) !important;
    box-shadow: inset 0 0 8px rgba(251, 191, 36, 0.5);
}

.square.legal-move::after {
    content: '';
    position: absolute;
    width: 28%;
    height: 28%;
    background: var(--board-move-dot);
    border-radius: 50%;
    z-index: 3;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.4);
}

.square.legal-capture::after {
    content: '';
    position: absolute;
    width: 85%;
    height: 85%;
    border: 3px solid var(--board-move-dot);
    border-radius: 50%;
    z-index: 3;
}

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

.square.in-check {
    background: var(--board-check) !important;
    animation: checkPulse 1s ease-in-out infinite;
}

@keyframes checkPulse {
    0%, 100% { box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.7); }
}

.square:hover {
    filter: brightness(1.1);
}

/* Hint highlights */
.square.hint-from {
    background: rgba(34, 197, 94, 0.45) !important;
    animation: hintPulse 1s ease-in-out infinite;
    box-shadow: inset 0 0 15px rgba(34, 197, 94, 0.4);
}

.square.hint-to {
    background: rgba(34, 197, 94, 0.35) !important;
    animation: hintPulse 1s ease-in-out infinite 0.2s;
    box-shadow: inset 0 0 15px rgba(34, 197, 94, 0.3);
}

.square.hint-to::before {
    content: '➜';
    position: absolute;
    font-size: calc(var(--square-size) * 0.4);
    color: rgba(34, 197, 94, 0.8);
    z-index: 3;
    animation: hintArrow 1s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: inset 0 0 10px rgba(34, 197, 94, 0.3); }
    50% { box-shadow: inset 0 0 25px rgba(34, 197, 94, 0.6); }
}

@keyframes hintArrow {
    0%, 100% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.square.piece-animating .piece {
    transition: none;
}

/* White pieces - styled */
.piece-white {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Black pieces - styled */
.piece-black {
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Modern piece style */
.pieces-modern .piece-white {
    color: #f8fafc;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 255, 255, 0.1);
}

.pieces-modern .piece-black {
    color: #0f172a;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ===== BOARD THEMES ===== */
/* Ocean Theme (default) */
.theme-ocean .square.light { background: #b8d4e8; }
.theme-ocean .square.dark { background: #4a7fa5; }

/* Forest Theme */
.theme-forest .square.light { background: #b5c99a; }
.theme-forest .square.dark { background: #718355; }

/* Classic Theme */
.theme-classic .square.light { background: #f0d9b5; }
.theme-classic .square.dark { background: #b58863; }

/* Midnight Theme */
.theme-midnight .square.light { background: #7b8794; }
.theme-midnight .square.dark { background: #3d4a5c; }

/* Sunset Theme */
.theme-sunset .square.light { background: #fcd5ce; }
.theme-sunset .square.dark { background: #e8726c; }

/* Theme previews */
.theme-preview {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.ocean-preview { background: linear-gradient(135deg, #b8d4e8 50%, #4a7fa5 50%); }
.forest-preview { background: linear-gradient(135deg, #b5c99a 50%, #718355 50%); }
.classic-preview { background: linear-gradient(135deg, #f0d9b5 50%, #b58863 50%); }
.midnight-preview { background: linear-gradient(135deg, #7b8794 50%, #3d4a5c 50%); }
.sunset-preview { background: linear-gradient(135deg, #fcd5ce 50%, #e8726c 50%); }

/* ===== GAME STATUS ===== */
.game-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 5px var(--accent-cyan); }
    50% { opacity: 0.5; box-shadow: 0 0 15px var(--accent-cyan); }
}

/* ===== GAME CONTROLS ===== */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 8px 0;
}

.control-btn {
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: var(--radius-md);
    font-size: 20px;
}

/* ===== MOVE HISTORY ===== */
.move-history-panel {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 8px;
}

.move-history-panel h4 {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.move-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 80px;
    overflow-y: auto;
    font-size: 12px;
}

.move-list::-webkit-scrollbar {
    width: 4px;
}

.move-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.move-entry {
    display: inline-flex;
    gap: 4px;
    padding: 3px 6px;
    background: var(--bg-glass);
    border-radius: 4px;
    font-family: 'Inter', monospace;
    color: var(--text-secondary);
}

.move-entry .move-number {
    color: var(--text-muted);
    font-weight: 600;
}

.move-entry .white-move {
    color: var(--text-primary);
}

.move-entry .black-move {
    color: var(--accent-cyan);
}

/* ===== PROMOTION MODAL ===== */
.promotion-content {
    padding: 24px;
}

.promotion-pieces {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.promotion-piece-btn {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    background: var(--bg-glass);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.promotion-piece-btn:hover {
    background: rgba(34, 211, 238, 0.15);
    border-color: var(--accent-cyan);
    transform: scale(1.1);
}

/* ===== GAME OVER MODAL ===== */
.gameover-content {
    padding: 32px 24px;
}

.gameover-icon {
    font-size: 64px;
    margin-bottom: 12px;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.gameover-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    margin-bottom: 6px;
}

.gameover-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.gameover-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 24px;
}

.go-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.go-stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-cyan);
}

.go-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== LEARN SCREEN ===== */
.learn-container {
    padding: 8px 16px 30px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.learn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 20px;
}

.learn-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.learn-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.learn-topic {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.learn-topic h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--accent-cyan);
}

.learn-topic h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 14px 0 8px;
    color: var(--text-primary);
}

.learn-topic p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.learn-piece-demo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    margin: 8px 0;
}

.learn-piece-icon {
    font-size: 36px;
}

.learn-piece-info {
    flex: 1;
}

.learn-piece-info strong {
    display: block;
    font-size: 14px;
    margin-bottom: 3px;
}

.learn-piece-info span {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: block;
}

.learn-mini-board {
    display: inline-grid;
    grid-template-columns: repeat(5, 32px);
    grid-template-rows: repeat(5, 32px);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.learn-mini-board .mini-sq {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.learn-mini-board .mini-sq.lt { background: var(--board-light); }
.learn-mini-board .mini-sq.dk { background: var(--board-dark); }
.learn-mini-board .mini-sq.hl { background: rgba(34, 211, 238, 0.4); }

/* ===== SETTINGS SCREEN ===== */
.settings-container {
    padding: 8px 16px 30px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 20px;
}

.settings-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-group {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 18px;
}

.setting-group h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 14px;
    color: var(--text-secondary);
}

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

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 26px;
    cursor: pointer;
    transition: var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: var(--transition-normal);
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--water-500), var(--accent-cyan));
}

input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* Theme Options */
.theme-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: var(--bg-glass);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    color: var(--text-secondary);
    font-size: 11px;
}

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

.theme-btn:hover {
    background: var(--bg-glass-hover);
}

/* Piece Style Options */
.piece-style-options {
    display: flex;
    gap: 10px;
}

.piece-style-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px;
    background: var(--bg-glass);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    color: var(--text-secondary);
    font-size: 12px;
}

.piece-style-btn.active {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.piece-preview {
    font-size: 24px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: var(--bg-glass);
    border-radius: var(--radius-md);
}

.stat-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-cyan);
}

.stat-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* About */
.about-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.copyright {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===== AI THINKING INDICATOR ===== */
.ai-thinking {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 14px;
    background: rgba(34, 211, 238, 0.1);
    border-radius: var(--radius-full);
    margin: 4px auto;
    width: fit-content;
}

.ai-thinking span {
    font-size: 12px;
    color: var(--accent-cyan);
    font-weight: 500;
}

.thinking-dots {
    display: flex;
    gap: 3px;
}

.thinking-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-cyan);
    animation: thinkingDot 1.4s ease-in-out infinite;
    font-style: normal;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingDot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 360px) {
    :root {
        --board-size: min(94vw, 340px);
    }

    .home-container {
        padding: 12px 14px 24px;
    }

    .mode-card {
        padding: 16px;
    }

    .splash-title {
        font-size: 28px;
    }
}

@media (min-width: 768px) {
    :root {
        --board-size: 440px;
    }
}

/* Landscape phone */
@media (max-height: 600px) and (orientation: landscape) {
    :root {
        --board-size: min(70vh, 320px);
    }

    .game-container {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 4px 10px;
    }

    .game-header {
        width: 100%;
    }

    .player-info {
        padding: 6px 10px;
    }

    .move-history-panel {
        display: none;
    }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.glass-card {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ===== PRINT ===== */
@media print {
    body { background: white; color: black; }
    .screen { position: static; }
    .water-btn, .icon-btn, .game-controls, .move-history-panel { display: none; }
}
