/* Road Rally cabinet */
#road-rally {
  --tour-ink: #0d161d;
  --tour-metal: #192a31;
  --tour-line: #3b555b;
  --tour-muted: #afc5c9;
  --tour-ice: #8de5da;
  --tour-gold: #ffcb68;
}
.tour-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: 1rem;
}
.tour-kicker, .tour-location small, .tour-clock small, .tour-select-wrap label, .tour-gauge label, .tour-points span, .tour-final span {
  font: bold .75rem/1.35 ui-monospace, Consolas, monospace;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.tour-kicker { color: var(--tour-ice); }
.tour-heading h2 {
  margin: .45rem 0 0;
  color: #ffedd1;
  font: italic clamp(1.6rem, 4vw, 2.8rem)/1.35 var(--pixel);
  letter-spacing: -.065em;
  text-transform: uppercase;
  text-shadow: 3px 3px #874927;
}
.tour-heading p {
  max-width: 33ch;
  margin: 0;
  color: #cedadb;
  font: 1rem/1.5 system-ui, sans-serif;
}
.tour-cabinet {
  --tour-route-color: #ffd18a;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--tour-ink);
  color: #f3f6f2;
  border: 2px solid var(--tour-line);
  border-top-color: #88a5aa;
  box-shadow: 0 6px #050708;
  font: 1rem/1.4 system-ui, sans-serif;
}
.tour-cabinet[data-route="1"] { --tour-route-color: #fface2; }
.tour-cabinet[data-route="2"] { --tour-route-color: #ffbd7a; }
.tour-cabinet:focus { outline: none; }
.tour-cabinet [hidden], .tour-records [hidden] { display: none !important; }
.tour-cabinet button, .tour-records button {
  background: #17282e;
  color: #e9f3f2;
  border: 1px solid #50666a;
  border-bottom: 2px solid #486066;
  border-radius: 2px;
  min-height: 42px;
  padding: .4rem .8rem;
  font: 650 .9rem/1.2 system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
.tour-cabinet button:hover, .tour-records button:hover { background: #294047; }
.tour-cabinet button:active, .tour-inputs button[aria-pressed="true"], .tour-inputs button.is-active { background: #42626a; }
.tour-cabinet button:disabled { opacity: .6; cursor: default; }
#road-rally :is(button, select, input, summary, a, canvas):focus-visible { outline: 3px solid var(--tour-gold); outline-offset: -3px; }
.tour-bar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .75rem;
  background: linear-gradient(100deg,#1d3339,#101e25);
  border-bottom: 1px solid var(--tour-line);
}
.tour-brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  white-space: nowrap;
  color: #f2f5ed;
  font: italic .85rem/1.5 var(--pixel);
  letter-spacing: -.04em;
  text-transform: uppercase;
}
.tour-checks {
  display: inline-block;
  width: 32px;
  height: 16px;
  background: repeating-conic-gradient(#ffd079 0 25%, transparent 0 50%) 0/8px 8px;
  transform: skewX(-14deg);
}
.tour-tools, .tour-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.tour-tools button[aria-pressed=true] { color: var(--tour-ice); border-color: #67a59f; }
.tour-layout { display: grid; position: relative; min-width: 0; min-height: 0; }
.tour-screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  height: clamp(250px, min(48vw, 58svh), 580px);
  background: #282435;
}
#tourCanvas { position: absolute; inset: 0; display: block; height: 100%; width: 100%; image-rendering: pixelated; touch-action: pan-y; }
.tour-cabinet:not([data-mode=garage]) #tourCanvas { touch-action: none; }
.tour-cabinet[data-mode=garage] .tour-screen { height: auto; min-height: 280px; }
.tour-race-hud {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: .5rem;
  padding: .8rem;
  pointer-events: none;
}
.tour-clock, .tour-location {
  color: #fffcf1;
  background: #0a131cea;
  border-left: 3px solid var(--tour-route-color);
  padding: .4rem .65rem .45rem;
}
.tour-clock { text-align: right; border: 0; border-right: 3px solid var(--tour-gold); }
.tour-location small, .tour-clock small { display: block; color: #cedcdb; }
.tour-location strong, .tour-clock strong {
  display: block;
  margin-top: .18rem;
  font: bold clamp(.95rem,1.6vw,1.2rem)/1.15 ui-monospace, Consolas, monospace;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.tour-clock strong { color: var(--tour-gold); }
.tour-cabinet[data-lowtime=true] .tour-clock { background: #481c21; border-right-color: #ff897f; }
.tour-cabinet[data-lowtime=true] .tour-clock strong { color: #ffb2a8; }
#tourProgress {
  display: block;
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 4px;
  border: none;
  appearance: none;
  background: #172532;
  color: var(--tour-route-color);
}
#tourProgress::-webkit-progress-bar { background: #172532; }
#tourProgress::-webkit-progress-value { background: var(--tour-route-color); }
#tourProgress::-moz-progress-bar { background: var(--tour-route-color); }
.tour-cabinet[data-mode=garage] :is(.tour-clock, #tourProgress) { display: none; }
.tour-message {
  position: absolute;
  z-index: 2;
  top: 4.75rem;
  left: .8rem;
  max-width: calc(100% - 1.6rem);
  padding: .4rem .65rem;
  color: #aeffdf;
  background: #0c1e21eb;
  border: 1px solid currentColor;
  font: bold .9rem/1.35 ui-monospace, Consolas, monospace;
  text-transform: uppercase;
  pointer-events: none;
}
.tour-cabinet[data-cue=warning] .tour-message { color: #ffd09d; background: #321819ee; }
.tour-cabinet[data-cue=stage] .tour-message { color: var(--tour-route-color); }
.tour-countdown {
  position: absolute;
  inset: 34% 0 auto;
  text-align: center;
  color: #fff1c9;
  font: italic clamp(2rem,6vw,4.5rem)/1.3 var(--pixel);
  text-shadow: 4px 4px #24202f, -2px -2px #24202f;
  pointer-events: none;
}
.tour-countdown:empty, .tour-message:empty, #tourScoreNote:empty, #tourCarTag:empty { display: none; }
.tour-setup {
  display: grid;
  gap: .9rem;
  align-content: center;
  padding: 1.2rem;
  background: linear-gradient(150deg,#20363b,#111f27 65%);
  border-left: 1px solid var(--tour-line);
  min-width: 0;
}
.tour-car-preview {
  display: grid;
  place-items: center;
  position: relative;
  height: clamp(85px,10vw,128px);
  overflow: hidden;
  background:
    linear-gradient(transparent 66%,#B7F3E410 67%, transparent 68%),
    radial-gradient(ellipse at 50% 94%,#314e54 0%,transparent 72%);
}
#tourCarImage { position: absolute; inset: 2% 0; height: 96%; width: 100%; object-fit: contain; z-index: 1; image-rendering: pixelated; }
.tour-select-wrap { min-width: 0; }
.tour-select-wrap label, .tour-gauge label { display: block; color: #c5d4d2; }
.tour-select-wrap select, .tour-board-picker select {
  appearance: none;
  width: 100%;
  margin-top: .3rem;
  min-height: 44px;
  padding: .48rem 2rem .48rem .6rem;
  background:
    linear-gradient(45deg,transparent 50%,#9fd0c9 50%) calc(100% - 15px) center/5px 6px no-repeat,
    linear-gradient(135deg,#9fd0c9 50%,transparent 50%) calc(100% - 10px) center/5px 6px no-repeat, #0b171f;
  color: #f7f8f0;
  border: 1px solid #557176;
  border-radius: 2px;
  font: 600 1rem/1.35 system-ui,sans-serif;
  cursor: pointer;
  text-overflow: ellipsis;
}
#tourCarTag, #tourBestTime { margin: .35rem 0 0; color: var(--tour-ice); font: .88rem/1.4 system-ui,sans-serif; }
.tour-cabinet .tour-primary {
  min-height: 46px;
  border-color: #ffe8b3 #be8537 #a46c26;
  background: #ffca6b;
  color: #24190d;
  text-transform: uppercase;
  font-weight: 800;
}
.tour-cabinet .tour-primary:hover { background: #ffdc92; }
.tour-cabinet .tour-start { font: bold 1.1rem/1.35 ui-monospace, Consolas, monospace; letter-spacing: .06em; }
.tour-video-pane { min-width: 0; min-height: 0; padding: .7rem; align-self: center; overflow: auto; }
#tourVideoPlayer { width: 100%; aspect-ratio: 16/9; background: #080e11; }
#tourVideoPlayer iframe { height: 100%; width: 100%; border: 0; display: block; }
.tour-video-meta { display: flex; gap: .35rem .7rem; flex-wrap: wrap; justify-content: space-between; color: var(--tour-muted); font: .83rem/1.4 system-ui,sans-serif; margin-top: .35rem; }
.tour-video-meta a { color: var(--tour-ice); text-decoration: underline; }
.tour-video-meta b { color: var(--tour-gold); }
.tour-instruments {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr 1.25fr;
  align-items: center;
  gap: .8rem 1.5rem;
  background: linear-gradient(#17282e,#13212a);
  padding: .65rem 1rem;
  border-block: 1px solid var(--tour-line);
}
.tour-dial { display: flex; align-items: baseline; gap: .45rem; }
.tour-dial span { color: var(--tour-muted); }
.tour-speed strong { font: italic bold 1.7rem/1 ui-monospace, Consolas, monospace; }
.tour-speed span { font: bold .75rem/1 ui-monospace, Consolas, monospace; text-transform: uppercase; }
.tour-points { flex-direction: column; align-items: start; gap: .05rem; }
.tour-points strong, .tour-final strong { font: bold 1.1rem/1.25 ui-monospace, Consolas, monospace; }
.tour-gauge label, .tour-points span { font-size: .7rem; }
.tour-gauge meter {
  --fill: #80e0b3;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  height: .55rem;
  margin-top: .35rem;
  border: 0;
  background: #080f17;
}
.tour-nitro meter { --fill: #ffca6b; }
.tour-gauge meter::-webkit-meter-bar { background: #080f17; border: 0; border-radius: 0; height: .55rem; }
.tour-gauge meter::-webkit-meter-optimum-value { background: var(--fill); }
.tour-gauge meter::-moz-meter-bar { background: var(--fill); }
.tour-inputs {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 1fr 1fr;
  gap: .45rem;
  padding: .5rem .65rem;
}
.tour-inputs button { min-height: 46px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/* Draw the steer arrows consistently across system emoji fonts. */
.tour-inputs button span { display: block; width: 0; height: 0; margin: auto; font-size: 0; border-block: .47rem solid transparent; }
.tour-inputs [data-tour-input=left] span { border-right: .72rem solid var(--tour-ice); }
.tour-inputs [data-tour-input=right] span { border-left: .72rem solid var(--tour-ice); }
.tour-inputs [data-tour-input=boost] { color: var(--tour-gold); border-color: #a48149; }
.tour-inputs [data-tour-input=boost][data-ready=true] { color: #271c0b; background: #ffcc70; border-color: #ffe7b6 #c79143 #ad7e3b; }
.tour-inputs [data-tour-input=boost][data-ready=true]:is(:active,.is-active) { background: #fff2b8; }
.tour-veil {
  display: none;
  position: absolute;
  inset: 0;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .75rem;
  background: #07121999;
}
.tour-dialog {
  width: min(100%, 24rem);
  padding: clamp(.9rem, 2.4vw, 1.6rem);
  background: linear-gradient(130deg,#1d323a,#101d24);
  border: 1px solid #7d9c9a;
  border-top: 4px solid var(--tour-route-color);
  box-shadow: 4px 5px #091116bb;
}
.tour-dialog h3 { margin: 0; color: #fff2d4; font: clamp(.9rem,1.6vw,1.15rem)/1.55 var(--pixel); text-transform: uppercase; }
.tour-dialog p { margin: .4rem 0; line-height: 1.4; font-size: .94rem; color: #d4e0df; }
.tour-actions { margin-top: .85rem; }
.tour-actions button { flex: 1 1 auto; }
.tour-cabinet .tour-finish { font-size: .83rem; min-height: 40px; margin-top: .5rem; width: 100%; border-color: transparent; color: var(--tour-ice); background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.tour-final { display: flex; align-items: baseline; justify-content: space-between; margin: .65rem 0; padding: .35rem 0; border-block: 1px solid var(--tour-line); color: var(--tour-gold); }
.tour-final strong { font-size: 1.4rem; }
#tourScoreForm { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; }
#tourInitials { width: 4.5rem; min-height: 42px; color: #f7f6ed; background: #0c1720; border: 1px solid var(--tour-line); text-align: center; font: bold 1rem/1 monospace; text-transform: uppercase; }
#tourScoreNote { margin: .5rem 0 0; color: var(--tour-gold); }
.tour-cabinet:not([data-mode=garage]) .tour-setup, .tour-cabinet[data-mode=garage] :is(.tour-instruments,.tour-inputs),
.tour-cabinet:not(:is([data-mode=racing],[data-mode=countdown])) #tourPause { display: none; }
.tour-cabinet[data-mode=paused] .tour-pause-panel, .tour-cabinet[data-mode=result] .tour-result-panel { display: grid; }
.tour-cabinet:is([data-mode=paused],[data-mode=result]) :is(.tour-inputs,.tour-message,.tour-countdown) { display: none; }
.tour-cabinet[data-mode=result] .tour-screen { min-height: 310px; }
.tour-cabinet[data-mode=garage] .tour-layout { grid-template-columns: minmax(0,1fr) clamp(16rem,27%,21rem); }
.tour-cabinet[data-mode=garage] .tour-video-pane { grid-column: 1 / -1; margin: auto; width: min(34rem,100%); }
@media (orientation:landscape) {
  .tour-cabinet:not([data-mode=garage]) .tour-layout:has(.tour-video-pane:not([hidden])) { grid-template-columns: minmax(0,2.7fr) minmax(0,1fr); }
}
.tour-help, .tour-records { padding: .85rem .25rem; color: #d0dddc; font: 1rem/1.55 system-ui,sans-serif; border-bottom: 1px solid #304144; }
#road-rally details > summary { cursor: pointer; color: var(--tour-ice); font-weight: 650; }
.tour-help p { max-width: 78ch; margin: .65rem 0 0; }
.tour-help kbd { font: bold .85rem/1 ui-monospace,Consolas,monospace; color: #e8f2ed; }
.tour-board-picker { display: flex; align-items: center; gap: .75rem; margin-top: .65rem; max-width: 26rem; }
.tour-board-picker select { width: auto; min-width: 10rem; }
#tourScores { padding: 0; list-style: none; counter-reset: position; margin: .5rem 0 0; max-width: 26rem; }
#tourScores li { counter-increment: position; display: grid; grid-template-columns: 2rem 1fr auto; gap: .5rem; align-items: center; padding: .4rem .65rem; border-bottom: 1px solid #293c41; font-family: ui-monospace, Consolas, monospace; }
#tourScores li::before { content: counter(position, decimal-leading-zero); font-size: .8rem; color: var(--tour-muted); }
#tourScores li:first-child { color: var(--tour-gold); background: #25251e; }
#tourScoresNote { margin: .5rem 0 0; }
#tourScoreReload { margin-top: .5rem; }
@media (max-width: 680px) {
  .tour-heading { display: grid; gap: .5rem; }
  .tour-heading p { max-width: 48ch; }
  .tour-brand { font-size: .7rem; gap: .4rem; }
  .tour-checks { width: 24px; }
  .tour-bar { padding: .35rem; }
  .tour-tools { gap: .25rem; }
  .tour-tools button { padding: .35rem .45rem; font-size: .78rem; }
  .tour-cabinet[data-mode=garage] .tour-layout { grid-template-columns: 1fr; }
  .tour-cabinet[data-mode=garage] .tour-screen { height: clamp(195px,56vw,290px); min-height: 0; }
  .tour-setup { grid-template-columns: minmax(62px,.55fr) minmax(0,1.8fr); gap: .7rem; padding: .8rem; border-left: 0; border-top: 1px solid var(--tour-line); }
  .tour-car-preview { grid-column: 1; grid-row: 1 / 3; height: auto; min-height: 85px; }
  .tour-select-wrap { grid-column: 2; }
  .tour-start { grid-column: 1/-1; }
  .tour-instruments { gap: .4rem .7rem; padding: .5rem; }
  .tour-speed strong { font-size: 1.3rem; }
  .tour-points strong { font-size: .95rem; }
  .tour-inputs { gap: .3rem; padding: .4rem; }
  .tour-inputs button { padding-inline: .15rem; }
  .tour-race-hud { padding: .5rem; }
  .tour-message { left: .5rem; top: 3.9rem; }
  .tour-location, .tour-clock { padding: .3rem .45rem; }
}
@media (max-width:410px) {
  .tour-checks { display: none; }
  .tour-brand { font: italic 750 .97rem/1.1 system-ui,sans-serif; }
  .tour-location small,.tour-clock small { font-size: .68rem; }
  .tour-setup { grid-template-columns: minmax(52px,.45fr) minmax(0,1.8fr); }
}
@media (max-width:465px) {
  .tour-cabinet:not([data-mode=garage]) .tour-brand { display:none; }
  .tour-tools { margin-left:auto; }
}
@media (orientation:portrait) {
  .tour-cabinet:not([data-mode=garage]) .tour-video-pane { width: min(100%,24rem); justify-self: center; }
}
html.tour-lock-scroll, html.tour-lock-scroll body { overflow: hidden; overscroll-behavior: none; }
.tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive) {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  box-shadow: none;
  background: var(--tour-ink);
}
.tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive) > :is(.tour-bar,.tour-instruments,.tour-inputs) { flex: none; }
.tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):not([data-mode=garage]) .tour-layout { flex: 1 1 0; grid-template-rows: minmax(0,1fr); }
.tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):not([data-mode=garage]) .tour-screen { height: 100%; min-height: 0; }
.tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive)[data-mode=garage] .tour-layout { flex: 1 0 auto; }
.tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive)[data-mode=garage] .tour-screen { height: auto; }
@media (orientation:portrait) {
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):not([data-mode=garage]) .tour-layout:has(.tour-video-pane:not([hidden])) { grid-template-rows: minmax(0,1fr) auto; }
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):not([data-mode=garage]) .tour-video-pane { width: min(100%,28dvh); padding: .25rem; }
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive)[data-mode=garage] .tour-layout { display: flex; flex-direction: column; }
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive)[data-mode=garage] .tour-screen { flex: 1 0 auto; min-height: 26svh; }
}
@media (orientation:landscape) and (max-height:520px) {
  .tour-bar { padding: .15rem .4rem; }
  .tour-tools button { min-height: 34px; }
  .tour-inputs { padding: .25rem .5rem; }
  .tour-inputs button { min-height: 41px; }
  .tour-instruments { padding: .28rem .7rem; }
  .tour-points { flex-direction: row; align-items: baseline; gap: .45rem; }
  .tour-gauge { display: flex; align-items: center; gap: .4rem; }
  .tour-gauge meter { margin: 0; }
  .tour-cabinet[data-mode=garage] .tour-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(15rem,32%); }
  .tour-cabinet[data-mode=garage] .tour-screen { min-height: 190px; height: auto; }
  .tour-setup { display: flex; flex-direction: column; justify-content: center; gap: .55rem; padding: .6rem .8rem; border-top: none; border-left: 1px solid var(--tour-line); }
  .tour-car-preview { display: none; }
  .tour-setup select,.tour-start { min-height: 38px; }
  .tour-race-hud { padding: .35rem; }
  .tour-location,.tour-clock { padding: .2rem .5rem; }
  .tour-message { top: 3.5rem; }
  .tour-veil { padding: .35rem; }
  .tour-dialog { padding: .55rem .8rem; }
  .tour-dialog p,.tour-actions,.tour-final { margin-block: .3rem; }
  .tour-dialog :is(button,input) { min-height: 36px; }
}
@media (prefers-reduced-motion:reduce) { #road-rally * { scroll-behavior: auto; } }

/* Championship garage, timing and pit lane. */
.tour-career {
  display: grid;
  grid-template-columns: 1fr 1.12fr minmax(12rem,1fr);
  background: #101d25;
  border-bottom: 1px solid #456067;
}
.tour-career > * {
  min-width: 0;
  padding: .55rem .9rem;
  display: grid;
  align-content: center;
  gap: .13rem;
}
.tour-career > * + * { border-left: 1px solid #33484f; }
.tour-career span, .tour-tv-bezel {
  color: #a7bfc1;
  font: bold .72rem/1.3 ui-monospace,Consolas,monospace;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.tour-career strong { color: #f1f6ef; font: 650 .94rem/1.35 system-ui,sans-serif; }
.tour-career-xp progress {
  display: block;
  appearance: none;
  background: #283c43;
  width: 100%;
  height: 4px;
  border: none;
  margin-top: .16rem;
  color: var(--tour-ice);
}
.tour-career-xp progress::-webkit-progress-bar { background: #283c43; }
.tour-career-xp progress::-webkit-progress-value { background: var(--tour-ice); }
.tour-career-xp progress::-moz-progress-bar { background: var(--tour-ice); }
.tour-rank-card {
  padding-left: .9rem;
  background: linear-gradient(105deg,#372d20,#26271f);
  box-shadow: inset 3px 0 #e3ac52;
}
.tour-rank-card span,.tour-rank-card strong { color: #ffda8e; }
.tour-rank-card:hover strong { text-decoration: underline; text-underline-offset: .16em; }
#tourUnlockStatus { margin: .25rem 0 0; color: #f2cd88; font-size: .84rem; line-height: 1.3; }
#tourUnlockStatus:empty, #tourRunMode:empty, #tourUnlockNews:empty, #tourEarnedXp:empty, #tourResultTarget:empty, #tourHudTarget:empty { display: none; }
.tour-cabinet .tour-start:disabled { opacity: 1; background: #26373e; border-color: #4f6667; color: #b3c3c5; }
.tour-run-mode { flex: none; margin: 0; padding: .28rem .8rem; background: #182820; color: #d6e7d3; font: .82rem/1.3 system-ui,sans-serif; border-bottom: 1px solid #354943; }
.tour-challenge-hud {
  flex: none;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem .8rem;
  padding: .45rem .9rem;
  background: #13232a;
  border-top: 1px solid #425860;
  line-height: 1.3;
}
.tour-challenge-level { min-width: 0; display: flex; gap: .13rem .55rem; align-items: baseline; flex-wrap: wrap; }
#tourLevelName { color: var(--tour-ice); font: 700 .93rem/1.3 system-ui,sans-serif; }
#tourObjective { color: #d2dedc; font-size: .87rem; }
#tourHudTarget { flex: none; padding-left: .65rem; border-left: 2px solid #b28d53; color: #ffe0a5; font: 650 .81rem/1.25 ui-monospace,Consolas,monospace; }
.tour-cabinet:not([data-mode=garage]) :is(.tour-career, .tour-records) { display: none; }
.tour-cabinet[data-mode=garage] .tour-challenge-hud,
.tour-cabinet:is([data-mode=pit],[data-mode=result],[data-mode=paused]) .tour-challenge-hud { display:none; }
.tour-cabinet[data-mode=pit] .tour-pit-panel { display:grid; }
.tour-cabinet[data-mode=pit] :is(.tour-instruments,.tour-inputs,.tour-countdown,.tour-message,.tour-race-hud) { display: none; }
.tour-result-gains { display: flex; gap: .2rem .5rem; flex-wrap: wrap; align-items: baseline; color: #aceed4; font-size: .88rem; }
.tour-dialog .tour-result-target { color: #ffe4ad; font-weight: 650; }
.tour-cabinet .tour-watch-shortcut {
  display: block;
  min-height: 36px;
  padding-inline: .2rem;
  margin: .3rem auto 0;
  font-size: .86rem;
  color: var(--tour-ice);
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: .19em;
}
.tour-pitwall { display: contents; }
.tour-cabinet[data-mode=garage] .tour-pitwall {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr);
  align-items: start;
  gap: 1.2rem;
  border-top: 1px solid #4c6469;
  background: #101b21;
  padding: 1rem;
}
.tour-cabinet[data-mode=garage] .tour-pitwall:has(.tour-video-pane[hidden]) { grid-template-columns: minmax(0,1fr); }
.tour-cabinet[data-mode=garage] .tour-pitwall .tour-video-pane {
  grid-column: auto;
  width: 100%;
  max-width: 29rem;
  margin: 0;
  padding: 0;
  justify-self: center;
  align-self: start;
}
.tour-tv-frame {
  min-width: 0;
  padding: .5rem;
  background: linear-gradient(145deg,#30444b,#1d2b30 60%,#273b42);
  border: 1px solid #617278;
  border-radius: 4px;
  box-shadow: inset 0 1px #87989a55, 0 2px #050d10;
}
.tour-tv-bezel { display: flex; align-items: center; gap: .65rem; padding: .03rem .15rem .38rem; color: #e8f0e8; }
.tour-tv-grille { flex: 1; height: 5px; background: repeating-linear-gradient(90deg,#0c181b 0 2px,transparent 2px 4px); }
.tour-tv-screen { display: grid; isolation: isolate; position: relative; overflow: hidden; background: #0b1014; }
.tour-tv-screen > * { grid-area: 1/1; }
.tour-video-pane:not([data-playing=true]) #tourVideoPlayer {
  background:
    repeating-linear-gradient(0deg,#101a284d 0 1px,transparent 1px 4px),
    linear-gradient(0deg,#172027 0 13%,#26333d 13% 23%,transparent 23%),
    linear-gradient(90deg,#bdd0c6 0 14%,#c4ad74 14% 28%,#6eafa9 28% 42%,#6b9781 42% 56%,#a889a2 56% 70%,#b57470 70% 84%,#72889e 84% 100%);
}
.tour-cabinet .tour-tv-play {
  z-index: 1;
  place-self: center;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 44px;
  border: 1px solid #e4ede9;
  border-radius: 2px;
  background: #101c24f2;
  color: #fff5d9;
  box-shadow: 3px 3px #0b101877;
}
.tour-tv-play::before { content: ''; border-block: .35rem solid transparent; border-left: .55rem solid #ffca74; }
.tour-tv-play:hover { background: #22353b; }
.tour-video-meta { padding-inline: .12rem; color: #cedcd9; }
.tour-video-meta a { text-underline-offset: .14em; }
.tour-cabinet .tour-records { border: 0; padding: 0; min-width: 0; scroll-margin-top: .6rem; }
#road-rally .tour-records > summary { color: #ffdc98; font: 700 1rem/1.4 ui-monospace,Consolas,monospace; text-transform: uppercase; }
.tour-board-picker { justify-content: space-between; margin-top: .5rem; max-width: none; font-size: .93rem; }
.tour-board-picker select { width: min(13rem,67%); min-width: 0; color: #f0f5ef; }
#tourScores { max-width: none; }
#tourScoresNote { color: #bdccce; font-size: .9rem; }
.tour-records:has(#tourScores li:nth-child(6)) #tourScores {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(5,auto);
  grid-template-columns: repeat(2,minmax(0,1fr));
  column-gap: .8rem;
}
@media (min-width:681px) {
  .tour-cabinet[data-mode=garage] .tour-setup { gap: .65rem; padding: .85rem 1rem; }
  .tour-cabinet[data-mode=garage] .tour-car-preview { height: clamp(68px,8vw,98px); }
}
@media (orientation:landscape) {
  .tour-cabinet:is([data-mode=pit],[data-mode=paused],[data-mode=result]) .tour-layout:has(.tour-video-pane:not([hidden])) { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); }
}
@media (max-width:680px) {
  .tour-career { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .tour-career > * { padding: .4rem .6rem; }
  .tour-career strong { font-size: .84rem; }
  .tour-career > .tour-rank-card { grid-column: 1/-1; display: flex; align-items: baseline; gap: .3rem .65rem; flex-wrap: wrap; border-left: 0; border-top: 1px solid #3c3d31; }
  .tour-career span { font-size: .68rem; }
  .tour-challenge-hud { padding: .35rem .55rem; gap: .35rem; }
  .tour-challenge-level { display: grid; }
  #tourObjective, #tourHudTarget { font-size: .76rem; }
  #tourHudTarget { max-width: 40%; }
  .tour-cabinet[data-mode=garage] .tour-pitwall { grid-template-columns: 1fr; gap: .95rem; padding: .75rem; }
  .tour-cabinet[data-mode=garage] .tour-pitwall .tour-video-pane { max-width: none; }
  .tour-records:has(#tourScores li:nth-child(6)) #tourScores { column-gap: .45rem; }
  #tourScores li { padding: .38rem .2rem; font-size: .85rem; grid-template-columns: 1.35rem 1fr auto; gap: .25rem; }
  .tour-cabinet[data-mode=garage] .tour-screen { height: clamp(170px,49vw,250px); }
}
@media (max-width:430px) {
  .tour-brand { font: italic 750 .86rem/1.1 system-ui,sans-serif; white-space: normal; }
}
@media (orientation:portrait) {
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):is([data-mode=pit],[data-mode=paused],[data-mode=result]) .tour-video-pane { width: min(100%,48dvh); padding: .35rem; }
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive) .tour-video-meta { gap: .15rem .5rem; font-size: .75rem; }
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive)[data-mode=racing] .tour-video-meta span { display: none; }
}
@media (orientation:landscape) and (max-height:520px) {
  .tour-career > * { padding-block: .3rem; }
  .tour-challenge-hud { gap: .25rem .6rem; padding-block: .2rem; }
  .tour-challenge-level { display: flex; }
  .tour-run-mode { padding-block: .12rem; font-size: .72rem; }
  .tour-video-pane { padding: .35rem; }
  .tour-tv-frame { padding: .28rem; }
  .tour-tv-bezel { padding-bottom: .2rem; font-size: .68rem; }
  .tour-video-meta { font-size: .72rem; gap: .1rem .4rem; }
  .tour-cabinet:not([data-mode=garage]) .tour-video-meta span { display: none; }
  .tour-cabinet[data-mode=garage] .tour-pitwall { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}

/* Keep the embedded player usable at its minimum 200-by-200 viewport. */
.tour-video-pane[data-playing=true] #tourVideoPlayer {
  position: relative;
  min-width: 200px;
  min-height: 200px;
}
.tour-video-pane[data-playing=true] #tourVideoPlayer iframe {
  position: absolute;
  inset: 0;
}
@media (orientation:landscape) {
  .tour-cabinet:is([data-mode=racing],[data-mode=countdown]) .tour-layout:has(.tour-video-pane[data-playing=true]) {
    grid-template-columns: minmax(0,2fr) minmax(calc(200px + 2.5rem + 2px),1fr);
  }
}
@media (orientation:portrait) {
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):not([data-mode=garage]) .tour-video-pane[data-playing=true] {
    width: min(100%,clamp(230px,46dvh,24rem));
  }
}
@media (orientation:landscape) and (max-height:520px) {
  /* Allow TV to use the full height next to both the road and the controls. */
  .tour-cabinet:is(:fullscreen,:-webkit-full-screen,.tour-immersive):not([data-mode=garage]):has(.tour-video-pane[data-playing=true]) {
    display: grid;
    grid-template-columns: minmax(0,1fr) clamp(216px,32vw,25rem);
    grid-template-rows: auto auto minmax(0,1fr) auto auto auto;
    grid-template-areas:
      "bar bar"
      "status tv"
      "road tv"
      "goal tv"
      "dials tv"
      "controls tv";
    & > .tour-bar { grid-area: bar; }
    & > .tour-run-mode { grid-area: status; }
    & > .tour-layout { display: contents; }
    & .tour-screen { grid-area: road; }
    & > .tour-challenge-hud { grid-area: goal; }
    & > .tour-instruments { grid-area: dials; }
    & > .tour-inputs { grid-area: controls; }
    & .tour-video-pane {
      grid-area: tv;
      width: 100%;
      max-height: 100%;
      box-sizing: border-box;
      padding: 3px;
    }
    & .tour-tv-frame { padding: 3px; }
  }
}
@media (orientation:landscape) and (max-height:360px) {
  .tour-cabinet:not([data-mode=garage]) .tour-video-pane[data-playing=true] .tour-tv-bezel { display: none; }
  .tour-cabinet:not([data-mode=garage]) .tour-video-pane[data-playing=true] .tour-video-meta { margin-top: 2px; }
}
