:root {
    color-scheme: light;
    --ink: #15191c;
    --ink-soft: #2d3539;
    --cream: #fff5d8;
    --paper: #fffaf0;
    --gold: #ffb81c;
    --gold-light: #ffd568;
    --river: #36a9e1;
    --sky: #bfe9ff;
    --hill: #3d944d;
    --pickle: #3d7218;
    --signal: #bd2f26;
    --orange: #f47b20;
    --muted: #647179;
    --line: rgba(21, 25, 28, 0.2);
    --shadow: 0 12px 0 rgba(21, 25, 28, 0.16);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    font-family: 'Outfit', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

html {
    background: var(--sky);
}

body {
    background: var(--sky);
    color: var(--ink);
    margin: 0;
    min-width: 320px;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid var(--paper);
    outline-offset: 2px;
    box-shadow: 0 0 0 7px var(--ink);
}

[hidden] {
    display: none !important;
}

.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.skip-link {
    background: var(--ink);
    color: var(--cream);
    font-weight: 700;
    left: 12px;
    padding: 10px 14px;
    position: fixed;
    top: 10px;
    transform: translateY(-160%);
    z-index: 1000;
}

.skip-link:focus {
    transform: translateY(0);
}

.game-app {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 100dvh;
}

.game-header {
    align-items: center;
    background: var(--ink);
    border-bottom: 4px solid var(--gold);
    color: var(--cream);
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(120px, 1fr) auto minmax(260px, 1fr);
    min-height: 72px;
    padding: max(9px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 9px
        max(18px, env(safe-area-inset-left));
}

.home-link {
    align-items: center;
    color: var(--cream);
    display: inline-flex;
    font-weight: 700;
    gap: 8px;
    justify-self: start;
    min-height: 44px;
    text-decoration: none;
}

.home-link span:first-child {
    color: var(--gold);
    font-size: 1.35rem;
}

.game-wordmark {
    align-items: center;
    display: flex;
    flex-direction: column;
    line-height: 1;
    text-align: center;
}

.game-wordmark-kicker {
    color: var(--gold-light);
    font-family: 'Oswald', sans-serif;
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.game-wordmark strong {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.utility-controls {
    display: flex;
    gap: 6px;
    justify-self: end;
}

.icon-button {
    align-items: center;
    background: transparent;
    border: 1px solid rgba(255, 245, 216, 0.3);
    border-radius: 8px;
    color: var(--cream);
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    font-size: 0.8rem;
    gap: 1px;
    justify-content: center;
    min-height: 46px;
    min-width: 54px;
    padding: 5px 8px;
    transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.icon-button:hover,
.icon-button[aria-pressed='true'] {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--ink);
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.utility-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.game-main {
    align-items: stretch;
    display: flex;
    min-height: 0;
    min-width: 0;
    width: 100%;
}

.screen {
    margin: 0 auto;
    max-width: 1600px;
    min-width: 0;
    padding: clamp(20px, 3.4vw, 54px);
    width: 100%;
}

.screen.is-active {
    animation: screen-in 260ms var(--ease-out) both;
}

.loading-screen,
.fatal-screen {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: min(720px, calc(100dvh - 118px));
    text-align: center;
}

.loading-screen h1,
.fatal-screen h1,
.select-copy h1,
.results-screen h1 {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2.5rem, 8vw, 6.5rem);
    line-height: 0.92;
    margin: 8px 0 16px;
    max-width: 12ch;
    text-transform: uppercase;
}

.loading-screen p,
.fatal-screen p {
    max-width: 56ch;
}

.loading-mark {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(2, 22px);
    transform: rotate(-6deg);
}

.loading-mark span {
    background: var(--ink);
    height: 22px;
}

.loading-mark span:nth-child(2),
.loading-mark span:nth-child(3) {
    background: var(--gold);
}

.load-meter {
    background: var(--paper);
    border: 3px solid var(--ink);
    height: 20px;
    margin-top: 18px;
    overflow: hidden;
    width: min(460px, 82vw);
}

.load-meter span {
    background: var(--gold);
    display: block;
    height: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 180ms var(--ease-out);
}

.eyebrow {
    color: var(--signal);
    font-family: 'Oswald', sans-serif;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    margin: 0;
    text-transform: uppercase;
}

.select-screen {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.select-copy {
    align-items: end;
    display: grid;
    gap: 12px 32px;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
}

.select-copy .eyebrow,
.select-copy h1 {
    grid-column: 1;
}

.select-copy h1 {
    margin-bottom: 0;
}

.select-copy > p:last-child {
    font-size: 1.05rem;
    grid-column: 2;
    grid-row: 1 / 3;
    line-height: 1.55;
    margin: 0;
    max-width: 52ch;
}

.select-layout {
    display: grid;
    gap: clamp(18px, 2.5vw, 38px);
    grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.7fr);
}

.racer-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.racer-card {
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 6px;
    box-shadow: 5px 5px 0 rgba(21, 25, 28, 0.18);
    cursor: pointer;
    display: grid;
    grid-template-rows: minmax(120px, 1fr) auto auto;
    min-height: 238px;
    overflow: hidden;
    padding: 0;
    text-align: left;
    transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out),
        background-color 180ms var(--ease-out);
}

.racer-card:hover {
    transform: translateY(-4px);
}

.racer-card[aria-checked='true'] {
    background: var(--gold-light);
    box-shadow: 7px 7px 0 var(--signal);
    transform: translateY(-4px) rotate(-0.7deg);
}

.racer-portrait {
    align-self: stretch;
    background-position: left center;
    background-repeat: no-repeat;
    background-size: calc(var(--frame-count, 8) * 100%) 100%;
    border-bottom: 3px solid var(--ink);
    display: block;
    min-height: 150px;
}

.racer-portrait.is-fallback {
    align-items: center;
    background: var(--sky);
    display: flex;
    font-size: 4rem;
    justify-content: center;
}

.racer-name {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1rem, 1.7vw, 1.35rem);
    font-weight: 700;
    line-height: 1;
    padding: 12px 12px 5px;
    text-transform: uppercase;
}

.racer-special {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0 12px 12px;
    text-transform: uppercase;
}

.racer-dossier {
    background: var(--ink);
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
    color: var(--cream);
    display: grid;
    grid-template-rows: minmax(240px, 1fr) auto;
    min-height: 100%;
    overflow: hidden;
}

.dossier-poster {
    background-color: var(--sky);
    background-image: url('/games/pierogi-race/assets/poster.webp');
    background-position: center;
    background-size: cover;
    border-bottom: 4px solid var(--gold);
    min-height: 240px;
}

.dossier-copy {
    padding: 24px;
}

.dossier-number {
    color: var(--gold);
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    letter-spacing: 0.15em;
    margin: 0;
}

.dossier-copy h2 {
    color: var(--cream);
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 0.95;
    margin: 7px 0;
    text-transform: uppercase;
}

.dossier-special {
    color: var(--gold-light);
    font-weight: 700;
    margin: 0 0 12px;
}

.dossier-copy > p:last-of-type {
    line-height: 1.48;
}

.dossier-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 18px;
}

.dossier-tags span {
    border: 1px solid rgba(255, 245, 216, 0.42);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 5px 9px;
    text-transform: uppercase;
}

.pre-race-actions {
    align-items: center;
    border-top: 2px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding-top: 22px;
}

.assist-toggle {
    align-items: flex-start;
    cursor: pointer;
    display: flex;
    gap: 12px;
    line-height: 1.35;
    max-width: 46ch;
}

.assist-toggle input {
    accent-color: var(--pickle);
    height: 24px;
    margin: 1px 0 0;
    width: 24px;
}

.assist-toggle span {
    display: grid;
    font-size: 0.84rem;
}

.assist-toggle strong {
    font-size: 0.96rem;
}

.start-actions,
.result-actions,
.fatal-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.primary-button,
.secondary-button,
.text-button {
    align-items: center;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    gap: 10px;
    justify-content: center;
    min-height: 48px;
    padding: 12px 18px;
    text-decoration: none;
    transition: transform 180ms var(--ease-out), background-color 180ms var(--ease-out),
        box-shadow 180ms var(--ease-out);
}

.primary-button {
    background: var(--gold);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    color: var(--ink);
    font-family: 'Oswald', sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.primary-button:hover {
    background: var(--gold-light);
    box-shadow: 2px 2px 0 var(--ink);
    transform: translate(2px, 2px);
}

.secondary-button {
    background: var(--signal);
    border: 2px solid var(--ink);
    color: var(--paper);
}

.secondary-button:hover {
    background: #bd2f26;
}

.text-button {
    background: transparent;
    border: 2px solid var(--ink);
    color: var(--ink);
}

.text-button:hover {
    background: var(--paper);
}

.race-screen {
    display: grid;
    gap: 12px;
    grid-template-rows: minmax(0, 1fr) auto auto;
    max-width: 1720px;
    padding: 12px;
}

.race-stage {
    aspect-ratio: 16 / 9;
    background: var(--sky);
    border: 4px solid var(--ink);
    box-shadow: 8px 8px 0 rgba(21, 25, 28, 0.2);
    max-height: calc(100dvh - 228px);
    min-height: 320px;
    overflow: hidden;
    position: relative;
}

#raceCanvas {
    display: block;
    height: 100%;
    touch-action: none;
    width: 100%;
}

.race-hud {
    display: grid;
    gap: 7px;
    grid-template-columns: 0.7fr 1.1fr 0.9fr 1.3fr;
    left: 10px;
    position: absolute;
    right: 10px;
    top: 10px;
}

.hud-tile {
    background: rgba(21, 25, 28, 0.94);
    border: 2px solid var(--cream);
    color: var(--cream);
    display: flex;
    flex-direction: column;
    min-height: 58px;
    padding: 7px 12px;
}

.hud-tile span {
    color: var(--gold-light);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.hud-tile strong {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.05rem, 2.4vw, 1.65rem);
    line-height: 1.1;
}

button.hud-tile {
    cursor: pointer;
    text-align: left;
}

.special-tile:not(:disabled) {
    background: var(--pickle);
    border-color: var(--gold-light);
}

.special-tile:disabled {
    cursor: not-allowed;
    opacity: 0.78;
}

.segment-banner {
    align-items: center;
    background: var(--cream);
    border: 3px solid var(--ink);
    bottom: 16px;
    display: flex;
    gap: 10px;
    left: 16px;
    max-width: min(440px, 70%);
    padding: 8px 12px;
    position: absolute;
    transform: rotate(-1deg);
}

.segment-banner span {
    color: var(--signal);
    font-family: 'Oswald', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.segment-banner strong {
    font-family: 'Oswald', sans-serif;
    font-size: 0.96rem;
    text-transform: uppercase;
}

.hazard-warning {
    align-items: center;
    background: var(--gold);
    border: 4px solid var(--ink);
    display: flex;
    gap: 12px;
    left: 50%;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    position: absolute;
    top: 88px;
    transform: translateX(-50%);
}

.warning-icon {
    align-items: center;
    background: var(--signal);
    border-radius: 50%;
    color: var(--cream);
    display: inline-flex;
    font-family: 'Oswald', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.hazard-warning span:last-child {
    font-weight: 800;
}

.caption-strip {
    background: var(--ink);
    bottom: 66px;
    color: var(--cream);
    font-weight: 700;
    left: 50%;
    max-width: min(80%, 620px);
    padding: 8px 12px;
    position: absolute;
    text-align: center;
    transform: translateX(-50%);
}

.pause-card {
    background: var(--cream);
    border: 5px solid var(--ink);
    box-shadow: 10px 10px 0 rgba(21, 25, 28, 0.35);
    left: 50%;
    padding: 28px;
    position: absolute;
    text-align: center;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(390px, calc(100% - 32px));
    z-index: 10;
}

.pause-card h2 {
    font-family: 'Oswald', sans-serif;
    font-size: 2.4rem;
    margin: 6px 0 18px;
    text-transform: uppercase;
}

.race-controls {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.lane-controls,
.action-controls {
    display: flex;
    gap: 9px;
}

.race-controls button {
    align-items: center;
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 5px;
    box-shadow: 3px 3px 0 rgba(21, 25, 28, 0.22);
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    gap: 7px;
    justify-content: center;
    min-height: 52px;
    min-width: 92px;
    padding: 8px 13px;
    touch-action: manipulation;
    user-select: none;
}

.race-controls button:active,
.race-controls button.is-active {
    box-shadow: 1px 1px 0 rgba(21, 25, 28, 0.22);
    transform: translate(2px, 2px);
}

.race-controls button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.race-controls button > span:first-child {
    color: var(--signal);
    font-size: 1.35rem;
}

.race-controls .jump-control {
    background: var(--signal);
    color: var(--cream);
}

.race-controls .jump-control > span:first-child {
    color: var(--cream);
}

.race-controls .special-control:not(:disabled) {
    background: var(--pickle);
    color: var(--cream);
}

.keyboard-help {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.72rem;
    gap: 14px;
    justify-content: center;
}

kbd {
    background: var(--paper);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--ink);
    font-family: inherit;
    font-size: 0.68rem;
    margin-right: 2px;
    padding: 2px 5px;
}

.results-screen {
    align-content: center;
    display: grid;
    gap: clamp(24px, 4vw, 58px);
    grid-template-columns: minmax(280px, 0.72fr) minmax(420px, 1fr);
}

.results-celebration {
    align-content: center;
    background-color: var(--sky);
    background-image: url('/games/pierogi-race/assets/poster.webp');
    background-position: center;
    background-size: cover;
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
    display: grid;
    min-height: 590px;
    padding: clamp(28px, 4vw, 58px);
    position: relative;
}

.results-celebration::before {
    background: rgba(255, 250, 240, 0.88);
    content: '';
    inset: 0;
    position: absolute;
}

.results-celebration > * {
    position: relative;
}

.final-time {
    align-items: baseline;
    background: var(--ink);
    border: 3px solid var(--gold);
    color: var(--cream);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 14px 18px;
    width: fit-content;
}

.final-time span {
    color: var(--gold-light);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.final-time strong {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2rem, 5vw, 4.3rem);
    line-height: 1;
}

.result-message {
    font-size: 1.08rem;
    font-weight: 600;
    line-height: 1.45;
    max-width: 40ch;
}

.leaderboard-panel {
    align-self: center;
    background: var(--paper);
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
    min-height: 590px;
    padding: clamp(22px, 3vw, 38px);
}

.leaderboard-heading {
    align-items: end;
    border-bottom: 3px solid var(--ink);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding-bottom: 15px;
}

.leaderboard-heading h2 {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3.1rem);
    line-height: 1;
    margin: 5px 0 0;
    text-transform: uppercase;
}

.period-tabs {
    display: flex;
}

.period-tabs button {
    background: transparent;
    border: 2px solid var(--ink);
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 800;
    min-height: 42px;
    padding: 8px 12px;
    text-transform: uppercase;
}

.period-tabs button + button {
    border-left: 0;
}

.period-tabs button[aria-selected='true'] {
    background: var(--gold);
}

.offline-notice {
    background: var(--gold-light);
    border: 2px solid var(--ink);
    font-weight: 700;
    margin-top: 16px;
    padding: 10px 12px;
}

.score-form {
    border-bottom: 2px solid var(--line);
    margin-top: 18px;
    padding-bottom: 16px;
}

.score-form > label {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.score-form-row {
    display: flex;
    gap: 8px;
}

.score-form input {
    background: var(--cream);
    border: 2px solid var(--ink);
    border-radius: 4px;
    color: var(--ink);
    flex: 1 1 auto;
    min-height: 48px;
    min-width: 0;
    padding: 10px 12px;
}

.field-help,
.form-status {
    color: var(--muted);
    font-size: 0.74rem;
    margin: 6px 0 0;
}

.form-status {
    color: var(--signal);
    font-weight: 700;
}

.leaderboard-list {
    list-style: none;
    margin: 15px 0 0;
    padding: 0;
}

.leaderboard-list li {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: 34px 1fr auto;
    min-height: 43px;
    padding: 7px 4px;
}

.leaderboard-rank {
    color: var(--signal);
    font-family: 'Oswald', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.leaderboard-name {
    font-weight: 700;
}

.leaderboard-time {
    font-family: 'Oswald', sans-serif;
    font-size: 1.08rem;
    font-weight: 700;
}

.game-footer {
    align-items: center;
    background: var(--cream);
    border-top: 2px solid var(--ink);
    display: flex;
    font-size: 0.72rem;
    gap: 18px;
    justify-content: center;
    min-height: 44px;
    padding: 7px max(16px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom))
        max(16px, env(safe-area-inset-left));
    text-align: center;
}

body.is-racing .game-footer {
    display: none;
}

.footer-button {
    background: transparent;
    border: 0;
    color: var(--signal);
    cursor: pointer;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lore-dialog {
    background: var(--cream);
    border: 4px solid var(--ink);
    color: var(--ink);
    height: min(860px, calc(100dvh - 32px));
    max-width: 1180px;
    padding: 0;
    width: min(1180px, calc(100dvw - 32px));
}

.lore-dialog::backdrop {
    background: rgba(21, 25, 28, 0.78);
}

.lore-shell {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
}

.lore-header {
    align-items: center;
    background: var(--gold);
    border-bottom: 4px solid var(--ink);
    display: flex;
    justify-content: space-between;
    padding: 18px 22px;
}

.lore-header h2 {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 1;
    margin: 4px 0 0;
    text-transform: uppercase;
}

.dialog-close {
    align-items: center;
    background: var(--ink);
    border: 0;
    border-radius: 4px;
    color: var(--cream);
    cursor: pointer;
    display: inline-flex;
    font-size: 2rem;
    height: 46px;
    justify-content: center;
    width: 46px;
}

.lore-filters {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 12px 18px;
}

.lore-filters button {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 999px;
    cursor: pointer;
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 800;
    min-height: 38px;
    padding: 7px 12px;
    text-transform: uppercase;
}

.lore-filters button[aria-pressed='true'] {
    background: var(--pickle);
    color: var(--paper);
}

.lore-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow-y: auto;
    padding: 6px 18px 22px;
}

.lore-card {
    align-items: start;
    background: var(--paper);
    border: 2px solid var(--ink);
    display: grid;
    gap: 12px;
    grid-template-columns: 36px 1fr;
    min-height: 190px;
    padding: 14px;
}

.lore-card-number {
    color: var(--signal);
    font-family: 'Oswald', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
}

.lore-category {
    color: var(--pickle);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 0 0 5px;
    text-transform: uppercase;
}

.lore-card h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.25rem;
    line-height: 1.05;
    margin: 0;
    text-transform: uppercase;
}

.lore-card-body {
    font-size: 0.82rem;
    line-height: 1.4;
}

.lore-source {
    color: var(--signal);
    font-size: 0.75rem;
    font-weight: 800;
}

@keyframes screen-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1050px) {
    .game-header {
        grid-template-columns: auto 1fr auto;
    }

    .home-link span:last-child,
    .utility-label {
        display: none;
    }

    .select-layout {
        grid-template-columns: 1fr;
    }

    .racer-dossier {
        grid-template-columns: minmax(240px, 0.7fr) 1fr;
        grid-template-rows: auto;
    }

    .dossier-poster {
        border-bottom: 0;
        border-right: 4px solid var(--gold);
    }

    .results-screen {
        grid-template-columns: 1fr;
    }

    .results-celebration {
        min-height: 430px;
    }

    .leaderboard-panel {
        min-height: 0;
    }
}

@media (max-width: 760px) {
    html,
    body,
    .game-app {
        max-width: 100%;
        width: 100%;
    }

    .game-header {
        gap: 8px;
        min-height: 58px;
        padding: max(6px, env(safe-area-inset-top)) 8px 6px;
    }

    body.is-racing .game-header {
        gap: 4px;
        min-height: 42px;
        padding-bottom: 3px;
        padding-top: max(3px, env(safe-area-inset-top));
    }

    body.is-racing .game-wordmark,
    body.is-racing .home-link span:last-child,
    body.is-racing #captionsButton,
    body.is-racing #motionButton {
        display: none;
    }

    body.is-racing .home-link {
        min-width: 34px;
        min-height: 34px;
    }

    body.is-racing .utility-controls {
        gap: 4px;
    }

    body.is-racing .icon-button {
        min-height: 34px;
        min-width: 36px;
        padding: 2px 4px;
    }

    body.is-racing .utility-label {
        display: none;
    }

    .game-wordmark-kicker {
        display: none;
    }

    .game-wordmark strong {
        font-size: 1.12rem;
    }

    .icon-button {
        min-height: 42px;
        min-width: 42px;
        padding: 4px;
    }

    .utility-controls {
        gap: 3px;
    }

    .screen {
        padding: 18px 12px;
    }

    .select-copy {
        display: block;
    }

    .select-copy > p:last-child {
        font-size: 0.95rem;
    }

    .select-copy h1 {
        font-size: clamp(2.8rem, 15vw, 4.8rem);
        margin-bottom: 12px;
    }

    .racer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .racer-card {
        grid-template-rows: 126px auto auto;
        min-height: 206px;
    }

    .racer-portrait {
        min-height: 126px;
    }

    .racer-dossier {
        grid-template-columns: 1fr;
    }

    .dossier-poster {
        border-bottom: 4px solid var(--gold);
        border-right: 0;
        min-height: 210px;
    }

    .pre-race-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .start-actions {
        display: grid;
        grid-template-columns: 1fr 1.25fr;
    }

    .race-screen {
        padding: 6px;
    }

    body.is-racing .race-screen {
        padding-top: 3px;
    }

    .race-stage {
        aspect-ratio: 16 / 9;
        max-height: calc(100dvh - 250px);
        min-height: 0;
    }

    .race-hud {
        gap: 4px;
        grid-template-columns: repeat(2, 1fr);
        left: 6px;
        right: 6px;
        top: 6px;
    }

    .hud-tile {
        min-height: 45px;
        padding: 5px 8px;
    }

    .hud-tile strong {
        font-size: 1rem;
    }

    .hazard-warning {
        top: 108px;
    }

    .segment-banner {
        bottom: 8px;
        left: 8px;
        padding: 5px 8px;
    }

    .caption-strip {
        bottom: 53px;
        font-size: 0.78rem;
    }

    .race-controls {
        gap: 6px;
    }

    .lane-controls,
    .action-controls {
        flex: 1 1 auto;
        gap: 5px;
    }

    .race-controls button {
        flex: 1 1 auto;
        font-size: 0.68rem;
        min-height: 50px;
        min-width: 0;
        padding: 6px;
    }

    .race-controls button > span:first-child {
        font-size: 1rem;
    }

    .keyboard-help {
        display: none;
    }

    .results-screen {
        align-content: start;
        padding-top: 14px;
    }

    .results-celebration {
        min-height: 360px;
        padding: 24px;
    }

    .results-celebration h1 {
        font-size: 4rem;
    }

    .leaderboard-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .score-form-row {
        align-items: stretch;
        flex-direction: column;
    }

    .game-footer {
        justify-content: space-between;
    }

    .game-footer span:nth-child(2) {
        display: none;
    }

    .lore-dialog {
        height: calc(100dvh - 12px);
        width: calc(100dvw - 12px);
    }

    .lore-grid {
        grid-template-columns: 1fr;
    }
}

/* Phones are designed around a sideways race. Keep the stage and controls
   inside the visible viewport even when browser chrome changes its height. */
@media (max-width: 900px) and (min-width: 500px),
       (max-height: 600px) and (orientation: landscape) {
    html,
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .game-app {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    .game-header {
        min-height: clamp(36px, 12dvh, 48px);
        padding-bottom: 4px;
        padding-top: max(4px, env(safe-area-inset-top));
    }

    .icon-button {
        min-height: clamp(30px, 9dvh, 38px);
        min-width: 42px;
        padding: 3px 5px;
    }

    .game-wordmark-kicker {
        display: none;
    }

    .game-wordmark strong {
        font-size: 1.05rem;
    }

    .screen {
        padding: 6px 14px;
    }

    .game-footer {
        display: none;
    }

    .select-screen {
        gap: 6px;
        overflow: auto;
    }

    .select-copy {
        align-items: center;
        gap: 0;
        grid-template-columns: 1fr;
    }

    .select-copy h1 {
        font-size: clamp(1.5rem, 5vw, 2.4rem);
        margin: 0;
        white-space: nowrap;
    }

    .select-copy .eyebrow {
        display: none;
    }

    .select-copy > p:last-child {
        display: none;
    }

    .racer-grid {
        gap: 6px;
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    .racer-card {
        gap: 3px;
        grid-template-rows: clamp(38px, 15dvh, 64px) auto auto;
        min-height: clamp(64px, 25dvh, 106px);
        padding: 4px;
    }

    .racer-portrait {
        min-height: clamp(38px, 15dvh, 64px);
    }

    .racer-name {
        font-size: 0.68rem;
        padding: 4px 4px 2px;
    }

    .racer-special {
        font-size: 0.46rem;
        line-height: 1.15;
        padding: 0 4px 4px;
    }

    .racer-dossier {
        display: none;
    }

    .pre-race-actions {
        align-items: center;
        gap: 8px;
        padding-top: 6px;
    }

    .assist-toggle {
        font-size: 0.67rem;
    }

    .assist-toggle span {
        line-height: 1.2;
    }

    .start-actions .primary-button {
        font-size: 0.85rem;
        min-height: clamp(32px, 9dvh, 38px);
        padding: 6px 14px;
    }

    .start-actions .text-button {
        display: none;
    }

    .start-actions {
        display: block;
    }

    .race-screen {
        gap: 5px;
        height: 100%;
        max-width: none;
        min-width: 0;
        padding: 4px max(6px, env(safe-area-inset-right)) 5px max(6px, env(safe-area-inset-left));
    }

    .race-stage {
        aspect-ratio: auto;
        height: 100%;
        max-height: none;
        min-height: 0;
        width: 100%;
    }

    .race-hud {
        left: 5px;
        right: 5px;
        top: 5px;
    }

    .hud-tile {
        min-height: clamp(28px, 9dvh, 38px);
        padding: 4px 7px;
    }

    .hud-tile span {
        font-size: 0.52rem;
    }

    .hud-tile strong {
        font-size: 0.88rem;
    }

    .hazard-warning {
        top: 72px;
        padding: 6px 10px;
    }

    .warning-icon {
        height: 27px;
        width: 27px;
    }

    .segment-banner {
        bottom: auto;
        left: 7px;
        padding: 4px 7px;
        top: calc(5px + clamp(28px, 9dvh, 38px) + 6px);
    }

    .segment-banner span {
        font-size: 1.1rem;
    }

    .segment-banner strong {
        font-size: 0.75rem;
    }

    .caption-strip {
        bottom: 47px;
        font-size: 0.68rem;
        padding: 5px 8px;
    }

    .race-controls {
        gap: 5px;
    }

    .lane-controls,
    .action-controls {
        gap: 4px;
    }

    .race-controls button {
        min-height: clamp(32px, 10dvh, 42px);
        padding: 4px 6px;
    }

    .race-controls button > span:first-child {
        font-size: 0.9rem;
    }

    .keyboard-help {
        display: none;
    }
}

@media (max-width: 390px) {
    .game-header {
        grid-template-columns: 40px 1fr auto;
    }

    .home-link {
        justify-content: center;
        min-width: 40px;
    }

    .utility-controls .icon-button {
        min-width: 38px;
    }

    .racer-name {
        font-size: 0.96rem;
    }

    .racer-special {
        font-size: 0.62rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
}
