:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #1f2933;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d7dee8;
  --accent: #0f8b8d;
  --accent-dark: #0a6264;
  --gold: #f2b705;
  --danger: #d64545;
  --pipe: #e8eef5;
  --pipe-shadow: #aeb9c7;
}

/* Production finish cinematic — selected from the result-screen prototype. */
.race-result-overlay {
  display: block;
  padding: 0;
  overflow: hidden;
  background: #91a9b4;
  backdrop-filter: none;
}

.race-finish-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.race-finish-cinema-bars::before,
.race-finish-cinema-bars::after {
  position: absolute;
  z-index: 2;
  left: 0;
  width: 100%;
  height: 5.2%;
  background: #08090b;
  transform: translateY(-100%);
  transition: transform 600ms ease;
  content: "";
}

.race-finish-cinema-bars::before { top: 0; }
.race-finish-cinema-bars::after { bottom: 0; transform: translateY(100%); }
.race-result-overlay.is-slowmo .race-finish-cinema-bars::before,
.race-result-overlay.is-slowmo .race-finish-cinema-bars::after { transform: none; }

.race-finish-header {
  position: absolute;
  z-index: 3;
  top: 34px;
  left: 44px;
  right: 44px;
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, .78);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.race-finish-kicker::before {
  width: 22px;
  height: 2px;
  display: inline-block;
  margin: 0 10px 3px 0;
  background: #ff4f2f;
  content: "";
}

.race-finish-reveal {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 7%;
  width: 290px;
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translate(-25px, -42%);
  transition: opacity 550ms ease, transform 700ms cubic-bezier(.2, .8, .2, 1);
}

.race-result-overlay.is-result-visible .race-finish-reveal {
  opacity: 1;
  transform: translate(0, -42%);
}

.race-finish-reveal .race-result-tag {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #ffbea9;
  font: 700 11px/1 monospace;
  letter-spacing: .3em;
}

.race-finish-place {
  height: 138px;
  display: flex;
  align-items: flex-start;
  text-shadow: 0 7px 30px rgba(0, 0, 0, .24);
}

#racingFinishPlaceNumber {
  font: 900 150px/.9 Impact, sans-serif;
  letter-spacing: -.06em;
}

#racingFinishPlaceSuffix {
  padding: 21px 0 0 8px;
  color: #ff4f2f;
  font: italic 900 32px/1 Impact, sans-serif;
}

.race-finish-rule {
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff4f2f, transparent);
  transition: width 700ms 200ms;
}

.race-result-overlay.is-result-visible .race-finish-rule { width: 270px; }

.race-finish-reveal .race-result-title {
  margin-top: 10px;
  color: white;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: .25em;
}

.race-finish-caption {
  margin: 4px 0;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  letter-spacing: .13em;
}

.race-finish-slowmo {
  position: absolute;
  z-index: 3;
  left: 44px;
  bottom: 82px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 9px;
  letter-spacing: .2em;
  opacity: 0;
  transition: opacity 300ms;
}

.race-result-overlay.is-slowmo .race-finish-slowmo { opacity: .75; }
.race-finish-slowmo span {
  width: 7px;
  height: 7px;
  border: 1px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .12);
}

.race-result-overlay .race-result-card {
  position: absolute;
  z-index: 4;
  right: 34px;
  bottom: 34px;
  width: min(420px, calc(100% - 68px));
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 14px;
  background: rgba(8, 12, 18, .82);
  color: white;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity 450ms, transform 550ms cubic-bezier(.2, .8, .2, 1);
  backdrop-filter: blur(12px);
}

.race-result-overlay.is-cinematic-complete .race-result-card {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.race-result-overlay .race-result-card.is-loss {
  border-color: rgba(255, 255, 255, .2);
  background: rgba(8, 12, 18, .82);
  color: white;
}

.race-result-overlay .race-result-card.is-loss::before,
.race-result-overlay .race-confetti { display: none; }
.race-result-overlay .race-result-summary { max-width: none; }
.race-result-overlay .race-result-stats div,
.race-result-overlay .race-result-card.is-loss .race-result-stats div {
  border-color: rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .07);
}

@media (max-width: 720px) {
  .race-finish-header { top: 22px; left: 20px; right: 20px; }
  .race-finish-track { display: none; }
  .race-finish-reveal { left: 6%; transform: translate(-20px, -38%) scale(.78); transform-origin: left center; }
  .race-result-overlay.is-result-visible .race-finish-reveal { transform: translate(0, -38%) scale(.78); }
  .race-finish-slowmo { left: 20px; bottom: 58px; }
  .race-result-overlay .race-result-card { right: 16px; bottom: 16px; width: calc(100% - 32px); }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(15, 139, 141, 0.08), rgba(242, 183, 5, 0.07)),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

body[data-active-view="racing"] {
  padding: 10px;
  background:
    radial-gradient(circle at top, rgba(118, 163, 212, 0.12), transparent 44%),
    #0b1016;
}

body[data-active-view="typing-garage"] {
  background:
    radial-gradient(circle at 18% 12%, rgba(242, 183, 5, 0.2), transparent 24%),
    linear-gradient(180deg, rgba(15, 139, 141, 0.1), rgba(255, 255, 255, 0.18)),
    #eef3f7;
}

.app-shell {
  width: 100%;
}

.home-view {
  width: min(100%, 1240px);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: 22px;
}

.home-header {
  display: grid;
  gap: 8px;
}

.brand,
.home-header h1 {
  margin: 0;
}

.brand {
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.home-header h1 {
  font-size: clamp(36px, 7vw, 64px);
  line-height: 1;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.game-card {
  min-height: 292px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 18px 46px rgba(31, 41, 51, 0.12);
}

.game-card:hover,
.game-card:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.22);
  border-color: var(--accent);
}

.game-card-disabled {
  cursor: default;
  opacity: 0.72;
}

.game-card-disabled:hover,
.game-card-disabled:focus-visible {
  outline: none;
  border-color: var(--line);
}

.game-card-art {
  position: relative;
  min-height: 178px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #fafdff, #e9f1f5);
}

.mini-pipe {
  position: absolute;
  top: 24px;
  bottom: 18px;
  width: 52px;
  border: 8px solid #b9c5d3;
  border-radius: 24px;
  background: linear-gradient(90deg, #c8d3df, #ffffff 42%, #d7e0ea);
}

.mini-pipe:nth-child(1) {
  left: 38px;
}

.mini-pipe:nth-child(2) {
  left: 122px;
}

.mini-pipe:nth-child(3) {
  left: 206px;
}

.mini-coin {
  position: absolute;
  top: 50px;
  left: 148px;
  width: 34px;
  height: 34px;
  border: 4px solid #b77900;
  border-radius: 50%;
  background: var(--gold);
}

.mini-bill {
  position: absolute;
  top: 92px;
  left: 62px;
  width: 54px;
  height: 30px;
  border: 3px solid #177245;
  border-radius: 5px;
  background: #36a96a;
  transform: rotate(-12deg);
}

.mini-vacuum {
  position: absolute;
  left: 30px;
  bottom: 10px;
  width: 82px;
  height: 42px;
  border-radius: 15px;
  background: var(--accent);
}

.mini-vacuum::before,
.mini-vacuum::after {
  position: absolute;
  bottom: 8px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.mini-vacuum::before {
  left: 16px;
}

.mini-vacuum::after {
  right: 16px;
}

.racing-card-art {
  background:
    linear-gradient(180deg, rgba(74, 125, 191, 0.26), rgba(255, 255, 255, 0.1) 46%),
    linear-gradient(180deg, #eef7ff 0%, #edf3e8 100%);
}

.editor-card-art {
  background:
    radial-gradient(circle at 18% 22%, rgba(15, 139, 141, 0.18), transparent 28%),
    linear-gradient(180deg, #f7fbfd, #e6eef1);
}

.typing-garage-card-art {
  background:
    linear-gradient(180deg, rgba(36, 49, 67, 0.16), transparent 42%),
    linear-gradient(180deg, #f8fbff, #dfe8ef);
}

.garage-card-floor,
.garage-card-light,
.garage-card-car,
.garage-card-key {
  position: absolute;
}

.garage-card-floor {
  left: 0;
  right: 0;
  bottom: 0;
  height: 58px;
  background:
    linear-gradient(90deg, rgba(31, 41, 51, 0.08) 1px, transparent 1px) 0 0 / 34px 100%,
    linear-gradient(180deg, #cfd9e3, #eef3f7);
}

.garage-card-light {
  top: 14px;
  width: 74px;
  height: 80px;
  background: linear-gradient(180deg, rgba(255, 216, 74, 0.7), transparent);
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%);
  opacity: 0.8;
}

.garage-card-light-one {
  left: 30px;
}

.garage-card-light-two {
  right: 42px;
}

.garage-card-car {
  left: 50%;
  bottom: 38px;
  width: 190px;
  height: 58px;
  border-radius: 34px 48px 18px 18px;
  background:
    radial-gradient(circle at 18% 74%, #17202a 0 16px, transparent 17px),
    radial-gradient(circle at 78% 74%, #17202a 0 16px, transparent 17px),
    linear-gradient(155deg, transparent 0 18%, rgba(255, 255, 255, 0.8) 19% 35%, transparent 36%),
    linear-gradient(180deg, #ff5747, #c4202a);
  box-shadow: 0 20px 28px rgba(31, 41, 51, 0.24);
  transform: translateX(-50%);
}

.garage-card-car::before {
  position: absolute;
  left: 58px;
  top: -28px;
  width: 86px;
  height: 38px;
  border-radius: 42px 48px 8px 8px;
  background: linear-gradient(180deg, #294055, #152638);
  content: "";
}

.garage-card-key {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: #ffffff;
  color: #1f2933;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(31, 41, 51, 0.16);
}

.garage-card-key {
  left: 28px;
  bottom: 26px;
  transform: rotate(-8deg);
}

.garage-card-key-alt {
  left: auto;
  right: 30px;
  bottom: 86px;
  transform: rotate(9deg);
}

.editor-grid,
.editor-curve,
.editor-node,
.editor-block {
  position: absolute;
}

.editor-grid {
  inset: 18px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(16, 32, 43, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 32, 43, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
}

.editor-curve {
  left: 44px;
  top: 34px;
  width: 210px;
  height: 112px;
  border: 5px solid #1f2024;
  border-color: #1f2024 transparent transparent transparent;
  border-radius: 58% 42% 0 0 / 84% 70% 0 0;
  transform: rotate(-6deg);
}

.editor-node {
  width: 16px;
  height: 16px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 6px 14px rgba(31, 41, 51, 0.16);
}

.editor-node-one {
  left: 54px;
  top: 116px;
}

.editor-node-two {
  left: 138px;
  top: 54px;
}

.editor-node-three {
  right: 56px;
  top: 118px;
}

.editor-block {
  right: 48px;
  bottom: 34px;
  width: 62px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(180deg, #d77c2f, #b25d22);
  transform: rotate(12deg);
}

.mini-road {
  position: absolute;
  left: 126px;
  top: -20px;
  width: 118px;
  height: 236px;
  border-radius: 50%;
  background: #323940;
  transform: rotate(-18deg);
}

.mini-road::after {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #eff5e8, #e6efdf);
  content: "";
}

.mini-road-line {
  position: absolute;
  left: 176px;
  top: 28px;
  width: 6px;
  height: 96px;
  border-radius: 99px;
  background: repeating-linear-gradient(
    180deg,
    #f4d35e 0 14px,
    transparent 14px 27px
  );
  transform: rotate(-18deg);
}

.mini-car {
  position: absolute;
  left: 148px;
  bottom: 34px;
  width: 76px;
  height: 36px;
  border-radius: 8px 8px 14px 14px;
  background: linear-gradient(180deg, #c72c41, #8c1b2a);
  box-shadow: 0 10px 20px rgba(31, 41, 51, 0.22);
  transform: rotate(-18deg);
}

.mini-car::before {
  position: absolute;
  left: 20px;
  top: 6px;
  width: 34px;
  height: 12px;
  border-radius: 4px;
  background: #cfe9f7;
  content: "";
}

.mini-car::after {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -5px;
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, #15191f 0 18%, transparent 18% 78%, #15191f 78%);
  content: "";
}

.mini-tree {
  position: absolute;
  width: 22px;
  height: 42px;
  border-radius: 50% 50% 42% 42%;
  background: #2f7d4f;
}

.mini-tree::after {
  position: absolute;
  left: 9px;
  bottom: -18px;
  width: 5px;
  height: 22px;
  border-radius: 4px;
  background: #7b4a2a;
  content: "";
}

.mini-tree-one {
  left: 48px;
  top: 54px;
}

.mini-tree-two {
  right: 44px;
  bottom: 46px;
}

.empty-art {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px;
  align-items: end;
}

.empty-art span {
  height: 44%;
  border-radius: 8px;
  background: #d7dee8;
}

.empty-art span:nth-child(2) {
  height: 66%;
  background: #c6d2de;
}

.empty-art span:nth-child(3) {
  height: 82%;
  background: #dfe7ef;
}

.game-card-copy {
  display: grid;
  gap: 8px;
}

.game-state {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.game-card-copy strong {
  font-size: 24px;
  line-height: 1.1;
}

.game-card-copy span:last-child {
  color: var(--muted);
  font-size: 15px;
}

.game-view {
  width: min(100%, 680px);
  margin: 0 auto;
}

.typing-garage-view {
  width: min(100%, 1240px);
}

.racing-view {
  width: 100%;
  min-height: calc(100dvh - 48px);
  display: grid;
}

.racing-editor-view {
  width: min(100%, 1220px);
}

.racing-map-select-view {
  width: min(100%, 1120px);
}

.racing-stage {
  position: relative;
  min-height: 0;
  border: 1px solid rgba(207, 222, 236, 0.18);
  border-radius: 14px;
  overflow: hidden;
  background: #9fc9f3;
  box-shadow: 0 24px 60px rgba(4, 10, 18, 0.38);
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.topbar-actions {
  display: inline-flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}

.icon-button:hover,
.icon-button:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.2);
  border-color: var(--accent);
}

.primary-button,
.secondary-button,
.editor-chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:disabled,
.secondary-button:disabled,
.editor-chip:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  outline: none;
}

.primary-button,
.secondary-button {
  padding: 0 16px;
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}

.primary-button {
  border-color: rgba(15, 139, 141, 0.2);
  background: linear-gradient(180deg, #13a0a4, #0f8b8d);
  color: #f7fbfd;
}

.secondary-button:hover,
.secondary-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.editor-chip:hover,
.editor-chip:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.2);
  border-color: var(--accent);
}

.typing-garage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 16px;
  align-items: stretch;
}

.typing-garage-stage {
  position: relative;
  min-height: 620px;
  display: grid;
  grid-template-rows: minmax(320px, 1fr) auto;
  gap: 14px;
}

.typing-garage-photo-shell {
  position: relative;
  min-height: 420px;
}

.typing-garage-photo {
  position: relative;
  height: 100%;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.92), transparent 24%),
    linear-gradient(180deg, #dae5ef 0%, #edf3f8 48%, #bdc9d5 49%, #f1f5f8 100%);
  background-size: cover;
  background-position: center;
  box-shadow: 0 22px 54px rgba(31, 41, 51, 0.18);
}

.typing-garage-photo[data-scene="night"] {
  background:
    radial-gradient(circle at 34% 20%, rgba(255, 216, 74, 0.38), transparent 16%),
    radial-gradient(circle at 72% 24%, rgba(80, 190, 210, 0.34), transparent 18%),
    linear-gradient(180deg, #172033 0%, #26374a 52%, #121821 53%, #394353 100%);
}

.typing-garage-photo[data-scene="studio"] {
  background:
    radial-gradient(circle at 50% 25%, rgba(255, 255, 255, 0.94), transparent 22%),
    linear-gradient(180deg, #e8eef4, #f8fafc 52%, #d4dde6 53%, #eef3f7);
}

.typing-garage-photo[data-scene="sunset"] {
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 224, 102, 0.95), transparent 15%),
    linear-gradient(180deg, #ef9f6b 0%, #f5d092 44%, #46566a 45%, #c6ccd2 100%);
}

.typing-garage-photo[data-scene="track"] {
  background:
    linear-gradient(180deg, #9ed6f2 0%, #dff4ff 38%, #8abf82 39%, #6f7b87 58%, #232a33 59%, #535e6a 100%);
}

.typing-garage-photo[data-scene="city"] {
  background:
    linear-gradient(90deg, rgba(45, 55, 72, 0.52) 0 12%, transparent 12% 18%, rgba(45, 55, 72, 0.42) 18% 29%, transparent 29% 100%),
    linear-gradient(180deg, #bfe4f3 0%, #edf7fb 52%, #bac5ce 53%, #edf2f6 100%);
}

.typing-garage-photo.has-photo-asset {
  background-size: cover;
  background-position: center;
}

.typing-garage-photo.has-photo-asset .typing-garage-car-visual {
  display: none;
}

.typing-garage-lights {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 0 18%, rgba(255, 255, 255, 0.28) 19% 24%, transparent 25%),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.42), transparent 24%);
  pointer-events: none;
}

.typing-garage-car-visual {
  position: absolute;
  left: 50%;
  bottom: 78px;
  width: min(78%, 720px);
  aspect-ratio: 3.2 / 1;
  filter: blur(var(--car-blur));
  opacity: var(--car-opacity);
  transform: translateX(-50%) scale(var(--car-scale));
  transition:
    filter 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

.typing-car-shadow,
.typing-car-body,
.typing-car-roof,
.typing-car-window,
.typing-car-light,
.typing-car-wheel {
  position: absolute;
}

.typing-car-shadow {
  left: 8%;
  right: 8%;
  bottom: -4%;
  height: 16%;
  border-radius: 50%;
  background: rgba(16, 24, 40, 0.28);
  filter: blur(12px);
}

.typing-car-body {
  left: 3%;
  right: 3%;
  bottom: 18%;
  height: 42%;
  border-radius: 48% 54% 18% 18% / 72% 82% 24% 24%;
  background:
    radial-gradient(circle at 13% 68%, #121820 0 8%, transparent 8.5%),
    radial-gradient(circle at 86% 68%, #121820 0 8%, transparent 8.5%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.44), transparent 32%),
    linear-gradient(100deg, color-mix(in srgb, var(--car-color), #ffffff 28%), var(--car-color) 48%, color-mix(in srgb, var(--car-color), #000000 24%));
  box-shadow:
    inset 0 -22px 38px rgba(0, 0, 0, 0.2),
    0 28px 42px rgba(17, 24, 39, 0.24);
}

.typing-car-roof {
  left: 27%;
  top: 18%;
  width: 42%;
  height: 34%;
  border-radius: 58% 64% 8% 8%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 42%),
    linear-gradient(120deg, #223142, #0f1722);
  transform: skewX(-14deg);
}

.typing-car-window {
  top: 27%;
  height: 17%;
  border-radius: 10px 16px 5px 5px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(120, 190, 220, 0.3) 42%, #142131 43%);
}

.typing-car-window-left {
  left: 33%;
  width: 14%;
  transform: skewX(-16deg);
}

.typing-car-window-right {
  left: 50%;
  width: 16%;
  transform: skewX(-16deg);
}

.typing-car-light {
  bottom: 34%;
  width: 9%;
  height: 7%;
  border-radius: 999px;
  background: var(--car-accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--car-accent), transparent 15%);
}

.typing-car-light-left {
  left: 8%;
}

.typing-car-light-right {
  right: 8%;
}

.typing-car-wheel {
  bottom: 5%;
  width: 18%;
  aspect-ratio: 1;
  border: min(12px, 1.8vw) solid #111827;
  border-radius: 50%;
  background:
    radial-gradient(circle, #c8d1dc 0 22%, #46515e 23% 42%, #111827 43%);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.08);
}

.typing-car-wheel-left {
  left: 16%;
}

.typing-car-wheel-right {
  right: 15%;
}

.typing-garage-cover {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(245, 247, 251, var(--cover-opacity)) 1px, transparent 1px) 0 0 / 9.09% 100%,
    linear-gradient(180deg, rgba(18, 24, 33, 0.1), rgba(18, 24, 33, 0.06)),
    rgba(245, 247, 251, var(--cover-opacity));
  backdrop-filter: blur(12px);
  transition:
    transform 220ms ease,
    background 220ms ease;
}

.typing-garage-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 18% 62%, rgba(255, 240, 160, 0.96), transparent 16%),
    radial-gradient(circle at 82% 62%, rgba(255, 240, 160, 0.96), transparent 16%),
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
}

.typing-garage-flash.is-flashing {
  animation: typing-flash 760ms ease-out;
}

.typing-garage-badge {
  position: absolute;
  left: 14px;
  top: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #1f2933;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(31, 41, 51, 0.14);
}

.typing-garage-play-panel {
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(150px, 1fr) 132px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(31, 41, 51, 0.12);
}

.typing-garage-keyboard {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 14px 34px rgba(31, 41, 51, 0.1);
  touch-action: manipulation;
  user-select: none;
}

.typing-keyboard-row {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.typing-keyboard-key {
  width: clamp(31px, 6.8vw, 54px);
  height: clamp(42px, 8vw, 58px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #eef3f7);
  color: #172033;
  font: inherit;
  font-size: clamp(18px, 3.8vw, 27px);
  font-weight: 900;
  line-height: 1;
  box-shadow:
    inset 0 -5px 0 rgba(31, 41, 51, 0.08),
    0 8px 16px rgba(31, 41, 51, 0.1);
  cursor: pointer;
}

.typing-keyboard-key:hover,
.typing-keyboard-key:focus-visible {
  outline: 3px solid rgba(242, 183, 5, 0.22);
  border-color: var(--gold);
}

.typing-keyboard-key.is-needed {
  border-color: rgba(15, 139, 141, 0.24);
}

.typing-keyboard-key.is-used {
  background: linear-gradient(180deg, #ddf7ef, #c7efe4);
  color: var(--accent-dark);
}

.typing-keyboard-key.is-target {
  border-color: #f2b705;
  background: linear-gradient(180deg, #fff8d8, #ffe89b);
  color: #172033;
  animation: typing-target-key-pulse 1050ms ease-in-out infinite;
  box-shadow:
    inset 0 -5px 0 rgba(172, 116, 0, 0.14),
    0 0 0 5px rgba(242, 183, 5, 0.18),
    0 13px 22px rgba(172, 116, 0, 0.18);
}

.typing-garage-keyboard.is-mistake {
  animation: typing-soft-shake 240ms ease;
}

.typing-garage-library-button.is-pulsing {
  animation: typing-library-pulse 820ms ease-out;
}

.typing-target-row {
  display: grid;
  place-items: center;
  min-height: 94px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.14), rgba(242, 183, 5, 0.18)),
    #ffffff;
}

.typing-target-word {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #172033;
  font-size: clamp(46px, 8vw, 84px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.typing-target-letter {
  min-width: 0.75em;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  opacity: 0.38;
}

.typing-target-letter.is-typed {
  color: var(--accent-dark);
  opacity: 1;
}

.typing-target-letter.is-current {
  background: rgba(242, 183, 5, 0.22);
  color: #172033;
  opacity: 1;
  animation: typing-target-letter-pulse 1050ms ease-in-out infinite;
}

.typing-progress-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.typing-progress-cell {
  width: clamp(42px, 6vw, 62px);
  height: clamp(50px, 7vw, 70px);
  display: grid;
  place-items: center;
  border: 2px solid rgba(31, 41, 51, 0.16);
  border-radius: 8px;
  background: #f8fafc;
  color: #172033;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 900;
  line-height: 1;
}

.typing-progress-cell.is-filled {
  border-color: rgba(15, 139, 141, 0.26);
  background: #dff6ef;
  color: #0a6264;
}

.typing-progress-cell.is-next {
  border-color: var(--gold);
  box-shadow: 0 0 0 5px rgba(242, 183, 5, 0.18);
}

.typing-key-hint {
  min-height: 94px;
  display: grid;
  grid-template-rows: auto 1fr;
  place-items: center;
  padding: 9px;
  border-radius: 8px;
  background: #172033;
  color: #f8fafc;
}

.typing-key-hint span {
  color: rgba(248, 250, 252, 0.72);
  font-size: 13px;
  font-weight: 800;
}

.typing-key-hint strong {
  display: grid;
  place-items: center;
  min-width: 54px;
  height: 54px;
  padding: 0 12px;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-size: 34px;
  line-height: 1;
  box-shadow: inset 0 -5px 0 rgba(31, 41, 51, 0.12);
}

.typing-key-hint strong.is-hinting {
  animation: typing-key-hint 360ms ease;
}

.typing-garage-message {
  grid-column: 1 / -1;
  min-height: 24px;
  margin: 0;
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.typing-garage-sidebar {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 42px rgba(31, 41, 51, 0.12);
}

.typing-garage-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.typing-garage-close-button {
  display: none;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.typing-garage-sidebar-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1;
}

.typing-garage-sidebar-header strong {
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
  font-size: 14px;
}

.typing-garage-cards {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.typing-garage-card {
  min-height: 76px;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.typing-garage-card:disabled {
  cursor: default;
}

.typing-garage-card.is-current {
  border-color: rgba(242, 183, 5, 0.72);
  box-shadow: 0 0 0 4px rgba(242, 183, 5, 0.16);
}

.typing-garage-card.is-locked {
  opacity: 0.58;
}

.typing-garage-card-thumb {
  position: relative;
  height: 56px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #dbe7ef 0 54%, #aeb9c7 55%);
  background-position: center;
  background-size: cover;
}

.typing-garage-card-thumb span {
  position: absolute;
  left: 50%;
  bottom: 11px;
  width: 70px;
  height: 22px;
  border-radius: 18px 24px 8px 8px;
  background:
    radial-gradient(circle at 20% 82%, #111827 0 8px, transparent 8.5px),
    radial-gradient(circle at 80% 82%, #111827 0 8px, transparent 8.5px),
    linear-gradient(180deg, color-mix(in srgb, var(--card-car-color), #ffffff 20%), var(--card-car-color));
  transform: translateX(-50%);
}

.typing-garage-card-thumb span::before {
  position: absolute;
  left: 24px;
  top: -13px;
  width: 28px;
  height: 16px;
  border-radius: 16px 18px 2px 2px;
  background: #172033;
  content: "";
}

.typing-garage-card-thumb.has-photo-thumb span {
  display: none;
}

.typing-garage-card.is-locked .typing-garage-card-thumb {
  filter: grayscale(1) blur(0.8px);
}

.typing-garage-card-copy {
  display: grid;
  gap: 4px;
}

.typing-garage-card-copy strong {
  font-size: 19px;
  line-height: 1;
}

.typing-garage-card-copy span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.typing-garage-backdrop {
  display: none;
}

.typing-unlock-card-fly {
  position: absolute;
  right: 18px;
  bottom: 132px;
  z-index: 6;
  width: 156px;
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid rgba(242, 183, 5, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: #172033;
  box-shadow: 0 22px 44px rgba(31, 41, 51, 0.2);
  pointer-events: none;
  animation: typing-card-fly 960ms cubic-bezier(0.22, 0.9, 0.2, 1) forwards;
}

.typing-unlock-card-fly-thumb {
  height: 74px;
  border-radius: 7px;
  background-position: center;
  background-size: cover;
}

.typing-unlock-card-fly strong,
.typing-unlock-card-fly span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-unlock-card-fly strong {
  font-size: 19px;
  line-height: 1;
}

.typing-unlock-card-fly span {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.typing-garage-stage.is-mistake {
  animation: typing-soft-shake 240ms ease;
}

.typing-garage-stage.is-complete .typing-garage-car-visual {
  animation: typing-engine 560ms ease;
}

.typing-garage-stage.is-complete .typing-garage-photo {
  animation: typing-photo-celebrate 640ms ease-out;
}

@keyframes typing-soft-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  30% {
    transform: translateX(-5px);
  }

  65% {
    transform: translateX(5px);
  }
}

@keyframes typing-key-hint {
  0%,
  100% {
    transform: translateY(0);
  }

  45% {
    transform: translateY(-5px);
  }
}

@keyframes typing-photo-celebrate {
  0%,
  100% {
    filter: brightness(1);
    transform: translateX(0);
  }

  20% {
    filter: brightness(1.22);
    transform: translateX(-2px);
  }

  46% {
    filter: brightness(1.04);
    transform: translateX(2px);
  }

  72% {
    filter: brightness(1.16);
    transform: translateX(0);
  }
}

@keyframes typing-target-key-pulse {
  0%,
  100% {
    filter: brightness(1);
    box-shadow:
      inset 0 -5px 0 rgba(172, 116, 0, 0.14),
      0 0 0 4px rgba(242, 183, 5, 0.18),
      0 13px 22px rgba(172, 116, 0, 0.16);
  }

  50% {
    filter: brightness(1.08);
    box-shadow:
      inset 0 -5px 0 rgba(172, 116, 0, 0.14),
      0 0 0 9px rgba(242, 183, 5, 0.08),
      0 16px 26px rgba(172, 116, 0, 0.2);
  }
}

@keyframes typing-target-letter-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(242, 183, 5, 0.26);
    transform: translateY(0);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(242, 183, 5, 0);
    transform: translateY(-2px);
  }
}

@keyframes typing-library-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(242, 183, 5, 0.2);
  }
}

@keyframes typing-card-fly {
  0% {
    opacity: 0;
    transform: translate3d(-40px, 28px, 0) scale(0.72) rotate(-5deg);
  }

  18% {
    opacity: 1;
  }

  72% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate3d(58px, -132px, 0) scale(0.58) rotate(5deg);
  }
}

@keyframes typing-engine {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  25% {
    transform: translateX(calc(-50% - 4px)) scale(1.01);
  }

  55% {
    transform: translateX(calc(-50% + 4px)) scale(1.01);
  }
}

@keyframes typing-flash {
  0% {
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.editor-chip {
  min-height: 38px;
  padding: 0 12px;
  box-shadow: none;
}

.editor-chip.is-active {
  border-color: var(--accent);
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.racing-hud {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.hud div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.06);
}

.hud span,
.hud strong {
  display: block;
}

.hud span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.hud strong {
  margin-top: 4px;
  font-size: clamp(18px, 4vw, 24px);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-canvas {
  width: 100%;
  aspect-ratio: 640 / 760;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafdff;
  box-shadow: 0 18px 46px rgba(31, 41, 51, 0.16);
  touch-action: none;
}

.racing-canvas {
  width: 100%;
  height: clamp(560px, calc(100dvh - 36px), 92dvh);
  min-height: 560px;
  display: block;
  background: #9fc9f3;
  border: 0;
  touch-action: none;
}

.race-hud-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.race-hud-panel {
  position: absolute;
  min-width: 118px;
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(206, 222, 237, 0.16);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(7, 14, 22, 0.62), rgba(7, 14, 22, 0.32));
  color: #edf5fe;
  box-shadow: 0 12px 28px rgba(4, 8, 14, 0.26);
  backdrop-filter: blur(10px);
}

.race-hud-panel-top-left {
  top: 18px;
  left: 18px;
}

.race-hud-panel-top-right {
  top: 18px;
  right: 18px;
  text-align: right;
}

.race-camera-panel {
  top: 18px;
  left: 50%;
  min-width: 104px;
  padding: 10px 13px;
  text-align: center;
  transform: translateX(-50%);
}

.race-camera-value {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1;
}

.race-hud-panel-bottom-left {
  left: 18px;
  bottom: 18px;
}

.race-hud-panel-bottom-right {
  right: 18px;
  bottom: 18px;
}

.race-hud-label,
.race-speed-unit {
  display: block;
  color: rgba(237, 245, 254, 0.72);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.race-hud-value,
.race-speed-value {
  display: block;
  line-height: 1;
}

.race-hud-value {
  font-size: clamp(24px, 4vw, 34px);
}

.race-boost-panel .race-hud-value {
  font-size: clamp(28px, 4.6vw, 40px);
}

.race-speed-panel {
  min-width: 194px;
  justify-items: end;
  padding: 16px 18px 14px;
}

.race-speed-value {
  font-size: clamp(52px, 9vw, 84px);
  line-height: 0.88;
}

.race-start-overlay,
.race-pause-overlay,
.race-result-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 28, 0.46);
  backdrop-filter: blur(7px);
}

.race-start-overlay {
  --race-overlay-padding: 20px;
  z-index: 5;
  padding: var(--race-overlay-padding);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(4, 10, 16, 0.84), rgba(6, 12, 18, 0.66)),
    radial-gradient(circle at top, rgba(118, 163, 212, 0.14), transparent 46%);
  backdrop-filter: blur(10px);
}

.race-pause-overlay {
  z-index: 3;
}

.race-start-card,
.race-pause-card {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(206, 222, 237, 0.18);
  box-shadow: 0 24px 56px rgba(4, 8, 14, 0.36);
}

.race-start-card {
  width: min(100%, 1080px);
  height: min(calc(100dvh - (var(--race-overlay-padding) * 2)), 980px);
  max-height: min(calc(100dvh - (var(--race-overlay-padding) * 2)), 980px);
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
  padding: 28px;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(85, 140, 210, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(15, 21, 31, 0.98), rgba(9, 14, 22, 0.96));
  color: #f5f8fc;
}

.race-pause-card {
  width: min(100%, 410px);
  padding: 24px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 21, 31, 0.96), rgba(9, 14, 22, 0.94));
  color: #f5f8fc;
}

.race-start-tag,
.race-start-title,
.race-start-copy,
.race-pause-tag,
.race-pause-title,
.race-pause-copy {
  margin: 0;
}

.race-start-tag,
.race-pause-tag {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(19, 160, 164, 0.16);
  color: #9be8e9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.race-start-title {
  font-size: clamp(34px, 5vw, 48px);
  line-height: 0.96;
}

.race-pause-title {
  font-size: clamp(32px, 5vw, 42px);
  line-height: 0.96;
}

.race-start-copy,
.race-pause-copy {
  color: rgba(245, 248, 252, 0.78);
  font-size: 14px;
  line-height: 1.5;
}

.race-start-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.race-start-summary div {
  padding: 13px 14px;
  border: 1px solid rgba(206, 222, 237, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.race-start-summary span,
.race-start-summary strong {
  display: block;
}

.race-start-summary span {
  color: rgba(245, 248, 252, 0.64);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.race-start-summary strong {
  margin-top: 7px;
  font-size: 20px;
  line-height: 1.1;
}

.race-start-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(280px, 340px);
  gap: 16px;
  align-items: stretch;
  min-height: 0;
}

.race-car-feature {
  --car-accent: #d64545;
  display: grid;
  gap: 14px;
  min-height: 0;
  align-content: start;
}

.race-car-feature-stage {
  position: relative;
  min-height: 250px;
  height: clamp(250px, 31dvh, 390px);
  overflow: hidden;
  border: 1px solid rgba(206, 222, 237, 0.14);
  border-radius: 16px;
  background:
    radial-gradient(circle at 18% 16%, color-mix(in srgb, var(--car-accent) 22%, transparent), transparent 26%),
    radial-gradient(circle at 84% 0%, rgba(134, 168, 214, 0.24), transparent 34%),
    linear-gradient(180deg, #152130, #0d141d 72%);
  box-shadow: 0 22px 52px rgba(4, 8, 14, 0.26);
}

.race-car-feature-stage.is-dragging {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--car-accent) 44%, transparent),
    0 22px 52px rgba(4, 8, 14, 0.3);
}

.race-car-feature-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

.race-car-feature-stage.is-dragging .race-car-feature-canvas {
  cursor: grabbing;
}

.race-car-feature-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.race-car-feature-hint {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(206, 222, 237, 0.16);
  border-radius: 999px;
  background: rgba(9, 14, 22, 0.26);
  color: rgba(245, 248, 252, 0.74);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.race-car-feature-copy {
  display: grid;
  gap: 8px;
  padding: 16px 18px 18px;
  border: 1px solid rgba(206, 222, 237, 0.12);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    linear-gradient(135deg, color-mix(in srgb, var(--car-accent) 10%, transparent), transparent 58%);
}

.race-car-feature-make,
.race-car-feature-name,
.race-car-feature-summary {
  margin: 0;
}

.race-car-feature-make {
  color: rgba(245, 248, 252, 0.72);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.race-car-feature-name {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 0.96;
}

.race-car-feature-summary {
  max-width: 56ch;
  color: rgba(245, 248, 252, 0.78);
  font-size: 14px;
  line-height: 1.55;
}

.race-car-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 10px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(132, 164, 202, 0.46) rgba(255, 255, 255, 0.04);
}

.race-car-grid::-webkit-scrollbar {
  width: 8px;
}

.race-car-grid::-webkit-scrollbar-thumb {
  border: 1px solid rgba(9, 14, 22, 0.4);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(173, 198, 228, 0.64), rgba(111, 140, 179, 0.38));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.race-car-grid::-webkit-scrollbar-track {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(9, 14, 22, 0.18));
}

.race-car-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(120px, 148px) minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(206, 222, 237, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)),
    linear-gradient(135deg, color-mix(in srgb, var(--car-accent) 12%, transparent), transparent 46%);
  color: #f5f8fc;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.race-car-option:hover,
.race-car-option:focus-visible {
  outline: none;
  border-color: var(--car-accent);
  transform: translateY(-1px);
}

.race-car-option.is-selected {
  border-color: var(--car-accent);
  box-shadow: 0 0 0 1px var(--car-accent), 0 14px 30px rgba(0, 0, 0, 0.18);
}

.race-car-hero {
  position: relative;
  display: block;
  min-height: 110px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, color-mix(in srgb, var(--car-accent) 22%, transparent), transparent 26%),
    radial-gradient(circle at 84% 0%, rgba(134, 168, 214, 0.24), transparent 34%),
    linear-gradient(180deg, #152130, #0d141d 72%);
}

.race-car-thumbnail {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.race-car-option-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.race-car-badge,
.race-car-picked {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.race-car-badge {
  background: color-mix(in srgb, var(--car-accent) 22%, transparent);
  color: var(--car-accent);
}

.race-car-picked {
  border: 1px solid rgba(206, 222, 237, 0.18);
  color: rgba(245, 248, 252, 0.72);
}

.race-car-option.is-selected .race-car-picked {
  border-color: color-mix(in srgb, var(--car-accent) 40%, transparent);
  color: #ffffff;
}

.race-car-copy {
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 14px 16px;
}

.race-car-name,
.race-car-meta {
  display: block;
}

.race-car-name {
  font-size: clamp(22px, 3vw, 28px);
  line-height: 0.98;
}

.race-car-meta {
  color: rgba(245, 248, 252, 0.72);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.race-start-status {
  margin: 0;
  color: rgba(245, 248, 252, 0.7);
  font-size: 13px;
  line-height: 1.5;
}

.race-start-status.is-error {
  color: #ffb29c;
}

.race-start-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 900px) {
  .race-start-card {
    width: min(100%, 760px);
    height: auto;
    max-height: min(calc(100dvh - (var(--race-overlay-padding) * 2)), 980px);
    overflow-y: auto;
  }

  .race-start-layout {
    grid-template-columns: 1fr;
  }

  .race-car-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .race-car-option {
    grid-template-columns: 1fr;
  }

  .race-car-hero {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .race-car-copy {
    padding: 14px 16px 16px;
  }
}

.race-pause-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.race-pause-actions-secondary {
  margin-top: 2px;
}

.map-select-layout {
  display: grid;
  gap: 16px;
}

.map-select-hero,
.map-select-group {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 30px rgba(31, 41, 51, 0.08);
}

.map-select-tag,
.map-select-name,
.map-select-meta,
.map-select-copy,
.map-select-group-header h2,
.map-select-empty {
  margin: 0;
}

.map-select-tag {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.map-select-name {
  font-size: clamp(30px, 4.2vw, 42px);
  line-height: 0.96;
}

.map-select-meta {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.map-select-copy,
.map-select-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.map-select-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.map-select-group-header h2 {
  font-size: 22px;
  line-height: 1.05;
}

.map-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.map-select-card {
  border: 1px solid rgba(15, 139, 141, 0.12);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 252, 0.96)),
    linear-gradient(135deg, rgba(15, 139, 141, 0.06), transparent 56%);
  box-shadow: 0 12px 24px rgba(31, 41, 51, 0.08);
}

.map-select-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(15, 139, 141, 0.14), 0 16px 30px rgba(31, 41, 51, 0.1);
}

.map-select-card-button {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.map-select-card-button:hover,
.map-select-card-button:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.18);
  outline-offset: 2px;
}

.map-select-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.map-select-card-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.map-select-card-title {
  font-size: 22px;
  line-height: 1;
}

.map-select-card-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.map-select-delete {
  min-width: 68px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(214, 69, 69, 0.22);
  border-radius: 8px;
  background: rgba(214, 69, 69, 0.08);
  color: var(--danger);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.map-select-delete:hover,
.map-select-delete:focus-visible {
  outline: 3px solid rgba(214, 69, 69, 0.12);
  border-color: rgba(214, 69, 69, 0.44);
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.editor-sidebar {
  display: grid;
  gap: 12px;
}

.editor-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
}

.editor-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.editor-input,
.editor-json {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--ink);
  font: inherit;
}

.editor-input {
  min-height: 42px;
  padding: 0 12px;
}

.editor-chip-row,
.editor-chip-grid,
.editor-actions {
  display: grid;
  gap: 8px;
}

.editor-stage-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.editor-stage-summary div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(15, 139, 141, 0.08);
  border-radius: 8px;
  background: rgba(248, 251, 252, 0.88);
}

.editor-stage-summary span,
.editor-stage-summary strong {
  display: block;
}

.editor-stage-summary span {
  color: var(--muted);
  font-size: 12px;
}

.editor-stage-summary strong {
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.15;
}

.editor-chip-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-chip-grid,
.editor-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.editor-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-stats div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(15, 139, 141, 0.08);
  border-radius: 8px;
  background: rgba(248, 251, 252, 0.88);
}

.editor-stats span,
.editor-stats strong {
  display: block;
}

.editor-stats span {
  color: var(--muted);
  font-size: 12px;
}

.editor-stats strong {
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.15;
}

.editor-json {
  min-height: 200px;
  padding: 12px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", Monaco, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.editor-stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #eef7ff, #edf3e8);
  box-shadow: 0 18px 46px rgba(31, 41, 51, 0.16);
}

.editor-canvas {
  width: 100%;
  height: min(76vh, 760px);
  min-height: 520px;
  display: block;
  touch-action: none;
}

.race-result-overlay {
  z-index: 4;
}

.race-result-card {
  position: relative;
  width: min(100%, 410px);
  display: grid;
  gap: 12px;
  padding: 24px 24px 22px;
  overflow: hidden;
  border: 1px solid rgba(15, 139, 141, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 249, 247, 0.98));
  color: #10202b;
  box-shadow: 0 18px 44px rgba(7, 17, 26, 0.3);
}

.race-result-card.is-loss {
  border-color: rgba(233, 100, 73, 0.34);
  background: linear-gradient(180deg, rgba(47, 53, 61, 0.98), rgba(22, 26, 31, 0.98));
  color: #f7eee4;
}

.race-result-card.is-loss::before {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.18), transparent 58%),
    conic-gradient(
      from 45deg,
      #f3f5f7 0deg 90deg,
      #262a31 90deg 180deg,
      #f3f5f7 180deg 270deg,
      #262a31 270deg 360deg
    );
  opacity: 0.14;
  transform: rotate(-20deg);
  content: "";
}

.race-result-tag,
.race-result-title,
.race-result-summary {
  margin: 0;
}

.race-result-tag {
  position: relative;
  z-index: 1;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.race-result-card.is-loss .race-result-tag {
  background: rgba(233, 100, 73, 0.14);
  color: #ffccb9;
}

.race-result-title {
  position: relative;
  z-index: 1;
  font-size: clamp(34px, 7vw, 46px);
  line-height: 1;
}

.race-result-summary {
  position: relative;
  z-index: 1;
  max-width: 30ch;
  color: inherit;
  opacity: 0.84;
  font-size: 15px;
  line-height: 1.55;
}

.race-result-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.race-result-stats div {
  padding: 12px 14px;
  border: 1px solid rgba(14, 34, 47, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.race-result-card.is-loss .race-result-stats div {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.race-result-stats span,
.race-result-stats strong {
  display: block;
}

.race-result-stats span {
  color: inherit;
  opacity: 0.68;
  font-size: 13px;
}

.race-result-stats strong {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
}

.race-result-button {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(15, 139, 141, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #13a0a4, #0f8b8d);
  color: #f7fbfd;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.race-result-button:hover,
.race-result-button:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.22);
  border-color: var(--accent-dark);
}

.race-result-card.is-loss .race-result-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, #ed7b5a, #d85d44);
}

.race-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.race-result-card.is-win .race-confetti {
  opacity: 1;
}

.confetti-piece {
  position: absolute;
  top: -28px;
  width: 10px;
  height: 26px;
  border-radius: 4px;
  background: var(--piece-color);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);
  animation: confetti-fall var(--duration) linear infinite;
  animation-delay: var(--delay);
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -28px, 0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translate3d(var(--drift), 292px, 0) rotate(var(--spin));
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .typing-garage-topbar {
    grid-template-columns: 44px 1fr;
  }

  .typing-garage-topbar .topbar-actions {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .typing-garage-layout {
    grid-template-columns: 1fr;
  }

  .typing-garage-stage,
  .typing-garage-sidebar {
    min-height: auto;
  }

  .typing-garage-photo-shell,
  .typing-garage-photo {
    min-height: 390px;
  }

  .typing-garage-sidebar {
    max-height: none;
  }

  .typing-garage-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
}

@media (max-width: 700px) {
  body[data-active-view="typing-garage"] {
    padding: 8px 8px 0;
  }

  .typing-garage-view {
    width: 100%;
    min-height: 100dvh;
  }

  .typing-garage-layout {
    display: block;
  }

  .typing-garage-stage {
    min-height: auto;
    grid-template-rows: auto auto auto;
    gap: 10px;
  }

  .typing-garage-play-panel {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px;
  }

  .typing-target-row,
  .typing-key-hint {
    min-height: 82px;
  }

  .typing-key-hint {
    display: none;
  }

  .typing-target-word {
    font-size: clamp(42px, 15vw, 66px);
  }

  .typing-progress-cell {
    width: clamp(40px, 13vw, 54px);
    height: clamp(48px, 14vw, 62px);
  }

  .typing-garage-photo-shell,
  .typing-garage-photo {
    min-height: min(36dvh, 310px);
  }

  .typing-garage-badge {
    left: 10px;
    top: 10px;
  }

  .typing-garage-keyboard {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 0 -8px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 30px rgba(31, 41, 51, 0.14);
  }

  .typing-garage-car-visual {
    width: 88%;
    bottom: 58px;
  }

  .typing-garage-backdrop.is-open {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    border: 0;
    background: rgba(17, 24, 39, 0.44);
  }

  .typing-garage-sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    max-height: 72dvh;
    min-height: 0;
    padding: 14px 14px max(14px, env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
    transform: translateY(110%);
    transition: transform 220ms ease;
  }

  .typing-garage-sidebar.is-open {
    transform: translateY(0);
  }

  .typing-garage-sidebar-header {
    grid-template-columns: auto 1fr auto;
  }

  .typing-garage-close-button {
    display: grid;
  }

  .typing-garage-cards {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .typing-unlock-card-fly {
    right: 14px;
    bottom: 240px;
    width: 140px;
  }
}

@media (max-width: 420px) {
  body {
    padding: 14px;
  }

  body[data-active-view="racing"] {
    padding: 6px;
  }

  .home-view {
    min-height: calc(100vh - 28px);
  }

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

  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .typing-garage-keyboard {
    gap: 6px;
    padding: 8px;
  }

  .typing-keyboard-row {
    gap: 4px;
  }

  .typing-keyboard-key {
    width: calc((100vw - 88px) / 10);
    height: 42px;
    border-radius: 7px;
    font-size: 16px;
  }

  .racing-canvas {
    height: 72vh;
    min-height: 380px;
  }

  .race-hud-panel-top-left,
  .race-hud-panel-top-right {
    top: 12px;
  }

  .race-hud-panel-top-left,
  .race-hud-panel-bottom-left {
    left: 12px;
  }

  .race-hud-panel-top-right,
  .race-hud-panel-bottom-right {
    right: 12px;
  }

  .race-hud-panel-bottom-left,
  .race-hud-panel-bottom-right {
    bottom: 12px;
  }

  .race-hud-panel {
    min-width: 92px;
    padding: 10px 12px;
  }

  .race-speed-panel {
    min-width: 148px;
    padding: 12px 14px;
  }

  .race-start-card {
    padding: 22px;
    max-height: min(calc(100dvh - (var(--race-overlay-padding) * 2)), 980px);
  }

  .race-start-summary,
  .race-start-actions {
    grid-template-columns: 1fr;
  }

  .race-start-layout,
  .race-car-grid {
    grid-template-columns: 1fr;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-chip-grid,
  .editor-actions,
  .editor-stats,
  .editor-stage-summary {
    grid-template-columns: 1fr;
  }

  .editor-canvas {
    height: 58vh;
    min-height: 380px;
  }

  .map-select-grid {
    grid-template-columns: 1fr;
  }

  .race-result-overlay {
    padding: 14px;
  }

  .race-start-overlay,
  .race-pause-overlay {
    padding: 14px;
  }

  .race-start-overlay {
    --race-overlay-padding: 14px;
  }

  .race-pause-actions {
    grid-template-columns: 1fr;
  }

  .race-start-card,
  .race-pause-card,
  .race-result-card {
    padding: 18px 18px 16px;
  }
}

/* Keep the cinematic full-bleed after the shared overlay/mobile rules above. */
.race-result-overlay {
  display: block;
  padding: 0;
  overflow: hidden;
  background: #91a9b4;
  backdrop-filter: none;
}
