/* ═══════════════════════════════════════════════════
   GOMOKU AI — Premium Dark Mode Glassmorphism Theme
   ═══════════════════════════════════════════════════ */

/* ── Reset & Variables ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --bg-primary: #06060f;
    --bg-secondary: #0c0c1d;
    --bg-tertiary: #12122a;

    --glass-bg: rgba(15, 15, 35, 0.65);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    --accent-cyan: #00e5ff;
    --accent-purple: #7c4dff;
    --accent-pink: #ff4081;
    --accent-green: #00e676;
    --accent-orange: #ff9100;
    --accent-gradient: linear-gradient(135deg, #00e5ff, #7c4dff);

    --text-primary: #e8eaf6;
    --text-secondary: #9fa8c4;
    --text-muted: #5c6484;

    --stone-black: #1a1a2e;
    --stone-black-highlight: #2a2a4e;
    --stone-white: #e8e8f0;
    --stone-white-highlight: #ffffff;

    --board-bg: #dcb35c;
    --board-line: #8b7335;
    --board-grid: rgba(0, 0, 0, 0.45);

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

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ── */
html {
    font-size: 14px;
    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;
    line-height: 1.5;
}

/* ── Background Particles ── */
.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(124, 77, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 229, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(255, 64, 129, 0.04) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-5%, -3%) rotate(3deg); }
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat linear infinite;
    opacity: 0;
}

@keyframes particleFloat {
    0% { opacity: 0; transform: translateY(100vh) scale(0); }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-10vh) scale(1); }
}

/* ── Glass ── */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--glass-shadow);
}

/* ── Header ── */
.header {
    position: relative;
    z-index: 10;
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--glass-border);
    background: rgba(6, 6, 15, 0.85);
    backdrop-filter: blur(20px);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    position: relative;
    width: 40px;
    height: 40px;
}

.logo-stone {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.logo-stone.black {
    top: 0;
    left: 0;
    background: radial-gradient(ellipse at 35% 30%, #444, #111);
}

.logo-stone.white {
    bottom: 0;
    right: 0;
    background: radial-gradient(ellipse at 35% 30%, #fff, #ccc);
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 2px;
    line-height: 1;
}

.logo-text .accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.header-stats {
    display: flex;
    gap: var(--space-sm);
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    font-size: 0.75rem;
}

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

.stat-value {
    color: var(--accent-cyan);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* ── Main Layout ── */
.main-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: var(--space-lg);
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-lg);
    min-height: calc(100vh - 72px);
    align-items: start;
}

/* ── Panels ── */
.panel {
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: sticky;
    top: var(--space-lg);
}

.panel-section {
    margin-bottom: var(--space-lg);
}

.panel-section:last-child {
    margin-bottom: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-title .icon {
    width: 16px;
    height: 16px;
    stroke: var(--accent-cyan);
}

/* ── Info Grid ── */
.info-grid {
    display: grid;
    gap: var(--space-sm);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
}

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

.info-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.black-dot { background: #333; box-shadow: 0 0 4px rgba(0,0,0,0.5); }
.white-dot { background: #eee; box-shadow: 0 0 4px rgba(255,255,255,0.3); }

/* ── Score Board ── */
.score-board {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

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

.score-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--space-xs);
}

.score-number {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.score-item.you .score-number { color: var(--accent-cyan); }
.score-item.ai .score-number { color: var(--accent-purple); }

.score-divider {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 300;
}

.draws-display {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

/* ── Move History ── */
.move-history {
    max-height: 200px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
}

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

.move-history::-webkit-scrollbar-track {
    background: transparent;
}

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

.move-history-empty {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-lg);
    font-style: italic;
    font-family: 'Inter', sans-serif;
}

.move-entry {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 3px var(--space-sm);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

.move-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.move-number {
    color: var(--text-muted);
    min-width: 24px;
}

.move-stone {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.move-stone.black { background: #444; }
.move-stone.white { background: #ddd; }

.move-coord {
    color: var(--text-secondary);
}

/* ── Board Container ── */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.board-wrapper {
    position: relative;
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameBoard {
    cursor: pointer;
    border-radius: var(--radius-md);
    display: block;
}

/* ── Board Overlay ── */
.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 6, 15, 0.5);
    border-radius: var(--radius-xl);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 5;
}

.board-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.ai-thinking {
    text-align: center;
    color: var(--text-primary);
}

.ai-thinking p {
    margin-top: var(--space-md);
    font-size: 0.9rem;
    color: var(--accent-cyan);
    font-weight: 500;
}

/* Spinner */
.thinking-spinner {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto;
}

.spinner-ring {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 50%;
}

.spinner-ring:nth-child(1) {
    width: 60px; height: 60px;
    border-top-color: var(--accent-cyan);
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 45px; height: 45px;
    top: 7.5px; left: 7.5px;
    border-right-color: var(--accent-purple);
    animation: spin 0.8s linear infinite reverse;
}

.spinner-ring:nth-child(3) {
    width: 30px; height: 30px;
    top: 15px; left: 15px;
    border-bottom-color: var(--accent-pink);
    animation: spin 0.6s linear infinite;
}

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

/* ── Controls ── */
.controls {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    outline: none;
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #000;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px rgba(0, 229, 255, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Level Selector ── */
.setting-group {
    margin-bottom: var(--space-lg);
}

.setting-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.level-selector {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.level-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    text-align: left;
}

.level-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.level-btn.active {
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.25);
    color: var(--accent-cyan);
}

.level-num {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', monospace;
    flex-shrink: 0;
}

.level-btn.active .level-num {
    background: rgba(0, 229, 255, 0.2);
    color: var(--accent-cyan);
}

.level-name {
    font-weight: 500;
}

/* ── Color Selector ── */
.color-selector {
    display: flex;
    gap: var(--space-sm);
}

.color-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
}

.color-btn.active {
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.25);
    color: var(--accent-cyan);
}

.color-stone {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.black-stone {
    background: radial-gradient(ellipse at 35% 30%, #555, #111);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.white-stone {
    background: radial-gradient(ellipse at 35% 30%, #fff, #bbb);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── AI Info Card ── */
.ai-info-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-level-badge {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.badge-number {
    font-size: 1.2rem;
    font-weight: 800;
    color: #000;
    font-family: 'JetBrains Mono', monospace;
}

.ai-details h3 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.ai-details p {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.ai-stats {
    margin-top: var(--space-md);
}

.ai-stat {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) 0;
    font-size: 0.72rem;
}

.ai-stat-label { color: var(--text-muted); }
.ai-stat-value {
    color: var(--accent-cyan);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

/* ── How to Play ── */
.how-to-play {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.how-to-play ul {
    margin-top: var(--space-sm);
    padding-left: var(--space-md);
}

.how-to-play li {
    margin-bottom: var(--space-xs);
}

.how-to-play strong {
    color: var(--accent-cyan);
    font-weight: 600;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    text-align: center;
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    min-width: 320px;
    transform: scale(0.9);
    transition: transform var(--transition-smooth);
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: var(--space-md);
    animation: modalBounce 0.6s ease;
}

@keyframes modalBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.modal-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: var(--space-sm);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--space-xl);
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

/* ── Stone placement animation ── */
@keyframes stoneDrop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes stoneGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(0, 229, 255, 0.3); }
    50% { box-shadow: 0 0 15px rgba(0, 229, 255, 0.6); }
}

/* ── Responsive ── */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
        max-width: 700px;
    }

    .panel {
        position: static;
    }

    .panel-left {
        order: 2;
    }

    .board-container {
        order: 1;
    }

    .panel-right {
        order: 3;
    }

    .panel-left, .panel-right {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: var(--space-md);
    }

    .panel-section {
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    html { font-size: 13px; }

    .header-content {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .main-layout {
        padding: var(--space-md);
        gap: var(--space-md);
    }

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

    .controls {
        gap: var(--space-xs);
        padding: var(--space-sm);
    }

    .btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.72rem;
    }

    .panel-left, .panel-right {
        grid-template-columns: 1fr;
    }
}
