:root {
    --abyss: #06031a;
    --abyss-2: #0b0726;
    --cyan: #22d3ee;
    --magenta: #e83d84;
    --gold: #fbbf24;
    --ink: #d7f7ff;
    --font: "Rajdhani", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--abyss);
    color: var(--ink);
    font-family: var(--font);
    touch-action: none;
    overscroll-behavior: none;
}

#gameCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Vignette — subtle darkening at the edges for depth */
#vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    background: radial-gradient(ellipse at center,
        rgba(6, 3, 26, 0) 40%,
        rgba(6, 3, 26, 0.35) 78%,
        rgba(2, 1, 12, 0.85) 100%);
}

/* ---------- Screens ---------- */
.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    transition: opacity 0.35s ease;
}

.screen.hidden {
    display: none;
    opacity: 0;
}

.screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    max-width: 90vw;
}

#startScreen, #gameOverScreen, #landscapeWarning {
    background: radial-gradient(ellipse at center,
        rgba(11, 7, 38, 0.35) 0%,
        rgba(6, 3, 26, 0.82) 70%,
        rgba(3, 1, 14, 0.94) 100%);
    backdrop-filter: blur(2px);
}

/* ---------- Titles ---------- */
.game-title {
    font-size: clamp(3rem, 18vw, 6rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--cyan);
    text-shadow:
        0 0 12px rgba(34, 211, 238, 0.9),
        0 0 42px rgba(34, 211, 238, 0.55),
        0 0 90px rgba(34, 211, 238, 0.3);
    animation: titleGlow 3.5s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 12px rgba(34,211,238,0.9), 0 0 42px rgba(34,211,238,0.55), 0 0 90px rgba(34,211,238,0.3); }
    50% { text-shadow: 0 0 18px rgba(34,211,238,1), 0 0 60px rgba(34,211,238,0.75), 0 0 120px rgba(232,61,132,0.35); }
}

.subtitle {
    font-size: clamp(0.8rem, 4vw, 1.1rem);
    letter-spacing: 0.5em;
    text-indent: 0.5em;
    color: var(--magenta);
    text-shadow: 0 0 16px rgba(232, 61, 132, 0.7);
    margin-top: -8px;
}

.gameover-title {
    font-size: clamp(2rem, 12vw, 3.5rem);
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--magenta);
    text-shadow: 0 0 14px rgba(232, 61, 132, 0.85), 0 0 48px rgba(232, 61, 132, 0.45);
}

/* ---------- Scores ---------- */
.high-score {
    font-size: clamp(0.9rem, 4.5vw, 1.15rem);
    letter-spacing: 0.28em;
    color: var(--ink);
    opacity: 0.85;
}
.high-score span { color: var(--gold); text-shadow: 0 0 12px rgba(251, 191, 36, 0.7); }

.final-score {
    font-size: clamp(1.4rem, 7vw, 2rem);
    letter-spacing: 0.2em;
    color: var(--cyan);
}
.final-score span { color: var(--cyan); text-shadow: 0 0 16px rgba(34,211,238,0.8); }

.final-depth {
    font-size: clamp(0.95rem, 4.5vw, 1.15rem);
    letter-spacing: 0.24em;
    opacity: 0.85;
}
.final-depth span { color: var(--gold); }

.new-high-score {
    font-size: clamp(1rem, 5vw, 1.3rem);
    letter-spacing: 0.3em;
    color: var(--gold);
    text-shadow: 0 0 18px rgba(251, 191, 36, 0.9);
    animation: pulseText 0.7s ease-in-out infinite;
}
.new-high-score.hidden { display: none; }

@keyframes pulseText {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.08); }
}

/* ---------- Buttons ---------- */
.game-button {
    margin-top: 10px;
    padding: 16px 44px;
    font-family: var(--font);
    font-size: clamp(1rem, 5vw, 1.3rem);
    font-weight: 600;
    letter-spacing: 0.22em;
    color: var(--abyss);
    background: var(--cyan);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.6), 0 0 60px rgba(34, 211, 238, 0.25);
    transition: transform 0.12s ease, box-shadow 0.2s ease;
    animation: buttonPulse 2.4s ease-in-out infinite;
}
.game-button:active { transform: scale(0.95); }

@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(34,211,238,0.6), 0 0 60px rgba(34,211,238,0.25); }
    50% { box-shadow: 0 0 30px rgba(34,211,238,0.9), 0 0 90px rgba(34,211,238,0.4); }
}

/* ---------- Camera-angle toggle (menu + HUD) ---------- */
#cameraButton {
    position: fixed;
    z-index: 11;
    right: calc(env(safe-area-inset-right, 0px) + 16px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--ink);
    background: rgba(6, 3, 26, 0.42);
    border: 1px solid rgba(215, 247, 255, 0.28);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.62;
    backdrop-filter: blur(3px);
    transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
#cameraButton:hover { opacity: 0.95; }
#cameraButton:active {
    transform: scale(0.9);
    opacity: 1;
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.55);
    border-color: rgba(34, 211, 238, 0.7);
}
/* A tiny caption of the current preset, to hint what the button does. */
#cameraButton::after {
    content: attr(data-preset);
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink);
    opacity: 0.55;
    pointer-events: none;
}

/* God-mode toggle — sits left of the camera button. */
#godButton {
    position: fixed;
    z-index: 11;
    right: calc(env(safe-area-inset-right, 0px) + 72px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    width: 46px;
    height: 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 0;
    color: var(--ink);
    background: rgba(6, 3, 26, 0.42);
    border: 1px solid rgba(215, 247, 255, 0.28);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.62;
    backdrop-filter: blur(3px);
    transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
#godButton .god-label { font-size: 0.42rem; letter-spacing: 0.12em; opacity: 0.7; }
#godButton:hover { opacity: 0.95; }
#godButton:active { transform: scale(0.9); }
#godButton.on {
    opacity: 1;
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.85);
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.6);
}

/* ---------- HUD ---------- */
#hud {
    z-index: 8;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    pointer-events: none;
    background: none;
    backdrop-filter: none;
}

.hud-score {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 20px);
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(2.4rem, 13vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--cyan);
    text-shadow: 0 0 14px rgba(34, 211, 238, 0.75), 0 0 40px rgba(34, 211, 238, 0.35);
    font-variant-numeric: tabular-nums;
}

.hud-depth {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 22px);
    left: calc(env(safe-area-inset-left, 0px) + 18px);
    font-size: clamp(0.75rem, 3.6vw, 0.95rem);
    letter-spacing: 0.18em;
    color: var(--ink);
    opacity: 0.72;
    font-variant-numeric: tabular-nums;
}

.hud-speed {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 22px);
    right: calc(env(safe-area-inset-right, 0px) + 18px);
    font-size: clamp(0.75rem, 3.6vw, 0.95rem);
    letter-spacing: 0.18em;
    color: var(--gold);
    opacity: 0.85;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
    font-variant-numeric: tabular-nums;
}

/* ---------- Control hint ---------- */
#controlHint {
    z-index: 9;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 18vh;
    pointer-events: none;
    background: none;
    backdrop-filter: none;
    transition: opacity 0.8s ease;
}

.hint-text {
    font-size: clamp(0.9rem, 4.5vw, 1.2rem);
    letter-spacing: 0.3em;
    color: var(--ink);
    opacity: 0.8;
    text-shadow: 0 0 16px rgba(34, 211, 238, 0.5);
    border: 1px solid rgba(34, 211, 238, 0.35);
    border-radius: 999px;
    padding: 10px 26px;
    background: rgba(6, 3, 26, 0.35);
}

#controlHint.fade-out { opacity: 0; }

/* ---------- Landscape warning ---------- */
.rotate-icon {
    font-size: 4rem;
    color: var(--cyan);
    animation: spin 2.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#landscapeWarning p {
    font-size: clamp(1rem, 5vw, 1.4rem);
    letter-spacing: 0.24em;
}

/* ---------- Flash overlay (collision / ring) ---------- */
.flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    background: rgba(232, 61, 132, 0.55);
    mix-blend-mode: screen;
}

/* Floating bonus indicators */
.bonus-pop {
    position: fixed;
    z-index: 7;
    pointer-events: none;
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-shadow: 0 0 12px currentColor;
    transform: translate(-50%, -50%);
    animation: bonusFloat 0.9s ease-out forwards;
}
@keyframes bonusFloat {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(1.1); }
}

/* ---------- AAA polish: HUD juice ---------- */

/* Score punch-scale on bonuses */
.hud-score.punch {
    animation: scorePunch 0.28s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes scorePunch {
    0% { transform: translateX(-50%) scale(1); }
    35% { transform: translateX(-50%) scale(1.22); }
    100% { transform: translateX(-50%) scale(1); }
}

/* Speed multiplier bar under the score */
#multBar {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 20px + clamp(2.9rem, 15vw, 4.6rem));
    left: 50%;
    transform: translateX(-50%);
    width: clamp(90px, 30vw, 150px);
    height: 3px;
    border-radius: 2px;
    background: rgba(215, 247, 255, 0.14);
    overflow: hidden;
}
#multFill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--cyan), var(--gold));
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
    transition: width 0.2s linear;
}

/* Hull pips under the score/mult bar */
.hud-hull {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 20px + clamp(3.5rem, 17.5vw, 5.4rem));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}
.hud-hull .pip {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.85);
    transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.hud-hull .pip.broken {
    background: rgba(215, 247, 255, 0.16);
    box-shadow: none;
    opacity: 0.55;
}
.hud-hull .pip.break { animation: pipBreak 0.45s ease-out; }
.hud-hull .pip.restore { animation: pipRestore 0.55s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pipBreak {
    0% { transform: scale(1.6); background: var(--magenta); box-shadow: 0 0 16px rgba(232, 61, 132, 0.95); }
    100% { transform: scale(1); }
}
@keyframes pipRestore {
    0% { transform: scale(0.2); }
    50% { transform: scale(1.55); box-shadow: 0 0 18px rgba(34, 211, 238, 1); }
    100% { transform: scale(1); }
}

/* Depth milestone popup */
.milestone-pop {
    position: fixed;
    left: 50%;
    top: 30%;
    z-index: 7;
    pointer-events: none;
    font-family: var(--font);
    font-weight: 700;
    font-size: clamp(1.6rem, 8vw, 2.4rem);
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    color: var(--ink);
    text-shadow: 0 0 18px rgba(34, 211, 238, 0.8), 0 0 50px rgba(34, 211, 238, 0.4);
    transform: translate(-50%, -50%);
    animation: milestoneIn 1.35s ease-out forwards;
}
@keyframes milestoneIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); letter-spacing: 0.6em; }
    18% { opacity: 0.95; transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 0.9; }
    100% { opacity: 0; transform: translate(-50%, -62%) scale(0.96); }
}

/* Game-over overlay fade-in for the death sequence */
#gameOverScreen.cine-in {
    animation: goFade 0.6s ease-out;
}
@keyframes goFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
