/**
 * Orbit Survival - Mobile-First Arcade Survival Styles
 *
 * @file        styles.css
 * @author      Mike Fairbrother <mike@fairbrother.me>
 * @copyright   2024-2026 Mike Fairbrother. All rights reserved.
 * @license     PROPRIETARY - No rights to copy, modify, distribute, or reuse
 *              any part of this code without explicit written permission from the author.
 */

:root {
    --bg-dark: #0f0c29;
    --bg-mid: #1a1640;
    --text-primary: #fff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --accent: #ffd93d;
    --accent-glow: rgba(255, 217, 61, 0.4);
    --danger: #ff4757;
    --danger-glow: rgba(255, 71, 87, 0.5);
    --success: #2ed573;
    --neon-cyan: #00d2ff;
    --neon-pink: #ff6b9d;
    --neon-purple: #a855f7;
    --fire-a: #ff6b6b;
    --fire-b: #ff9f43;
    --transition-fast: 150ms;
    --transition-normal: 300ms;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* ---- App container ---- */
#app {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    background: linear-gradient(170deg, #1a1640 0%, #0f0c29 40%, #1e1245 100%);
}

/* ---- Screen system ---- */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
}
.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}
.screen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    padding: 40px 24px;
    text-align: center;
    overflow-y: auto;
}

/* ---- Menu Screen ---- */
.game-logo {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.logo-emoji {
    font-size: 42px;
    animation: logo-float 3s ease-in-out infinite;
}
.logo-emoji:nth-child(2) { animation-delay: 0.2s; }
.logo-emoji:nth-child(3) { animation-delay: 0.4s; }
.logo-orbit {
    font-size: 52px;
    animation: logo-spin 4s linear infinite;
}

@keyframes logo-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes logo-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.game-title {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    background: linear-gradient(135deg, #fff 0%, #00d2ff 50%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}
.game-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.menu-best {
    font-size: 18px;
    color: var(--accent);
    margin-bottom: 24px;
    font-weight: 600;
}

/* ---- Settings Row ---- */
.settings-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    align-items: center;
    justify-content: center;
}
.pause-settings {
    margin-top: 20px;
}

/* ---- Footer ---- */
.game-footer {
    margin-top: 16px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.5px;
    font-weight: 500;
    flex-shrink: 0;
}
.game-footer a {
    color: inherit;
    text-decoration: none;
}
.game-footer a:hover {
    text-decoration: underline;
}

/* ---- Buttons ---- */
.btn {
    display: block;
    width: 220px;
    padding: 16px 32px;
    border: none;
    border-radius: 16px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    letter-spacing: 0.5px;
}
.btn:active { transform: scale(0.95); }
.btn-primary {
    background: linear-gradient(135deg, #ffd93d, #ff9f43);
    color: #1a1640;
    box-shadow: 0 4px 20px rgba(255, 217, 61, 0.3);
}
.btn-primary:active { box-shadow: 0 2px 10px rgba(255, 217, 61, 0.2); }
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    margin-top: 12px;
    font-size: 16px;
    padding: 12px 32px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.15); }

/* ---- Game Area ---- */
#screen-game { display: flex; flex-direction: column; }

#game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ---- HUD Overlay ---- */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    padding: 10px 12px 6px;
    gap: 8px;
    min-height: 52px;
    pointer-events: none;
    z-index: 15;
}
#game-hud > * { pointer-events: auto; }

.hud-left, .hud-right {
    flex-shrink: 0;
}
.hud-center {
    flex: 1;
    display: flex;
    justify-content: center;
}
.hud-right {
    display: flex;
    align-items: center;
}

.stat {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.stat-value {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

/* ---- Overlays ---- */
.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.game-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.overlay-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 20px;
}

/* ---- Help Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 20px;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: linear-gradient(170deg, #1e1650, #150f35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.25s ease;
}
.modal-overlay.active .modal-content {
    transform: scale(1);
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 20px;
}
.help-section {
    margin-bottom: 16px;
    text-align: left;
}
.help-section h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--accent);
}
.help-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.help-powerups {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.help-pw {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.help-pw span {
    margin-right: 6px;
}

/* ---- Game Over Screen ---- */
.gameover-title {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #ff4757 50%, #ff9f43 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#new-best-badge {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(255, 217, 61, 0.15);
    padding: 6px 20px;
    border-radius: 20px;
    margin-bottom: 16px;
    animation: badge-pop 0.5s ease-out;
}
@keyframes badge-pop {
    0%  { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
.hidden { display: none !important; }

.final-score-block, .final-best-block { margin-bottom: 6px; }
.final-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.final-value {
    font-size: 52px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.final-value-small {
    font-size: 26px;
    color: var(--text-secondary);
}
.final-stats {
    display: flex;
    gap: 24px;
    margin: 20px 0 16px;
}
.final-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.final-stat-num {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.final-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}
.motivation-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--fire-a);
    margin-bottom: 20px;
    animation: badge-pop 0.5s ease-out 0.3s both;
}

/* ---- Back to Games ---- */
.back-to-games-inline {
    display: inline-block;
    color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    transition: color 150ms, background 150ms;
}
.back-to-games-inline:active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.gameover-back {
    margin-top: 12px;
    margin-bottom: 0;
}

/* ---- Responsive ---- */
@media (min-width: 421px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background: #080620;
    }
    #app {
        border-radius: 24px;
        box-shadow: 0 0 60px rgba(30, 20, 80, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.05);
        max-height: 900px;
    }
}

@supports (padding-top: env(safe-area-inset-top)) {
    #game-hud {
        padding-top: calc(10px + env(safe-area-inset-top));
    }
}
