/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    --bg: #0a0a1a;
    --surface: #12122a;
    --surface-light: #1a1a3a;
    --border: #2a2a4a;
    --text: #e8e8f0;
    --text-dim: #8888aa;

    --red: #ff4466;
    --green: #44ff88;
    --cyan: #00e5ff;
    --magenta: #ff44cc;
    --gold: #ffd700;
    --orange: #ff8844;

    --laser-red: #ff1744;
    --laser-glow: #ff4466;
    --mirror-blue: #4488ff;
    --mirror-glow: #6699ff;
    --target-green: #44ff88;
    --target-glow: #66ffaa;
    --emitter-orange: #ff8844;

    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    justify-content: center;
    align-items: center;
}
.screen.active {
    display: flex;
}

/* ===== START SCREEN ===== */
.start-container {
    text-align: center;
    max-width: 520px;
    padding: 2rem;
}

.title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--laser-red), var(--orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.2rem;
}

.title-accent {
    background: linear-gradient(135deg, var(--cyan), var(--mirror-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    margin-bottom: 2rem;
}

/* ===== HIGH SCORE ===== */
.high-score {
    color: var(--gold);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ===== BUTTONS ===== */
.btn {
    font-family: var(--font-display);
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    letter-spacing: 0.05em;
}

.btn:active {
    transform: scale(0.96);
}

.btn-start {
    background: linear-gradient(135deg, var(--laser-red), var(--orange));
    color: #fff;
    font-size: 1.3rem;
    padding: 0.9rem 3rem;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.3);
}

.btn-start:hover {
    box-shadow: 0 0 30px rgba(255, 23, 68, 0.5);
}

.btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--mirror-blue));
    color: #fff;
    font-size: 1rem;
    padding: 0.7rem 2rem;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 1rem;
    padding: 0.7rem 2rem;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    font-size: 1rem;
    padding: 0.7rem 2rem;
}

.btn-danger:hover {
    box-shadow: 0 0 20px rgba(255, 68, 102, 0.3);
}

.btn-pause {
    background: transparent;
    color: var(--text-dim);
    font-size: 1.2rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.btn-pause:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

/* ===== HOW TO PLAY ===== */
.how-to-play {
    margin-top: 2rem;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
}

.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.8rem;
}

.how-to-play ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.how-to-play li {
    font-size: 0.85rem;
    color: var(--text-dim);
    padding-left: 1.2rem;
    position: relative;
}

.how-to-play li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--cyan);
    font-weight: bold;
}

.key-hint { color: var(--cyan); }
.laser-hint { color: var(--laser-red); }
.target-hint { color: var(--target-green); }
.timer-hint { color: var(--gold); }

/* ===== GAME LAYOUT ===== */
.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0.5rem;
}

/* ===== HUD ===== */
.hud {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    padding: 0.6rem 1.5rem;
    width: 600px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.hud-label {
    font-size: 0.6rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.hud-value {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
}

.hud-level { color: var(--magenta); }
.hud-score { color: var(--cyan); }
.hud-moves { color: var(--orange); }
.hud-timer { color: var(--green); }
.hud-timer.warning { color: var(--gold); }
.hud-timer.critical { color: var(--red); animation: pulse 0.5s ease-in-out infinite; }
.hud-best { color: var(--gold); }

.hud-right {
    margin-left: auto;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== CANVAS ===== */
.canvas-wrap {
    position: relative;
    border: 2px solid var(--border);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(255, 23, 68, 0.1), 0 0 60px rgba(0, 229, 255, 0.05);
}

#game-canvas {
    display: block;
    background: var(--bg);
    cursor: pointer;
}

/* ===== COUNTDOWN ===== */
.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 26, 0.85);
    z-index: 10;
}

.countdown-text {
    font-family: var(--font-display);
    font-size: 6rem;
    font-weight: 900;
    color: var(--cyan);
    text-shadow: 0 0 40px var(--cyan);
    animation: countPulse 1s ease-in-out infinite;
}

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

/* ===== LEVEL BANNER ===== */
.level-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--cyan);
    text-shadow: 0 0 30px var(--cyan);
    z-index: 20;
    pointer-events: none;
    animation: bannerFade 1.5s ease-in-out forwards;
}

@keyframes bannerFade {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ===== MODALS ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem 2.5rem;
    text-align: center;
    min-width: 340px;
    max-width: 420px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--cyan), var(--magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
}

.victory-title {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.victory-subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

/* ===== MODAL STATS ===== */
.modal-stats {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
}

.stat-cyan { color: var(--cyan); }
.stat-green { color: var(--green); }
.stat-gold { color: var(--gold); }

/* ===== STAR RATING ===== */
.star-rating {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.star {
    font-size: 2.5rem;
    color: var(--border);
    transition: color 0.3s, text-shadow 0.3s;
}

.star.earned {
    color: var(--gold);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* ===== NEW HIGH SCORE ===== */
.new-high-score {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    margin-bottom: 1.5rem;
    animation: hsGlow 1s ease-in-out infinite alternate;
}

@keyframes hsGlow {
    from { text-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
    to { text-shadow: 0 0 25px rgba(255, 215, 0, 0.7); }
}

/* ===== MODAL BUTTONS ===== */
.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* ===== HIDDEN UTILITY ===== */
.hidden {
    display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .title { font-size: 2.5rem; }
    .hud { width: 100%; padding: 0.5rem 0.8rem; gap: 0.8rem; }
    .canvas-wrap { width: 100%; }
    #game-canvas { width: 100%; height: auto; }
}
