:root {
  color-scheme: dark;
  --ink: #f8efe2;
  --muted: #cbbeb0;
  --black: #070707;
  --panel: #171514;
  --brick: #b94830;
  --brick-dark: #712b22;
  --cream: #f4ead8;
  --gold: #e5b44d;
  --blue: #3e94b8;
  --green: #45a66a;
  --font-display: "Bungee", "Arial Black", Impact, sans-serif;
  --font-ui: "Barlow Condensed", Inter, ui-sans-serif, system-ui, sans-serif;
  --font-body: "Barlow Condensed", Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  background: #090807;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  overscroll-behavior: none;
}

button,
a,
input,
select {
  font: inherit;
}

button,
a {
  min-height: 46px;
}

.app-shell {
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

.cover-screen {
  min-height: 100vh;
  position: relative;
  display: grid;
  align-items: end;
  padding: clamp(22px, 4vw, 64px);
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 38%, rgba(229, 180, 77, 0.25), transparent 30%),
    linear-gradient(90deg, rgba(7, 7, 7, 0.96) 0%, rgba(36, 24, 18, 0.54) 55%, rgba(7, 7, 7, 0.92) 100%),
    repeating-linear-gradient(0deg, #6f3d31 0 28px, #8c4c38 28px 56px);
}

.cover-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 5, 5, 0.6) 0%, rgba(5, 5, 5, 0.34) 30%, rgba(5, 5, 5, 0.06) 58%, rgba(5, 5, 5, 0.08) 100%),
    linear-gradient(0deg, rgba(5, 5, 5, 0.5) 0%, rgba(5, 5, 5, 0.1) 38%, rgba(5, 5, 5, 0) 68%);
}

.cover-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0b0d0f;
  pointer-events: none;
}

.cover-picture,
.cover-poster {
  display: block;
  width: 100%;
  height: 100%;
}

.cover-poster {
  object-fit: cover;
  object-position: center;
}

.cover-copy {
  position: relative;
  z-index: 6;
  max-width: 520px;
  margin: 0 0 clamp(82px, 11vh, 140px);
  text-shadow: 5px 5px 0 rgba(5, 5, 5, 0.78);
}

.cover-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin-bottom: 14px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(5px 5px 0 #050505);
}

.eyebrow,
.speaker {
  color: var(--gold);
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 15px;
  font-weight: 900;
}

.cover-copy h1 {
  margin: 8px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(56px, 9.2vw, 126px);
  font-weight: 400;
  line-height: 0.88;
  letter-spacing: 0;
}

.tagline {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(18.9px, 2.025vw, 23.4px);
  font-weight: 700;
  line-height: 1.25;
}

.cover-actions,
.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.cover-actions button,
.cover-actions a,
.dialog-card button,
.entry-actions button {
  display: inline-grid;
  place-items: center;
  padding: 0 24px;
  border: 3px solid #050505;
  border-radius: 6px;
  background: var(--cream);
  color: #111;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 950;
  box-shadow: 5px 5px 0 #050505;
  cursor: pointer;
}

.cover-actions a {
  background: #111;
  color: var(--cream);
  border-color: var(--cream);
  box-shadow: 5px 5px 0 rgba(244, 234, 216, 0.3);
}

.game-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at 72% 12%, rgba(229, 180, 77, 0.25), transparent 30%),
    linear-gradient(180deg, #181513, #090807 78%);
}

.debug-control {
  display: none !important;
}

.debug-mode .debug-control {
  display: inline-flex !important;
}

.hud {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(220px, auto) minmax(360px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 0 12px;
}

.hud-left,
.hud-center,
.hud-right {
  min-width: 0;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 86px;
  padding: 12px 16px;
  border: 2px solid rgba(244, 234, 216, 0.12);
  border-radius: 8px;
  background: rgba(8, 8, 8, 0.42);
}

.hud-center {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 3px solid #050505;
  border-radius: 8px;
  background: var(--cream);
  color: #111;
  font-size: 32px;
  font-weight: 950;
}

.brand-lockup p,
.brand-lockup h2 {
  margin: 0;
}

.brand-lockup p {
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 900;
}

.brand-lockup h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.hud-label {
  color: var(--gold);
  font-family: var(--font-ui);
  text-transform: uppercase;
  font-size: 15px;
  font-weight: 950;
}

.life-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
}

.life-shoe {
  position: relative;
  width: 42px;
  height: 22px;
  display: inline-block;
  filter: drop-shadow(3px 3px 0 #050505);
}

.life-shoe::before,
.life-shoe::after {
  content: "";
  position: absolute;
  display: block;
}

.life-shoe::before {
  left: 4px;
  top: 4px;
  width: 34px;
  height: 14px;
  border: 3px solid #050505;
  border-radius: 12px 13px 7px 5px;
  background:
    linear-gradient(90deg, var(--cream) 0 64%, var(--brick) 64% 100%);
}

.life-shoe::after {
  left: 0;
  bottom: 0;
  width: 40px;
  height: 6px;
  border: 2px solid #050505;
  border-radius: 999px;
  background: #111;
}

@supports (background-image: url("./assets/sprites/collectibles/brick-after-brick-shoe-life.png")) {
  .life-shoe {
    width: 52px;
    height: 64px;
    background: url("./assets/sprites/collectibles/brick-after-brick-shoe-life.png") center / contain no-repeat;
  }

  .life-shoe::before,
  .life-shoe::after {
    display: none;
  }
}

.life-shoe.is-empty {
  opacity: 0.28;
  filter: grayscale(1) drop-shadow(3px 3px 0 #050505);
}

.timer {
  min-width: 128px;
  border: 3px solid #050505;
  border-radius: 7px;
  background: var(--cream);
  color: #111;
  padding: 7px 13px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 4px 4px 0 #050505;
}

.run-progress {
  position: relative;
  width: min(250px, 42vw);
  height: 10px;
  overflow: hidden;
  border: 2px solid #050505;
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.8);
  box-shadow: 3px 3px 0 #050505;
}

.run-progress::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 9px 0 0 var(--brick);
}

.run-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brick), var(--gold));
  transition: width 180ms ease-out;
}

.run-status {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.mark img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 900;
}

.stats span,
.controls span {
  border: 2px solid #302b26;
  border-radius: 6px;
  background: rgba(8, 8, 8, 0.74);
  padding: 9px 11px;
  min-width: 96px;
  text-align: center;
}

.stats span {
  display: grid;
  min-width: 104px;
  min-height: 48px;
  align-content: center;
  gap: 3px;
  border-color: rgba(244, 234, 216, 0.15);
  background:
    linear-gradient(180deg, rgba(244, 234, 216, 0.06), rgba(244, 234, 216, 0)),
    rgba(8, 8, 8, 0.78);
  box-shadow: inset 0 1px 0 rgba(244, 234, 216, 0.08);
}

.stats span::before {
  content: attr(data-label);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.stage-wrap {
  position: relative;
  width: min(1120px, 100%, calc((100vh - 250px) * 16 / 9));
  border: 4px solid #050505;
  border-radius: 8px;
  overflow: hidden;
  background: #050505;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.48);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.run-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 6;
  display: grid;
  place-items: center;
  max-width: min(520px, calc(100% - 32px));
  min-height: 42px;
  padding: 8px 18px;
  border: 3px solid #050505;
  border-radius: 7px;
  background: rgba(244, 234, 216, 0.96);
  color: #111;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 5px 5px 0 #050505;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
}

.run-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 5, 5, 0.48);
}

.overlay.is-comic-intro {
  place-items: center;
  background:
    linear-gradient(90deg, rgba(6, 5, 5, 0.38), rgba(6, 5, 5, 0.12)),
    rgba(244, 234, 216, 0.08);
}

.dialog-card,
.entry-card,
.legend-card {
  border: 4px solid #050505;
  border-radius: 8px;
  padding: 22px;
  background: rgba(244, 234, 216, 0.97);
  color: #111;
  box-shadow: 9px 9px 0 #050505;
}

.dialog-card {
  width: min(520px, 94%);
}

.entry-card {
  width: min(620px, 94%);
}

.legend-card {
  width: min(900px, 94%);
  max-height: calc(100% - 28px);
  overflow: auto;
  padding: 16px 18px;
}

.legend-card h3 {
  margin: 2px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(27px, 3.2vw, 38px);
  font-weight: 400;
  line-height: 0.96;
}

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

.legend-panel {
  display: grid;
  gap: 8px;
  border: 3px solid #15100d;
  border-radius: 8px;
  background: #fffaf1;
  padding: 8px;
}

.legend-panel h4 {
  margin: 0;
  color: var(--brick);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.legend-items {
  display: grid;
  gap: 4px;
}

.legend-items div {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.legend-items div.is-wide {
  grid-template-columns: 84px minmax(0, 1fr);
}

.legend-items div.is-bus {
  grid-template-columns: 108px minmax(0, 1fr);
}

.legend-items div.is-tall {
  grid-template-columns: 50px minmax(0, 1fr);
}

.legend-items img,
.legend-sprite,
.legend-bus {
  width: 38px;
  height: 30px;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.legend-items div.is-wide img {
  width: 84px;
  height: 38px;
}

.legend-items div.is-bus img {
  width: 108px;
  height: 44px;
}

.legend-items div.is-tall img {
  width: 50px;
  height: 54px;
}

.legend-items span:last-child {
  color: #241916;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.05;
}

.legend-sprite {
  background-image: url("./assets/sprites/world/generated/course-variety-sheet.png");
  background-repeat: no-repeat;
  background-size: 768px 512px;
}

.legend-ticket {
  background-position: -609px -105px;
}

.legend-barrier {
  background-position: -24px -86px;
}

.legend-paint {
  background-position: -385px -335px;
}

.legend-van {
  background-position: -391px -95px;
}

.legend-ramp {
  background-position: -204px -99px;
}

.legend-drone {
  background-position: -590px -274px;
}

.legend-crowd {
  background-position: -27px -272px;
}

.legend-bus {
  position: relative;
  border: 3px solid #050505;
  border-radius: 6px;
  background: #d9b23d;
}

.legend-bus::before {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 8px;
  height: 8px;
  background: var(--cream);
}

.legend-bus::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -6px;
  height: 6px;
  background: var(--green);
}

.legend-card > button {
  display: grid;
  position: sticky;
  bottom: 0;
  z-index: 2;
  place-items: center;
  min-height: 42px;
  margin: 10px auto 0;
  padding: 0 34px;
  border: 3px solid #050505;
  border-radius: 6px;
  background: var(--cream);
  color: #111;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 950;
  box-shadow: 5px 5px 0 #050505;
  cursor: pointer;
}

.overlay.is-comic-intro .dialog-card {
  position: relative;
  width: min(720px, 94%);
  min-height: 250px;
  padding: 28px 250px 28px 28px;
  overflow: visible;
  text-align: center;
}

.overlay.is-comic-intro .dialog-card::before {
  content: "";
  position: absolute;
  right: -64px;
  bottom: -20px;
  width: 290px;
  height: 310px;
  background: url("./assets/sprites/nigel/poses/talk.png") right bottom / contain no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(8px 8px 0 rgba(5, 5, 5, 0.72));
}

.overlay.is-comic-intro .dialog-card::after {
  content: "";
  position: absolute;
  right: 176px;
  top: 78px;
  width: 32px;
  height: 32px;
  background: inherit;
  border-right: 4px solid #050505;
  border-bottom: 4px solid #050505;
  transform: rotate(-45deg);
}

.overlay.is-comic-intro .dialog-card button {
  margin-inline: auto;
}

.legend-card .speaker {
  color: var(--brick);
}

.overlay.is-win-scene {
  place-items: center start;
  padding-left: 28px;
  background:
    linear-gradient(90deg, rgba(6, 5, 5, 0.32), rgba(6, 5, 5, 0.08) 62%),
    rgba(6, 5, 5, 0.24);
}

.overlay.is-win-scene .dialog-card {
  width: min(430px, 47%);
  padding: 18px 20px;
}

.overlay.is-win-scene .dialog-card h3 {
  font-size: clamp(34px, 4vw, 46px);
  margin-bottom: 0;
}

.dialog-card h3,
.entry-card h3 {
  margin: 2px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.1vw, 50px);
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: 0;
}

.entry-card h3 {
  font-size: clamp(32px, 4.2vw, 48px);
}

.dialog-card p,
.entry-card p {
  margin: 0;
  color: #372b25;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.12;
}

.overlay.is-comic-intro #dialogText {
  font-size: 18px;
}

.overlay.is-bike-scene #dialogText {
  font-size: 18px;
}

.overlay.is-win-scene #dialogText {
  font-size: 18px;
}

.dialog-card .speaker,
.entry-card .speaker {
  color: var(--brick);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: #372b25;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 2px solid #15100d;
  border-radius: 6px;
  background: #fffaf1;
  color: #111;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
}

.consent {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.consent input {
  width: 18px;
  min-height: 18px;
}

.entry-status {
  min-height: 20px;
  margin-top: 10px !important;
  font-weight: 800;
}

.leaderboard {
  margin-top: 12px;
  border: 2px solid #15100d;
  border-radius: 8px;
  background: #fffaf1;
  padding: 10px 12px;
}

.leaderboard-title {
  margin: 0 0 7px !important;
  color: #15100d !important;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 950;
  text-transform: uppercase;
}

.leaderboard ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 22px;
}

.leaderboard li {
  color: #372b25;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
}

.controls {
  width: min(1120px, 100%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 700;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  margin-right: 5px;
  border: 2px solid #2e2924;
  border-radius: 5px;
  background: #111;
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 900;
}

.touch-controls {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: none;
  grid-template-columns: 1fr 1.15fr 1fr 0.9fr;
  gap: 10px;
  pointer-events: none;
}

.touch-controls button {
  min-height: 58px;
  border: 3px solid #050505;
  border-radius: 8px;
  background: rgba(244, 234, 216, 0.9);
  color: #111;
  font-family: var(--font-ui);
  font-size: 19px;
  font-weight: 950;
  box-shadow: 4px 4px 0 #050505;
  pointer-events: auto;
  touch-action: none;
}

body:has(#dialog:not(.is-hidden)) .touch-controls,
body:has(#legendOverlay:not(.is-hidden)) .touch-controls,
body:has(#entryOverlay:not(.is-hidden)) .touch-controls {
  display: none;
}

@media (max-width: 820px) {
  .cover-screen {
    min-height: 100svh;
    align-items: start;
    padding: 18px;
  }

  .cover-art {
    min-height: 100%;
  }

  .cover-poster {
    object-fit: contain;
    object-position: center top;
  }

  .cover-copy {
    max-width: 360px;
    margin: 18px 0 0;
  }

  .cover-logo {
    width: 62px;
    height: 62px;
    margin-bottom: 8px;
  }

  .cover-copy h1 {
    font-size: clamp(46px, 17vw, 76px);
  }

  .tagline {
    max-width: 310px;
    font-size: 17.1px;
  }

  .cover-actions {
    margin-top: 16px;
  }

  .hud {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
    padding-bottom: 8px;
  }

  .stage-wrap {
    width: min(1120px, 100%);
    overflow: visible;
  }

  .hud-left,
  .hud-center,
  .stats {
    justify-content: flex-start;
  }

  .hud-center {
    justify-items: start;
  }

  .run-progress {
    width: 100%;
  }

  .stats {
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    font-size: 16px;
  }

  .stats span {
    min-width: 0;
    min-height: 42px;
    padding: 7px 8px;
  }

  .stats span::before {
    font-size: 11px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .legend-card {
    width: 100%;
    max-height: calc(100vh - 28px);
    padding: 14px;
  }

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

  .legend-card h3 {
    font-size: 28px;
    margin-bottom: 10px;
  }

  .legend-panel {
    padding: 8px;
  }

  .legend-items div {
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 42px;
  }

  .legend-items div.is-wide {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .legend-items div.is-bus {
    grid-template-columns: 118px minmax(0, 1fr);
  }

  .legend-items div.is-tall {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .legend-items img,
  .legend-sprite,
  .legend-bus {
    width: 48px;
    height: 38px;
  }

  .legend-items div.is-wide img {
    width: 96px;
    height: 46px;
  }

  .legend-items div.is-bus img {
    width: 118px;
    height: 52px;
  }

  .legend-items div.is-tall img {
    width: 60px;
    height: 66px;
  }

  .legend-items span:last-child {
    font-size: 15px;
  }

  .legend-card > button {
    position: sticky;
    bottom: 0;
    width: min(180px, 100%);
  }

  .overlay.is-comic-intro .dialog-card {
    min-height: 0;
    padding: 12px 14px;
  }

  .overlay {
    position: fixed;
    inset: 8px;
    z-index: 40;
    padding: 8px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .overlay.is-comic-intro .dialog-card h3 {
    font-size: clamp(25px, 7.5vw, 34px);
    line-height: 0.96;
  }

  .overlay.is-comic-intro .dialog-card p:not(.speaker) {
    font-size: 16px;
    line-height: 1.08;
  }

  .overlay.is-comic-intro #dialogText {
    font-size: 14.4px;
  }

  .overlay.is-comic-intro .dialog-card button {
    min-height: 40px;
    padding: 0 18px;
    font-size: 16px;
  }

  .overlay.is-comic-intro .dialog-card::before,
  .overlay.is-comic-intro .dialog-card::after {
    display: none;
  }

  .overlay.is-win-scene {
    place-items: center;
    padding-left: 18px;
  }

  .overlay.is-win-scene .dialog-card {
    width: min(520px, 94%);
  }

  .dialog-card,
  .entry-card {
    width: min(520px, 100%);
    max-height: calc(100svh - 32px);
    overflow: auto;
  }

  .entry-card {
    padding: 14px;
  }

  .entry-card h3 {
    font-size: clamp(28px, 8vw, 38px);
  }

  .entry-actions {
    gap: 8px;
  }

  .entry-actions button {
    flex: 1 1 120px;
    padding-inline: 14px;
  }
}

@media (max-width: 760px), (pointer: coarse) {
  .game-screen {
    min-height: 100svh;
    padding: 10px 10px calc(78px + env(safe-area-inset-bottom, 0px));
    align-content: start;
  }

  .controls {
    display: none;
  }

  .touch-controls {
    display: grid;
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .touch-controls button {
    min-height: 54px;
    padding: 0 8px;
    font-size: 18px;
  }
}

@media (max-width: 600px) {
  .cover-screen {
    padding: 14px;
  }

  .cover-poster {
    object-fit: contain;
    object-position: center top;
  }

  .cover-copy {
    max-width: 300px;
  }

  .cover-logo {
    width: 54px;
    height: 54px;
  }

  .cover-copy h1 {
    font-size: clamp(42px, 17vw, 66px);
  }

  .tagline {
    max-width: 270px;
    font-size: 15.3px;
    line-height: 1.18;
  }

  .cover-actions button,
  .cover-actions a {
    min-height: 44px;
    padding-inline: 18px;
  }

  .hud-left {
    min-height: 62px;
    padding: 7px 10px;
  }

  .life-row {
    min-height: 44px;
  }

  .life-shoe {
    width: 40px;
    height: 50px;
  }

  .brand-lockup {
    gap: 7px;
  }

  .mark {
    width: 36px;
    height: 36px;
    border-width: 2px;
  }

  .mark img {
    width: 28px;
    height: 28px;
  }

  .brand-lockup p {
    font-size: 11px;
  }

  .brand-lockup h2 {
    font-size: 18px;
  }

  .timer {
    min-width: 112px;
    padding: 6px 10px;
    font-size: 18px;
  }

  .stage-wrap {
    border-width: 3px;
  }

  .legend-card {
    padding: 12px;
  }

  .legend-items div,
  .legend-items div.is-wide,
  .legend-items div.is-bus,
  .legend-items div.is-tall {
    grid-template-columns: 54px minmax(0, 1fr);
    min-height: 42px;
  }

  .legend-items img,
  .legend-items div.is-wide img,
  .legend-items div.is-bus img,
  .legend-items div.is-tall img {
    width: 54px;
    height: 42px;
  }

  .legend-items span:last-child {
    font-size: 14px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .cover-screen {
    align-items: end;
    padding: 14px 18px;
  }

  .cover-poster {
    object-position: center;
  }

  .cover-copy {
    max-width: 330px;
    margin-bottom: 24px;
  }

  .cover-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
  }

  .cover-copy h1 {
    font-size: clamp(44px, 8vw, 66px);
  }

  .tagline {
    max-width: 300px;
    font-size: 14.4px;
    line-height: 1.12;
  }

  .cover-actions {
    margin-top: 12px;
  }

  .cover-actions button,
  .cover-actions a {
    min-height: 40px;
    padding-inline: 18px;
  }

  .game-screen {
    grid-template-rows: auto auto 1fr;
    padding: 6px 8px calc(62px + env(safe-area-inset-bottom, 0px));
  }

  .hud {
    grid-template-columns: auto minmax(220px, 0.7fr) minmax(260px, 1fr);
    gap: 8px;
    padding-bottom: 6px;
  }

  .hud-left {
    min-height: 56px;
    padding: 5px 8px;
  }

  .hud-label {
    font-size: 12px;
  }

  .life-row {
    gap: 6px;
    min-height: 38px;
  }

  .life-shoe {
    width: 34px;
    height: 42px;
  }

  .hud-center {
    grid-template-columns: auto auto;
    justify-content: center;
    align-items: center;
    gap: 6px 10px;
  }

  .brand-lockup {
    gap: 6px;
  }

  .mark {
    width: 32px;
    height: 32px;
    border-width: 2px;
  }

  .mark img {
    width: 25px;
    height: 25px;
  }

  .brand-lockup p {
    font-size: 10px;
  }

  .brand-lockup h2 {
    font-size: 15px;
  }

  .timer {
    min-width: 96px;
    padding: 5px 8px;
    font-size: 16px;
    box-shadow: 3px 3px 0 #050505;
  }

  .run-progress {
    grid-column: 1 / -1;
    width: 100%;
    height: 8px;
  }

  .run-status {
    display: none;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    font-size: 13px;
  }

  .stats span {
    min-width: 0;
    min-height: 38px;
    padding: 5px 4px;
  }

  .stats span::before {
    font-size: 9px;
  }

  .stage-wrap {
    width: min(100%, calc((100svh - 128px) * 16 / 9));
    border-width: 3px;
  }

  .controls {
    display: none;
  }

  .touch-controls {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr 0.82fr;
    gap: 7px;
  }

  .touch-controls button {
    min-height: 48px;
    font-size: 16px;
  }

  .overlay {
    position: fixed;
    inset: 6px;
    padding: 6px;
    overflow: auto;
  }

  .legend-card {
    width: min(760px, 100%);
    max-height: calc(100svh - 20px);
    padding: 10px;
  }

  .legend-card h3 {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .legend-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .legend-panel {
    padding: 6px;
    gap: 5px;
  }

  .legend-panel h4 {
    font-size: 13px;
  }

  .legend-items {
    gap: 3px;
  }

  .legend-items div,
  .legend-items div.is-wide,
  .legend-items div.is-bus,
  .legend-items div.is-tall {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 6px;
    min-height: 34px;
  }

  .legend-items img,
  .legend-items div.is-wide img,
  .legend-items div.is-bus img,
  .legend-items div.is-tall img {
    width: 46px;
    height: 34px;
  }

  .legend-items span:last-child {
    font-size: 12px;
  }

  .legend-card > button {
    min-height: 38px;
    margin-top: 8px;
  }

  .dialog-card,
  .entry-card {
    max-height: calc(100svh - 20px);
    padding: 12px 14px;
  }

  .dialog-card h3,
  .entry-card h3 {
    font-size: clamp(26px, 6vw, 36px);
  }

  .dialog-card p,
  .entry-card p {
    font-size: 16px;
  }

  .overlay.is-comic-intro #dialogText {
    font-size: 14.4px;
  }

  .overlay.is-bike-scene #dialogText {
    font-size: 14.4px;
  }

  .overlay.is-win-scene #dialogText {
    font-size: 14.4px;
  }
}
