:root {
    --bg-dark: #090d16;
    --bg-card: rgba(18, 26, 42, 0.75);
    --accent-emerald: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.4);
    --board-bg: #092017;
    --board-border: #1e3a2b;
    --cell-bg: #114230;
    --cell-hover: #195841;
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --modal-bg: rgba(6, 9, 15, 0.85);
    --disc-black-gradient: radial-gradient(circle at 35% 35%, #3a3a3a 0%, #111111 60%, #000000 100%);
    --disc-white-gradient: radial-gradient(circle at 35% 35%, #ffffff 0%, #e2e8f0 60%, #cbd5e1 100%);
    --shadow-disc: 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 4px rgba(0,0,0,0.5);
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: radial-gradient(circle at 50% 20%, #152033 0%, var(--bg-dark) 75%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

#app-wrapper {
    width: 100%;
    max-width: 680px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 8px;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--accent-emerald);
    color: var(--accent-emerald);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
}

#game-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Toast Message */
.toast {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #fca5a5;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* Game Info Dashboard */
#game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.score-card {
    flex: 1;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.score-card.active {
    border-color: var(--accent-emerald);
    box-shadow: 0 0 16px var(--accent-glow);
    transform: translateY(-2px);
}

.player-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.disc-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.disc-icon.black {
    background: var(--disc-black-gradient);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.disc-icon.white {
    background: var(--disc-white-gradient);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.score-val {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-family);
}

.turn-indicator-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}

.turn-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.turn-status {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-emerald);
}

/* Board */
#board-wrapper {
    background: var(--board-bg);
    padding: 10px;
    border-radius: 16px;
    border: 2px solid var(--board-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(16, 185, 129, 0.1);
}

#board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 3px;
    width: 82vmin;
    height: 82vmin;
    max-width: 480px;
    max-height: 480px;
    background-color: var(--board-border);
    border-radius: 8px;
    overflow: hidden;
}

.cell {
    background-color: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background-color 0.2s ease;
    perspective: 1000px;
}

.cell:hover {
    background-color: var(--cell-hover);
}

/* Disc & Flip Animation */
.disc {
    width: 84%;
    height: 84%;
    border-radius: 50%;
    position: relative;
    box-shadow: var(--shadow-disc);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.disc.black {
    background: var(--disc-black-gradient);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.disc.white {
    background: var(--disc-white-gradient);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.disc.flipping {
    transform: rotateY(180deg);
}

/* Valid Move Indicator */
.valid-move-hint {
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse 1.5s infinite ease-in-out;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(0.85);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

/* Buttons & Controls */
.controls {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-family);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 16px;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    backdrop-filter: blur(10px);
}

.glass-panel {
    position: relative;
    z-index: 10;
    background: rgba(20, 30, 48, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.glass-panel.glow {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.25);
}

.glass-panel h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

select {
    width: 100%;
    padding: 12px 14px;
    background: rgba(10, 15, 26, 0.8);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-family);
    outline: none;
}

select:focus {
    border-color: var(--accent-emerald);
}

.final-score-box {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 14px;
    border-radius: 12px;
    margin: 20px 0 24px 0;
    font-size: 1.2rem;
}

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

/* Canvas Fireworks */
#fireworks-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    pointer-events: none;
}

/* Responsive Fixes */
@media (max-width: 480px) {
    #board {
        width: 88vmin;
        height: 88vmin;
    }
    .score-card {
        padding: 8px 12px;
    }
    .player-name {
        font-size: 0.8rem;
    }
    .score-val {
        font-size: 1.2rem;
    }
}
