/* Design System & Variable Tokens */
:root {
    --bg-main: #030611;
    --panel-bg: rgba(6, 11, 26, 0.85);
    --border-color: rgba(0, 240, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --cyan: #00f0ff;
    --cyan-glow: rgba(0, 240, 255, 0.3);
    --green: #00ff66;
    --green-glow: rgba(0, 255, 102, 0.2);
    --magenta: #ff007f;
    --magenta-glow: rgba(255, 0, 127, 0.2);
    --amber: #f59e0b;
    --font-ui: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.font-mono {
    font-family: var(--font-mono);
}

/* CRT Scanlines Filter Overlay */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 3px 100%;
    z-index: 100;
    pointer-events: none;
    opacity: 0.65;
}

.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* Floating HUD Dashboard */
.hud-panel {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 18px;
    z-index: 10;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 240, 255, 0.05);
}

.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

.btn-back {
    color: var(--cyan);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 1px;
    transition: opacity 0.2s;
}

.btn-back:hover {
    opacity: 0.8;
    text-shadow: 0 0 5px var(--cyan);
}

.hud-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.btn-sound {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sound:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.hud-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-container {
    position: relative;
    width: 100%;
    height: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--green), #00ffaa);
    box-shadow: 0 0 10px var(--green-glow);
    transition: width 0.15s ease-out;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    font-weight: bold;
    letter-spacing: 1px;
}

.hud-stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    text-align: center;
}

.mini-stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--cyan);
    text-shadow: 0 0 5px var(--cyan-glow);
}

/* Glassmorphism Overlays */
.overlay-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 4, 10, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
    padding: 20px;
}

.overlay-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 22px 28px;
    text-align: center;
    max-width: 580px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 240, 255, 0.05);
}

.max-w-md { max-width: 450px; }
.max-w-lg { max-width: 750px; }

.glow-text {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffffff 40%, var(--cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.subtitle {
    font-family: var(--font-mono);
    color: var(--cyan);
    font-size: 0.75rem;
    letter-spacing: 3px;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.intro-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 14px;
    text-align: left;
    margin-bottom: 14px;
}

.intro-box p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.intro-instructions {
    list-style: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.intro-instructions code {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    color: var(--cyan);
}

/* Control Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--cyan), #00a8ff);
    border: none;
    color: #000000;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 15px var(--cyan-glow);
    transition: all 0.25s;
    text-transform: uppercase;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.5);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    letter-spacing: 1px;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-secondary:hover {
    border-color: #ffffff;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

/* Scorecard formatting */
.scorecard-panel {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.score-row.border-top {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 10px;
}

.score-val {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--cyan);
}

.button-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Upgrade Card Grid */
.upgrade-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 10px;
}

@media (min-width: 600px) {
    .upgrade-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.upgrade-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.upgrade-card:hover {
    transform: translateY(-4px);
    background: rgba(0, 240, 255, 0.03);
}

/* Color codes for card types */
.card-weapon { border-color: var(--magenta); }
.card-weapon:hover { box-shadow: 0 0 15px var(--magenta-glow); border-color: var(--magenta); }
.card-weapon .card-type { color: var(--magenta); }

.card-passive { border-color: var(--cyan); }
.card-passive:hover { box-shadow: 0 0 15px var(--cyan-glow); border-color: var(--cyan); }
.card-passive .card-type { color: var(--cyan); }

.card-type {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.upgrade-card h3 {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.upgrade-card p {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex-grow: 1;
    margin-bottom: 12px;
}

.card-lvl {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    color: #ffffff;
}

/* Difficulty Selection Cards */
.difficulty-container {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.diff-card {
    background: rgba(10, 15, 30, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 14px;
    width: 100%;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease-in-out;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.diff-card:hover {
    transform: translateY(-2px);
    background: rgba(15, 25, 45, 0.95);
}

/* Easy Card */
.diff-easy {
    border-color: rgba(255, 204, 0, 0.35);
}
.diff-easy:hover {
    border-color: #ffcc00;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.3);
}
.diff-easy .diff-title {
    color: #ffcc00;
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.3);
}

/* Medium Card */
.diff-medium {
    border-color: rgba(0, 240, 255, 0.35);
}
.diff-medium:hover {
    border-color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}
.diff-medium .diff-title {
    color: #00f0ff;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

/* Hard Card */
.diff-hard {
    border-color: rgba(255, 51, 102, 0.35);
}
.diff-hard:hover {
    border-color: #ff3366;
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
}
.diff-hard .diff-title {
    color: #ff3366;
    text-shadow: 0 0 8px rgba(255, 51, 102, 0.3);
}

.diff-title {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.diff-badge {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.diff-easy .diff-badge { background: rgba(255, 204, 0, 0.15); color: #ffcc00; }
.diff-medium .diff-badge { background: rgba(0, 240, 255, 0.15); color: #00f0ff; }
.diff-hard .diff-badge { background: rgba(255, 51, 102, 0.15); color: #ff3366; }

.diff-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    line-height: 1.4;
}

/* Active Selections */
.diff-card.active {
    transform: translateY(-2px);
    background: rgba(15, 25, 45, 0.95);
    border-width: 2px;
}
.diff-easy.active {
    border-color: #ffcc00;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
}
.diff-medium.active {
    border-color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}
.diff-hard.active {
    border-color: #ff3366;
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.4);
}
