/* In-game HUD: score, Focus charge bar, corruption meter, control guide, countdown, toast, banner. */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud[hidden] { display: none; }
.hud-top {
    position: absolute;
    top: 14px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.hud-score-box {
    position: relative;
    padding: 6px 18px 8px 14px;
    background: linear-gradient(90deg, rgba(7, 4, 20, 0.72), rgba(7, 4, 20, 0.2));
}
.hud-label { display: block; font-family: var(--font-m); font-size: 11px; letter-spacing: 0.3em; color: var(--cyan); }
.hud-score {
    display: block;
    font-family: var(--font-b);
    font-weight: 800;
    font-size: clamp(30px, 5.8vw, 48px);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 18px rgba(46, 249, 255, 0.55);
}
/* Focus: five sections, one per level (+4% speed each, +20% at the top). Filled sections are
   reached levels; the next one fills as it charges. --fc is the level color (hud.js). */
.focus {
    --fc: var(--cyan);
    margin-top: 22px;
    padding: 7px 12px 9px;
    border-radius: 10px;
    background: rgba(7, 4, 20, 0.66);
    border: 1px solid var(--line-soft);
    backdrop-filter: blur(6px);
    font-family: var(--font-m);
}
.focus-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.focus .hud-label { color: var(--fc); }
.focus-speed { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.focus.on .focus-speed { color: var(--text); text-shadow: 0 0 10px var(--fc); }
.focus-bar { display: flex; gap: 4px; margin-top: 6px; }
.focus-seg {
    flex: 1;
    height: 10px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.focus-seg i {
    display: block;
    height: 100%;
    background: var(--fc);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.15s linear;
}
.focus-seg.full { border-color: var(--fc); box-shadow: 0 0 8px var(--fc); }
.focus-seg.charging i { opacity: 0.55; }

/* Top centre column: the corruption meter with the Focus bar directly under it. */
.hud-center {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: min(340px, 34vw);
}
/* Speed bar under the Focus bar: 0-12x, with a mark at 10x (top base speed). */
.speedo {
    margin-top: 8px;
    padding: 7px 12px 9px;
    border-radius: 10px;
    background: rgba(7, 4, 20, 0.66);
    border: 1px solid var(--line-soft);
    backdrop-filter: blur(6px);
    font-family: var(--font-m);
}
.speedo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.speedo .hud-label { color: #ffd257; }
.speedo-val {
    font-family: var(--font-b);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 12px rgba(255, 210, 87, 0.7);
}
.speedo-bar { position: relative; height: 10px; margin-top: 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.speedo-bar::after { content: ''; position: absolute; top: 0; bottom: 0; left: 83.3%; width: 2px; background: rgba(255, 255, 255, 0.6); }
.speedo-fill {
    height: 100%;
    width: 100%;
    transform-origin: left;
    transform: scaleX(0.167);
    background: linear-gradient(90deg, var(--cyan), #ffd257 60%, #ff5ce1);
    transition: transform 0.12s linear;
}
/* Corruption meter: full bar = far away. Threshold marks at --warn and --crit. */
.danger {
    position: relative;
    padding: 7px 12px 8px;
    border-radius: 10px;
    background: rgba(7, 4, 20, 0.66);
    border: 1px solid var(--line-soft);
    backdrop-filter: blur(6px);
}
.danger-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.danger .hud-label { color: #ff5c8a; }
.danger-state { display: flex; align-items: center; gap: 6px; font-family: var(--font-m); font-size: 13px; font-weight: 700; letter-spacing: 0.12em; }
.danger-ico { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; }
.danger-bar { position: relative; height: 8px; margin-top: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.danger-bar::before, .danger-bar::after { content: ''; position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.55); z-index: 1; }
.danger-bar::before { left: var(--warn, 46%); }
.danger-bar::after { left: var(--crit, 23%); }
.danger-fill { height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, #ff2a55, #ffc23d 40%, var(--cyan)); transition: transform 0.12s linear; }
.danger-dist { position: absolute; right: 12px; bottom: -18px; font-size: 11px; color: var(--muted); }
.danger[data-level="safe"] .danger-state { color: var(--cyan); }
.danger[data-level="near"] .danger-state { color: var(--amber); }
.danger[data-level="near"] .danger-ico { border-radius: 2px; transform: rotate(45deg); }
.danger[data-level="crit"] { border-color: #ff2a55; box-shadow: 0 0 18px rgba(255, 42, 85, 0.45); }
.danger[data-level="crit"] .danger-state { color: #ff5c8a; }
.danger[data-level="crit"] .danger-ico { border: 0; border-radius: 0; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid currentColor; }
body.danger-crit:not(.reduced) .danger { animation: dangerPulse 1.1s ease-in-out infinite; }
@keyframes dangerPulse { 50% { box-shadow: 0 0 26px rgba(255, 42, 85, 0.7); } }

/* Control guide: compact key reminder at the bottom while running. */
#ctrlGuide {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    gap: 18px;
    padding: 7px 14px;
    border-radius: 12px;
    background: rgba(7, 4, 20, 0.55);
    border: 1px solid var(--line-soft);
    font-family: var(--font-m);
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--muted);
    white-space: nowrap;
}
.cg-item { display: inline-flex; align-items: center; gap: 7px; }
.cg-keys { display: inline-flex; align-items: center; gap: 3px; }
.cg-keys kbd { font-size: 11px; padding: 1px 6px; }
.cg-keys .sep, .cg-keys .or { opacity: 0.55; margin: 0 2px; }
.cg-label { text-transform: uppercase; color: var(--text); }


#countdown {
    position: fixed;
    inset: 0;
    z-index: 9;
    display: grid;
    place-items: center;
    pointer-events: none;
    font-family: var(--font-d);
    font-weight: 900;
    font-size: clamp(80px, 22vw, 160px);
    color: var(--cyan);
    text-shadow: 0 0 30px rgba(46, 249, 255, 0.7), 0 0 80px rgba(176, 77, 255, 0.5);
}
#countdown[hidden] { display: none; }
#countdown.tick { animation: cd 0.5s ease-out; }

/* The big RUN at the top of the screen when a run starts (intro.js). */
#runCall {
    position: fixed;
    z-index: 9;
    top: 8%;
    left: 0;
    right: 0;
    text-align: center;
    pointer-events: none;
    font-family: var(--font-d);
    font-weight: 900;
    font-size: clamp(72px, 17vw, 190px);
    letter-spacing: 0.14em;
    color: var(--theme-accent, var(--cyan));
    text-shadow: 0 0 30px var(--theme-accent, rgba(46, 249, 255, 0.7)), 0 0 90px rgba(176, 77, 255, 0.5);
    opacity: 0;
}
#runCall.show { animation: runcall 1.2s ease-out forwards; }
body.reduced #runCall.show { animation-name: runcall-fade; }
@keyframes runcall {
    0% { opacity: 0; transform: scale(1.9); }
    14% { opacity: 1; transform: scale(1); }
    70% { opacity: 1; transform: scale(1.03); }
    100% { opacity: 0; transform: translateY(-14px) scale(1.06); }
}
@keyframes runcall-fade { 0% { opacity: 0; } 14%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cd { from { transform: scale(1.6); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); } }

#banner {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-d);
    font-weight: 800;
    font-size: clamp(18px, 4vw, 30px);
    letter-spacing: 0.2em;
    white-space: nowrap;
    color: var(--text);
    text-shadow: 0 0 20px var(--violet), 0 0 4px #000;
    opacity: 0;
}
#banner.show { animation: banner 1.6s ease-out forwards; }
@keyframes banner {
    0% { opacity: 0; transform: translate(-50%, 12px) scale(0.9); letter-spacing: 0.6em; }
    15% { opacity: 1; transform: translate(-50%, 0) scale(1); letter-spacing: 0.2em; }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -10px); }
}
body.reduced #banner.show { opacity: 1; }

/* --zone follows the current zone color. */
:root { --zone: #2ef9ff; }

#toast {
    position: fixed;
    z-index: 20;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(8px);
    background: var(--panel-solid);
    border: 1px solid var(--line);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-height: 520px) {
    .hud-score { font-size: 26px; }
    .speedo { margin-top: 4px; }
    .speedo-val { font-size: 16px; }
    .hud-center { width: min(280px, 34vw); }
}
