:root {
  /* One typewriter face across the whole game; everything inherits it. */
  --type: 'Courier New', Courier, ui-monospace, monospace;
  --hud-fg: #f2f6ff;
  --hud-dim: #b9c8e2;
  --hud-accent: #4fd8ff;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--type);
  color: var(--hud-fg);
  -webkit-font-smoothing: antialiased;
}

canvas {
  display: block;
  /* Or a drag on the canvas pans and pinches the page instead of driving. */
  touch-action: none;
}

html, body {
  overscroll-behavior: none;
}

/* =============================================================
   TOUCH CONTROLS
   =============================================================
   Only ever shown on a touch device, and only while playing. A stick on
   the left because that is the hand that steers on every controller ever
   made, and the actions on the right under the thumb that is not busy. */
#touch {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body.touch.playing #touch {
  display: block;
}

#stick {
  position: absolute;
  left: calc(28px + env(safe-area-inset-left));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(0, 0, 0, .22);
  pointer-events: auto;
  touch-action: none;
}

/* Square, to match the mixer caps and the particles. A round pip would be
   the only soft thing on the screen. */
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  background: var(--hud-fg);
  opacity: .82;
  will-change: transform;
}

.touch-btn {
  position: absolute;
  right: calc(28px + env(safe-area-inset-right));
  width: 92px;
  height: 92px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(0, 0, 0, .22);
  color: var(--hud-fg);
  font: inherit;
  font-size: .72rem;
  letter-spacing: .12em;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn.held {
  background: rgba(255, 255, 255, .30);
}

#btn-jump { bottom: calc(28px + env(safe-area-inset-bottom)); }
/* Space is the one world you steer in three dimensions, so it gets the two
   extra keys the keyboard build binds to K and L. */
#btn-dive, #btn-rise { display: none; }
body.in-space #btn-dive { display: grid; bottom: calc(132px + env(safe-area-inset-bottom)); }
body.in-space #btn-rise { display: grid; bottom: calc(236px + env(safe-area-inset-bottom)); }

/* =============================================================
   DEBUG PANEL
   =============================================================
   Every cheat in this game was a number key, which an iPad does not have.
   Opened by holding the score down for a moment - out of the way of the
   stick and the jump button, and not something a thumb finds by accident. */
#debug {
  position: fixed;
  z-index: 120;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px;
  width: min(460px, 92vw);
  max-height: 86vh;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px;
  background: rgba(4, 7, 13, .93);
  -webkit-overflow-scrolling: touch;
}

body.debug #debug {
  display: grid;
}

#debug-cmd {
  grid-column: 1 / -1;
  appearance: none;
  padding: 12px 12px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  color: var(--hud-fg);
  font: inherit;
  font-size: 1rem;   /* under 16px and iOS zooms the whole page to focus it */
  letter-spacing: .04em;
}

#debug-cmd::placeholder {
  color: var(--hud-fg);
  opacity: .35;
}

#debug-out {
  grid-column: 1 / -1;
  margin: 0;
  min-height: 1.2em;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--hud-accent);
  word-break: break-word;
}

#debug h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: .74rem;
  font-weight: normal;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--hud-fg);
  opacity: .55;
}

#debug button {
  appearance: none;
  padding: 11px 6px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  color: var(--hud-fg);
  font: inherit;
  font-size: .66rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}

#debug button:active {
  background: rgba(255, 255, 255, .24);
}

#debug button.wide { grid-column: span 2; }
#debug button.here { border-color: var(--hud-accent); }

#btn-pause {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  right: calc(18px + env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(0, 0, 0, .22);
  color: var(--hud-fg);
  font: inherit;
  font-size: .8rem;
  display: grid;
  place-items: center;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  background: rgba(0, 0, 0, .85);
  cursor: pointer;
  user-select: none;
  z-index: 99;
}

[hidden] {
  display: none !important;
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #05070d;
  color: var(--hud-fg);
  transition: opacity .5s ease;
}

#loader.done {
  opacity: 0;
  pointer-events: none;
}

#loader-bar {
  width: min(360px, 70vw);
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .14);
  overflow: hidden;
}

#loader-fill {
  height: 100%;
  width: 0%;
  background: var(--hud-accent);
  transition: width .3s ease;
}

#overlay-text {
  text-align: center;
  line-height: 1.7;
}

#overlay-text .cta {
  display: block;
  margin-top: 1.4em;
}

/* The mixer sits alongside the overlay text rather than inside it: the text
   is rewritten wholesale every time the reason for pausing changes, and
   anything living in it would be destroyed along with the sliders' state. */
#mixer {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px 14px;
  align-items: center;
  width: min(340px, 74vw);
  font-size: .78rem;
  letter-spacing: .09em;
  color: var(--hud-fg);
  opacity: .75;
  cursor: default;
}

#mixer label {
  text-transform: uppercase;
  white-space: nowrap;
}

#mixer output {
  min-width: 3ch;
  text-align: right;
  color: var(--hud-fg);
  font-variant-numeric: tabular-nums;
}

#mixer input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .2);
  cursor: pointer;
}

/* Keyboard focus stays visible - it is how the sliders are reachable at all
   without a mouse - but as a thin accent line rather than the browser's
   default box, which reads as a broken widget next to the other one. */
#mixer input[type="range"]:focus-visible {
  outline: 1px solid var(--hud-fg);
  outline-offset: 4px;
}

/* A square cap, not a round one - the rest of this game is monospaced text
   and blocky particles, and a soft blue pill was the one thing on screen
   pretending to be a native widget. */
#mixer input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 0;
  border: 0;
  background: var(--hud-fg);
}

#mixer input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 0;
  border: 0;
  background: var(--hud-fg);
}

#hud {
  padding: env(safe-area-inset-top) 0 0 env(safe-area-inset-left);
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 10;
  pointer-events: none;
  font-size: 1.5rem;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* The arrival card. Sits high so it never covers the road, fades rather than
   appears, and cannot be clicked - it is an announcement, not a dialogue. */
#arrival {
  position: fixed;
  top: max(16vh, calc(60px + env(safe-area-inset-top)));
  left: 0;
  right: 0;
  z-index: 12;
  text-align: center;
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
  /* No plate behind it. Space and the ice sheet are pale enough that white
     letters vanish into them, so on those two the type goes black instead
     - which is all the contrast it needs and leaves the world untouched.
     The shadow is on the glyphs, not behind the card. */
  text-shadow: 0 1px 14px rgba(0, 0, 0, .85), 0 0 3px rgba(0, 0, 0, .6);
}

#arrival.bright {
  text-shadow: 0 1px 14px rgba(255, 255, 255, .95), 0 0 3px rgba(255, 255, 255, .8);
}

#arrival.bright b { color: #0a0e15; }
#arrival.bright span { color: rgba(10, 14, 21, .7); }

#arrival.show { opacity: 1; }

#arrival b {
  display: block;
  font-weight: normal;
  font-size: clamp(1.6rem, 5vw, 2.9rem);
  letter-spacing: .34em;
  text-indent: .34em;   /* the last letter's tracking, put back */
  text-transform: uppercase;
  color: var(--hud-fg);
}

#arrival span {
  display: block;
  margin-top: .7em;
  font-size: clamp(.68rem, 1.8vw, .86rem);
  letter-spacing: .22em;
  text-indent: .22em;
  color: var(--hud-dim);
}

#toast {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 10;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--hud-dim);
  background: rgba(8, 12, 22, .6);
  border: 1px solid rgba(120, 170, 220, .2);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
}
