/* =========================================================
   STYLE - DUEL CHRONO
   Design premium : Arcade / Cyberpunk / Synthwave
========================================================= */

:root {
    --bg-main: #020617;
    --neon-blue: #0ea5e9;
    --neon-pink: #ec4899;
    --neon-green: #22c55e;
    --neon-red: #ef4444;
    
    --text-main: #f8fafc;
}

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

body {
    font-family: 'Rajdhani', sans-serif;
    background-color: var(--bg-main);
    background-image: 
        linear-gradient(rgba(2, 6, 23, 0.9), rgba(2, 6, 23, 0.7)), 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(14, 165, 233, 0.1) 2px, rgba(14, 165, 233, 0.1) 4px);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent scrolling in game */
}

/* Floating Back Button */
.btn-back {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 5px var(--neon-blue);
    box-shadow: inset 0 0 10px rgba(14, 165, 233, 0.2);
    transition: all 0.3s ease;
}

.btn-back:hover {
    background: rgba(14, 165, 233, 0.2);
    box-shadow: 0 0 15px var(--neon-blue);
}

.app-container {
    width: 100%;
    max-width: 600px; /* Arcade vertical screen style */
    height: 100vh;
    max-height: 900px;
    margin: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

/* Menu Screen */
#menu-screen {
    justify-content: center;
    padding: 2rem;
}

.neon-panel {
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid var(--neon-pink);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 0 30px rgba(236, 72, 153, 0.3), inset 0 0 20px rgba(236, 72, 153, 0.2);
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 15px var(--neon-green));
}

h1.glitch {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--neon-pink),
        0 0 40px var(--neon-pink);
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--neon-blue);
    margin-bottom: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.instructions {
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--neon-blue);
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
    color: #cbd5e1;
}

h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--neon-green);
    text-transform: uppercase;
}

.level-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-level {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--neon-blue);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    text-align: center;
}

.btn-level:hover {
    background: rgba(14, 165, 233, 0.2);
    box-shadow: 0 0 15px var(--neon-blue);
    transform: scale(1.02);
}

.level-name {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.level-desc {
    font-size: 0.95rem;
    color: #94a3b8;
}

/* Game Screen */
.game-hud {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 2px solid var(--neon-blue);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.3);
    z-index: 10;
}

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

.hud-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--neon-blue);
    margin-bottom: 0.2rem;
}

#score-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px var(--neon-blue);
}

.combo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6rem;
    font-weight: 900;
    color: #f472b6;
    text-shadow: 0 0 10px var(--neon-pink);
    transition: transform 0.15s ease;
}

.combo-text.pulse {
    transform: scale(1.3);
    color: #fbbf24;
}

.level-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6rem;
    font-weight: 900;
    color: #4ade80;
    text-shadow: 0 0 10px var(--neon-green);
}

/* Floating Combo Text */
.floating-combo {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 900;
    color: #fbbf24;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.8);
    pointer-events: none;
    z-index: 20;
    animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    50% { transform: translateY(-25px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-50px) scale(0.9); }
}

/* Level Up Banner */
.level-up-banner {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    font-weight: 900;
    color: #38bdf8;
    background: rgba(2, 6, 23, 0.9);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 30px var(--neon-blue);
    padding: 1rem 2rem;
    border-radius: 12px;
    z-index: 30;
    pointer-events: none;
    animation: levelUpPop 1.5s ease-out forwards;
}

@keyframes levelUpPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

#lives-display {
    font-size: 1.5rem;
    letter-spacing: 3px;
}

.life {
    transition: filter 0.3s;
}
.life.lost {
    filter: grayscale(100%) opacity(0.3);
}

#game-canvas {
    flex-grow: 1;
    position: relative;
    background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
    overflow: hidden;
}

/* Falling Asteroid (Math Problem) */
.asteroid {
    position: absolute;
    top: -60px;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.9);
    border: 2px solid var(--neon-pink);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.6);
    text-align: center;
    min-width: 120px;
    white-space: nowrap;
    z-index: 5;
    /* Transition applied via JS frame update for smooth movement, or CSS animation */
}

.asteroid.targeted {
    border-color: var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green);
    color: var(--neon-green);
}

.asteroid.exploding {
    animation: explode 0.3s ease-out forwards;
}

@keyframes explode {
    0% { transform: translateX(-50%) scale(1); opacity: 1; }
    50% { transform: translateX(-50%) scale(1.5); opacity: 0.8; background: var(--neon-green); }
    100% { transform: translateX(-50%) scale(2); opacity: 0; }
}

/* Input Area */
.input-area {
    padding: 0.8rem 1rem 1.6rem 1rem;
    background: rgba(0, 0, 0, 0.95);
    border-top: 2px solid var(--neon-pink);
    box-shadow: 0 -4px 20px rgba(236, 72, 153, 0.3);
    z-index: 10;
    position: relative;
}

#calc-form {
    display: flex;
    gap: 0.75rem;
    height: 52px;
    width: 100%;
}

#answer-input {
    flex: 1 1 0px;
    min-width: 0;
    background: #0f172a;
    border: 2px solid var(--neon-blue);
    border-radius: 8px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    text-align: center;
    outline: none;
    transition: all 0.2s;
}

#answer-input:focus {
    box-shadow: 0 0 15px var(--neon-blue);
}

.btn-fire {
    background: var(--neon-pink);
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    padding: 0 1.2rem;
    cursor: pointer;
    box-shadow: 0 0 15px var(--neon-pink);
    transition: all 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-fire:active {
    transform: scale(0.95);
    background: #be185d;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    backdrop-filter: blur(5px);
}

.overlay.hidden {
    display: none;
}

.game-over-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    color: var(--neon-red);
    text-shadow: 0 0 20px var(--neon-red);
    margin-bottom: 1rem;
    letter-spacing: 5px;
}

#final-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    color: var(--neon-blue);
    font-weight: 700;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
}

/* Hall of Fame */
.hof-section {
    margin-top: 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--neon-blue);
    border-radius: 8px;
    padding: 1rem;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.hof-section h3 {
    font-family: 'Orbitron', sans-serif;
    color: var(--neon-blue);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

#hof-input-area {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#player-name {
    flex-grow: 1;
    background: #020617;
    border: 1px solid var(--neon-pink);
    color: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'Rajdhani', sans-serif;
    outline: none;
}

.hof-list {
    list-style: none;
    padding: 0;
    text-align: left;
    margin-bottom: 1rem;
}

.hof-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(14, 165, 233, 0.2);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
}

.hof-list li:last-child {
    border-bottom: none;
}
.hof-name { color: #f8fafc; }
.hof-score { color: var(--neon-green); font-weight: bold; }

@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
    }
    h1.glitch { font-size: 2.2rem; }
    #answer-input { font-size: 1.5rem; }
    .btn-fire { font-size: 1rem; padding: 0 1rem; }
}

.footer-discreet {
    position: absolute;
    bottom: 3px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 5;
}
