:root {
  --bg: #08131f;
  --bg-alt: #101c2b;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.2);
  --text: #eaf4ff;
  --muted: #9eb5cd;
  --accent: #ff3d2e;
  --accent-2: #0bd6ff;
  --ok: #65d364;
  --playfield-max-width: 980px;
  --playfield-max-height: 62vh;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, #1f3f64 0%, rgba(31, 63, 100, 0) 40%),
    radial-gradient(circle at 85% 10%, #3b2432 0%, rgba(59, 36, 50, 0) 35%),
    linear-gradient(155deg, var(--bg) 0%, #050910 100%);
  padding: 1rem;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.hero {
  margin: 1rem 0 1.75rem;
}

.kicker {
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0;
  color: var(--accent-2);
  font-size: 0.75rem;
}

h1 {
  margin: 0.2rem 0 0.45rem;
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", sans-serif;
  letter-spacing: 0.02em;
  font-size: clamp(2rem, 4vw, 3.1rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

.centre-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 61, 46, 0.8);
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 0.85rem;
}

.card h3 {
  margin: 0 0 0.3rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar {
  display: grid;
  gap: 1rem;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  margin-bottom: 1rem;
}

.btn {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff6847, var(--accent));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  padding: 0.6rem 0.9rem;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.site-meta h2 {
  margin: 0;
}

.site-meta p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hud {
  display: flex;
  gap: 0.65rem;
}

.hud-item {
  min-width: 84px;
  text-align: right;
}

.hud-action-btn {
  align-self: flex-end;
  white-space: nowrap;
  padding: 0.44rem 0.68rem;
  font-size: 0.8rem;
}

.hud-action-btn.active {
  border-color: rgba(11, 214, 255, 0.8);
  color: #b9f4ff;
}

.hud-action-btn.hint-flash {
  border-color: rgba(255, 115, 79, 0.95);
  color: #ffd6c8;
  animation: dirtHintFlash 0.75s ease-in-out infinite alternate;
}

.label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.value {
  font-size: 1.35rem;
  font-weight: 800;
}

#timer.night-shift {
  color: #a8f4ff;
  text-shadow:
    0 0 8px rgba(108, 214, 255, 0.65),
    0 0 16px rgba(255, 102, 204, 0.35);
  animation: nightShiftPulse 0.9s ease-in-out infinite alternate;
}

.tool-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.tool-panel {
  margin-bottom: 0.2rem;
}

.zone-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
}

.zone-panel .btn {
  padding: 0.42rem 0.72rem;
  font-size: 0.85rem;
}

.zone-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.tool-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
}

.tool-panel-head p {
  margin: 0;
}

.tool-panel-head p:first-child {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

#active-tool-label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-2);
}

.tool {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  padding: 0.75rem;
  cursor: pointer;
}

.tool strong {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.tool small {
  color: var(--muted);
}

.tool-icon {
  display: inline-grid;
  place-items: center;
  width: 1.1rem;
  font-size: 0.95rem;
  line-height: 1;
}

.tool.active {
  border-color: rgba(11, 214, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(11, 214, 255, 0.5) inset;
  background: linear-gradient(165deg, rgba(11, 214, 255, 0.16), rgba(255, 255, 255, 0.09));
}

.playfield-wrap {
  display: grid;
  place-items: center;
}

.playfield {
  position: relative;
  display: inline-block;
  width: fit-content;
  max-width: min(100%, var(--playfield-max-width));
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #07121f;
}

.playfield img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, var(--playfield-max-width));
  max-height: var(--playfield-max-height);
  user-select: none;
}

.playfield canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#fx-canvas {
  pointer-events: none;
}

#guide-canvas {
  pointer-events: none;
}

.truck-sprite {
  position: absolute;
  left: 0.7rem;
  bottom: 0.7rem;
  --truck-travel: 760px;
  --truck-scale: 1;
  z-index: 5;
  display: block;
  width: clamp(160px, 24vw, 250px);
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
  transform: translateX(var(--truck-travel)) scale(var(--truck-scale));
  transform-origin: left bottom;
  opacity: 0;
}

.truck-sprite.parked {
  transform: translateX(0) scale(var(--truck-scale));
  opacity: 1;
}

.truck-sprite.drive-in {
  animation: truckDriveIn 1.5s cubic-bezier(0.22, 0.7, 0.18, 1) forwards;
}

.truck-sprite img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.38));
}

.completion-card {
  position: absolute;
  inset: auto 1rem 1rem auto;
  border-radius: 12px;
  background: rgba(3, 18, 31, 0.92);
  border: 1px solid rgba(101, 211, 100, 0.7);
  padding: 0.8rem;
  max-width: 240px;
  animation: rise 220ms ease;
}

.completion-card h3 {
  margin: 0 0 0.25rem;
  color: var(--ok);
}

.completion-card p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.completion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.completion-actions .btn {
  flex: 1 1 auto;
}

.hidden {
  display: none;
}

.legend {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend p {
  margin: 0 0 0.3rem;
}

.legend ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
}

.swatch.dust {
  background: rgba(226, 193, 120, 0.85);
}

.swatch.mud {
  background: rgba(112, 74, 42, 0.9);
}

.swatch.bird {
  background: rgba(231, 237, 222, 0.95);
}

.swatch.soot {
  background: rgba(48, 50, 55, 0.95);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nightShiftPulse {
  from {
    text-shadow:
      0 0 7px rgba(108, 214, 255, 0.55),
      0 0 14px rgba(255, 102, 204, 0.28);
  }
  to {
    text-shadow:
      0 0 12px rgba(108, 214, 255, 0.82),
      0 0 22px rgba(255, 102, 204, 0.45);
  }
}

@keyframes dirtHintFlash {
  from {
    box-shadow:
      0 0 0 0 rgba(255, 92, 52, 0.42),
      0 0 10px rgba(255, 92, 52, 0.28);
  }
  to {
    box-shadow:
      0 0 0 6px rgba(255, 92, 52, 0),
      0 0 16px rgba(255, 92, 52, 0.45);
  }
}

@keyframes truckDriveIn {
  0% {
    transform: translateX(var(--truck-travel)) scale(var(--truck-scale));
    opacity: 1;
  }
  72% {
    transform: translateX(-4%) scale(var(--truck-scale));
    opacity: 1;
  }
  100% {
    transform: translateX(0) scale(var(--truck-scale));
    opacity: 1;
  }
}

@media (max-width: 760px) {
  :root {
    --playfield-max-width: 100%;
    --playfield-max-height: 52vh;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .hud {
    justify-content: flex-start;
  }
}
