.repair { max-width: 45rem; margin: auto; padding: 1rem; }
.repair .controls { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.repair button, .repair select, .repair input { min-height: 44px; font: inherit; }
.repair input { width: 8rem; padding: .4rem; }
.repair label { font-weight: bold; }
.repair form label { display: block; margin-bottom: .5rem; }
.road { --car-width: min(38cqw, 14rem); container-type: inline-size; position: relative; overflow: hidden; height: 7rem; margin-top: 1rem; border-radius: .6rem; background: #263748; }
.road::before { content: ''; position: absolute; inset: auto 0 12px; border-bottom: 3px dashed #e8cf84; }
.road img { position: absolute; width: var(--car-width); height: auto; bottom: calc(21px - var(--car-width) * .05); left: 4%; }
.road.driving img, .road.stopped img { left: calc(90% - var(--car-width) * .975 - 1.15rem); }
.road.driving img { transition: left 1.2s ease-out; }
.obstacle { position: absolute; right: 10%; bottom: 21px; width: 1.2rem; height: 1.7rem; }
#repair-panel { padding: 1rem; background: #fff; color: #142c3e; border-radius: .6rem; animation: panel-in .22s ease-out; }
#component { margin-top: 0; }
#diagram svg { display: block; width: min(100%, 25rem); height: auto; }
@keyframes panel-in { from { opacity: .4; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .road.driving img { transition: none; } #repair-panel { animation: none; } }


.road.stopped::after { content: ''; position: absolute; bottom: calc(21px + var(--car-width) * .31); right: calc(10% + var(--car-width) * .52); width: 1rem; height: .7rem; background: #c6ece7; animation: panel-out .22s ease-out; }
.road[data-shape="square"]::after { width: .7rem; }
.road[data-shape="triangle"]::after { clip-path: polygon(0 100%, 100% 100%, 40% 0); }
.road[data-shape="parallelogram"]::after { clip-path: polygon(0 100%, 75% 100%, 100% 0, 25% 0); }
.road[data-shape="trapezium"]::after { clip-path: polygon(0 100%, 100% 100%, 75% 0, 25% 0); }
@keyframes panel-out { from { transform: translate(-.7rem, 1rem) scale(.5); opacity: 0; } }
.road.repaired::after { animation: panel-home .35s ease-in forwards; }
@keyframes panel-home { to { transform: translate(-.7rem, 1rem) scale(.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .road.stopped::after { animation: none; } .road.repaired::after { display: none; } }

.repair h1 { margin-block: .55rem 1rem; }
.repair #progress, .repair #feedback { margin-block: .6rem; line-height: 1.45; }
.repair #progress { font-weight: 650; }
.repair #feedback { min-height: 2.9em; }
.repair #feedback.unlocked { color: #00584e; font-weight: 750; }
.repair #formula { margin-block: .4rem .2rem; font-weight: 650; }
.repair #repair-panel { border: 1px solid var(--line); }
.repair #visit-footer { margin-top: 1rem; font-size: .875rem; }
.repair #visit-footer a { display: inline-block; padding: .45rem .5rem .45rem 0; }

.repair button:disabled, .repair select:disabled { opacity: .55; cursor: default; }

#teaching:not(:empty) { margin-block: .5rem .9rem; padding: .75rem; border-left: 4px solid var(--teal); background: #eef8f6; }
#teaching p + p { margin-top: .3rem; }
#teaching ol { margin-block: .35rem 0; padding-left: 1.4rem; }
#teaching .rearranged { font-weight: bold; }
#diagram.highlight .measurement { fill: #075449; paint-order: stroke; stroke: #f8ffbe; stroke-width: 5px; stroke-linejoin: round; }

.track-map {
  margin-top: 1rem;
  padding: .65rem .8rem .25rem;
  border-radius: .75rem;
  border: 1px solid #bfcec8;
  background: #e5f0e7;
}
.track-map[data-theme="winding"] { background: #e0efec; }
.track-map[data-theme="mountain"] { background: #e4eaf3; }
.track-heading { display: flex; justify-content: space-between; align-items: baseline; gap: .35rem 1rem; flex-wrap: wrap; }
.track-heading p { color: var(--muted); font-size: .85rem; }
.track-map svg { width: 100%; height: clamp(76px, 28vw, 140px); display: block; }
#route, #route-outline { fill: none; stroke-linecap: round; }
#route-outline { stroke: #fff; stroke-width: 20; }
#route { stroke: #354955; stroke-width: 13; }
#route-stops circle { fill: #fff; stroke: #263748; stroke-width: 2; }
#route-stops .reached { fill: #75d9a7; }
#route-car { fill: #f6ba53; stroke: #fff; stroke-width: 2; }
.road { margin-top: .65rem; background: linear-gradient(#bedbd3 0 36%, #263748 36%); }
.road[data-theme="winding"] { background: linear-gradient(#99c4bb 0 36%, #233b42 36%); }
.road[data-theme="mountain"] { background: linear-gradient(#b0c6e3 0 36%, #283447 36%); }
.road[data-theme="winding"]::before { border-color: #c5dbc9; }
.road[data-theme="mountain"]::before { border-color: #e5e9f5; }

[data-obstacle="cone"] .obstacle {
  background: linear-gradient(#ff883b 55%, #fff 55% 73%, #ff883b 73%);
  clip-path: polygon(45% 0, 60% 0, 86% 82%, 100% 82%, 100% 100%, 0 100%, 0 82%, 17% 82%);
}
[data-obstacle="box"] .obstacle {
  height: 1.2rem;
  background: linear-gradient(90deg, #d59f58 40%, #ffe0ab 40% 61%, #b67d3e 61%);
  border: 2px solid #71451c;
  border-radius: 2px;
}
[data-obstacle="tyre"] .obstacle {
  height: 1.2rem;
  border: 4px solid #101820;
  outline: 1px solid #aab9bf;
  border-radius: 50%;
}
[data-obstacle="pothole"] .obstacle {
  height: .5rem;
  background: #131b25;
  border: 1px solid #9aabb4;
  border-radius: 50%;
}
.road.stopped .obstacle { transition: transform .18s ease-out; transform: rotate(35deg); transform-origin: bottom; }
.road.stopped[data-obstacle="box"] .obstacle { transform: translateX(.25rem) rotate(24deg); }
.road.stopped[data-obstacle="tyre"] .obstacle { transform: translateX(.4rem) rotate(65deg); }
.road.stopped[data-obstacle="pothole"] .obstacle { transform: none; }
.road.stopped[data-obstacle="pothole"] img { animation: wheel-bump .26s ease-out; }
@keyframes wheel-bump { 38% { transform: translateY(-5px) rotate(-2deg); } }
.track-finish {
  position: relative;
  overflow: hidden;
  text-align: center;
  background: #fff8df;
  color: #17263d;
  border: 1px solid #ddc983;
  border-radius: .85rem;
  padding: 1rem;
}
.track-finish h2 { font-size: 1.65rem; }
.track-finish p { margin-block: .25rem; }
.track-finish button { margin-top: .65rem; }
#finish-reward { font-weight: 750; color: #075449; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: 0; left: 15%; width: .4rem; height: .7rem; background: #d27d0a; animation: confetti .75s ease-out both; }
.confetti i:nth-child(2n) { background: #147866; width: .55rem; height: .55rem; }
.confetti i:nth-child(2) { left: 30%; animation-delay: .08s; }
.confetti i:nth-child(3) { left: 42%; animation-delay: .18s; }
.confetti i:nth-child(4) { left: 58%; animation-delay: .11s; }
.confetti i:nth-child(5) { left: 73%; animation-delay: .16s; }
.confetti i:nth-child(6) { left: 86%; animation-delay: .05s; }
@keyframes confetti { to { transform: translateY(105px) rotate(145deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .road.stopped .obstacle { transition: none; }
  .road.stopped[data-obstacle="pothole"] img { animation: none; }
}

.road-scenery { position: absolute; inset: 0 0 auto; height: 37%; }
[data-theme="straight"] .road-scenery {
  background: #7ba892;
  clip-path: polygon(0 80%, 20% 68%, 44% 78%, 60% 51%, 80% 66%, 100% 49%, 100% 100%, 0 100%);
}
[data-theme="winding"] .road-scenery {
  background: #4e8f7e;
  clip-path: polygon(0 92%, 8% 33%, 15% 83%, 23% 23%, 32% 86%, 42% 40%, 58% 95%, 72% 21%, 86% 84%, 94% 46%, 100% 76%, 100% 100%, 0 100%);
}
[data-theme="mountain"] .road-scenery {
  background: #6b86aa;
  clip-path: polygon(0 86%, 15% 19%, 23% 39%, 32% 4%, 49% 69%, 66% 27%, 72% 38%, 80% 11%, 100% 81%, 100% 100%, 0 100%);
}
