:root {
    --bg-dark: #0a0a0f;
    --bg-light: #1a1a2e;
    --grid-neon: #00f5ff;
    --p1-color: #ff2a2a;
    --p1-glow: #ff2a2a88;
    --p2-color: #2a2aff;
    --p2-glow: #2a2aff88;
    --glass-bg: rgba(20, 20, 35, 0.6);
    --glass-border: rgba(0, 245, 255, 0.2);
    --cell-size: 80px;
    --gap: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-light));
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.game-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Glassmorphism Panels */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.glass-heavy {
    background: rgba(10, 10, 20, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid var(--grid-neon);
    border-radius: 16px;
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.2), inset 0 0 20px rgba(0, 245, 255, 0.1);
}

/* Header & Typography */
header {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.title-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

h1 {
    font-size: 2.5rem;
    letter-spacing: 2px;
    margin: 0;
}

.neon-text {
    color: var(--grid-neon);
    text-shadow: 0 0 10px var(--grid-neon), 0 0 20px var(--grid-neon);
}

.move-counter {
    color: #888;
    font-size: 0.9rem;
    font-family: monospace;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 15px 20px;
    gap: 15px;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

select {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s;
}

select:hover {
    border-color: var(--grid-neon);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background: var(--grid-neon);
    color: black;
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.4);
}

.btn.primary:hover {
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.8);
    transform: translateY(-2px);
}

.btn.secondary {
    background: transparent;
    color: white;
    border: 1px solid white;
}

.btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn.icon {
    font-size: 1.2rem;
    padding: 8px 12px;
    background: transparent;
}

.button-group {
    display: flex;
    gap: 10px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
}

.score-card {
    display: flex;
    align-items: center;
    gap: 15px;
    opacity: 0.5;
    transition: all 0.3s;
}

.score-card.active {
    opacity: 1;
    transform: scale(1.05);
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-info.right {
    align-items: flex-end;
}

.score {
    font-size: 1.5rem;
    font-weight: bold;
}

.turn-indicator {
    text-align: center;
    flex-grow: 1;
}

.ai-thinking {
    font-size: 0.8rem;
    color: #aaa;
    opacity: 0;
    transition: opacity 0.3s;
    height: 15px;
}

.ai-thinking.visible {
    opacity: 1;
}

@keyframes blink { 0% { opacity: .2; } 20% { opacity: 1; } 100% { opacity: .2; } }
.dots span { animation-name: blink; animation-duration: 1.4s; animation-iteration-count: infinite; animation-fill-mode: both; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }

/* 3D Discs */
.disc-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.p1-disc {
    background: radial-gradient(circle at 30% 30%, #ff8888, var(--p1-color) 60%, #880000);
    box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 -4px 8px rgba(0,0,0,0.4), 0 0 15px var(--p1-glow);
}

.p2-disc {
    background: radial-gradient(circle at 30% 30%, #8888ff, var(--p2-color) 60%, #000088);
    box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 -4px 8px rgba(0,0,0,0.4), 0 0 15px var(--p2-glow);
}

/* Board */
.board-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.column-indicators {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--gap);
    margin-bottom: 5px;
    padding: 0 var(--gap);
}

.col-btn {
    height: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255,255,255,0.2);
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.col-btn:hover {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--grid-neon);
}

.board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: var(--gap);
    padding: var(--gap);
    position: relative;
    overflow: hidden;
    /* Determine height based on width ratio in JS/CSS */
    aspect-ratio: 7 / 6;
}

.cell {
    background: var(--bg-dark);
    border-radius: 50%;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.8), inset 0 0 10px var(--glass-border);
    position: relative;
    z-index: 2; /* Cells stay above drops to mask them, but we actually put drops inside cells */
}

.disc {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Animations */
@keyframes drop {
    0% { transform: translateY(-600%); }
    60% { transform: translateY(0); }
    75% { transform: translateY(-25%); }
    90% { transform: translateY(0); }
    95% { transform: translateY(-10%); }
    100% { transform: translateY(0); }
}

.disc.animating {
    animation: drop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.win-pulse {
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% { filter: brightness(1) drop-shadow(0 0 10px currentColor); transform: scale(1); }
    100% { filter: brightness(1.5) drop-shadow(0 0 30px currentColor); transform: scale(1.1); z-index: 10; }
}

.hints {
    text-align: center;
    color: #666;
    font-size: 0.85rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.modal {
    padding: 40px;
    text-align: center;
    transform: translateY(-50px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal h2 {
    font-size: 3rem;
    margin-bottom: 20px;
}

.stats {
    margin-bottom: 30px;
    font-size: 1.2rem;
    color: #aaa;
}

.btn.large {
    font-size: 1.2rem;
    padding: 12px 30px;
}

/* Responsive */
@media (max-width: 600px) {
    .controls { flex-direction: column; align-items: stretch; }
    .button-group { justify-content: space-between; }
    h1 { font-size: 2rem; }
    .score { font-size: 1.2rem; }
    :root { --gap: 5px; }
}