/* System fonts only — no external hosts anywhere in this game. */

:root {
  --ink: #f2f0ec;
  --dim: rgba(242, 240, 236, 0.55);
  --faint: rgba(242, 240, 236, 0.28);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
}

#gl {
  display: block;
  width: 100%;
  height: 100%;
}

/* The whole HUD sits above the canvas and never eats a pointer event — every control in this
   game is the canvas, so anything here that could swallow a tap is a bug waiting to happen. */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  font-variant-numeric: tabular-nums;
}

/* --- flash + vignette ------------------------------------------------------ */

#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  mix-blend-mode: screen;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
  opacity: 0.85;
}

/* --- stage plate (top left) ------------------------------------------------ */

.plate {
  position: absolute;
  top: 22px;
  left: 26px;
  line-height: 1.15;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.plate.on { opacity: 1; }

.plate .num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--faint);
}
.plate .name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.16em;
  margin-top: 3px;
}
.plate .size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  margin-top: 5px;
  letter-spacing: 0.04em;
}

/* --- growth meter (left edge) ---------------------------------------------- */

.meter {
  position: absolute;
  left: 28px;
  bottom: 92px;
  width: 3px;
  height: 168px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.meter.on { opacity: 1; }
.meter i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  background: var(--ink);
  border-radius: 2px;
  height: 0%;
  transition: height 0.18s ease-out;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
}
.meter label {
  position: absolute;
  left: 12px;
  bottom: -2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--faint);
  white-space: nowrap;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

/* --- objective + verb hint (bottom centre) --------------------------------- */

.hint {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.6s ease;
  max-width: min(560px, 86vw);
}
.hint.on { opacity: 1; }
.hint .obj {
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.85);
}
.hint .verb {
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--dim);
  text-transform: uppercase;
}
.hint .verb b {
  color: var(--ink);
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  padding: 2px 7px;
  margin: 0 3px;
}

/* --- title card (centre, on stage entry) ----------------------------------- */

.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.card.on { opacity: 1; }
.card .n {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.4em;
  color: var(--faint);
}
.card .t {
  font-size: clamp(34px, 8vw, 76px);
  font-weight: 200;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.8);
}
.card .s {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.28em;
  color: var(--dim);
}
.card .b {
  margin-top: 6px;
  font-size: 15px;
  color: var(--dim);
  font-style: italic;
  letter-spacing: 0.02em;
}

/* --- dialogue (bottom, the intro and the ending) --------------------------- */

.say {
  position: absolute;
  left: 50%;
  bottom: 13%;
  transform: translateX(-50%);
  text-align: center;
  font-size: clamp(17px, 2.6vw, 25px);
  font-weight: 300;
  letter-spacing: 0.03em;
  line-height: 1.5;
  max-width: min(740px, 88vw);
  opacity: 0;
  transition: opacity 0.9s ease;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.9);
}
.say.on { opacity: 1; }

/* --- the growth banner between stages -------------------------------------- */

.grew {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.grew.on { opacity: 1; }
.grew .k {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: var(--faint);
}
.grew .v {
  font-family: var(--mono);
  font-size: clamp(22px, 4.4vw, 40px);
  letter-spacing: 0.12em;
  margin-top: 8px;
}

/* --- corner note ------------------------------------------------------------ */

.note {
  position: absolute;
  right: 26px;
  top: 24px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--faint);
  text-align: right;
  line-height: 1.7;
}

/* --- phones ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .plate { top: 14px; left: 16px; }
  .plate .name { font-size: 16px; }
  .meter { left: 18px; bottom: 108px; height: 130px; }
  .hint { bottom: 30px; }
  .hint .obj { font-size: 14px; }
  .note { right: 16px; top: 16px; }
}

@media (max-height: 480px) {
  .meter { height: 96px; bottom: 74px; }
  .say { bottom: 9%; }
}

/* --- stage select ---------------------------------------------------------- */
/* The HUD is pointer-events:none so gameplay taps always reach the canvas; the menu is the one
   layer that opts back in, and it stops its own clicks so a tap never also serves as a game tap. */

.menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(18px, 4vh, 46px) 20px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.86) 70%);
  backdrop-filter: blur(2px);
}
.menu.on { opacity: 1; visibility: visible; pointer-events: auto; }

.menu-head { text-align: center; margin-bottom: 20px; }
.menu-title {
  font-size: clamp(30px, 6.5vw, 58px);
  font-weight: 200;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}
.menu-sub {
  margin-top: 8px;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--dim);
  font-style: italic;
}

.menu-start {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 13px 26px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}
.menu-start:hover, .menu-start:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.7);
  outline: none;
  transform: translateY(-1px);
}

.menu-label {
  margin: 26px 0 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--faint);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 940px;
}

.menu-tile {
  --tint: #fff;
  --bg: #14141a;
  --fg: rgba(242, 240, 236, 0.92);
  --fg-dim: rgba(242, 240, 236, 0.5);
  --edge: rgba(255, 255, 255, 0.14);
  font: inherit;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--edge);
  border-left: 3px solid var(--tint);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  padding: 9px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 74px;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.menu-tile:hover, .menu-tile:focus-visible {
  transform: translateY(-2px);
  border-color: var(--tint);
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--tint) inset;
  outline: none;
}
.menu-tile i {
  font-family: var(--mono);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
}
.menu-tile b {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  color: var(--tint);
}
.menu-tile u {
  font-family: var(--mono);
  text-decoration: none;
  font-size: 10px;
  color: var(--fg-dim);
  margin-top: auto;
}

.menu-foot {
  margin-top: 22px;
  padding-bottom: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--faint);
  text-align: center;
}
.menu-foot b { color: var(--dim); font-weight: 600; }

.menu-btn {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 25;
  font: inherit;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--faint);
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  padding: 6px 11px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s, color 0.15s ease, border-color 0.15s ease;
}
.menu-btn.on { opacity: 1; visibility: visible; pointer-events: auto; }
.menu-btn:hover, .menu-btn:focus-visible {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.5);
  outline: none;
}

@media (max-width: 640px) {
  .menu-grid { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
  .menu-tile { min-height: 64px; padding: 7px 8px; }
  .menu-tile b { font-size: 11px; }
  .menu-btn { top: 12px; right: 14px; }
  .note { top: 12px; right: 78px; }
}
