:root {
    --royal-purple: #1a012c;
    --gold-leaf: linear-gradient(180deg, #ffed8a 0%, #ffd700 50%, #b8860b 100%);
    --gem-red: radial-gradient(circle at 35% 35%, #ff5f8d, #b90031);
    --gem-blue: radial-gradient(circle at 35% 35%, #4facfe, #0033cc);
    --board-blue: rgba(30, 60, 150, 0.98); 
    --neon-cyan: #00f2ff;
}

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background: #010005;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    align-items: center; justify-content: center;
}

/* --- DEEP SPACE BACKGROUND --- */
#bg-canvas {
    position: fixed;
    top: 0; left: 0;
    z-index: -3;
}

.nebula-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.nebula {
    position: absolute;
    width: 150%; height: 150%;
    top: -25%; left: -25%;
    background: 
        radial-gradient(circle at 30% 40%, rgba(79, 172, 254, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(185, 0, 49, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(26, 1, 44, 0.2) 0%, transparent 60%);
    filter: blur(80px);
    animation: nebulaRotate 30s linear infinite;
    opacity: 0.4;
}

@keyframes nebulaRotate {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(360deg) scale(1.1); }
}

.grid-floor {
    position: fixed;
    bottom: -20%; left: -50%;
    width: 200%; height: 100%;
    background-image: 
        linear-gradient(rgba(0, 242, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 242, 255, 0.08) 1px, transparent 1px);
    background-size: 80px 80px;
    transform: perspective(600px) rotateX(72deg);
    z-index: -1;
    mask-image: linear-gradient(to top, rgba(0,0,0,1), transparent);
    opacity: 0.3;
}

#menu-screen, #settings-screen {
    position: fixed;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    width: 100%; height: 100%;
    background: rgba(1, 0, 5, 0.88);
    backdrop-filter: blur(25px);
    z-index: 100;
}

#settings-screen { display: none; }

/* --- ABOUT DIALOG --- */
#about-dialog-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center; justify-content: center;
    z-index: 200;
    backdrop-filter: blur(10px);
}

.about-box {
    background: linear-gradient(145deg, #1a012c, #0d0016);
    border: 2px solid #ffd700;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.2);
    max-width: 450px;
    width: 90%;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#about-dialog-overlay.active { display: flex; }
#about-dialog-overlay.active .about-box { transform: scale(1); }

.about-box h2 {
    background: var(--gold-leaf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 25px;
    font-size: 2rem;
    text-transform: uppercase;
}

.about-details {
    color: #eee;
    line-height: 1.8;
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.about-link {
    color: #00f2ff;
    text-decoration: none;
    display: block;
    margin: 10px 0;
    transition: 0.3s;
}

.about-link:hover {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}

.about-link i { margin-right: 10px; width: 20px; }

/* --- GAME CONTAINER --- */
.game-container {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100vw;
    height: 100vh; /* Lock to viewport height */
    padding: 10px;
    box-sizing: border-box;
}

.game-container::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(0, 242, 255, 0.1) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.sparkling-heading {
    /* Adjusted size to take up less vertical space */
    font-size: clamp(1.2rem, 5vh, 2.5rem); 
    margin: 5px 0;
    background: var(--gold-leaf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 8px;
    font-weight: 900;
    text-transform: uppercase;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4));
}

#status, .settings-label {
    font-size: clamp(0.9rem, 2.5vh, 1.2rem);
    color: #ffd700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: bold;
}

/* --- THE BOARD --- */
.board {
    display: grid;
    /* Grid cells scale strictly based on viewport height to ensure fit */
    grid-template-columns: repeat(7, clamp(35px, 8.5vh, 75px)); 
    grid-gap: clamp(8px, 1.5vh, 15px);
    background: var(--board-blue);
    padding: clamp(15px, 3vh, 25px);
    border-radius: 20px;
    position: relative;
    box-shadow: 
        0 0 30px rgba(0, 242, 255, 0.4), 
        0 20px 50px rgba(0,0,0,0.8);
    border: 4px solid var(--neon-cyan);
}

.cell {
    width: clamp(35px, 8.5vh, 75px);
    height: clamp(35px, 8.5vh, 75px);
    background: #030308;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    box-shadow: 
        inset 0 8px 20px rgba(0,0,0,1), 
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.cell.highlight {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 15px var(--neon-cyan), inset 0 0 10px var(--neon-cyan);
}

.token {
    width: 86%; height: 86%;
    margin: 7%;
    border-radius: 50%;
    position: relative;
    animation: dropToken 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    border: 2px solid #fff;
}

.p1-token { 
    background: var(--gem-red); 
    box-shadow: 0 0 25px rgba(255, 20, 100, 0.8), inset 0 -5px 10px rgba(0,0,0,0.6);
}
.p2-token { 
    background: var(--gem-blue); 
    box-shadow: 0 0 25px rgba(0, 242, 255, 0.8), inset 0 -5px 10px rgba(0,0,0,0.6);
}

@keyframes dropToken {
    0% { transform: translateY(-100vh); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.sparkle-win {
    animation: winPulse 0.4s ease-in-out infinite alternate;
    box-shadow: 0 0 50px #fff, 0 0 40px gold !important;
    z-index: 10;
    border: 4px solid #fff;
}

@keyframes winPulse {
    to { transform: scale(1.1); filter: brightness(1.5); }
}

/* --- BUTTONS --- */
.btn {
    background: var(--gold-leaf);
    color: #0d0016;
    border: none;
    padding: clamp(10px, 2vh, 16px) clamp(20px, 4vw, 40px);
    font-size: clamp(0.8rem, 2vh, 1rem);
    font-weight: 800;
    border-radius: 8px;
    cursor: pointer;
    margin: 5px;
    box-shadow: 0 4px 0 #8b6d00;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 280px;
    text-align: center;
}

.btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8b6d00; }

.btn.active-diff {
    outline: 3px solid var(--neon-cyan);
    box-shadow: 0 0 20px var(--neon-cyan);
}

.btn-back {
    background: linear-gradient(180deg, #555 0%, #333 50%, #111 100%);
    color: white;
    box-shadow: 0 4px 0 #000;
}

.game-controls { 
    margin-top: clamp(10px, 3vh, 25px); 
    display: flex; 
    gap: 15px; 
}

.btn-small { 
    padding: clamp(8px, 1.5vh, 12px) 25px; 
    font-size: 0.8rem; 
    width: auto; 
    min-width: 140px; 
}