:root {
  --ink: #17201d;
  --paper: rgba(255, 251, 240, 0.9);
  --paper-strong: rgba(255, 251, 240, 0.98);
  --clay: #bd6146;
  --moss: #2f6f56;
  --gold: #d7a640;
  --sea: #4a9ca1;
  --shadow: rgba(19, 28, 25, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  background: #f0dfbd;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

#game-canvas {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 245, 206, 0.5), transparent 26rem),
    linear-gradient(180deg, #94c7bd 0%, #f0dfbd 58%, #c97955 100%);
  display: block;
  height: 100vh;
  inset: 0;
  position: fixed;
  touch-action: none;
  width: 100vw;
}

.top-buttons {
  align-items: center;
  background: rgba(255, 251, 240, 0.76);
  border: 1px solid rgba(23, 32, 29, 0.1);
  border-radius: 999px;
  box-shadow: 0 14px 36px rgba(19, 28, 25, 0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  left: 50%;
  padding: 7px;
  position: fixed;
  top: 14px;
  transform: translateX(-50%);
  width: min(92vw, 620px);
  z-index: 8;
}

.top-buttons a {
  background: rgba(255, 255, 255, 0.54);
  border-radius: 999px;
  color: #26312d;
  flex: 1 1 auto;
  font-size: 0.78rem;
  font-weight: 800;
  min-width: max-content;
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
}

.nav-toggle {
  display: none;
}

.game-shell {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 5;
}

.hud,
.intro-panel,
.instruction-chip,
.touch-controls {
  pointer-events: auto;
}

.hud {
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.94), rgba(255, 251, 240, 0.72));
  border: 1px solid rgba(23, 32, 29, 0.12);
  border-radius: 8px;
  box-shadow: 0 22px 54px var(--shadow);
  display: grid;
  gap: 14px;
  left: 18px;
  padding: 16px;
  position: absolute;
  top: 80px;
  width: min(360px, calc(100vw - 36px));
}

.hud__brand {
  display: grid;
  gap: 3px;
}

.hud__eyebrow,
.route-panel__label,
.intro-panel__kicker {
  color: var(--moss);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud h1,
.intro-panel h2 {
  line-height: 1.05;
  margin: 0;
}

.hud h1 {
  font-size: clamp(1.7rem, 5vw, 2.45rem);
}

.hud__stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hud__stats div {
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(23, 32, 29, 0.08);
  border-radius: 8px;
  min-width: 0;
  padding: 9px;
}

.hud__stats span {
  color: #62716b;
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.hud__stats strong {
  display: block;
  font-size: 1.1rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.route-panel {
  background: rgba(47, 111, 86, 0.1);
  border: 1px solid rgba(47, 111, 86, 0.16);
  border-radius: 8px;
  padding: 12px;
}

.route-panel p {
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.35;
  margin: 5px 0 0;
}

.signal-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.signal-strip span {
  background: rgba(189, 97, 70, 0.12);
  border: 1px solid rgba(189, 97, 70, 0.2);
  border-radius: 999px;
  color: #5f3328;
  font-size: 0.72rem;
  font-weight: 850;
  padding: 7px 9px;
}

.hud__actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 0.72fr 0.72fr;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.hud__actions button,
.intro-panel button,
.boost-button {
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(23, 32, 29, 0.2);
  color: #fff8e8;
  min-height: 44px;
  padding: 10px 12px;
}

.hud__actions button:nth-child(2) {
  background: var(--sea);
}

.hud__actions button:nth-child(3) {
  background: var(--clay);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(215, 166, 64, 0.72);
  outline-offset: 3px;
}

.intro-panel {
  align-items: start;
  background: linear-gradient(135deg, rgba(255, 251, 240, 0.96), rgba(250, 224, 171, 0.84));
  border: 1px solid rgba(23, 32, 29, 0.1);
  border-radius: 8px;
  box-shadow: 0 24px 64px var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 520px;
  padding: 20px;
  position: absolute;
  right: 22px;
  top: 118px;
  width: min(520px, calc(100vw - 44px));
}

.intro-panel[hidden] {
  display: none;
}

.intro-panel h2 {
  font-size: clamp(1.45rem, 4vw, 2.25rem);
  margin-top: 7px;
}

.intro-panel p {
  color: #4d5c55;
  font-size: 1rem;
  line-height: 1.5;
  margin: 10px 0 0;
}

.intro-panel button {
  background: var(--moss);
  justify-self: start;
  min-width: 152px;
}

.instruction-chip {
  background: rgba(23, 32, 29, 0.82);
  border: 1px solid rgba(255, 248, 232, 0.24);
  border-radius: 999px;
  bottom: 22px;
  box-shadow: 0 16px 36px rgba(23, 32, 29, 0.2);
  color: #fff8e8;
  font-size: 0.88rem;
  font-weight: 850;
  left: 50%;
  max-width: min(560px, calc(100vw - 40px));
  padding: 11px 16px;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
}

.touch-controls {
  align-items: end;
  bottom: 22px;
  display: flex;
  gap: 14px;
  position: absolute;
  right: 18px;
}

.touch-pad {
  background: rgba(255, 251, 240, 0.44);
  border: 1px solid rgba(23, 32, 29, 0.14);
  border-radius: 50%;
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.15), 0 16px 36px rgba(23, 32, 29, 0.14);
  display: none;
  height: 118px;
  position: relative;
  touch-action: none;
  width: 118px;
}

.touch-pad__nub {
  background: var(--paper-strong);
  border: 2px solid rgba(23, 32, 29, 0.18);
  border-radius: 50%;
  box-shadow: 0 10px 22px rgba(23, 32, 29, 0.18);
  height: 42px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
}

.boost-button {
  background: var(--gold);
  color: #2b2412;
  display: none;
  height: 64px;
  min-width: 72px;
}

@media (hover: none), (pointer: coarse) {
  .touch-pad,
  .boost-button {
    display: block;
  }
}

@media (max-width: 820px) {
  .nav-toggle {
    background: rgba(255, 251, 240, 0.92);
    border: 1px solid rgba(23, 32, 29, 0.12);
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(23, 32, 29, 0.14);
    color: var(--ink);
    display: block;
    font-size: 0.86rem;
    min-height: 42px;
    padding: 9px 14px;
    position: fixed;
    right: 14px;
    top: 12px;
    z-index: 10;
  }

  .top-buttons {
    align-items: stretch;
    border-radius: 8px;
    display: none;
    left: auto;
    right: 14px;
    top: 62px;
    transform: none;
    width: min(280px, calc(100vw - 28px));
  }

  .top-buttons.is-open {
    display: grid;
  }

  .hud {
    gap: 10px;
    left: 12px;
    padding: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }

  .hud h1 {
    font-size: 1.45rem;
  }

  .hud__brand {
    padding-right: 76px;
  }

  .hud__stats div {
    padding: 8px;
  }

  .hud__stats strong {
    font-size: 0.98rem;
  }

  .route-panel p {
    font-size: 0.84rem;
  }

  .signal-strip {
    display: none;
  }

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

  .hud__actions button {
    min-height: 40px;
    padding: 8px;
  }

  .touch-pad,
  .boost-button {
    display: block;
  }

  .intro-panel {
    left: 12px;
    max-width: none;
    padding: 16px;
    right: 12px;
    top: 260px;
    width: auto;
  }

  .intro-panel h2 {
    font-size: 1.35rem;
  }

  .intro-panel p {
    font-size: 0.9rem;
  }

  .touch-controls {
    bottom: 18px;
    left: 18px;
    right: auto;
  }

  .instruction-chip {
    bottom: 156px;
    font-size: 0.78rem;
    padding: 10px 13px;
  }
}

@media (max-height: 680px) and (max-width: 820px) {
  .intro-panel {
    top: 210px;
  }

  .intro-panel p {
    display: none;
  }

  .instruction-chip {
    bottom: 18px;
    left: auto;
    right: 14px;
    transform: none;
    width: min(280px, calc(100vw - 164px));
  }
}
