:root {
  color-scheme: dark;
  --ink: #fff6df;
  --muted: #dfcaa8;
  --night: #160f13;
  --panel: rgba(25, 16, 17, 0.82);
  --gold: #ffd43b;
  --orange: #ff8243;
  --cyan: #28dcff;
  --line: rgba(255, 246, 223, 0.22);
  font-family: "Arial Black", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
}

button,
kbd {
  font: inherit;
}

.game-shell,
#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

.brand-bar {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 24px 12px;
  pointer-events: none;
}

.brand-lockup {
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.brand-lockup div {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-lockup strong {
  font-size: 17px;
}

.brand-lockup span:not(.brand-mark) {
  margin-top: 5px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.22em;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 8px 8px 15px 15px;
  background: #7c3f26;
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.2), 0 4px 18px rgba(0, 0, 0, 0.3);
  color: var(--gold);
  font-size: 23px;
}

.prototype-tag {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 13, 15, 0.45);
  color: var(--muted);
  font: 700 9px/1 system-ui, sans-serif;
  letter-spacing: 0.16em;
}

.hud {
  position: fixed;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.score-card {
  position: absolute;
  top: 86px;
  left: 24px;
  display: flex;
  min-width: 172px;
  flex-direction: column;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.score-card span,
.boost-wrap > span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.score-card strong {
  color: var(--gold);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 27px;
  letter-spacing: 0.06em;
}

.score-card small {
  color: var(--muted);
  font: 700 11px/1.4 system-ui, sans-serif;
  text-transform: uppercase;
}

.score-card small b {
  color: var(--ink);
}

.time-card {
  position: absolute;
  top: 84px;
  left: 50%;
  display: flex;
  min-width: 118px;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  color: var(--ink);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}

.time-card span {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 30px;
}

.time-card small {
  color: var(--muted);
  font: 700 9px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.combo {
  position: absolute;
  top: 154px;
  left: 50%;
  min-height: 44px;
  transform: translateX(-50%) rotate(-2deg);
  color: var(--cyan);
  font-size: clamp(23px, 3vw, 38px);
  text-shadow: 3px 3px 0 #102237, 0 0 18px rgba(40, 220, 255, 0.45);
  white-space: nowrap;
}

.boost-wrap {
  position: absolute;
  bottom: max(25px, env(safe-area-inset-bottom));
  left: 50%;
  width: min(440px, calc(100vw - 48px));
  transform: translateX(-50%);
  text-align: center;
}

.boost-track {
  height: 22px;
  margin-top: 7px;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: rgba(12, 18, 31, 0.85);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
}

.boost-track i {
  display: block;
  width: 55%;
  height: 100%;
  background: repeating-linear-gradient(135deg, #f6ff71 0 11px, var(--cyan) 11px 22px);
  box-shadow: 0 0 18px var(--cyan);
  transition: width 80ms linear;
}

.modal-panel {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: clamp(24px, 7vw, 100px);
  width: min(560px, calc(100vw - 48px));
  padding: clamp(24px, 4vw, 46px);
  transform: translateY(-44%) translateX(-24px);
  border: 1px solid rgba(255, 246, 223, 0.25);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(29, 18, 18, 0.94), rgba(51, 28, 23, 0.83));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(12px);
}

.modal-panel.is-visible {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.modal-panel::before {
  position: absolute;
  top: -7px;
  right: 32px;
  width: 76px;
  height: 13px;
  transform: skewX(-22deg);
  background: var(--gold);
  content: "";
}

.eyebrow {
  margin-bottom: 15px;
  color: var(--gold);
  font: 800 10px/1 system-ui, sans-serif;
  letter-spacing: 0.22em;
}

.modal-panel h1,
.modal-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(42px, 7vw, 74px);
  line-height: 0.92;
  letter-spacing: -0.06em;
  text-transform: uppercase;
}

.modal-panel h2 {
  font-size: clamp(36px, 6vw, 62px);
}

.modal-panel em {
  color: var(--orange);
  font-style: normal;
}

.modal-panel p {
  max-width: 48ch;
  margin: 22px 0;
  color: var(--muted);
  font: 500 15px/1.55 system-ui, sans-serif;
}

.primary-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  background: var(--gold);
  box-shadow: 0 6px 0 #9e591e, 0 14px 28px rgba(0, 0, 0, 0.25);
  color: #2f1b15;
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 0.08em;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #9e591e, 0 18px 32px rgba(0, 0, 0, 0.3);
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #9e591e;
}

.controls-list {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 24px;
  color: var(--muted);
  font: 700 10px/1.5 system-ui, sans-serif;
  text-transform: uppercase;
}

kbd {
  display: inline-grid;
  min-width: 25px;
  height: 24px;
  margin-right: 4px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 9px;
}

.touch-controls {
  position: fixed;
  z-index: 8;
  right: clamp(16px, 3vw, 42px);
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px));
  left: clamp(16px, 3vw, 42px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transform: translateY(18px);
  visibility: hidden;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
}

.touch-controls,
.touch-controls * {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-shell.controls-active .touch-controls {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition-delay: 0s;
}

.joystick-wrap,
.action-controls {
  display: flex;
  pointer-events: auto;
}

.joystick-wrap {
  position: relative;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.control-caption {
  color: var(--muted);
  font: 900 9px/1 system-ui, sans-serif;
  letter-spacing: 0.2em;
  text-shadow: 0 2px 5px #000;
}

.joystick {
  position: relative;
  width: 118px;
  height: 86px;
  border: 3px solid rgba(255, 246, 223, 0.66);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.18)),
    rgba(26, 17, 20, 0.82);
  box-shadow: inset 0 5px 12px rgba(0, 0, 0, 0.42), 0 8px 0 rgba(0, 0, 0, 0.26);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.joystick:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

.joystick.is-active {
  cursor: grabbing;
}

.joystick i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffb062, var(--orange) 54%, #9e4429 56%);
  box-shadow: 0 6px 0 #6c2d22, 0 10px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: transform 55ms linear;
}

.joystick-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 246, 223, 0.5);
  font: 900 12px/1 system-ui, sans-serif;
  pointer-events: none;
}

.left-arrow {
  left: 9px;
}

.right-arrow {
  right: 9px;
}

.action-controls {
  align-items: flex-end;
  gap: 13px;
}

.action-button {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  width: 82px;
  height: 82px;
  padding: 8px;
  place-content: center;
  gap: 5px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffb15d, var(--orange));
  box-shadow: 0 7px 0 #813c28, 0 12px 22px rgba(0, 0, 0, 0.38);
  color: var(--ink);
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.action-button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .action-button:hover {
    outline: 3px solid var(--cyan);
    outline-offset: 4px;
  }
}

.action-button:active,
.action-button.is-pressed {
  transform: translateY(6px);
  box-shadow: 0 1px 0 #813c28, 0 5px 10px rgba(0, 0, 0, 0.36);
}

.action-icon {
  font-size: 25px;
  line-height: 1;
  pointer-events: none;
}

.button-label {
  font: 900 9px/1 system-ui, sans-serif;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.boost-button {
  width: 94px;
  height: 94px;
  border-color: var(--cyan);
  background: linear-gradient(145deg, #2d4560, #17243a);
  box-shadow: 0 7px 0 #0e1325, 0 0 22px rgba(40, 220, 255, 0.28);
  color: var(--cyan);
}

.boost-button:active,
.boost-button.is-pressed {
  box-shadow: 0 1px 0 #0e1325, 0 0 30px rgba(40, 220, 255, 0.55);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (pointer: coarse), (max-width: 760px) {
  .boost-wrap {
    bottom: max(16px, env(safe-area-inset-bottom));
    width: min(290px, calc(100vw - 255px));
  }

  .score-card {
    top: 78px;
    left: 14px;
    min-width: 142px;
    padding: 10px 12px;
  }

  .score-card strong {
    font-size: 21px;
  }

  .time-card {
    top: 80px;
    right: 14px;
    left: auto;
    transform: none;
  }

  .modal-panel {
    top: auto;
    right: 14px;
    bottom: 120px;
    left: 14px;
    width: auto;
    max-height: calc(100vh - 180px);
    padding: 25px;
    transform: translateY(20px);
  }

  .modal-panel.is-visible {
    transform: translateY(0);
  }

  .modal-panel h1,
  .modal-panel h2 {
    font-size: clamp(34px, 11vw, 56px);
  }

  .modal-panel p {
    margin: 16px 0;
  }

  .controls-list,
  .prototype-tag {
    display: none;
  }

  .joystick {
    width: 104px;
    height: 78px;
  }

  .joystick i {
    width: 49px;
    height: 49px;
  }

  .action-button {
    width: 68px;
    height: 68px;
  }

  .boost-button {
    width: 78px;
    height: 78px;
  }
}

@media (max-width: 520px) {
  .boost-wrap {
    bottom: max(11px, env(safe-area-inset-bottom));
    width: min(160px, calc(100vw - 230px));
  }

  .action-controls {
    gap: 8px;
  }

  .action-button {
    width: 62px;
    height: 62px;
  }

  .boost-button {
    width: 70px;
    height: 70px;
  }

  .action-icon {
    font-size: 21px;
  }
}

@media (max-height: 640px) {
  .modal-panel p {
    margin: 12px 0;
  }

  .controls-list {
    margin-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
