:root {
  color-scheme: dark;
  --bg: #111418;
  --panel: #20252a;
  --text: #f5f3e8;
  --muted: #bfc2bd;
  --line: #424947;
  --accent: #d5fa68;
  --display: "Barlow Condensed", "Fira Sans Condensed", "Arial Narrow", "Arial Black", sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 1rem/1.5 var(--body);
  background-color: var(--bg);
  background-image: linear-gradient(#c1dac005 1px, transparent 1px), linear-gradient(90deg, #c1dac005 1px, transparent 1px);
  background-size: 32px 32px;
}
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { color: inherit; font: inherit; }
button, label:has(input), .button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.wrap { width: min(1280px, 91%); margin-inline: auto; }
main.wrap { padding-block: clamp(30px, 4.5vh, 64px) 40px; }
.masthead { background: #141719; border-bottom: 1px solid var(--line); }
.header-bar { display: flex; align-items: center; min-height: 72px; gap: clamp(24px, 5vw, 80px); }
.brand { display: inline-flex; gap: .65rem; align-items: center; font: 850 1.5rem/1 var(--display); letter-spacing: -.04em; white-space: nowrap; }
.brand img { width: 34px; height: 34px; image-rendering: pixelated; }
.nav { display: flex; align-self: stretch; gap: 24px; }
.nav a { display: inline-flex; align-items: center; border-block: 3px solid transparent; color: var(--muted); font-weight: 680; font-size: .92rem; }
.nav a:hover, .nav [aria-current] { color: var(--accent); }
.nav [aria-current] { border-bottom-color: var(--accent); }
.sound-button { margin-left: auto; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 40px; padding: 7px 12px; border: 1px solid var(--line); background: #202528; font: .85rem var(--mono); }
.sound-button:hover, .quiet:hover { border-color: var(--accent); color: var(--accent); }
.sound-button svg { width: 18px; height: 18px; }
.sound-button[aria-pressed="true"] .sound-slash, .sound-button[aria-pressed="false"] .sound-waves { display: none; }
.section-intro { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: clamp(20px, 3vh, 38px); }
.section-intro h1, .player-heading h1, .card-copy h2, .game-overlay h2 { font-family: var(--display); font-weight: 900; font-style: italic; letter-spacing: -.045em; text-transform: uppercase; }
.section-intro h1 { font-size: clamp(2.9rem, 6.3vw, 6rem); line-height: .94; }
.section-intro em { color: var(--accent); }
.section-intro p { margin-top: .6rem; color: var(--muted); font-size: 1.04rem; }
.speed-stripes { width: clamp(64px, 12vw, 175px); height: clamp(24px, 3.6vw, 48px); margin-right: 8px; background: repeating-linear-gradient(90deg, transparent 0 8px, #d5fa68 8px 24px); transform: skewX(-24deg); opacity: .94; }
.library-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 2.4vw, 32px); }
.cartridge { --sport: var(--accent); position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-bottom: 4px solid var(--sport); background: #202529; }
.cartridge.athletics { --sport: #ff9566; }
.cartridge.driving { --sport: #77e1db; }
.cartridge:focus-within, .cartridge:hover { border-color: var(--sport); }
.cover { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.cover img { width: 100%; display: block; aspect-ratio: 1.91; object-fit: cover; image-rendering: pixelated; }
.athletics .cover img { object-position: center 57%; }
.driving .cover img { object-position: center 59%; }
.discipline { position: absolute; top: 14px; left: 14px; padding: 4px 10px; color: #172019; background: var(--sport); font: 720 .82rem/1.45 var(--mono); letter-spacing: .06em; text-transform: uppercase; box-shadow: 3px 3px 0 #0c101abd; }
.card-copy { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: clamp(15px, 2vw, 27px); }
.card-copy h2 { font-size: clamp(1.65rem, 3vw, 2.9rem); line-height: 1; }
.card-copy p { color: var(--muted); font-size: .96rem; margin-top: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .58rem; min-height: 42px; padding: .68rem 1.15rem; font: 730 .94rem/1.2 var(--body); border: 1px solid transparent; }
.primary { color: #121810; background: var(--sport, var(--accent)); }
.primary:hover { filter: brightness(1.09); }
.cartridge a::after { content: ""; position: absolute; inset: 0; }
.quiet { color: var(--text); border-color: var(--line); background: #202528; }
.play-icon { display: inline-block; width: 0; height: 0; border-block: 5px solid transparent; border-left: 8px solid currentColor; flex: 0 0 auto; }
.score-panel, .setup, .overlay-card { border: 1px solid var(--line); background: #1b2024; }
.score-panel { padding: clamp(15px, 3vw, 38px); }
.score-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.score-table :is(th, td) { border-bottom: 1px solid var(--line); text-align: right; padding: .65em .4em; }
.score-table thead th { color: var(--muted); font: .85rem/1.25 var(--mono); }
.score-table tr > :first-child { text-align: left; }
.score-table tbody td:last-child { color: var(--accent); }
.player-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.player-heading h1 { font-size: clamp(2rem, 4vw, 4rem); line-height: 1; }
.game-name { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
#running-difficulty { display: none; }
.playing #running-difficulty { display: inline; color: var(--muted); font: .875rem/1.2 var(--mono); }
.setup { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(0, 1fr); }
.setup-stage {
  min-width: 0; padding: clamp(16px, 2.6vw, 35px); border-right: 1px solid var(--line);
  background: linear-gradient(145deg, #272f31, #171c20 72%);
}
.setup-preview { margin: 0; }
.preview-screen { background: #080b0e; border: 1px solid #59655d; box-shadow: 0 6px 16px #090b0e66; }
.preview-screen img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.setup-preview figcaption { margin-top: 9px; color: var(--muted); font-size: .83rem; }
.graphics-setting {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 6px 12px;
  padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line);
}
.graphics-setting label { color: var(--accent); font-weight: 750; }
.graphics-setting select {
  width: 100%; max-width: 17rem; min-height: 42px; padding: 5px 8px;
  border: 1px solid #68736b; border-radius: 0; background: #111719; cursor: pointer;
}
.graphics-setting select:hover { border-color: var(--accent); }
.graphics-detail { grid-column: 1 / -1; color: var(--muted); font-size: .83rem; }
.setup-body { min-width: 0; padding: clamp(18px, 2.6vw, 35px); }
.setup fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.setup #difficulty-setting { margin-top: 1.25rem; }
.setup :is(legend, h2) { font: 850 1.4rem/1.15 var(--display); }
.setup legend { padding: 0 0 .65rem; }
#coast-format fieldset + fieldset { margin-top: 1.1rem; }
.choices { display: flex; flex-wrap: wrap; gap: .45rem; }
.choices label { position: relative; }
.choices input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; }
.choices span { min-height: 42px; display: grid; place-items: center; padding: 8px 14px; font-weight: 690; border: 1px solid #636b66; }
.choices input:checked + span { color: #152015; border-color: var(--accent); background: var(--accent); }
.choices input:focus-visible + span { outline: 2px solid white; outline-offset: 3px; }
.mode-detail, #guide-objective { font-size: .97rem; color: var(--muted); margin-top: .65rem; }
.guide-controls { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; }
.guide-controls dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; margin-block: .7rem 1rem; font-size: .9rem; }
.guide-controls dt { color: var(--accent); font-family: var(--mono); }
.programme { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.programme h3 { font: 700 .83rem var(--mono); letter-spacing: .035em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.programme ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.event-choice { min-height: 30px; text-align: left; border: 1px solid transparent; background: #252b2d; color: var(--text); width: 100%; padding: 3px 7px; font-size: .91rem; }
.event-choice:hover, .event-choice[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
#launch-error { color: #ffb498; }
body.playing { background: #0e1113; }
.playing .header-bar { min-height: 46px; }
.playing .brand { font-size: 1.15rem; }
.playing .brand img { height: 26px; width: 26px; }
.playing .sound-button { min-height: 34px; }
.playing main.wrap {
  --game-width: min(96vw, calc((100vh - 168px) * 16 / 9));
  --game-width: min(96vw, calc((100dvh - 168px) * 16 / 9));
  width: var(--game-width); padding-block: 6px;
}
.playing .player-heading { margin-bottom: 4px; min-height: 30px; }
.playing .player-heading h1 { font-size: clamp(1.12rem, 2.2vw, 1.65rem); }
.playing .button.quiet { min-height: 32px; padding: 4px 11px; font-size: .875rem; }
.game-hud { height: 31px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 9px; color: #e0e5d9; background: #252b2c; border: 1px solid var(--line); font: .87rem/1.15 var(--mono); }
.hud-score { white-space: nowrap; }
.hud-score strong { color: var(--accent); }
#hud-status { text-align: right; }
.game-frame { position: relative; background: #080b0e; outline: 1px solid var(--line); }
.render-screen { width: 100%; height: auto; aspect-ratio: 16/9; display: block; }
.render-screen.pixelated { image-rendering: pixelated; }
#game-canvas { outline-offset: 1px; }
#game-canvas:focus { outline: none; }
#game-canvas:focus-visible { outline: 1px solid #83906d; }
.game-toolbar, .toolbar-actions, .overlay-actions { display: flex; align-items: center; gap: 7px; }
.game-toolbar { justify-content: space-between; margin-top: 5px; }
.rotation-tip { display: none; }
.pause-shortcut { color: var(--muted); font-size: .85rem; }
kbd { font-family: var(--mono); }
.game-overlay { position: absolute; inset: 0; display: grid; place-items: center; overflow: auto; padding: 8px; background: #0e1214c9; }
.game-overlay.is-paused { place-items: end start; background: linear-gradient(0deg, #0e121473, #0e121421 65%); }
.overlay-card { margin: auto; width: min(100%, 520px); padding: clamp(12px, 2vw, 26px); border-top: 4px solid var(--accent); }
.is-paused .overlay-card { margin: 0; width: min(100%, 440px); padding: clamp(10px, 1.3vw, 18px); }
.is-paused .graphics-setting { margin-top: 10px; padding-top: 10px; }
.is-paused .graphics-detail { margin-top: 0; }
.overlay-card h2 { font-size: clamp(1.45rem, 4vw, 2.6rem); line-height: 1; }
.overlay-card p { margin-top: 5px; }
.overlay-card .score-table { font-size: .9rem; margin-top: 9px; }
.overlay-card .score-table :is(th, td) { padding: 2px 5px; }
.overlay-actions { margin-top: 12px; flex-wrap: wrap; }
.touch-controls { display: none; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; user-select: none; -webkit-user-select: none; touch-action: none; }
.directions { display: grid; grid-template-columns: repeat(3, 43px); gap: 3px; }
.touch-controls button { min-height: 42px; background: var(--panel); border: 1px solid #69746c; font-weight: 700; touch-action: none; }
.touch-controls button[data-held], .touch-controls button:active { color: #152015; background: var(--accent); }
[data-input="up"] { grid-column: 2; }
[data-input="left"] { grid-column: 1; }
#touch-action { min-width: 75px; padding-inline: 10px; }
.driving .directions { display: contents; }
.driving .touch-controls .directions button { min-width: 44px; }
.driving [data-input="left"] { order: 1; }
.driving [data-input="right"] { order: 2; }
.driving #touch-action { order: 3; margin-inline: auto; }
.driving [data-input="down"] { order: 4; }
.driving [data-input="up"] { order: 5; }
.driving [data-input="up"], .driving [data-input="down"] { padding-inline: .65rem; }
.driving [data-input="up"] { border-color: var(--accent); }
.driving .game-hud #hud-status:only-child, .driving .hud-score[hidden] + #hud-status { margin-left: auto; }
[data-horizontal] .directions { grid-template-columns: repeat(2, 52px); }
[data-horizontal] :is([data-input="up"], [data-input="down"]) { display: none; }
@media (min-width: 900px) {
  .library-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-copy { flex-direction: column; align-items: flex-start; gap: 18px; }
  .card-copy h2 { font-size: clamp(1.8rem, 2.7vw, 2.65rem); }
}
@media (max-width: 770px) {
  .wrap { width: 94%; }
  .header-bar { min-height: 59px; gap: 22px; }
  .card-copy { align-items: flex-start; flex-direction: column; }
  .setup { grid-template-columns: minmax(0, .9fr) minmax(0, 1fr); }
}
@media (max-width: 580px) {
  .wrap { width: calc(100% - 24px); }
  .header-bar { flex-wrap: wrap; gap: 0 18px; padding-top: 7px; }
  .brand { font-size: 1.25rem; }
  .brand img { width: 29px; height: 29px; }
  .sound-button { min-height: 36px; }
  .nav { order: 2; width: 100%; gap: 20px; }
  .nav a { min-height: 38px; }
  .library-cards { grid-template-columns: 1fr; gap: 17px; }
  .card-copy { flex-direction: row; align-items: center; }
  .section-intro { margin-bottom: 18px; }
  .speed-stripes { height: 23px; width: 59px; background-size: 15px 100%; }
  .setup { display: block; }
  .setup-stage { border-right: 0; border-bottom: 1px solid var(--line); }
  .event-choice { min-height: 36px; }
  .player-heading h1 { font-size: 1.85rem; }
  .playing .header-bar { flex-wrap: nowrap; min-height: 44px; padding: 0; }
  .playing .nav { display: none; }
  .playing main.wrap { width: calc(100% - 16px); }
  .game-hud { min-height: 48px; height: auto; gap: 6px; font-size: .81rem; padding-block: 4px; }
}
@media (max-width: 680px), (max-height: 570px) {
  .game-overlay.is-paused { position: static; display: block; background: #1b2024; padding: 0; }
  .is-paused .overlay-card { width: 100%; }
  .is-paused #overlay-message { font-size: .85rem; }
  .is-paused .overlay-actions { margin-top: 8px; }
}
@media (any-pointer: coarse), (max-width: 680px) {
  .touch-controls { display: flex; }
  .pause-shortcut { display: none; }
  .playing main.wrap { --game-width: min(96vw, calc((100dvh - 252px) * 16 / 9)); }
}
@media (orientation: landscape) and (max-height: 570px) {
  .playing .masthead { height: 0; border: 0; }
  .playing .header-bar { min-height: 0; }
  .playing :is(.brand, .nav) { display: none; }
  .playing .sound-button { position: absolute; z-index: 2; top: 3px; right: 6px; width: 34px; min-width: 34px; }
  .playing .sound-button span { display: none; }
  .playing main.wrap { width: 97%; padding: 4px 0; }
  .playing .player-heading { margin-right: 43px; }
  .playing .player-heading h1 { font-size: 1.1rem; }
  .game-frame { width: min(100%, calc((100dvh - 112px) * 16 / 9)); margin-inline: auto; }
  .game-hud { height: 29px; min-height: 29px; }
}
@media (orientation: landscape) and (max-height: 570px) and (any-pointer: coarse) {
  .playing main.wrap { width: calc(100% - 16px); }
  #game-play { display: grid; grid-template-columns: minmax(0, 1fr) 140px; grid-template-rows: auto 1fr; column-gap: 12px; }
  .game-hud { grid-column: 1; grid-row: 1; min-height: 28px; height: 28px; font-size: .79rem; }
  .game-frame { grid-column: 1; grid-row: 2; width: min(100%, calc((100dvh - 72px) * 16 / 9)); }
  .touch-controls { grid-column: 2; grid-row: 1 / 3; align-self: center; display: grid; justify-content: center; gap: 10px; margin: 0 0 42px; }
  .game-toolbar { grid-column: 2; grid-row: 2; align-self: end; justify-content: center; margin: 0; }
  .toolbar-actions { flex-wrap: wrap; justify-content: center; }
  .playing .toolbar-actions .button { padding-inline: 8px; min-height: 40px; }
  #game-play.driving {
    grid-template-columns: minmax(64px, 1fr) minmax(0, calc((100dvh - 74px) * 16 / 9)) minmax(64px, 1fr);
    grid-template-rows: auto repeat(4, minmax(0, 1fr)); column-gap: 5px;
  }
  .driving .game-hud { grid-column: 1 / -1; }
  .driving .game-frame { grid-area: 2 / 2 / 6 / 3; width: 100%; align-self: center; }
  .driving .touch-controls { display: contents; }
  .driving .touch-controls button { width: min(100%, 70px); min-width: 0; min-height: 44px; justify-self: center; align-self: center; }
  .driving [data-input="left"] { grid-area: 3 / 1; }
  .driving [data-input="right"] { grid-area: 4 / 1; }
  .driving [data-input="up"] { grid-area: 3 / 3; }
  .driving [data-input="down"] { grid-area: 4 / 3; }
  .driving #touch-action { grid-area: 2 / 1; min-width: 0; }
  .driving .game-toolbar { display: contents; }
  .driving .toolbar-actions { display: contents; }
  .driving :is(#pause-game, #restart-game) { justify-self: center; align-self: center; }
  .driving #pause-game { grid-area: 2 / 3; }
  .driving #restart-game { grid-area: 5 / 3; }
}
@media (orientation: portrait) and (any-pointer: coarse) and (max-width: 680px) {
  .rotation-tip { display: block; margin-top: 1rem; font-size: .88rem; color: var(--muted); }
}
