/* Stellar Forge: Nucleosynthesis - Style Sheet */
:root {
    --bg-dark: #04060f;
    --primary-cyan: #00e5ff;
    --primary-purple: #9c27b0;
    --accent-gold: #ffd700;
    --accent-orange: #ff6d00;
    --accent-magenta: #ff4081;
    --accent-green: #00e676;
    --text-light: #e0e6ed;
    --text-muted: #8a99ad;
    --glass-bg: rgba(12, 18, 36, 0.75);
    --glass-border: rgba(0, 229, 255, 0.25);
    --font-head: 'Orbitron', 'Noto Sans SC', sans-serif;
    --font-hud: 'Rajdhani', 'Orbitron', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-head);
}

/* Background Cosmos Effect */
.cosmos-bg-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

#cosmos-bg-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.cosmic-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 40%, rgba(3, 5, 12, 0.85) 100%);
}

/* App Container */
.app-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px 16px;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 229, 255, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: var(--primary-cyan);
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

.title-wrap {
    display: flex;
    flex-direction: column;
}

.main-title {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-cyan) 60%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sub-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-gold);
    -webkit-text-fill-color: initial;
    background: rgba(255, 215, 0, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.version-tag {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    font-family: var(--font-hud);
}

.header-right {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: var(--primary-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.hidden {
    display: none !important;
}

/* Main Area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* HUD Bar */
.hud-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.hud-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(0, 229, 255, 0.05);
}

.hud-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 2px;
    font-family: var(--font-hud);
}

.hud-value {
    font-size: 18px;
    font-weight: 900;
    font-family: var(--font-hud);
    letter-spacing: 1px;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.score-box .hud-value { color: var(--primary-cyan); }
.mass-box .hud-value { color: var(--accent-gold); }
.temp-box .hud-value { color: var(--accent-orange); }
.combo-box .hud-value { color: var(--accent-magenta); }
.high-score-box .hud-value { color: var(--accent-green); }

/* Energy Skill Meter */
.supernova-bar-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-cyan);
    font-family: var(--font-hud);
    letter-spacing: 1px;
}

.bar-track {
    position: relative;
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 6px;
    overflow: hidden;
}

.bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-cyan), var(--accent-magenta), var(--accent-gold));
    border-radius: 5px;
    transition: width 0.2s ease-out;
    box-shadow: 0 0 12px var(--primary-cyan);
}

.bar-fill.full {
    animation: barPulse 1s infinite alternate;
}

@keyframes barPulse {
    0% { filter: brightness(1) drop-shadow(0 0 8px #ffd700); }
    100% { filter: brightness(1.4) drop-shadow(0 0 16px #ff00ff); }
}

/* Canvas Viewport */
.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 560px;
    background: #04060f;
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 229, 255, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Overlay Screen */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 15, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 0.3s ease;
}

.overlay-content {
    max-width: 480px;
    width: 90%;
    text-align: center;
    padding: 24px;
    background: rgba(12, 18, 36, 0.9);
    border: 1px solid rgba(0, 229, 255, 0.4);
    border-radius: 18px;
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.cosmic-symbol {
    font-size: 42px;
    filter: drop-shadow(0 0 16px #ffd700);
    animation: floatAnim 3s infinite ease-in-out;
}

@keyframes floatAnim {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.08); }
}

.overlay-title {
    font-size: 22px;
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff, var(--primary-cyan), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overlay-sub {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
}

.overlay-sub b {
    color: var(--primary-cyan);
}

/* Legend items */
.element-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 4px 0;
}

.legend-item {
    font-size: 11px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.elem-dot {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 900;
    font-size: 10px;
    color: #000;
}

.dot-h { background: var(--primary-cyan); }
.dot-he { background: var(--accent-gold); }
.dot-c { background: var(--accent-green); }
.dot-o { background: var(--accent-magenta); }
.dot-fe { background: #ffd700; box-shadow: 0 0 8px #ffd700; }

.overlay-stats {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.stat-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: var(--text-muted);
}

.stat-card strong {
    font-size: 16px;
    color: var(--primary-cyan);
    font-family: var(--font-hud);
}

.btn-glow-primary {
    position: relative;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-head);
    color: #04060f;
    background: linear-gradient(135deg, var(--primary-cyan), var(--accent-gold));
    border: none;
    border-radius: 10px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
    margin-top: 4px;
}

.btn-glow-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.8), 0 0 15px rgba(255, 215, 0, 0.6);
}

.btn-glow-primary:active {
    transform: translateY(0) scale(0.98);
}

/* Mobile Controls */
.mobile-controls-panel {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    margin-top: 4px;
}

.dpad-container {
    position: relative;
    width: 130px;
    height: 130px;
}

.dpad-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 10px;
    color: var(--primary-cyan);
    font-size: 16px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: manipulation;
}

.dpad-btn:active {
    background: rgba(0, 229, 255, 0.4);
    box-shadow: 0 0 12px var(--primary-cyan);
}

.dpad-up { top: 0; left: 44px; }
.dpad-down { bottom: 0; left: 44px; }
.dpad-left { top: 44px; left: 0; }
.dpad-right { top: 44px; right: 0; }
.dpad-center { top: 44px; left: 44px; background: rgba(255, 215, 0, 0.15); border-color: rgba(255, 215, 0, 0.4); color: var(--accent-gold); }

.mobile-skill-wrapper {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.skill-btn-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(224, 64, 251, 0.3), rgba(255, 215, 0, 0.3));
    border: 2px solid var(--accent-magenta);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(224, 64, 251, 0.4);
    transition: all 0.2s;
}

.skill-btn-mobile:active {
    transform: scale(0.92);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
}

.skill-icon { font-size: 26px; }
.skill-text { font-size: 10px; font-weight: 700; font-family: var(--font-hud); margin-top: 2px; }

/* Footer */
.game-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    margin-top: auto;
    font-size: 11px;
    color: var(--text-muted);
}

.key-guide {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.key-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    font-family: var(--font-hud);
    font-weight: 700;
}

.key-separator {
    opacity: 0.3;
}

.footer-copy {
    font-size: 10px;
    opacity: 0.7;
}

/* Media Queries for Mobile Responsive */
@media (max-width: 768px) {
    .hud-bar {
        grid-template-columns: repeat(3, 1fr);
    }
    .high-score-box, .combo-box {
        grid-column: span 1;
    }
    .mobile-controls-panel {
        display: flex;
    }
    .main-title {
        font-size: 16px;
    }
    .sub-badge {
        display: none;
    }
    .canvas-wrapper {
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 480px) {
    .hud-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    .combo-box {
        grid-column: span 2;
    }
    .overlay-title {
        font-size: 18px;
    }
    .overlay-content {
        padding: 16px;
    }
}
