@font-face {
  font-family: "Barlow Condensed";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("vendor/fonts/barlow-condensed-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("vendor/fonts/barlow-condensed-700.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  src: url("vendor/fonts/barlow-condensed-800.woff2") format("woff2");
}
@font-face {
  font-family: "Saira Stencil One";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("vendor/fonts/saira-stencil-one.woff2") format("woff2");
}

:root {
  --plate-hi: #dfe5e7;
  --plate: #b6bfc3;
  --plate-lo: #737e83;
  --ink: #1b2a31;
  --safety: #f6c21c;
  --safety-lo: #b98b05;
  --crab: #d9262c;
  --sea: #0b4a5c;
  --foam: #f2f7f5;
  --stencil: "Saira Stencil One", "Arial Black", sans-serif;
  --sign: "Barlow Condensed", "Arial Narrow", sans-serif;
  --gutter: max(12px, env(safe-area-inset-left));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sea);
  color: var(--foam);
  font-family: var(--sign);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.3;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#world { z-index: 0; }
#overlay { z-index: 1; touch-action: none; cursor: grab; }

[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--foam); outline-offset: 2px; }

/* Stamped steel, the same material as the plates on the belts. */
.plate {
  background:
    radial-gradient(circle at 6px 6px, #5d686d 2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 6px) 6px, #5d686d 2px, transparent 2.6px),
    radial-gradient(circle at 6px calc(100% - 6px), #5d686d 2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 6px) calc(100% - 6px), #5d686d 2px, transparent 2.6px),
    linear-gradient(180deg, var(--plate-hi), var(--plate) 60%, #a2acb0);
  border: 1px solid var(--plate-lo);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 #f3f6f7, 0 3px 0 #48535a;
  color: var(--ink);
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.icon-btn {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  padding: 0;
}
.icon-btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #f3f6f7, 0 1px 0 #48535a; }

.pause-glyph { width: 15px; height: 17px; border-left: 5px solid var(--ink); border-right: 5px solid var(--ink); }

.parts {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 20px;
  min-width: 128px;
  height: 46px;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.parts.bump { animation: bump 0.16s ease-out; }
@keyframes bump { 40% { transform: scale(1.08); } }

.parts-bolt, .bolt {
  display: inline-block;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%);
}
.parts-bolt { width: 21px; height: 19px; background: var(--ink); }

.hud-status {
  align-self: center;
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.gauge {
  position: relative;
  width: 100%;
  height: 22px;
  background: rgba(16, 28, 34, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  overflow: hidden;
}
.gauge-fill {
  position: absolute;
  inset: 0;
  transform-origin: left;
  background: #3fbf7f;
  transition: transform 0.2s;
}
.gauge.warn .gauge-fill { background: var(--safety); }
.gauge.danger .gauge-fill { background: var(--crab); }
.gauge-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  grid-auto-flow: column;
  justify-content: center;
  gap: 5px;
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.gauge-text b { font-weight: 800; font-variant-numeric: tabular-nums; }

.wave-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  font-weight: 700;
  font-size: 17px;
  text-shadow: 0 1px 3px rgba(4, 30, 38, 0.95), 0 0 2px rgba(4, 30, 38, 0.9);
}
.send {
  pointer-events: auto;
  background: var(--safety);
  color: var(--ink);
  border: 0;
  border-radius: 3px;
  box-shadow: 0 2px 0 var(--safety-lo);
  padding: 3px 11px 2px;
  font-weight: 800;
  font-size: 15px;
  text-shadow: none;
}
.send:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--safety-lo); }

.effects { display: flex; gap: 6px; }
.effect {
  padding: 2px 10px;
  border-radius: 3px;
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.banner, .coach {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 440px);
  text-align: center;
  padding: 9px 14px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
}
.banner {
  top: 142px;
  background: var(--ink);
  color: var(--foam);
  border-left: 5px solid var(--safety);
}
.banner.alert { background: var(--crab); border-left-color: var(--foam); }
.coach {
  bottom: max(18px, env(safe-area-inset-bottom));
  background: var(--safety);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--safety-lo);
}

/* Screens */
.screen { position: fixed; inset: 0; z-index: 3; }

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: max(9vh, 46px) 20px max(5vh, 28px);
  background: linear-gradient(180deg, rgba(5, 42, 54, 0.62), rgba(5, 42, 54, 0) 44%, rgba(5, 42, 54, 0) 68%, rgba(5, 42, 54, 0.6));
}
.title {
  margin: 0;
  font-family: var(--stencil);
  font-weight: 400;
  font-size: clamp(50px, 15.5vw, 118px);
  line-height: 1;
  color: var(--foam);
  /* Road paint: a hard offset, not a glow. */
  text-shadow: 0 4px 0 rgba(16, 28, 34, 0.78);
  animation: paint 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes paint {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(-20% -5% -20% 0); }
}
.tagline { margin: 12px 0 0; font-size: clamp(21px, 5.2vw, 29px); font-weight: 700; text-shadow: 0 2px 3px rgba(4, 30, 38, 0.9); }
.promise { margin: 3px 0 0; font-size: clamp(18px, 4.4vw, 23px); text-shadow: 0 2px 3px rgba(4, 30, 38, 0.9); }
.title-screen .btn.big { margin-top: auto; }
.title-screen .btn.quiet { margin-top: 12px; }

.btn {
  display: block;
  width: 100%;
  padding: 11px 18px 10px;
  border: 1px solid var(--plate-lo);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--plate-hi), var(--plate));
  box-shadow: inset 0 1px 0 #f3f6f7, 0 3px 0 #48535a;
  color: var(--ink);
  font-weight: 800;
  font-size: 21px;
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #f3f6f7, 0 1px 0 #48535a; }
.btn.primary {
  background: var(--safety);
  border-color: var(--safety-lo);
  box-shadow: inset 0 1px 0 #ffe27a, 0 3px 0 var(--safety-lo);
  font-family: var(--stencil);
  font-weight: 400;
}
.btn.primary:active { box-shadow: inset 0 1px 0 #ffe27a, 0 1px 0 var(--safety-lo); }
.btn.big { width: min(100%, 290px); font-size: 33px; padding: 12px 18px 11px; }
.btn.quiet { width: auto; padding: 6px 14px 5px; font-size: 18px; }

.panel-screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) 30px;
  background: rgba(7, 52, 66, 0.95);
}
.panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto 8px;
  padding: 4px 0 8px;
  background: rgba(7, 52, 66, 0.96);
}
.panel-head .btn { justify-self: start; }
.panel-head h2 { margin: 0; font-family: var(--stencil); font-weight: 400; font-size: 27px; white-space: nowrap; }
.bolt-total { justify-self: end; display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }

.level-list { max-width: 760px; margin: 0 auto; }
.zone-name { margin: 16px 0 8px; font-size: 21px; font-weight: 700; }
.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 11px;
}

.level-plate {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 9px 12px 11px;
  text-align: center;
  width: 100%;
}
.level-plate:not(:disabled):active { transform: translateY(2px); box-shadow: inset 0 1px 0 #f3f6f7, 0 1px 0 #48535a; }
.level-plate .num { font-family: var(--stencil); font-size: 44px; line-height: 1; }
.level-plate .name { font-weight: 700; font-size: 18px; white-space: nowrap; }
.level-plate:disabled { opacity: 0.42; cursor: default; }
.level-plate.current { outline: 3px solid var(--safety); outline-offset: 1px; }

.bolts { display: flex; gap: 5px; justify-content: center; margin-top: 3px; }
.bolt { width: 15px; height: 14px; background: rgba(27, 42, 49, 0.28); }
.bolt.on { background: var(--ink); }
.bolts.large { margin: 2px 0 6px; gap: 9px; }
.bolts.large .bolt { width: 36px; height: 32px; }
.bolts.large .bolt.on { background: #b98b05; }
.bolt-total .bolt { background: var(--safety); }

.dialog-screen {
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 52, 66, 0.55);
}
.dialog {
  width: min(100%, 350px);
  padding: 20px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  text-align: center;
}
.dialog h2 { margin: 0; font-family: var(--stencil); font-weight: 400; font-size: 32px; line-height: 1.05; }
.dialog p { margin: 0 0 4px; font-weight: 700; line-height: 1.25; }

.fatal {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 26px;
  text-align: center;
  background: var(--sea);
  font-size: 21px;
}

@media (max-height: 500px) {
  .title { font-size: 58px; }
  .title-screen { padding-top: 16px; }
  .banner { top: 96px; }
  .hud-status { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: min(40%, 300px); margin-top: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .title, .parts.bump { animation: none; }
  .gauge-fill { transition: none; }
}
