:root {
    --primary: #3b82f6;
    --accent: #10b981;
    --danger: #ef4444;
    --bg-space: #020617;
    --panel-bg: rgba(15, 23, 42, 0.8);
    --border: rgba(51, 65, 85, 0.5);
    --text: #f8fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-space);
    color: var(--text);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    max-height: 600px;
    position: relative;
    border: 1px solid var(--border);
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 30px rgba(59, 130, 246, 0.1);
}

/* Header */
.game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 50;
    pointer-events: none;
}

.back-btn {
    pointer-events: auto;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s;
}
.back-btn:hover { color: #fff; }

.score-board {
    font-family: 'Outfit', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.8), 0 0 40px rgba(59, 130, 246, 0.4);
    letter-spacing: -0.05em;
    pointer-events: none;
    transition: 0.3s transform;
}

.best-score {
    font-size: 1rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    opacity: 0.8;
}

/* Stage */
#game-stage {
    width: 100%;
    height: 100%;
    position: relative;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD */
#math-hud {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 40;
    pointer-events: none;
}

.question-box {
    background: var(--panel-bg);
    backdrop-filter: blur(8px);
    padding: 1rem 2rem;
    border-radius: 50px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

#question-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 15px rgba(255,255,255,0.3);
}

.input-wrapper input {
    pointer-events: auto;
    width: 120px;
    background: #1e293b;
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1rem;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.8rem;
    text-align: center;
    outline: none;
    transition: 0.2s;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.input-wrapper input:focus {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}

/* Chrome, Safari, Edge, Opera: Remove arrows from number input */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Overlay */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    transition: 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    max-width: 400px;
}

#overlay-title {
    font-family: 'Outfit';
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#overlay-desc {
    color: #94a3b8;
    margin-bottom: 2rem;
}

.btn-start {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-start:hover {
    transform: translateY(-3px);
    background: #2563eb;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.instructions {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.instructions p {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
