:root {
  --bg: #0f0d0b;
  --fg: #e9dcc3;
  --dim: #6f6355;
  --mono: 'DejaVu Sans Mono', 'Cascadia Mono', 'Noto Sans Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font: 14px/1.4 var(--mono);
}

body {
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage { position: relative; line-height: 0; }
#screen { display: block; }

/* Scanlines: one CSS gradient, zero per-frame cost. */
body.scanlines #stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.35));
}

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--dim);
  font: inherit;
}
body.ready #boot { display: none; }

/* Touch controls, over the picture. One half of the screen is a floating
   stick, the other jumps (input.js). Shown only on touch (data-show="touch"),
   the stick appears under the thumb and the jump ring pulses where it landed,
   then both fade away; "always" leaves faint ghosts where they wait; "off"
   draws nothing but the pause. --ui and --glow are "r, g, b" from the current
   world's palette; --size comes from the options (main.js). */
#touch {
  --ui: 233, 220, 195;
  --glow: 242, 193, 78;
  --size: 1;
  position: fixed;
  inset: 0;
  z-index: 2;
  touch-action: none;
}
/* In the touch options the controls are only on show: taps go to the menu. */
#touch.preview, #touch.preview .pause { pointer-events: none; }

.stick, .tap {
  --d: calc(96px * var(--size));
  position: absolute;
  width: var(--d);
  height: var(--d);
  margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
}
.stick {
  border: 2px solid rgba(var(--ui), 0.5);
  background: rgba(var(--ui), 0.06);
}
.stick i {
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  background: rgba(var(--glow), 0.45);
}
.tap {
  --d: calc(76px * var(--size));
  border: 2px solid rgba(var(--glow), 0.8);
  background: rgba(var(--glow), 0.12);
}
.tap.on { animation: tap 0.18s ease-out; }
@keyframes tap { from { transform: scale(0.55); } }
.stick.on, .tap.on { opacity: 0.4; transition: none; }

/* Faint ghosts at rest: always shown, or while the touch options are open. */
#touch[data-show="always"] :is(.stick, .tap),
#touch.preview:not([data-show="off"]) :is(.stick, .tap) { opacity: 0.22; }
#touch[data-show="always"] :is(.stick, .tap).on { opacity: 0.45; }
#touch[data-show="off"] :is(.stick, .tap) { visibility: hidden; }

/* Top right corner, faint until pressed. */
.pause {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top));
  right: calc(env(safe-area-inset-right) + 2px);
  width: 48px;
  height: 44px;
  border: 0;
  color: rgba(var(--ui), 0.4);
  pointer-events: auto;
  /* Held, a bar fills underneath; when it is full the level restarts (input.js HOLD). */
  background: linear-gradient(rgb(var(--glow)), rgb(var(--glow))) no-repeat 50% 100% / 0 3px;
}
.pause.on {
  color: rgb(var(--glow));
  background-size: 32px 3px;
  transition: background-size 0.5s linear;
}
.pause::before, .pause::after {
  content: '';
  position: absolute;
  top: 14px;
  width: 5px;
  height: 16px;
  border-radius: 1px;
  background: currentColor;
}
.pause::before { left: 16px; }
.pause::after { right: 16px; }

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  background: var(--bg);
  place-content: center;
  text-align: center;
  gap: 18px;
  color: var(--dim);
}
#rotate pre { font: 16px/1.15 var(--mono); color: var(--fg); text-align: left; }

/* Touch-only devices get this before anything else (main.js): the game is made
   for a keyboard. Upright or not, it reads, so it sits above the rotate card. */
#phone {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--dim);
  text-align: center;
}
#phone[hidden] { display: none; }
#phone pre { font: 14px/1.15 var(--mono); color: var(--fg); margin-bottom: 8px; }
#phone p { text-wrap: balance; }
#phone .say { color: var(--fg); font-size: 16px; }
#phone .go { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 14px; }
#phone button {
  font: 15px var(--mono);
  padding: 12px 18px;
  border: 1px solid var(--dim);
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
}
#phone button.share { border-color: var(--fg); }
#phone button:active { background: rgba(233, 220, 195, 0.12); }
#phone .pad { font-size: 12px; margin-top: 6px; }

/* Phones only: upright tablets are wide enough to play. Same query in main.js. */
@media (orientation: portrait) and (pointer: coarse) and (max-width: 599px) {
  #rotate { display: grid; }
}
