/* style.css - Questar 3D Cyber Runner */
:root {
    --bg-dark: #070913;
    --card-bg: rgba(16, 22, 38, 0.85);
    --border-cyan: rgba(0, 240, 255, 0.4);
    --cyan-glow: #00f0ff;
    --neon-purple: #b537f2;
    --neon-green: #00ff88;
    --neon-gold: #ffd000;
    --neon-red: #ff3366;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-main);
    color: #ffffff;
    touch-action: none;
}

#game-viewport {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#webgl-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#webgl-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ==========================================================================
   In-Game HUD
   ========================================================================== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
    transition: opacity 0.3s ease;
}

.hud-top-left {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-badge {
    align-self: flex-start;
    padding: 4px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(181, 55, 242, 0.2));
    border: 1px solid var(--border-cyan);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--cyan-glow);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.hud-stats-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.hud-card {
    background: rgba(11, 16, 30, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    min-width: 68px;
}

.hud-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #8899aa;
    font-weight: 600;
}

.hud-val {
    font-size: 17px;
    font-weight: 800;
    font-family: monospace;
    color: #ffffff;
}

.hud-val.highlight {
    color: var(--neon-gold);
    text-shadow: 0 0 10px rgba(255, 208, 0, 0.5);
}

.hud-hearts {
    display: flex;
    gap: 4px;
    font-size: 20px;
    filter: drop-shadow(0 0 6px rgba(255, 51, 102, 0.6));
}

.hud-top-right {
    position: absolute;
    top: 16px;
    right: 16px;
    pointer-events: auto;
    display: flex;
    gap: 8px;
}

.hud-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(11, 16, 30, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.hud-btn:hover {
    border-color: var(--cyan-glow);
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

/* Junction Alert Overlay */
.turn-alert {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(11, 16, 30, 0.9);
    border: 2px solid var(--neon-gold);
    box-shadow: 0 0 25px rgba(255, 208, 0, 0.4);
    border-radius: 16px;
    padding: 12px 24px;
    text-align: center;
    animation: pulse-glow 1.2s infinite alternate;
}

@keyframes pulse-glow {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.04); }
}

.turn-alert-text {
    font-size: 18px;
    font-weight: 800;
    color: var(--neon-gold);
    letter-spacing: 1px;
}

.turn-alert-arrows {
    margin-top: 6px;
    display: flex;
    gap: 12px;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
}

.arrow {
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Touch Controls for iPad & Mobile
   ========================================================================== */
#touch-controls {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 15;
}

#joystick-zone {
    pointer-events: auto;
    width: 140px;
    height: 140px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#joystick-base {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.08) 0%, rgba(10, 20, 35, 0.6) 100%);
    border: 2px solid rgba(0, 240, 255, 0.35);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: none;
}

#joystick-knob {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, #00f0ff 0%, #0088cc 100%);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
    position: absolute;
    transform: translate(0, 0);
    transition: transform 0.05s ease-out;
}

.touch-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    font-weight: 600;
    text-shadow: 0 1px 2px #000;
}

/* Center Quick Turn Buttons */
#turn-buttons-zone {
    pointer-events: auto;
    display: flex;
    gap: 14px;
    margin-bottom: 8px;
}

.touch-btn {
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.08s ease, filter 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.touch-btn:active {
    transform: scale(0.92);
}

.turn-btn {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    background: rgba(16, 24, 45, 0.85);
    border: 2px solid var(--neon-purple);
    box-shadow: 0 0 15px rgba(181, 55, 242, 0.3);
    backdrop-filter: blur(8px);
}

.turn-btn:active {
    background: rgba(181, 55, 242, 0.4);
    box-shadow: 0 0 25px rgba(181, 55, 242, 0.7);
}

.turn-icon {
    font-size: 24px;
    line-height: 1;
}

.turn-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-top: 3px;
    color: var(--neon-purple);
}

/* Right Action Buttons */
#action-buttons-zone {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

.sprint-btn {
    width: 86px;
    height: 42px;
    border-radius: 12px;
    background: rgba(16, 24, 45, 0.85);
    border: 1.5px solid var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.25);
    font-size: 12px;
    font-weight: 800;
    color: var(--neon-green);
    letter-spacing: 0.5px;
}

.sprint-btn.active, .sprint-btn:active {
    background: rgba(0, 255, 136, 0.3);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
}

.jump-btn {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.4) 0%, rgba(10, 30, 60, 0.9) 100%);
    border: 3px solid var(--cyan-glow);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.jump-btn:active {
    background: radial-gradient(circle, rgba(0, 240, 255, 0.8) 0%, rgba(10, 30, 60, 0.9) 100%);
    box-shadow: 0 0 35px rgba(0, 240, 255, 0.9);
}

.jump-icon {
    font-size: 26px;
}

.jump-label {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--cyan-glow);
}

/* ==========================================================================
   Overlays & Dialogs (Start, GameOver, Victory, Pause)
   ========================================================================== */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 16, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 16px;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.screen-overlay.hidden, #hud.hidden, .hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
}

.dialog-box {
    background: var(--card-bg);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 240, 255, 0.15);
    padding: 28px 24px;
    max-width: 580px;
    width: 100%;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.brand-tag {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--neon-purple);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.game-title {
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #ffffff 30%, var(--cyan-glow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.game-subtitle {
    font-size: 14px;
    color: #9ab0c5;
    margin-bottom: 22px;
    line-height: 1.4;
}

/* Mode Selection Grid */
.mode-selection-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

@media (max-width: 540px) {
    .mode-selection-grid {
        grid-template-columns: 1fr;
    }
}

.mode-card {
    background: rgba(20, 30, 55, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.mode-card:hover, .mode-card.selected {
    transform: translateY(-3px);
}

.level-mode-card.selected, .level-mode-card:hover {
    border-color: var(--cyan-glow);
    background: rgba(0, 240, 255, 0.12);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.endless-mode-card.selected, .endless-mode-card:hover {
    border-color: var(--neon-purple);
    background: rgba(181, 55, 242, 0.12);
    box-shadow: 0 0 20px rgba(181, 55, 242, 0.3);
}

.mode-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.mode-name {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 6px;
}

.mode-desc {
    font-size: 12px;
    color: #8fa0b5;
    line-height: 1.35;
    margin-bottom: 12px;
    flex-grow: 1;
}

.mode-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #d0e0ff;
}

/* Controls Guide */
.controls-guide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 22px;
    text-align: left;
    background: rgba(8, 12, 22, 0.6);
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 500px) {
    .controls-guide {
        grid-template-columns: 1fr;
    }
}

.guide-item {
    display: flex;
    flex-direction: column;
}

.guide-key {
    font-size: 11px;
    font-weight: 800;
    color: var(--cyan-glow);
    font-family: monospace;
}

.guide-desc {
    font-size: 12px;
    color: #8da2ba;
}

/* Buttons */
.dialog-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.btn-primary {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, #00f0ff 0%, #0088ff 100%);
    border: none;
    color: #050a15;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.8px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 240, 255, 0.6);
}

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

.btn-secondary {
    width: 100%;
    padding: 12px 18px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
}

.archive-note {
    margin-top: 18px;
    font-size: 11px;
    color: #6d8096;
}

.archive-note code {
    color: var(--cyan-glow);
    background: rgba(0, 240, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Level Grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.level-card-btn {
    background: rgba(18, 26, 46, 0.8);
    border: 2px solid rgba(0, 240, 255, 0.25);
    border-radius: 14px;
    padding: 14px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.15s ease;
    color: #fff;
}

.level-card-btn:hover {
    border-color: var(--cyan-glow);
    background: rgba(0, 240, 255, 0.15);
    transform: translateY(-2px);
}

.level-num {
    font-size: 20px;
    font-weight: 900;
    color: var(--cyan-glow);
}

.level-title {
    font-size: 12px;
    font-weight: 700;
    margin-top: 4px;
}

/* Stats Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.summary-box {
    background: rgba(10, 15, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.stat-lbl {
    font-size: 11px;
    color: #8da2ba;
    text-transform: uppercase;
}

.stat-num {
    font-size: 20px;
    font-weight: 900;
    font-family: monospace;
    margin-top: 4px;
}

.stat-num.gold {
    color: var(--neon-gold);
}

.new-hs-ribbon {
    display: inline-block;
    background: linear-gradient(90deg, #ff007b, #ffd000);
    color: #000;
    font-weight: 900;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(255, 208, 0, 0.6);
}

.victory-ribbon {
    display: inline-block;
    background: linear-gradient(90deg, #00ff88, #00f0ff);
    color: #000;
    font-weight: 900;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
}

.stars-awarded {
    font-size: 34px;
    letter-spacing: 6px;
    margin: 10px 0;
    filter: drop-shadow(0 0 10px rgba(255, 208, 0, 0.6));
}
