/* ==========================================================================
   Primal Run — native-feeling prehistoric endless runner
   ========================================================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --ink: #0d0f1a;
    --amber: #ffb454;
    --amber-deep: #f5872b;
    --lava: #ff5a36;
    --bone: #f5ede0;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--ink);
    color: var(--bone);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    overscroll-behavior: none;
    position: fixed;
    inset: 0;
}

#game-root {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#game {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.hidden { display: none !important; }

/* --- HUD --- */
#hud {
    position: absolute;
    top: calc(var(--safe-top) + 14px);
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    pointer-events: none;
}

.hud-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}

#score {
    font-size: clamp(40px, 11vw, 72px);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1;
    color: var(--bone);
}

.hud-best {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(245,237,224,0.6);
}
.hud-best em { font-style: normal; color: var(--amber); }

.hud-mult {
    position: absolute;
    top: 8px;
    right: calc(var(--safe-right) + 18px);
    font-size: 28px;
    font-weight: 800;
    color: var(--amber);
    text-shadow: 0 0 18px rgba(255,180,84,0.7);
    transform-origin: center;
    animation: pop 0.3s ease;
}
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.25); } 100% { transform: scale(1); opacity: 1; } }

/* --- Overlays --- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
    background: radial-gradient(120% 120% at 50% 30%, rgba(13,15,26,0.35) 0%, rgba(13,15,26,0.82) 100%);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fade 0.4s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.overlay-inner {
    width: 100%;
    max-width: 420px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.logo-mark {
    font-size: 72px;
    filter: drop-shadow(0 8px 24px rgba(255,90,54,0.4));
    animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }

h1 {
    font-size: clamp(48px, 16vw, 92px);
    font-weight: 900;
    line-height: 0.92;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, var(--bone) 0%, var(--amber) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 6px 40px rgba(255,90,54,0.25);
}
h1 span { display: block; color: var(--amber-deep); -webkit-text-fill-color: initial; }

h2 {
    font-size: clamp(36px, 12vw, 64px);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--bone);
}

.tagline {
    font-size: 15px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(245,237,224,0.65);
    margin-top: -8px;
}

.btn-primary {
    margin-top: 8px;
    min-width: 220px;
    padding: 18px 40px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #1a0f06;
    background: linear-gradient(180deg, var(--amber) 0%, var(--amber-deep) 100%);
    border: none;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(245,135,43,0.45), inset 0 2px 0 rgba(255,255,255,0.4);
    cursor: pointer;
    -webkit-appearance: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-primary:active { transform: scale(0.95); box-shadow: 0 4px 14px rgba(245,135,43,0.4); }

.btn-ghost {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: rgba(245,237,224,0.6);
    padding: 10px 20px;
    border-radius: 999px;
    cursor: pointer;
    background: none;
    border: none;
    -webkit-appearance: none;
}
.btn-ghost:active { color: var(--amber); }

.controls-hint {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 13px;
    color: rgba(245,237,224,0.55);
    line-height: 1.4;
}
.controls-hint b { color: var(--amber); font-weight: 700; }

/* Game over */
.over-badge { font-size: 64px; line-height: 1; }
.over-stats {
    display: flex;
    gap: 36px;
    margin: 4px 0 8px;
}
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; letter-spacing: 0.18em; color: rgba(245,237,224,0.5); }
.stat-value { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--amber); }

#over-title.record {
    background: linear-gradient(180deg, var(--amber) 0%, var(--lava) 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* Pause button */
.btn-pause {
    position: absolute;
    top: calc(var(--safe-top) + 14px);
    right: calc(var(--safe-right) + 16px);
    z-index: 21;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(13,15,26,0.4);
    border: 1px solid rgba(245,237,224,0.18);
    color: var(--bone);
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    -webkit-appearance: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.btn-pause:active { transform: scale(0.92); }
