* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    font-family: 'Inter', system-ui, sans-serif;
    --bg-base: #060b13;
    --panel-dark: rgba(2, 6, 12, 0.9);
    --panel-light: rgba(12, 22, 38, 0.95);
    --accent-cyan: #00eaff;
    --accent-orange: #ff6a00;
    --accent-pink: #ff007b;
    --text-primary: #e0f2fe;
    --text-muted: #64748b;
}

html, body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
    font-family: 'Inter', system-ui, sans-serif;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 234, 255, 0.02) 2px,
            rgba(0, 234, 255, 0.02) 4px
        );
    pointer-events: none;
    z-index: 100;
}

#game-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    background: transparent;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    padding: 40px;
    background: transparent;
    overflow-y: auto;
    z-index: 20;
}

.screen.active {
    display: flex;
}

/* Typography & Titles */
.game-title {
    font-size: 5rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    color: transparent;
    -webkit-text-stroke: 2px var(--accent-cyan);
    margin: 0;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(0, 234, 255, 0.6);
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.8));
}

.subtitle {
    font-size: 1.2rem;
    color: var(--accent-orange);
    letter-spacing: 0.3em;
    margin-bottom: 48px;
    text-shadow: 0 0 10px rgba(255, 106, 0, 0.6);
}

.screen-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    -webkit-text-stroke: 1px var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 234, 255, 0.4);
    margin: 0 0 30px 0;
    letter-spacing: 0.15em;
    border-bottom: 2px solid rgba(0, 234, 255, 0.3);
    padding-bottom: 12px;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.biomass-display {
    font-size: 1.2rem;
    font-weight: 700;
    color: #4ade80;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    background: rgba(74, 222, 128, 0.1);
    padding: 12px 24px;
    border: 1px solid rgba(74, 222, 128, 0.3);
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

/* Menu Content */
.menu-content {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 20;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 320px;
}

/* Buttons (Chamfered minimalist) */
button {
    font: inherit;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.1em;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.nav-btn {
    padding: 20px 30px;
    background: var(--panel-light);
    color: var(--accent-cyan);
    clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
    border-left: 4px solid var(--accent-cyan);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.nav-btn:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 234, 255, 0.5);
}

.nav-btn.back {
    padding: 12px 20px;
    border-left-color: var(--accent-orange);
    color: var(--accent-orange);
}

.nav-btn.back:hover {
    background: var(--accent-orange);
    color: #000;
}

/* Garage Grid */
.garage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.loadout-slot {
    background: var(--panel-dark);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
    border-bottom: 2px solid var(--text-muted);
    cursor: pointer;
}

.loadout-slot:hover {
    background: var(--panel-light);
    border-bottom-color: var(--accent-cyan);
}

.slot-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.slot-item {
    font-size: 1.4rem;
    color: var(--text-primary);
}

/* Mission Grid */
.mission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
    padding-bottom: 40px;
}

.mission-card {
    background: var(--panel-dark);
    padding: 24px;
    text-align: center;
    clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
    border-top: 3px solid var(--accent-orange);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mission-card:hover {
    background: var(--panel-light);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

/* Game Canvas Shell */
#screen-game {
    padding: 0;
    display: flex;
    flex-direction: column;
    background: transparent;
    pointer-events: none;
    overflow: hidden;
    z-index: 20;
}

#canvas-wrap {
    position: fixed;
    inset: 0;
    z-index: 1; /* Above shell, below screens */
    pointer-events: none;
}

#canvas-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.5;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Overlay inside Game */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    pointer-events: auto; /* Ensure clicks are caught */
}

.overlay.hidden {
    display: none;
}

.result-panel {
    background: var(--panel-light);
    padding: 40px;
    text-align: center;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    border-bottom: 4px solid var(--accent-cyan);
}

.result-panel h1 {
    font-size: 2.5rem;
    margin: 0 0 16px;
    color: var(--accent-cyan);
}

.result-panel p {
    font-size: 1.2rem;
    margin: 0 0 32px;
}

/* HUD elements */
/* Minimalist HUD lines matching image */
#controls-hint {
    position: absolute;
    bottom: 30px;
    left: 30px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    font-family: monospace;
    font-size: 13px;
    text-transform: uppercase;
    transition: opacity 1s ease-in-out; /* Added for timed hide */
}

#controls-hint.fade-out {
    opacity: 0;
}

#controls-hint span {
    border: 1px solid rgba(255,255,255,0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    min-width: 24px;
    text-align: center;
}

#hud {
    position: absolute;
    top: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.hud-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.hud-pause {
    width: 20px;
    height: 18px;
    display: flex;
    gap: 4px;
    cursor: pointer;
    pointer-events: auto;
}

.hud-pause::before, .hud-pause::after {
    content: '';
    flex: 1;
    background: #fff;
    border-radius: 1px;
}

.hud-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meter-track {
    width: 140px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 1px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 100%;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(255,255,255,0.5);
    transition: width 0.1s linear;
}

.hud-icons {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.hud-icon {
    width: 14px;
    height: 12px;
    background: rgba(255,255,255,0.6);
}

.hud-icon.sq { clip-path: inset(10% 10% 10% 10%); }
.hud-icon.dm { clip-path: polygon(50% 10%, 90% 50%, 50% 90%, 10% 50%); }
.hud-icon.hx { clip-path: polygon(50% 0%, 90% 25%, 90% 75%, 50% 100%, 10% 75%, 10% 25%); }
.hud-icon.cr { clip-path: polygon(20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%); }

.meter-fill.secondary {
    background: #b1b3b5;
    opacity: 0.8;
}

.hud-score {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: monospace;
    font-size: 24px;
    color: rgba(255,255,255,0.9);
    letter-spacing: 0.25em;
    pointer-events: none;
}

/* Controls Hint - Bottom Left */
#controls-hint {
    position: absolute;
    bottom: 30px;
    left: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    z-index: 50;
    animation: fadeOutControls 2s forwards 6s;
}

@keyframes fadeOutControls {
    to { opacity: 0; visibility: hidden; }
}

#controls-hint .ctrl-row {
    display: flex;
    align-items: center;
    gap: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#controls-hint .key {
    border: 2px solid #ffffff;
    background: rgba(0,0,0,0.4);
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#controls-hint .key.mini {
    min-width: 24px;
    height: 24px;
    font-size: 0.7rem;
    border-width: 1.5px;
}

#controls-hint .key.long {
    padding: 0 12px;
    min-width: 80px;
}

.key-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.key-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.key-row {
    display: flex;
    gap: 2px;
}

#controls-hint .label {
    opacity: 0.9;
    font-weight: 500;
}
