:root {
  color-scheme: light;
  --paper: #f7f6f1;
  --ink: #181824;
  --muted: #59596a;
  --line: #dedde3;
  --accent: #5838ec;
  --accent-dark: #4526d5;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Plus Jakarta Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 500 1rem/1.55 var(--body); }
a { color: inherit; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .62; cursor: wait; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #8c65ff; outline-offset: 4px; }
svg { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); }
.wrap { width: min(1320px, calc(100% - 112px)); margin-inline: auto; }
.site-header, .site-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.site-header { min-height: 94px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .65rem; white-space: nowrap; text-decoration: none; font: 800 .98rem/1 var(--display); letter-spacing: -.025em; }
.brand-mark { width: 2.25rem; height: 2.25rem; display: grid; align-items: end; grid-template-columns: repeat(3,1fr); gap: 3px; padding: 8px; border-radius: .58rem; background: var(--accent); }
.brand-mark i { width: 100%; height: 36%; background: white; }
.brand-mark i:nth-child(2) { height: 67%; }
.brand-mark i:nth-child(3) { height: 98%; }
.brand-divider { margin-inline: .45rem; height: .78rem; display: inline-block; border-left: 1px solid #a8a6b5; vertical-align: -.03em; }
.brand em { font-style: normal; color: var(--accent); }
.site-header nav { display: flex; gap: clamp(1rem, 3.2vw, 2.5rem); align-items: center; font-size: .9rem; font-weight: 700; }
.nav-controls { text-decoration: none; }
.nav-controls:hover, .site-footer a:hover { color: var(--accent); }
.button { display: inline-flex; min-height: 3.25rem; gap: .6rem; padding: .75rem 1.2rem; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: .65rem; text-decoration: none; font-weight: 750; line-height: 1.15; transition: background-color 150ms, border-color 150ms; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: var(--accent-dark); }
.button-outline { background: transparent; border-color: var(--line); }
.button-outline:hover { background: #eeeafd; border-color: #c7bbfa; }
.button-small { min-height: 2.7rem; padding: .55rem .85rem; font-size: .875rem; }
.button-small svg { width: 1.05rem; height: 1.05rem; }
.hero { display: grid; grid-template-columns: .82fr 1.18fr; gap: clamp(1.4rem, 5vw, 5rem); padding-block: 3.45rem 3.75rem; align-items: center; }
.hero-copy { padding-block: 1rem; }
.eyebrow { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.3rem; color: #4e416b; font: 800 .78rem/1.1 var(--body); letter-spacing: .14em; }
.eyebrow > span { width: 1rem; height: 2px; background: var(--accent); }
.hero h1 { font-size: clamp(4.5rem, 8.5vw, 8.15rem); line-height: .86; letter-spacing: -.085em; font-weight: 800; }
.hero h1 em { display: inline-block; color: var(--accent); font-style: normal; }
.hero-copy p { max-width: 26rem; margin-block: 1.5rem 1.7rem; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.15rem); line-height: 1.65; }
.hero-copy small { display: block; margin-top: .95rem; color: var(--muted); font-size: .81rem; }
.cover { position: relative; min-height: clamp(390px, 39vw, 560px); isolation: isolate; overflow: hidden; border-radius: 1.3rem; background: #123246; }
.cover img, .cover-gradient { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover img { object-fit: cover; object-position: center 55%; z-index: -2; }
.cover-gradient { background: linear-gradient(0deg, #0a0e19f5 0%, #0a0e19ad 15%, transparent 58%); z-index: -1; }
.cover-label { position: absolute; inset: auto auto 1.6rem 1.7rem; color: white; }
.cover-label span { font-size: .75rem; font-weight: 800; letter-spacing: .15em; color: #e6e3ff; }
.cover h2 { margin-top: .14rem; font-size: clamp(2.5rem, 4.9vw, 4.9rem); font-weight: 800; line-height: 1; letter-spacing: -.07em; }
.players-tag { position: absolute; right: 1.25rem; top: 1.25rem; display: flex; gap: .45rem; align-items: center; background: #15182be8; color: #fff; border: 1px solid #ffffff45; border-radius: 100px; padding: .44rem .7rem; font-size: .77rem; font-weight: 700; }
.players-tag svg { width: .9rem; height: .9rem; }
.control-section { border-top: 1px solid var(--line); padding-block: 2.2rem 3.5rem; scroll-margin-top: 1rem; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; column-gap: 1rem; margin-bottom: 1.25rem; }
.section-heading h2 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.065em; line-height: 1.14; }
.section-heading p, .control-card p { color: var(--muted); }
.control-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: .9rem; }
.control-card { background: #fffefa; border: 1px solid var(--line); border-radius: .95rem; padding: 1.28rem; }
.tile-icon { width: 2.6rem; height: 2.6rem; display: inline-grid; place-items: center; border-radius: .7rem; }
.tile-icon.purple { color: #4c28d5; background: #eae2ff; }
.tile-icon.green { color: #1d724b; background: #dcf3e5; }
.tile-icon.orange { color: #994215; background: #fbe7d8; }
.control-card h3 { margin-block: .7rem .22rem; font-size: 1.3rem; letter-spacing: -.035em; }
.control-card a { display: inline-block; margin-top: .55rem; color: var(--accent-dark); font-size: .88rem; font-weight: 800; text-underline-offset: .25em; }
kbd { display: inline-block; margin-inline-end: .14rem; padding: .08em .27em; border: 1px solid #dedbe6; border-radius: .23rem; background: #f1eff7; font-size: .8em; line-height: 1.2; color: var(--ink); }
.site-footer { border-top: 1px solid var(--line); min-height: 76px; color: var(--muted); font-size: .85rem; }
.site-footer span { color: var(--ink); font-weight: 800; }
.site-footer a { text-underline-offset: .22em; }

.play-page, .controller-page { color-scheme: dark; --line: #343440; background: #101019; color: #f5f3fa; }
.play-shell { height: 100dvh; display: flex; flex-direction: column; background: #101019; }
.play-toolbar, .phone-header { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.play-toolbar { padding: .5rem max(.85rem, env(safe-area-inset-right)) .5rem max(.85rem, env(safe-area-inset-left)); min-height: 3.5rem; border-bottom: 1px solid var(--line); }
.play-toolbar h1 { margin-right: auto; margin-left: .5rem; border-left: 1px solid var(--line); padding-left: .9rem; font-size: 1.05rem; line-height: 1.3; }
.play-page .brand em, .controller-page .brand em { color: #bcaaff; }
.play-actions, .pair-tools { display: flex; align-items: center; gap: .5rem; }
.icon-button { display: grid; place-items: center; width: 2.65rem; height: 2.65rem; flex: none; padding: .42rem; border: 1px solid var(--line); border-radius: .6rem; background: transparent; }
.icon-button:hover { background: #79718c38; }
#game { width: 100%; flex: 1; min-height: 0; border: 0; background: #163a47; }
.pair-dialog { width: min(28rem, calc(100% - 1.4rem)); max-height: calc(100dvh - 1.4rem); padding: 1.45rem; overflow: auto; border: 1px solid #3b3749; border-radius: 1rem; background: #1d1b28; color: #f5f3fa; }
.pair-dialog::backdrop { background: #090716ce; }
.pair-dialog h2 { margin: 0 3rem .45rem 0; font-size: 2rem; letter-spacing: -.045em; }
.pair-dialog p { color: #d2cddd; }
.close-dialog { position: absolute; right: 1rem; top: 1rem; }
#join-address { overflow-wrap: anywhere; }
.pair-code { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem; padding: .9rem 0; }
#qr { border-radius: .5rem; background: white; }
#code { font: 800 1.65rem/1 monospace; letter-spacing: .09em; color: #ddd2ff; }
.pair-tools { justify-content: center; flex-wrap: wrap; }
.pair-tools .button-outline:hover { background: #3b2a60; }
.pair-status { margin-top: .8rem; font-size: .92rem; }
.pair-note { margin-top: .45rem; font-size: .83rem; }
.paired-players { list-style: none; padding: 0; margin: .55rem 0; display: grid; gap: .4rem; }
.paired-players li { display: flex; align-items: center; justify-content: space-between; gap: .6rem; font-size: .88rem; }

.phone-shell { width: min(100%, 860px); margin: auto; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.player-chip { color: #d9ccff; border: 1px solid #54437e; border-radius: 100px; padding: .32rem .65rem; font-size: .82rem; font-weight: 800; }
.join-card { width: min(100%, 31rem); margin: clamp(2rem, 12dvh, 7rem) auto 0; padding: clamp(1.15rem, 5vw, 2rem); background: #1a1826; border: 1px solid #343040; border-radius: 1rem; }
.join-card h1, #race-pad h1 { margin: .65rem 0 .2rem; font-size: clamp(2.3rem, 8vw, 3.6rem); line-height: 1; letter-spacing: -.062em; }
.join-card p, .pad-top p { color: #c7c1d4; }
#join-form { display: grid; gap: .65rem; margin-top: 1.5rem; }
#join-form label { font-weight: 750; font-size: .93rem; }
#join-code { min-width: 0; width: 100%; padding: .65rem .75rem; border: 1px solid #574e67; border-radius: .6rem; background: #12111c; color: #fff; text-transform: uppercase; font: 800 1.65rem/1.2 monospace; letter-spacing: .14em; }
#join-player, #pair-link { width: 100%; min-width: 0; padding: .6rem .75rem; border: 1px solid #574e67; border-radius: .6rem; background: #12111c; color: #fff; }
#pair-link { margin-top: .6rem; }
#join-code::placeholder { color: #a39ab3; }
.join-status:empty { display: none; }
.join-status { margin-top: .7rem; }
#race-pad { touch-action: none; user-select: none; -webkit-user-select: none; }
.pad-top { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-block: 1.4rem 1rem; }
#race-pad h1 { margin-top: 0; font-size: clamp(1.55rem, 6vw, 2.15rem); }
.driving { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.steering, .pedals, .race-actions { display: grid; gap: .45rem; }
.steering { grid-template-columns: repeat(2,1fr); }
.pedals { grid-template-columns: 1fr 1.2fr; }
.race-actions { grid-template-columns: 1fr 1fr 1.3fr .75fr; margin-top: .7rem; }
.pad-key { min-width: 0; border: 1px solid #4a455e; border-radius: .8rem; background: #272437; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: .25rem; padding: .35rem; touch-action: none; -webkit-tap-highlight-color: transparent; }
.driving .pad-key { min-height: clamp(106px, 26dvh, 190px); }
.steering svg { width: 1.8rem; height: 1.8rem; }
.race-actions .pad-key { min-height: 3.75rem; }
.pad-gas { background: #187447; border-color: #439b69; }
.pad-brake { background: #6b2942; border-color: #a4506a; }
.pad-boost { background: #5131ca; border-color: #916ff7; }
.pad-key[data-held="true"] { background: #cebaff; border-color: #e0d2ff; color: #160c30; }
@media (max-width: 900px) {
  .wrap { width: calc(100% - 64px); }
  .hero { grid-template-columns: .94fr 1.06fr; gap: 1.5rem; padding-block: 2.3rem; }
  .cover { min-height: 380px; }
}
@media (max-width: 650px) {
  .wrap { width: calc(100% - 32px); }
  .site-header { min-height: 68px; }
  .site-header .brand { gap: .4rem; font-size: .82rem; }
  .site-header .brand-mark { width: 1.95rem; height: 1.95rem; padding: 7px; }
  .site-header .button { padding-inline: .49rem; font-size: .74rem; gap: .32rem; }
  .nav-controls { display: none; }
  .hero { grid-template-columns: 1fr; gap: 1.1rem; padding-block: 1.5rem 1.7rem; }
  .hero-copy { padding-block: .65rem .35rem; }
  .hero h1 { font-size: clamp(4rem, 14vw, 6.25rem); }
  .hero-copy p { margin-block: 1rem 1.15rem; }
  .hero-copy small { margin-top: .65rem; }
  .cover { min-height: clamp(295px, 74vw, 410px); border-radius: .95rem; }
  .cover-label { inset: auto auto 1rem 1rem; }
  .players-tag { top: .7rem; right: .7rem; }
  .section-heading h2 { margin-bottom: .35rem; }
  .control-cards { grid-template-columns: 1fr; }
  .control-section { padding-block: 1.6rem 2rem; }
  .play-brand { display: none; }
  .play-toolbar h1 { padding: 0; margin-left: 0; border: 0; }
}
@media (max-width: 530px) and (orientation: portrait) {
  .driving { grid-template-columns: 1fr; }
  .steering { grid-row: 2; }
  .pedals { grid-row: 1; }
  .driving .pad-key { min-height: clamp(78px, 15dvh, 125px); }
}
@media (orientation: landscape) and (max-height: 490px) {
  .phone-shell { padding-block: .45rem; }
  .phone-header .brand-mark { width: 1.85rem; height: 1.85rem; padding: 7px; }
  .pad-top { margin-block: .3rem; }
  .pad-top p { font-size: .82rem; }
  .driving .pad-key { min-height: clamp(60px, 33dvh, 140px); }
  .race-actions { margin-top: .5rem; }
  .race-actions .pad-key { min-height: 2.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .button { transition: none; }
}

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/media/fonts/bricolage.woff2') format('woff2');
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/media/fonts/jakarta.woff2') format('woff2');
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}
