/* Gateway Offline: the page, the heads-up display and the menus. */
:root {
  --cyan: #38e8ff; --hud: #cfefff; --red: #ff3b30; --green: #7dff4a; --amber: #e8b923;
  --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, "Noto Sans Mono", "DejaVu Sans Mono", monospace;
  /* A phone's notch and rounded corners: nothing to read or press sits under them. */
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05090b; overflow: hidden; overscroll-behavior: none; color: var(--hud); font-family: var(--mono); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------------------------------------------------------------- heads-up display */
.hud { position: fixed; inset: 0; pointer-events: none; user-select: none; text-shadow: 0 0 6px rgba(56, 232, 255, 0.55), 0 1px 2px #000; }
.xh { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.xh i { position: absolute; background: rgba(210, 250, 255, 0.9); box-shadow: 0 0 4px var(--cyan); }
.xh i:nth-child(1) { left: -1px; top: -16px; width: 2px; height: 9px; }
.xh i:nth-child(2) { left: -1px; top: 7px; width: 2px; height: 9px; }
.xh i:nth-child(3) { left: -16px; top: -1px; width: 9px; height: 2px; }
.xh i:nth-child(4) { left: 7px; top: -1px; width: 9px; height: 2px; }
.xh b { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
#hitmark { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; opacity: 0; transform: rotate(45deg);
  background: linear-gradient(var(--green), var(--green)) center / 2px 100% no-repeat, linear-gradient(var(--green), var(--green)) center / 100% 2px no-repeat;
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px); mask: radial-gradient(circle, transparent 5px, #000 6px); }
#hitmark.on { animation: hit 0.18s ease-out; }
#hitmark.kill { animation: hit 0.3s ease-out; filter: drop-shadow(0 0 4px var(--green)); }
@keyframes hit { from { opacity: 1; transform: rotate(45deg) scale(1.5); } to { opacity: 0; transform: rotate(45deg) scale(0.9); } }

.panel { position: absolute; padding: 10px 16px; background: linear-gradient(180deg, rgba(8, 22, 28, 0.6), rgba(4, 10, 14, 0.4)); border: 1px solid rgba(56, 232, 255, 0.35);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
.lbl { font-size: 11px; letter-spacing: 0.22em; opacity: 0.75; text-transform: uppercase; }
.big { font-size: 40px; font-weight: 700; line-height: 1.05; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.bar { margin-top: 8px; height: 6px; background: rgba(56, 232, 255, 0.15); }
.bar i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #1fb7d6, var(--cyan)); box-shadow: 0 0 8px var(--cyan); transition: width 0.15s; }
.hp { left: calc(28px + var(--sl)); bottom: calc(26px + var(--sb)); min-width: 210px; }
.hp.low .big { color: var(--red); text-shadow: 0 0 8px var(--red); }
.hp.low .bar i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.ammo { right: calc(28px + var(--sr)); bottom: calc(26px + var(--sb)); text-align: right; min-width: 170px; }
.ammo.low .big { color: var(--amber); text-shadow: 0 0 8px var(--amber); }
.ammo .bar i { margin-left: auto; background: linear-gradient(90deg, var(--cyan), #fff); }
#keyicon { margin-top: 8px; color: var(--amber); opacity: 1; }
/* An empty carbine says so in the panel and under the crosshair, where the eyes already are. */
#recharge { display: none; margin-top: 8px; color: var(--amber); opacity: 1; animation: blink 0.5s steps(2, jump-none) infinite; }
.hud.dry #recharge { display: block; }
.hud.dry .ammo .big { color: var(--amber); text-shadow: 0 0 8px var(--amber); }
.hud.dry .xh i, .hud.dry .xh b { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.hud.dry .xh::after { content: "RECHARGING"; position: absolute; left: 0; top: 28px; transform: translateX(-50%); font-size: 11px; letter-spacing: 0.22em; color: var(--amber); white-space: nowrap; animation: blink 0.5s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.obj { left: calc(28px + var(--sl)); top: calc(24px + var(--st)); max-width: min(460px, 60vw); }
/* While a bar is up in the middle of the top edge (it is 40vw wide), the objective stops short of it. */
.hud.has-bar .obj { max-width: min(460px, calc(50vw - min(210px, 20vw) - 44px - var(--sl))); }
.obj .t { font-size: 18px; margin-top: 4px; color: #fff; }
.obj .way { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; opacity: 0.9; }
#arrow { display: inline-block; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 16px solid var(--green); filter: drop-shadow(0 0 4px var(--green)); }
.kills { right: calc(28px + var(--sr)); top: calc(24px + var(--st)); text-align: right; min-width: 120px; }
.kills .big { font-size: 28px; }
.boss { position: absolute; left: 50%; top: calc(26px + var(--st)); width: min(420px, 40vw); transform: translateX(-50%); text-align: center; }
.boss .bar { height: 10px; background: rgba(125, 255, 74, 0.15); border: 1px solid rgba(125, 255, 74, 0.4); }
.boss .bar i { background: linear-gradient(90deg, #3c8a1c, var(--green)); box-shadow: 0 0 10px var(--green); }
.boss.purple .bar { border-color: rgba(176, 76, 255, 0.5); background: rgba(176, 76, 255, 0.15); }
.boss.purple .bar i { background: linear-gradient(90deg, #5b2a8a, #b04cff); box-shadow: 0 0 10px #b04cff; }
.boss.cyan .bar { border-color: rgba(56, 232, 255, 0.5); background: rgba(56, 232, 255, 0.15); }
.boss.cyan .bar i { background: linear-gradient(90deg, #1fb7d6, var(--cyan)); box-shadow: 0 0 10px var(--cyan); }
.boss.red .bar { border-color: rgba(255, 59, 48, 0.5); background: rgba(255, 59, 48, 0.15); }
.boss.red .bar i { background: linear-gradient(90deg, #8a1c16, var(--red)); box-shadow: 0 0 10px var(--red); }
/* Centred by its margins: centred by a transform, a box that starts at the middle of the
   screen can only ever be half the screen wide. */
#msg { position: absolute; left: 0; right: 0; top: max(22%, 160px); margin: 0 auto; width: fit-content; max-width: 80vw; text-align: center; font-size: 20px; color: #fff; opacity: 0; transition: opacity 0.4s; }
#msg.on { opacity: 1; }
#prompt { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); font-size: 16px; padding: 6px 14px; border: 1px solid rgba(56, 232, 255, 0.5); background: rgba(4, 10, 14, 0.6); opacity: 0; transition: opacity 0.15s; white-space: nowrap; }
#prompt.on { opacity: 1; }
#mousehint { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); font-size: 14px; padding: 6px 14px; color: #fff; border: 1px solid rgba(232, 185, 35, 0.6); background: rgba(4, 10, 14, 0.7); opacity: 0; transition: opacity 0.2s; white-space: nowrap; }
#mousehint.on { opacity: 1; }
#vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 30, 20, 0.55) 100%); }
#dmgdir { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
#dmgdir i { position: absolute; left: -40px; top: -150px; width: 80px; height: 14px; border-radius: 50%; background: radial-gradient(ellipse, rgba(255, 59, 48, 0.9), transparent 70%); }

/* ---------------------------------------------------------------- touch controls */
/* One layer over the whole view takes every finger: the left side is the stick, the buttons
   are themselves, and anywhere else turns the view. */
#touch { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.tb { position: absolute; display: grid; place-items: center; border-radius: 50%; border: 2px solid rgba(56, 232, 255, 0.55); background: rgba(8, 22, 28, 0.35);
  color: var(--hud); font-size: 11px; letter-spacing: 0.16em; text-indent: 0.16em; text-transform: uppercase; text-shadow: 0 1px 2px #000; }
.tb.on { background: rgba(56, 232, 255, 0.4); border-color: #fff; }
#t-fire { right: calc(26px + var(--sr)); bottom: calc(44px + var(--sb)); width: 86px; height: 86px; }
#t-alt { right: calc(126px + var(--sr)); bottom: calc(20px + var(--sb)); width: 62px; height: 62px; }
#t-use { right: calc(38px + var(--sr)); bottom: calc(146px + var(--sb)); width: 62px; height: 62px; border-color: var(--amber); color: var(--amber); animation: blink 0.8s steps(2, jump-none) infinite; }
#t-pause { right: calc(12px + var(--sr)); top: calc(10px + var(--st)); width: 42px; height: 42px; border-radius: 8px; grid-auto-flow: column; gap: 6px; place-content: center; }
#t-pause i { width: 4px; height: 14px; background: var(--hud); }
/* The stick rests where the thumb is expected and jumps to wherever the thumb lands. */
#stick { position: absolute; left: calc(98px + var(--sl)); top: calc(100% - 98px - var(--sb)); width: 0; height: 0; opacity: 0.35; transition: opacity 0.15s; pointer-events: none; }
#stick::before { content: ""; position: absolute; left: -54px; top: -54px; width: 108px; height: 108px; border-radius: 50%; border: 2px solid rgba(56, 232, 255, 0.5); background: rgba(8, 22, 28, 0.25); }
#stick i { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; border-radius: 50%; background: rgba(56, 232, 255, 0.4); border: 2px solid rgba(255, 255, 255, 0.7); }
#stick.live { opacity: 1; }
#stick.sprint::before { border-color: #fff; box-shadow: 0 0 14px var(--cyan); }

/* Thumbs own the bottom corners, so the readouts move to the middle of the bottom edge. */
.touch .hp, .touch .ammo { bottom: calc(8px + var(--sb)); min-width: 0; }
.touch .hp { left: auto; right: calc(50% + 6px); text-align: right; }
.touch .ammo { right: auto; left: calc(50% + 6px); text-align: left; }
.touch .ammo .bar i { margin-left: 0; }
.touch .kills { right: calc(66px + var(--sr)); }
.touch #mousehint { display: none; }

/* ---------------------------------------------------------------- menus */
.overlay { --pad: 16px; position: fixed; inset: 0; display: grid; padding: max(var(--pad), var(--st)) max(var(--pad), var(--sr)) max(var(--pad), var(--sb)) max(var(--pad), var(--sl)); background: radial-gradient(ellipse at center, rgba(5, 14, 18, 0.72), rgba(2, 5, 7, 0.92)); overflow: auto; touch-action: pan-y; }
#rotate { background: #05090b; z-index: 2; }
/* Centred by its margins, not by the grid: a card taller than the screen then starts at the
   top and scrolls, where a grid-centred one would lose its top edge for good. */
.card { margin: auto; width: min(560px, 100%); padding: 28px 32px; border: 1px solid rgba(56, 232, 255, 0.4); background: rgba(6, 16, 21, 0.86);
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px)); }
.kicker { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--green); }
h1, h2 { margin: 0; color: #fff; letter-spacing: 0.04em; text-transform: uppercase; text-shadow: 0 0 18px rgba(56, 232, 255, 0.6); }
h1 { font-size: clamp(34px, 6vw, 54px); }
h2 { font-size: clamp(26px, 4vw, 36px); }
.lead { margin: 12px 0 20px; font-size: 15px; line-height: 1.5; color: #b9d6de; }
.btn { display: block; width: 100%; padding: 14px 18px; font: 700 17px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: #041014; background: var(--cyan); border: 0; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
.btn:hover, .btn:focus-visible { background: #8ff3ff; outline: none; }
.btn:disabled { background: #24424a; color: #7fa3ad; cursor: default; }
.keys, .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; margin: 22px 0 14px; }
.keys div, .stats div { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.keys dt { flex: none; min-width: 96px; color: var(--cyan); }
.keys dd, .stats dd { margin: 0; color: #b9d6de; }
.stats { grid-template-columns: 1fr 1fr; margin-top: 18px; }
.stats div { flex-direction: column; gap: 2px; }
.stats dt { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.75; }
.stats dd { font-size: 28px; font-weight: 700; color: #fff; }
.note { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: #8fb0b9; }
.note a { color: var(--cyan); }
.note:empty { display: none; }
.locknote { color: var(--amber); }
h2 + .note { margin: 8px 0 0; }
.setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-top: 18px; font-size: 13px; }
.seg { display: flex; }
.seg button { padding: 7px 12px; font: 12px var(--mono); color: var(--hud); background: transparent; border: 1px solid rgba(56, 232, 255, 0.4); cursor: pointer; }
.seg button + button { border-left: 0; }
.seg button.on { background: var(--cyan); color: #041014; font-weight: 700; }
input[type="range"] { width: 200px; accent-color: var(--cyan); }
#pause .btn, .note + .btn { margin-top: 18px; }
#faildetail { user-select: text; -webkit-user-select: text; }
/* A finger needs more to land on than a mouse pointer does. */
.touch .seg button { padding: 10px 16px; font-size: 13px; }
.touch input[type="range"] { height: 32px; }
/* Words that are only true of one way of playing. */
.for-touch, .touch .for-mouse { display: none; }
.touch dl.for-touch { display: grid; }
.touch div.for-touch { display: flex; }
.touch span.for-touch { display: inline; }

@media (max-width: 640px) {
  .card { padding: 22px 20px; }
}
/* One column of keys in a narrow window, but not on a phone on its side, which is short. */
@media (max-width: 640px) and (min-height: 521px) {
  .keys { grid-template-columns: 1fr; }
}

/* A phone on its side is wide and very short: everything tightens so no menu has to scroll
   and the readouts leave the middle of the view clear. */
@media (max-height: 520px) {
  .panel { padding: 6px 12px; }
  .lbl { font-size: 9px; }
  .big { font-size: 26px; }
  .bar { margin-top: 5px; height: 5px; }
  .obj { top: calc(10px + var(--st)); left: calc(12px + var(--sl)); max-width: 46vw; }
  .hud.has-bar .obj { max-width: calc(50vw - min(150px, 14vw) - 20px - var(--sl)); }
  .obj .lbl { display: none; }
  .obj .t { font-size: 13px; margin-top: 0; }
  .obj .way { margin-top: 4px; font-size: 12px; }
  .kills { top: calc(10px + var(--st)); min-width: 0; }
  .kills .big { font-size: 20px; }
  .boss { top: calc(10px + var(--st)); width: min(300px, 28vw); }
  #msg { top: 27%; max-width: 92vw; font-size: 13px; }
  #prompt { font-size: 14px; }
  /* By touch the readouts are under the prompt, so it is measured up from them, and the
     empty carbine's word moves above the crosshair to leave it room. */
  .touch #prompt { top: auto; bottom: calc(84px + var(--sb)); }
  .touch .hud.dry .xh::after { top: -42px; }
  #keyicon, #recharge { margin-top: 4px; }
  .overlay { --pad: 8px; }
  .card { width: min(700px, 100%); padding: 14px 22px; }
  .kicker { margin-bottom: 2px; font-size: 10px; }
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
  .lead { margin: 6px 0 10px; font-size: 13px; }
  .btn { padding: 10px 14px; font-size: 15px; }
  .keys, .stats { margin: 10px 0 6px; gap: 3px 18px; }
  .keys div { font-size: 12px; }
  .stats { grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
  .stats dd { font-size: 20px; }
  .note { margin-top: 8px; }
  .setting { margin-top: 10px; gap: 6px 10px; }
  .seg button { padding: 6px 12px; }
  #pause .btn, .note + .btn { margin-top: 10px; }
  /* The settings sit two abreast, so the pause card fits with the browser's bars showing. */
  #pause .card { display: grid; grid-template-columns: 1fr 1fr; column-gap: 26px; }
  #pause .card > :not(.setting) { grid-column: 1 / -1; }
  input[type="range"] { width: 140px; }
  .touch .seg button { padding: 9px; font-size: 12px; }
  /* The readouts share the bottom edge with the thumbs, so they stay one size: the key line
     goes, and an empty carbine says so under the crosshair alone. */
  .touch #keyicon, .touch.touch #recharge { display: none; }
}
