/* The page around the canvas. Everything that is not the game itself.
   Safe-area insets come from --safe-* ONCE here and are read as var() everywhere else, so a host
   that already insets the frame can zero them in one place instead of every rule. */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --ink: #f4f1ea;
  --bad: #ff7a6b;
  --panel: rgba(12, 16, 22, 0.82);
}

* { box-sizing: border-box; }

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

#stage, #gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at 50% 45%, transparent 52%, rgba(4, 8, 14, 0.5) 100%);
}

#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: #fff; opacity: 0; transition: opacity 90ms linear;
}

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }

/* ---- the live bar ---------------------------------------------------- */

.bar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 14px);
  right: calc(var(--safe-right) + 14px);
  display: flex; gap: 10px; align-items: flex-start;
}
.stat {
  background: rgba(9, 13, 19, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px; padding: 6px 12px 5px; min-width: 68px;
  text-align: center; backdrop-filter: blur(6px);
}
.stat b { display: block; font-size: 20px; line-height: 1.05; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat i { display: block; font-size: 8.5px; letter-spacing: 0.16em; opacity: 0.6; font-style: normal; margin-top: 2px; }
.stat:last-child { margin-left: auto; }

.track {
  position: absolute;
  top: calc(var(--safe-top) + 76px);
  left: calc(var(--safe-left) + 14px);
  right: calc(var(--safe-right) + 14px);
  height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.13);
}
.fill { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #8fd66a, #d8f08a); transition: width 140ms linear; }

/* ---- toast ----------------------------------------------------------- */

.toast {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 96px);
  background: rgba(9, 13, 19, 0.72); border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 7px 16px; border-radius: 999px; font-size: 13px; letter-spacing: 0.02em;
  opacity: 0; transition: opacity 220ms ease; white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ---- panels ---------------------------------------------------------- */

.panel {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  background: var(--panel); backdrop-filter: blur(10px); text-align: center;
}
.panel.hidden { display: none; }

.panel h1 { margin: 0; font-size: clamp(30px, 8vw, 54px); line-height: 0.95; letter-spacing: -0.02em; }
.panel h1 span { color: #ffd166; }
.panel h2 { margin: 0; font-size: clamp(22px, 6vw, 38px); letter-spacing: 0.02em; }
.panel h2.bad, .panel .bad { color: var(--bad); }

.lede { margin: 0; max-width: 30rem; font-size: 14px; line-height: 1.55; opacity: 0.82; }
.lede em { color: #ffd166; font-style: normal; }
.best { margin: 0; font-size: 13px; letter-spacing: 0.18em; opacity: 0.65; }
.go { margin: 6px 0 0; font-size: 11px; letter-spacing: 0.16em; opacity: 0.5; text-transform: uppercase; }

.grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.grid > div {
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px; padding: 10px 18px; min-width: 92px;
}
.grid b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.grid i { display: block; font-size: 8.5px; letter-spacing: 0.16em; opacity: 0.6; font-style: normal; margin-top: 3px; }

.herd {
  list-style: none; margin: 4px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center;
  max-width: 34rem; font-size: 13px; opacity: 0.9;
}
.herd li { display: flex; align-items: center; gap: 7px; }
.sw { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.35); }
