/* ==========================================================================
   Ship It. — Just The Web Guy
   Dark glass UI, gradient accents, system fonts, no dependencies.
   ========================================================================== */
:root {
  color-scheme: dark;
  --bg: #0a0c16;
  --glass: rgba(16, 19, 35, 0.62);
  --glass-strong: rgba(16, 19, 35, 0.82);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ebff;
  --muted: #8a90b2;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --lime: #a3e635;
  --amber: #fbbf24;
  --red: #f43f5e;
  --green: #34d399;
  --grad: linear-gradient(135deg, #a78bfa 0%, #22d3ee 55%, #f472b6 100%);
  --grad-btn: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --radius: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --hud-pad: clamp(10px, 1.6vw, 20px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
body { user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.center { text-align: center; }
.lime { color: var(--lime); }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
[hidden] { display: none !important; }

/* % (not vw/vh) so iOS Safari's collapsing toolbars can't stretch the canvas */
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: rgba(139, 92, 246, 0.16); color: var(--violet-2); border: 1px solid rgba(139, 92, 246, 0.3); }
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font: 600 11px var(--mono); color: var(--text); border-radius: 6px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-strong); border-bottom-width: 2px;
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 22px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font-weight: 650; font-size: 15px; letter-spacing: -0.01em;
  transition: transform 0.16s cubic-bezier(.2,.8,.2,1), box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); }
.btn-primary { background: var(--grad-btn); color: #fff; box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35); }
.btn-primary:hover, .btn-primary.hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(34, 211, 238, 0.35); }
.btn-ghost { background: rgba(255, 255, 255, 0.05); border-color: var(--line-strong); }
.btn-ghost:hover:not([disabled]), .btn-ghost.hover:not([disabled]) { transform: translateY(-2px); background: rgba(255, 255, 255, 0.09); }
.pause-note { font-size: 12.5px; margin-top: -4px !important; }
.btn:active:not([disabled]) { transform: translateY(0) scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .card:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 22px; line-height: 1; transition: background .2s, transform .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.1); transform: translateY(-1px); }
.icon-btn svg, .ab-icon svg, .card-icon svg, .loadout-item svg, .toast-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Vignette + low-HP pulse live in CSS so the compositor handles them, not the canvas. */
#vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(5,6,14,0) 38vmin, rgba(5,6,14,.6) 78vmax); }
#vignette::after { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: radial-gradient(circle at 50% 50%, rgba(244,63,94,0) 32vmin, rgba(244,63,94,.32) 72vmax); }
#vignette.danger::after { opacity: 1; animation: pulse-red 1s ease-in-out infinite; }
#fps { position: fixed; left: 50%; bottom: 4px; transform: translateX(-50%); z-index: 60; pointer-events: none;
  font: 600 11px var(--mono); color: #a3e635; background: rgba(0,0,0,.6); padding: 3px 8px; border-radius: 6px; }

/* ---- HUD ------------------------------------------------------------------ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; transition: opacity .3s; }
#hud.is-hidden { opacity: 0; visibility: hidden; }
#hud .icon-btns, #hud .icon-btn { pointer-events: auto; }
.hud-tl { position: absolute; left: var(--hud-pad); top: var(--hud-pad); display: flex; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; }
.avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; background: var(--grad-btn); box-shadow: 0 4px 14px rgba(139,92,246,.4); }
.who-row { display: flex; align-items: center; gap: 8px; }
.who-name { font-weight: 700; font-size: 14px; }
.hp { display: flex; gap: 3px; margin: 6px 0 5px; }
.hp i { width: 14px; height: 8px; border-radius: 3px; background: linear-gradient(180deg, #fb7185, #e11d48); box-shadow: 0 0 8px rgba(244,63,94,.45); transition: background .2s, box-shadow .2s, transform .2s; }
.hp i.off { background: rgba(255,255,255,.1); box-shadow: none; }
.hp i.lost { animation: pip-lost .45s ease; }
@keyframes pip-lost { 0% { transform: scale(1.6); background: #fff; } 100% { transform: scale(1); } }
.xp { height: 4px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; width: 100%; min-width: 150px; }
.xp span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--lime), #4ade80); transition: width .15s; }

.hud-tc { position: absolute; left: 50%; top: var(--hud-pad); transform: translateX(-50%); width: min(460px, 40vw); padding: 10px 16px 12px; }
.build-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.project { font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pct { font-weight: 700; font-size: 15px; }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad); background-size: 200% 100%; transition: width .25s ease; animation: shimmer 3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.boss { margin-top: 10px; }
.boss-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.boss-name { font-weight: 800; font-size: 13px; color: #d8b4fe; letter-spacing: .02em; }
.boss-sub { font-size: 11px; color: var(--muted); }
.boss-bar > span { background: linear-gradient(90deg, #c084fc, #f472b6); animation: none; width: 100%; }

.hud-tr { position: absolute; right: var(--hud-pad); top: var(--hud-pad); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.timer-card { padding: 8px 16px 10px; text-align: right; min-width: 140px; }
.timer-card .label { display: block; }
.timer { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.timer.urgent { color: var(--red); animation: pulse-red 1s ease-in-out infinite; }
@keyframes pulse-red { 50% { opacity: .55; } }
.icon-btns { display: flex; gap: 6px; }

.hud-bl { position: absolute; left: var(--hud-pad); bottom: var(--hud-pad); padding: 10px 16px; display: flex; flex-direction: column; min-width: 170px; }
.score { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.streak { font-size: 12px; font-weight: 700; color: var(--amber); min-height: 18px; transition: transform .12s; }
.streak.bump { transform: scale(1.18); }

.hud-bc { position: absolute; left: 50%; bottom: var(--hud-pad); transform: translateX(-50%); display: flex; gap: 6px; }
.loadout-item { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: pop-in .35s cubic-bezier(.2,1.6,.4,1); }
.loadout-item .lv { position: absolute; right: -4px; bottom: -4px; font: 700 10px var(--mono); padding: 1px 4px; border-radius: 6px; background: #1e2238; border: 1px solid var(--line-strong); color: var(--text); }

.lock-hint { position: absolute; left: 50%; bottom: calc(var(--hud-pad) + 52px); transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; font-size: 12.5px; color: #c5cae6; white-space: nowrap; background: rgba(14,17,32,.86); border: 1px solid var(--line-strong); animation: fade-in .3s ease; }
body.autoaim .lock-hint { display: none !important; }
.hud-br { position: absolute; right: var(--hud-pad); bottom: var(--hud-pad); display: flex; gap: 10px; }
.ability { position: relative; width: 60px; height: 72px; display: flex; flex-direction: column; align-items: center; }
.ability > svg { width: 52px; height: 52px; transform: rotate(-90deg); }
.ability .ring-bg { fill: rgba(16,19,35,.7); stroke: rgba(255,255,255,.08); stroke-width: 4; }
.ability .ring { fill: none; stroke: var(--cyan); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 138.2; stroke-dashoffset: 0; transition: stroke .2s; }
#ab-hotfix .ring { stroke: var(--amber); }
.ab-icon { position: absolute; top: 17px; left: 50%; transform: translateX(-50%); color: var(--text); opacity: .5; transition: opacity .2s, color .2s; }
.ability.ready .ab-icon { opacity: 1; }
#ab-hotfix.ready .ab-icon { color: var(--amber); animation: glow-pulse 1.2s ease-in-out infinite; }
@keyframes glow-pulse { 50% { filter: drop-shadow(0 0 6px var(--amber)); } }
.ability kbd { margin-top: 2px; font-size: 10px; height: 18px; }

/* In-game HUD: solid panels, no backdrop blur. Blurring a canvas that repaints
   every frame cost Firefox ~12 ms/frame on Retina. Menus keep the frosted look. */
#hud .glass, #hud .loadout-item, #hud .icon-btn, .toast {
  backdrop-filter: none; -webkit-backdrop-filter: none;
  background: rgba(14, 17, 32, 0.86);
}

/* ---- Toasts ---------------------------------------------------------------- */
#toasts { position: fixed; right: var(--hud-pad); top: calc(var(--hud-pad) + 118px); z-index: 20; display: flex; flex-direction: column; gap: 8px; width: min(320px, 80vw); pointer-events: none; }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toast-in .35s cubic-bezier(.2,1.2,.4,1); }
.toast.out { animation: toast-out .3s ease forwards; }
.toast-icon { flex: 0 0 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(34,211,238,.15); color: var(--cyan); }
.toast.warn .toast-icon { background: rgba(251,191,36,.15); color: var(--amber); }
.toast.ok .toast-icon { background: rgba(52,211,153,.15); color: var(--green); }
.toast.bad .toast-icon { background: rgba(244,63,94,.15); color: var(--red); }
.toast.boss .toast-icon { background: rgba(192,132,252,.18); color: #d8b4fe; }
.toast-title { font-weight: 700; font-size: 13px; }
.toast-body { font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* ---- Announcements ------------------------------------------------------------ */
#announce { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 15; opacity: 0; }
#announce.show { animation: announce 2.4s cubic-bezier(.2,.9,.2,1) forwards; }
.an-title { font-size: clamp(34px, 5.6vw, 72px); font-weight: 850; letter-spacing: -0.04em; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 24px rgba(139,92,246,.45)); }
#announce.bad .an-title { background: linear-gradient(135deg, #fb7185, #f59e0b); -webkit-background-clip: text; background-clip: text; }
#announce.boss .an-title { background: linear-gradient(135deg, #d8b4fe, #f472b6); -webkit-background-clip: text; background-clip: text; }
.an-sub { margin-top: 10px; font-size: 15px; color: var(--text); opacity: .85; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
@keyframes announce {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 14; opacity: 0; background: #fff; }
#flash.hit { background: radial-gradient(ellipse at center, transparent 40%, rgba(244,63,94,.55)); animation: flash .45s ease-out; }
#flash.white { background: #fff; animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---- Level up ------------------------------------------------------------------ */
/* Virtual cursor: used on the level-up screen while the pointer is captured. */
#vcursor { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; margin: -2px 0 0 -2px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; background: rgba(6, 8, 18, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade-in .2s ease; }
.lu-inner { width: min(900px, 100%); }
.lu-head { text-align: center; margin-bottom: 22px; }
.lu-head h2 { margin: 10px 0 4px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.03em; font-weight: 800; }
.lu-head p { margin: 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card {
  position: relative; text-align: left; cursor: pointer; padding: 20px; border-radius: 18px; min-height: 230px;
  background: linear-gradient(180deg, rgba(30, 34, 60, .85), rgba(16, 19, 35, .9)); border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 10px;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), border-color .2s, box-shadow .2s;
  animation: card-in .45s cubic-bezier(.2,1.2,.4,1) backwards;
}
.card:nth-child(2) { animation-delay: .06s; } .card:nth-child(3) { animation-delay: .12s; }
.card:hover, .card.hover { transform: translateY(-6px); border-color: var(--accent, var(--violet)); box-shadow: 0 22px 50px rgba(0,0,0,.5), 0 0 0 1px var(--accent, var(--violet)), 0 0 40px -10px var(--accent, var(--violet)); }
.card-top { display: flex; align-items: center; justify-content: space-between; }
.card-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--accent, var(--violet)); box-shadow: 0 6px 20px -4px var(--accent, var(--violet)); }
.card-icon svg { width: 24px; height: 24px; }
.card-badge { font: 700 11px var(--mono); padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line-strong); }
.card-badge.new { background: rgba(163,230,53,.15); border-color: rgba(163,230,53,.4); color: var(--lime); }
.card-kind { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card-name { font-size: 20px; font-weight: 750; letter-spacing: -0.02em; margin-top: -6px; }
.card-desc { font-size: 13.5px; color: #c5cae6; line-height: 1.45; flex: 1; }
.card-pips { display: flex; gap: 4px; }
.card-pips i { width: 16px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); }
.card-pips i.on { background: var(--accent, var(--violet)); }
.card-pips i.next { background: #fff; animation: pulse-red 0.9s infinite; }
.card-key { position: absolute; right: 14px; bottom: 14px; }
@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.96); } }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* ---- Screens -------------------------------------------------------------------- */
.screen { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; padding: 24px; overflow: auto; }
.screen.active { display: flex; animation: fade-in .3s ease; }
#screen-title { background: radial-gradient(1100px 650px at 50% 45%, rgba(10,12,22,.72), rgba(10,12,22,.92)); }
#screen-howto, #screen-win, #screen-lose, #screen-pause { background: rgba(6, 8, 18, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#screen-intro { background: rgba(6, 8, 18, .88); flex-direction: column; gap: 16px; }

.title-wrap { text-align: center; max-width: 760px; animation: rise .8s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); background: rgba(255,255,255,.05); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.eyebrow b { color: var(--text); font-weight: 650; }
.eyebrow .dot, .status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse-red 1.6s infinite; }
.title { margin: 18px 0 8px; font-size: clamp(72px, 13vw, 168px); line-height: .92; font-weight: 850; letter-spacing: -0.06em; background: var(--grad); background-size: 200% 200%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: grad-move 8s ease-in-out infinite; filter: drop-shadow(0 10px 40px rgba(139,92,246,.35)); }
.title-dot { color: var(--pink); -webkit-text-fill-color: var(--pink); }
@keyframes grad-move { 50% { background-position: 100% 50%; } }
.tagline { font-size: clamp(15px, 1.6vw, 19px); color: #c5cae6; margin: 0 auto 28px; max-width: 560px; }
.title-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.title-meta { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-top: 26px; font-size: 13px; color: var(--muted); }
.title-meta span { display: inline-flex; align-items: center; gap: 6px; }
.best { color: var(--amber); font-weight: 600; }

/* Auto-aim switch (title screen) */
.setting { display: inline-flex; align-items: center; gap: 14px; margin-top: 20px; padding: 10px 12px 10px 16px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-align: left; transition: border-color .2s, background .2s; }
.setting:hover { border-color: var(--line-strong); background: rgba(255,255,255,.08); }
.setting-text { display: flex; flex-direction: column; line-height: 1.3; }
.setting-text b { font-size: 14px; }
.setting-desc { font-size: 12.5px; color: var(--muted); }
.setting input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch { position: relative; flex: 0 0 44px; height: 26px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid var(--line-strong); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.setting input:checked + .switch { background: var(--grad-btn); border-color: transparent; }
.setting input:checked + .switch::after { transform: translateX(18px); }
.setting input:focus-visible + .switch { outline: 2px solid var(--cyan); outline-offset: 3px; }
body:not(.autoaim) .auto-only, body.autoaim .manual-only { display: none !important; }

.panel { padding: 26px 28px; max-height: calc(100vh - 48px); overflow: auto; animation: rise .35s cubic-bezier(.2,.8,.2,1); }
.panel.wide { width: min(880px, 100%); }
.panel.narrow { width: min(380px, 100%); }
.panel h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.03em; }
.panel h3 { margin: 18px 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel p { margin: 0 0 10px; color: #c5cae6; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-foot { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.howto-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; }
.keys { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 13.5px; }
.keys li { display: flex; align-items: center; gap: 5px; }
.keys li span { color: #c5cae6; margin-left: 6px; }
.keys .auto { font: 700 10px var(--mono); padding: 3px 7px; border-radius: 6px; background: rgba(34,211,238,.15); color: var(--cyan); margin-left: 0 !important; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.legend-col { padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.legend-col.good { border-color: rgba(52,211,153,.35); }
.legend-col.bad { border-color: rgba(244,63,94,.35); }
.legend-head { font-size: 11px; font-weight: 700; letter-spacing: .04em; margin-bottom: 6px; }
.legend-col.good .legend-head { color: #6ee7b7; }
.legend-col.bad .legend-head { color: #fda4af; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #c5cae6; line-height: 1.3; margin: 4px 0; }
.legend-item canvas { width: 60px; height: 28px; flex: 0 0 60px; }
.bestiary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.beast { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.beast canvas { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 10px; background: rgba(0,0,0,.25); }
.beast b { display: block; font-size: 13px; }
.beast span { font-size: 11.5px; color: var(--muted); line-height: 1.3; display: block; }

.terminal { width: min(720px, 100%); border-radius: 14px; overflow: hidden; background: #0d1020; border: 1px solid var(--line-strong); box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px -20px rgba(139,92,246,.5); }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: rgba(255,255,255,.04); border-bottom: 1px solid var(--line); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #f43f5e; }
.term-bar i:nth-child(2) { background: #fbbf24; } .term-bar i:nth-child(3) { background: #34d399; }
.term-bar span { margin-left: 10px; font-size: 12px; color: var(--muted); }
#term { margin: 0; padding: 18px 20px 22px; min-height: 250px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; color: #cbd5ff; }
#term .p { color: var(--cyan); } #term .ok { color: var(--green); } #term .err { color: var(--red); } #term .warn { color: var(--amber); } #term .me { color: #fff; font-weight: 700; } #term .dim { color: var(--muted); }
#term .caret { display: inline-block; width: 8px; height: 16px; background: var(--text); vertical-align: -3px; animation: pulse-red 1s steps(1) infinite; }
.skip { font-size: 12px; color: var(--muted); }

.result-head { text-align: center; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 650; }
.status-pill.ok { background: rgba(52,211,153,.12); color: var(--green); border: 1px solid rgba(52,211,153,.3); }
.status-pill.bad { background: rgba(244,63,94,.12); color: #fb7185; border: 1px solid rgba(244,63,94,.3); }
.status-pill.bad .dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
.result-title { font-size: clamp(48px, 7vw, 76px) !important; line-height: 1; margin: 12px 0 6px !important; font-weight: 850; letter-spacing: -0.05em !important; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-title.bad { background: linear-gradient(135deg, #fb7185, #f59e0b); -webkit-background-clip: text; background-clip: text; }
.gauges { display: flex; justify-content: center; gap: clamp(12px, 3vw, 34px); margin: 22px 0 18px; flex-wrap: wrap; }
.gauge { width: 96px; text-align: center; }
.gauge svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.gauge .g-bg { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 6; }
.gauge .g-fg { fill: none; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 226.2; stroke-dashoffset: 226.2; transition: stroke-dashoffset 1.3s cubic-bezier(.2,.8,.2,1); }
.gauge .g-wrap { position: relative; width: 84px; height: 84px; margin: 0 auto; }
.gauge .g-val { position: absolute; inset: 0; display: grid; place-items: center; font: 800 24px var(--mono); }
.gauge .g-label { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.25; }
.gauge.good .g-fg { stroke: var(--green); } .gauge.good .g-val { color: var(--green); }
.gauge.mid .g-fg { stroke: var(--amber); } .gauge.mid .g-val { color: var(--amber); }
.gauge.poor .g-fg { stroke: var(--red); } .gauge.poor .g-val { color: var(--red); }
.result-body { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: center; }
table.stats { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.stats td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
table.stats td:first-child { color: var(--muted); font-family: var(--font); }
table.stats td:last-child { text-align: right; font-weight: 700; }
.final { text-align: center; padding: 18px; border-radius: 16px; background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.final-score { font-size: 42px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 8px; }
.grade { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; font-size: 34px; font-weight: 900; color: #fff; background: var(--grad-btn); box-shadow: 0 10px 30px rgba(139,92,246,.45); animation: pop-in .6s cubic-bezier(.2,1.8,.4,1) .4s backwards; }
.best-note { font-size: 12px; color: var(--amber); margin-top: 10px; min-height: 16px; font-weight: 600; }
.quote { text-align: center; font-style: italic; color: var(--muted) !important; margin: 16px 0 0 !important; }
.errlog { margin: 18px 0; padding: 14px 16px; border-radius: 12px; background: #0d1020; border: 1px solid rgba(244,63,94,.25); color: #fda4af; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.errlog .dim { color: var(--muted); }

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
  .howto-grid, .result-body { grid-template-columns: 1fr; }
  .hud-bc { display: none; }
  .hud-tc { width: 46vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Touch mode. Everything below is scoped to body.touch, which js/touch.js sets
   on phones/tablets or after a real touch. Desktop never matches these rules.
   ========================================================================== */
body:not(.touch) .t-only { display: none !important; }
body.touch .k-only { display: none !important; }

body.touch { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; overscroll-behavior: none; }
body.touch .screen, body.touch .btn, body.touch .card, body.touch .icon-btn { touch-action: manipulation; }

#touch-layer { position: fixed; inset: 0; z-index: 4; display: none; touch-action: none; }
body.touch #touch-layer { display: block; }
.stick {
  position: absolute; left: 0; top: 0; width: 128px; height: 128px; margin: -64px 0 0 -64px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 1.5px solid rgba(255,255,255,.16);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: .28; transition: opacity .15s; pointer-events: none;
}
.stick.on { opacity: 1; }
.stick .knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(139,92,246,.95), rgba(6,182,212,.95));
  box-shadow: 0 6px 20px rgba(139,92,246,.45), inset 0 1px 0 rgba(255,255,255,.35);
}
#aim-stick { width: 112px; height: 112px; margin: -56px 0 0 -56px; }
#aim-stick .knob { background: linear-gradient(135deg, rgba(244,114,182,.95), rgba(34,211,238,.95)); box-shadow: 0 6px 20px rgba(244,114,182,.4), inset 0 1px 0 rgba(255,255,255,.35); }
#aim-stick::after { content: 'AIM'; position: absolute; left: 50%; top: -18px; transform: translateX(-50%); font: 700 9px var(--mono); letter-spacing: .12em; color: rgba(255,255,255,.55); }
#stick::after { content: 'MOVE'; position: absolute; left: 50%; top: -18px; transform: translateX(-50%); font: 700 9px var(--mono); letter-spacing: .12em; color: rgba(255,255,255,.55); }
#stick.on::after, #aim-stick.on::after { opacity: 0; }
/* Desktop: aim with the pointer (manual aim only) */
body:not(.touch):not(.autoaim) canvas#game { cursor: crosshair; }
/* Auto-aim: no aim stick, one thumb moves from anywhere */
body.autoaim #aim-stick { display: none; }

/* Big thumb buttons, clear of the notch / home indicator */
body.touch #hud .hud-br { pointer-events: auto; gap: 14px; }
body.touch .ability { width: 80px; height: 92px; cursor: pointer; }
body.touch .ability > svg { width: 72px; height: 72px; transition: transform .1s; }
body.touch .ability.pressed > svg { transform: rotate(-90deg) scale(.88); }
body.touch .ab-icon { top: 27px; }
body.touch .ab-name { margin-top: 3px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
body.touch .hud-tl, body.touch .hud-bl { left: calc(var(--hud-pad) + env(safe-area-inset-left)); }
body.touch .hud-tr, body.touch .hud-br { right: calc(var(--hud-pad) + env(safe-area-inset-right)); }
body.touch .hud-tl, body.touch .hud-tc, body.touch .hud-tr { top: calc(var(--hud-pad) + env(safe-area-inset-top)); }
body.touch .hud-br { bottom: calc(var(--hud-pad) + env(safe-area-inset-bottom)); }

/* ---- Phone-sized screens in touch mode: compact HUD ---------------------- */
@media (max-height: 560px), (max-width: 700px) {
  body.touch { --hud-pad: 8px; }
  body.touch .hud-tl { padding: 6px 10px 6px 6px; gap: 8px; border-radius: 12px; }
  body.touch .avatar { width: 30px; height: 30px; font-size: 11px; border-radius: 9px; }
  body.touch .who-name { font-size: 12px; }
  body.touch .hp { gap: 2px; margin: 4px 0 4px; }
  body.touch .hp i { width: 10px; height: 6px; }
  body.touch .xp { min-width: 96px; }
  body.touch .hud-tc { width: min(300px, 36vw); padding: 7px 12px 9px; border-radius: 12px; }
  body.touch .project { display: none; }
  body.touch .build-row { justify-content: space-between; margin-bottom: 5px; }
  body.touch .boss { margin-top: 6px; }
  body.touch .boss-sub { display: none; }
  body.touch .timer-card { padding: 5px 10px 6px; min-width: 0; border-radius: 12px; }
  body.touch .timer-card .label { font-size: 9px; }
  body.touch .timer { font-size: 19px; }
  body.touch .icon-btns { gap: 5px; }
  body.touch .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
  body.touch .hud-bl { top: calc(var(--hud-pad) + env(safe-area-inset-top) + 62px); bottom: auto; padding: 5px 10px 6px; min-width: 0; border-radius: 12px; }
  body.touch .hud-bl .label { display: none; }
  body.touch .score { font-size: 17px; }
  body.touch .streak { font-size: 10.5px; min-height: 0; white-space: nowrap; }
  body.touch .hud-bc { display: none; }
  body.touch #toasts { left: 50%; right: auto; transform: translateX(-50%); top: calc(var(--hud-pad) + env(safe-area-inset-top) + 66px); width: min(300px, 60vw); gap: 6px; }
  body.touch .toast { padding: 8px 10px; gap: 8px; border-radius: 12px; }
  body.touch .toast-icon { flex-basis: 22px; height: 22px; border-radius: 6px; }
  body.touch .toast-title { font-size: 12px; }
  body.touch .toast-body { font-size: 11.5px; }
  body.touch .toast:nth-last-child(n+3) { display: none; }
  body.touch .an-title { font-size: clamp(28px, 8vw, 46px); }
  body.touch .an-sub { font-size: 12.5px; }

  body.touch .overlay { overflow: auto; padding: 12px; }
  body.touch .lu-head { margin-bottom: 10px; }
  body.touch .lu-head h2 { font-size: 24px; margin: 6px 0 2px; }
  body.touch .lu-head p { font-size: 12.5px; }
  body.touch .cards { gap: 10px; }
  body.touch .card { min-height: 0; padding: 12px 14px; gap: 6px; border-radius: 14px; }
  body.touch .card:hover { transform: none; }
  body.touch .card-icon { width: 34px; height: 34px; border-radius: 10px; }
  body.touch .card-icon svg { width: 18px; height: 18px; }
  body.touch .card-kind { font-size: 10px; }
  body.touch .card-name { font-size: 16px; margin-top: -2px; }
  body.touch .card-desc { font-size: 12.5px; }

  body.touch .panel { padding: 18px; }
  body.touch .screen { padding: 12px; }
  body.touch .panel { max-height: calc(100% - 4px); }
  body.touch .panel-foot { position: sticky; bottom: -18px; margin: 14px -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: #0e1122; border-top: 1px solid var(--line); z-index: 1; flex-wrap: nowrap; }
  body.touch .panel-foot .btn { flex: 1 1 0; padding: 12px 14px; }
  body.touch .panel-foot .btn[disabled] { display: none; }
  body.touch .result-body { grid-template-columns: 1fr; gap: 12px; }
  body.touch .final { order: -1; padding: 12px; }
  body.touch .final-score { font-size: 34px; margin: 2px 0 6px; }
  body.touch .grade { width: 52px; height: 52px; font-size: 28px; border-radius: 14px; }
  body.touch .result-head p { font-size: 12px; }
  body.touch .result-title { font-size: 48px !important; margin: 8px 0 4px !important; }
  body.touch table.stats { font-size: 12.5px; }
  body.touch table.stats td { padding: 5px 2px; }
  body.touch .bestiary { grid-template-columns: 1fr; gap: 6px; }
  body.touch .beast { padding: 6px 8px; }
  body.touch .beast canvas { width: 40px; height: 40px; flex-basis: 40px; }
  body.touch .title { font-size: clamp(56px, 18vw, 120px); }
  body.touch .tagline { margin-bottom: 18px; }
  body.touch .title-meta { margin-top: 16px; gap: 12px; }
  body.touch .gauges { gap: 6px; margin: 12px 0 8px; flex-wrap: nowrap; }
  body.touch .gauge { width: 68px; flex: 0 1 68px; }
  body.touch .gauge svg, body.touch .gauge .g-wrap { width: 58px; height: 58px; }
  body.touch .gauge .g-val { font-size: 17px; }
  body.touch .gauge .g-label { font-size: 10.5px; }
}
/* Portrait phones: build bar gets its own row, toasts move right */
@media (orientation: portrait) and (max-width: 700px) {
  body.touch .hud-tc { top: calc(var(--hud-pad) + env(safe-area-inset-top) + 58px); left: calc(var(--hud-pad) + env(safe-area-inset-left) + 112px); right: calc(var(--hud-pad) + env(safe-area-inset-right)); width: auto; transform: none; }
  body.touch .hud-bl { top: calc(var(--hud-pad) + env(safe-area-inset-top) + 58px); }
  body.touch .hud-bl { width: 96px; }
  body.touch #toasts { left: auto; right: calc(var(--hud-pad) + env(safe-area-inset-right)); transform: none; top: calc(var(--hud-pad) + env(safe-area-inset-top) + 184px); width: min(250px, 64vw); }
  body.touch .toast:nth-last-child(n+2) { display: none; }
  body.touch .hud-tr { flex-direction: row-reverse; align-items: center; }
  body.touch .hud-bl { width: auto; min-width: 96px; max-width: 104px; }
  body.touch .streak { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.touch #announce { top: 38%; width: 92vw; }
}
/* Landscape phones: three compact cards side by side */
@media (orientation: landscape) and (max-height: 560px) {
  body.touch .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.touch .card-pips { display: none; }
  body.touch .lu-head .chip { display: none; }
  body.touch #toasts { left: auto; right: calc(var(--hud-pad) + env(safe-area-inset-right)); transform: none; top: calc(var(--hud-pad) + env(safe-area-inset-top) + 102px); width: min(250px, 32vw); }
  body.touch #announce { top: 44%; }
  body.touch .toast:nth-last-child(n+2) { display: none; }
  /* results: header shrinks, score sits beside the stats so it is visible without scrolling */
  body.touch .result-head .status-pill, body.touch .result-head p { display: none; }
  body.touch .result-title { font-size: 34px !important; margin: 0 0 2px !important; }
  body.touch .gauges { margin: 6px 0 8px; }
  body.touch .result-body { grid-template-columns: 1fr 1.3fr; align-items: start; }
  body.touch .final { order: 0; }
  body.touch .quote { display: none; }
}
