/* Edge Runner. Full-bleed canvas with glass panels on top, so the 3D scene does
   the talking and the interface stays out of the way. */

:root {
  --red: #ff282d;
  --red-soft: #ff5f52;
  --ice: #9fdcff;
  --amber: #ffb020;
  --ink: #05070a;
  --text: #e9eef4;
  --muted: #8d9bab;
  --panel: rgba(7, 10, 15, 0.82);
  --panel-line: rgba(255, 255, 255, 0.09);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  color: var(--text);
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-family: var(--mono);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.hud.on { opacity: 1; }

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px clamp(14px, 3vw, 30px);
}

.label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 116px;
}

.value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.shields-panel { text-align: right; }
.shields { display: flex; gap: 6px; justify-content: flex-end; margin: 7px 0 4px; }

.shield {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  transform: rotate(45deg);
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 40, 45, 0.75);
  transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.shield.gone {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: none;
  opacity: 0.5;
}

.word-panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 10px 16px 12px;
  text-align: center;
}

.word {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 7px 0 9px;
}

.slot {
  width: 27px;
  height: 33px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  font-family: var(--sans);
  font-weight: 800;
  font-size: 19px;
  color: rgba(255, 255, 255, 0.22);
  transition: all 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.slot.got {
  color: #fff;
  border-style: solid;
  border-color: rgba(255, 40, 45, 0.75);
  background: rgba(255, 40, 45, 0.18);
  text-shadow: 0 0 14px rgba(255, 40, 45, 0.9);
  transform: translateY(-2px);
}

.slot.next {
  border-color: rgba(255, 176, 32, 0.7);
  color: rgba(255, 176, 32, 0.8);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  50% { border-color: rgba(255, 176, 32, 0.2); }
}

.edge-meter {
  height: 4px;
  width: 168px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin: 0 auto;
}

.edge-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--red), var(--amber));
  transition: width 0.18s linear;
}

.edge-hint {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
  transition: color 0.2s ease;
}

.edge-hint.ready { color: var(--amber); }
.edge-hint.ready kbd { border-color: var(--amber); color: var(--amber); }

.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 clamp(14px, 3vw, 30px) 18px;
  display: flex;
  justify-content: flex-start;
}

.speed { width: min(280px, 42vw); }

.speed-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.unit {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.speed-bar {
  height: 3px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.speed-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ice), var(--red));
  transition: width 0.12s linear;
}

.toast-stack {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
}

.toast {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(17px, 3.4vw, 27px);
  letter-spacing: -0.01em;
  padding: 6px 16px;
  border-radius: 99px;
  background: rgba(5, 7, 10, 0.86);
  border: 1px solid var(--panel-line);
  animation: toast 1.5s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.toast.red { color: var(--red-soft); border-color: rgba(255, 40, 45, 0.4); }
.toast.amber { color: var(--amber); border-color: rgba(255, 176, 32, 0.45); }
.toast.ice { color: var(--ice); border-color: rgba(159, 220, 255, 0.45); }

@keyframes toast {
  0% { opacity: 0; transform: translateY(14px) scale(0.9); }
  16% { opacity: 1; transform: translateY(0) scale(1.04); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px) scale(0.97); }
}

.flash {
  position: absolute;
  inset: 0;
  background: var(--red);
  opacity: 0;
}

.flash.on { animation: flash 0.4s ease-out; }
.flash.ice.on { background: var(--ice); }

@keyframes flash {
  0% { opacity: 0.55; }
  100% { opacity: 0; }
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 190px 40px rgba(0, 0, 0, 0.72);
  opacity: 0.85;
  transition: box-shadow 0.3s ease, opacity 0.3s ease;
}

.vignette.hurt {
  box-shadow: inset 0 0 200px 46px rgba(255, 40, 45, 0.6);
  opacity: 1;
}

.vignette.edge {
  box-shadow: inset 0 0 210px 40px rgba(159, 220, 255, 0.34);
  opacity: 1;
}

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(58, 6, 12, 0.86), rgba(5, 7, 10, 0.96) 62%);
  z-index: 5;
  animation: screen-in 0.4s ease;
}

.screen[hidden] { display: none; }

@keyframes screen-in {
  from { opacity: 0; }
}

.screen-inner {
  width: min(560px, 100%);
  text-align: center;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red-soft);
  margin: 0 0 12px;
}

.title {
  font-size: clamp(46px, 12vw, 86px);
  line-height: 0.94;
  font-weight: 850;
  letter-spacing: -0.045em;
  margin: 0 0 6px;
}

.title span { color: var(--red); }
.title.small { font-size: clamp(30px, 7vw, 46px); }

.lede {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 42ch;
  margin: 14px auto 22px;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 20px;
  margin: 0 0 26px;
}

.keys div {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.keys span { margin-left: 4px; letter-spacing: 0.04em; }

.cta {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #fff;
  background: var(--red);
  border: 0;
  border-radius: 99px;
  padding: 15px 38px;
  cursor: pointer;
  box-shadow: 0 12px 34px -10px rgba(255, 40, 45, 0.85);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.cta:hover {
  transform: translateY(-2px);
  background: #ff4238;
  box-shadow: 0 18px 40px -12px rgba(255, 40, 45, 1);
}

.cta:active { transform: translateY(0) scale(0.98); }

.cta:focus-visible { outline: 2px solid var(--ice); outline-offset: 4px; }

.fineprint {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(141, 155, 171, 0.8);
  margin: 20px 0 0;
  line-height: 1.7;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
  margin: 4px 0 20px;
}

.results > div {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  padding: 12px 8px;
  display: grid;
  gap: 5px;
}

.big {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.unsupported {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--ink);
  z-index: 20;
  text-align: center;
}

.unsupported[hidden] { display: none; }

.countdown {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 6;
  font-family: var(--mono);
  font-size: clamp(64px, 18vw, 150px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 60px rgba(255, 40, 45, 0.9);
}

.countdown[hidden] { display: none; }

.countdown span { display: block; animation: count 0.7s ease-out forwards; }

@keyframes count {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.86); }
}

@media (max-width: 620px) {
  .value { font-size: 23px; }
  .panel { min-width: 88px; padding: 8px 10px; }
  .word-panel { padding: 8px 10px 10px; }
  .edge-meter { width: 118px; }
  .slot { width: 20px; height: 26px; font-size: 15px; }
  .keys { gap: 8px 12px; }
  .hud-top { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .countdown span, .screen { animation-duration: 0.01s; }
  .slot.next { animation: none; }
}
