/* Compact landscape keeps both complete command cards beside the live scene. */
.dialog-classification .classification {
  max-height: 60dvh;
  padding: 0;
}
@media (max-height: 500px) and (min-width: 601px) {
  #race {
    --race-left: 254px;
    --race-right: 244px;
    --race-top: 50px;
    --race-bottom: 94px;
  }
  #race .heading { height: 44px; padding: 5px 10px; gap: 12px; }
  #race .heading h2 { font-size: 15px; margin-top: 1px; }
  #race .heading small { font-size: 9px; letter-spacing: .3px; }
  #race .race-status { font-size: 10px; }
  #race .race-home, #race .race-save { padding: 4px 9px; font-size: 10px; }
  #race .race-stats, #race .commands .tip { display: none; }
  #race-classification {
    left: 8px;
    width: calc(var(--race-left) - 18px);
    max-height: calc(100% - var(--race-top) - var(--race-bottom));
    padding: 0 3px 3px;
  }
  #race-classification .classification-head,
  #race-classification .classification-row { --tower-gap-width: 46px; grid-template-columns: minmax(0, 1fr) 46px 54px 36px; gap: 3px; padding: 6px 2px; font-size: 9px; }
  #race-classification .classification-head { font-size: 8px; }
  #race-classification .classification-row b { margin-right: 0; }
  #race-classification .classification-driver { gap: 3px; }
  #race-classification .classification-team { width: 15px; height: 15px; flex-basis: 15px; padding: 1px; }
  #race-classification .classification-tyre::before { width: 6px; height: 6px; margin-right: 3px; }
  #race .commands {
    top: var(--race-top);
    right: 8px;
    bottom: 8px;
    width: calc(var(--race-right) - 16px);
    gap: 6px;
  }
  #race .driver.panel { --pad: 6px; padding-bottom: 4px; }
  #race .driver > header { gap: 6px; padding-block: 2px; }
  #race .driver .avatar { width: 22px; height: 22px; }
  #race .driver .avatar svg { width: 16px; height: 16px; }
  #race .driver header > span:nth-child(2) { display: flex; align-items: baseline; gap: 5px; }
  #race .driver > .ers, #race .driver > .ers-label,
  #race .driver .segments[data-type="ersMode"] { display: none; }
  #race .driver header small { font-size: 7px; letter-spacing: 0; white-space: nowrap; }
  #race .driver header b { margin: 0; font-size: 13px; white-space: nowrap; }
  #race .driver header b i { font-size: 8px; }
  #race .driver header > strong { font-size: 11px; }
  #race .driver header > strong em { font-size: 19px; }
  #race .driver label { margin-top: 2px; font-size: 9px; line-height: 11px; }
  #race .driver label:has(.tyre-heat) { flex-wrap: nowrap; align-items: baseline; white-space: nowrap; }
  #race .tyre-heat { display: inline; flex-basis: auto; margin-top: 0; margin-left: 3px; font-size: 8px; }
  #race .tire { height: 2px; margin: 2px 0; }
  #race .driver > small { display: none; }
  #race .strategy-feedback { min-height: 12px; font-size: 8px; line-height: 12px; padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #race .segments { margin-top: 2px; }
  #race .segments button { min-height: 28px; padding: 2px; font-size: 10px; }
  #race .pit { min-height: 30px; padding: 4px 6px; margin-top: 3px; font-size: 10px; }
  #race .pit small { font-size: 8px; }
  #race .race-controls {
    left: 8px;
    right: var(--race-right);
    bottom: 8px;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 5px 7px;
    border-radius: 5px;
  }
  #race .race-tools { gap: 7px; justify-content: space-between; font-size: 9px; }
  #race .race-tools > span, #race .race-tools > div { gap: 2px; }
  #race .race-controls button { min-height: 30px; padding: 4px 6px; font-size: 10px; }
  #race .race-tools .start { min-width: 58px; }
  #race .camera-tools { padding-left: 0; border: 0; gap: 3px; }
  #race .view-distance { gap: 5px; font-size: 10px; }
  #race .view-distance input { flex: 1; min-height: 30px; width: 45px; }
  #race .race-options { justify-self: end; }
  #race .race-quality { font-size: 10px; }
  #race .race-quality select { min-height: 30px; }
  #race .camera-caption { font-size: 9px; padding: 5px 7px; }
  #race .race-clock { font-size: 9px; padding: 5px 7px; }
  #race #banner { font-size: 9px; padding: 5px 7px; max-width: calc(100% - var(--race-left) - var(--race-right) - 140px); }
  #race .track > #race-minimap { width: 112px; height: 67px; right: 8px; bottom: 54px; }
  #race-render-error { top: 30%; padding: 10px; font-size: 11px; }
  body:has(#race.active) .toast { bottom: 90px; right: 250px; font-size: 11px; max-width: 45vw; }
}
@media (max-height: 500px) and (min-width: 601px) and (max-width: 760px) {
  #race { --race-left: 8px; --race-right: 226px; }
  #race-classification { display: none; }
  #race .race-tools { gap: 3px; }
  #race .race-controls { gap: 4px; }
  #race .race-controls button { padding: 4px; }
}

/* The dock remains reachable with all data panels folded. */
#race-map { touch-action: none; }
#race .hud-dock { position: absolute; z-index: 7; bottom: 8px; left: 8px; right: 8px; display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; pointer-events: none; }
#race .hud-dock button { pointer-events: auto; padding: 5px 10px; border: 1px solid var(--glass-line); border-radius: 3px; background: var(--inset); color: var(--text); font: 700 11px var(--ui); }
#race .hud-dock button[aria-expanded="true"] { border-color: var(--ink); }
#race #radio-history[hidden] { display: none; }
#race #radio-history.radio-alert { border-color: var(--amber); color: var(--amber); }
#race .hud-dock .start { border-color: transparent; background: linear-gradient(180deg, var(--cta), var(--cta-b)); color: var(--cta-text); font-weight: 800; }
#race .race-controls { bottom: 52px; z-index: 7; }
#race { --race-bottom: 130px; }
#race.hide-ranking { --race-left: 8px; }
#race.hide-commands { --race-right: 8px; }
#race.hide-ranking #race-classification,
#race.hide-commands .commands,
#race.hide-tools .race-controls,
#race.hide-info .race-stats,
#race.hide-info #race-minimap,
#race.hide-info #camera-caption,
#race.hide-info #race-clock,
#race.hide-info .tip { display: none; }
#race.hide-tools { --race-bottom: 56px; }
@media (max-height: 500px) and (min-width: 601px) {
  #race .hud-dock { right: var(--race-right); }
  #race .hud-dock button { font-size: 10px; padding: 4px 6px; min-height: 30px; }
  #race .race-controls { bottom: 82px; }
  #race { --race-bottom: calc(90px + var(--height-race-tools-panel, 76px)); }
  #race.hide-tools { --race-bottom: 56px; }
}
@media (max-width: 700px) and (min-height: 501px), (max-width: 600px) {
  #race .track { height: 100%; bottom: 0; }
  #race .hud-dock { right: 8px; }
  #race .hud-dock button { font-size: 10px; padding: 4px 6px; }
  #race, #race.hide-tools {
    --dock-space: calc(16px + var(--height-hud-dock, 68px));
    --race-bottom: calc(var(--dock-space) + var(--height-race-tools-panel, 0px));
    --commands-bottom: calc(var(--race-bottom) + var(--height-banner, 0px) + 14px);
  }
  #race .race-controls { top: auto; bottom: var(--dock-space); }
  #race .commands { top: auto; bottom: var(--commands-bottom); max-height: calc(100% - var(--commands-bottom) - 82px); }
  #race:not(.hide-ranking) #race-classification { display: block; left: 8px; top: 76px; width: min(296px, calc(100% - 16px)); max-height: 30%; z-index: 6; }
  #race .track > #race-minimap { top: 100px; bottom: auto; }
  #race:not(.hide-ranking) #race-minimap:not([data-following]) { display: none; }
}
@media (max-height: 500px) and (min-width: 601px) and (max-width: 760px) {
  #race:not(.hide-ranking) #race-classification { display: block; width: 250px; z-index: 6; }
}

.classification { --tower-bar-height: 38px; }
.tower-top { display: flex; align-items: center; justify-content: space-between; min-height: 30px; padding: 3px 6px; color: var(--text); background: var(--inset); font-variant-numeric: tabular-nums; }
.tower-top:has(.tower-mode:not([hidden])) { height: var(--tower-bar-height); gap: 4px; white-space: nowrap; }
.tower-heading { position: sticky; top: 0; z-index: 2; background: var(--inset); }
.tower-heading .classification-head { position: static; }
.tower-team-result { padding: 3px 6px; color: var(--ink); font-size: 11px; }
#race:not(.hide-commands) .tower-team-result, #race.qualifying-session .commands .tip { display: none; }
.tower-top button, .tower-expand, #qualifying-help, #watch-contender { background: var(--raised); color: var(--text); border: 1px solid var(--glass-line); padding: 5px 8px; border-radius: 3px; font: 700 11px var(--ui); }
.tower-mode { display: flex; }
.tower-mode button { min-height: 32px; padding-block: 3px; }
.tower-mode button:first-child { border-radius: 3px 0 0 3px; }
.tower-mode button:last-child { border-radius: 0 3px 3px 0; margin-left: -1px; }
.tower-mode button[aria-pressed="true"] { position: relative; border-color: var(--ink); color: var(--ink); }
.tower-mode button:focus-visible { z-index: 1; }
.classification [data-gap-mode] { background: none; color: var(--text); font: inherit; padding: 0; white-space: nowrap; min-height: 24px; }
#race-classification .classification-head:has([data-gap-mode]:not([hidden])),
.dialog-classification .classification-head:has([data-gap-mode]:not([hidden])) { padding-block: 0; }
.tower-expand { width: 100%; }
.classification-row[hidden], .tower-expand[hidden], .tower-mode[hidden], .classification-head[hidden], #locked-grid[hidden], #watch-contender[hidden] { display: none; }
.tower-team-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.tower-team-table th, .tower-team-table td { padding: 5px 6px; border-bottom: 1px solid var(--glass-line); text-align: left; }
.tower-team-table thead th { position: sticky; top: var(--tower-bar-height); z-index: 1; background: var(--inset); color: var(--muted); white-space: nowrap; }
.tower-team-table tr > :first-child { width: 1%; text-align: center; color: var(--muted); }
.tower-team-table tr > :last-child { width: 1%; text-align: right; }
.tower-team-table tbody th { font-weight: 500; }
.tower-team-table tbody td:last-child { font-weight: 700; }
.tower-team-name { display: flex; align-items: center; gap: 5px; overflow-wrap: anywhere; width: 100%; padding: 4px 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.tower-team-name:hover { color: var(--link); }
.tower-team-table .ours { background: var(--raised); }
.tower-team-table .ours td:first-child { box-shadow: inset 3px 0 var(--team); }
.tower-team-table .ours th { font-weight: 700; }
.tower-teams-empty { padding: 10px 6px; color: var(--muted); font-size: 11px; }
.classification-team { border-left: 3px solid var(--constructor); }
.classification-follow[aria-pressed="true"] .classification-name::before { content: '▸ '; color: var(--text); }
.battle-caption { position: absolute; left: var(--race-left); bottom: calc(var(--race-bottom) + var(--height-banner, 36px) + 16px); max-width: min(460px, calc(100% - var(--race-left) - var(--race-right))); padding: 8px 12px; border-left: 3px solid var(--ink); background: #101522e8; color: #fff; font-size: 12px; pointer-events: none; }
.battle-caption[hidden], #race.hide-info .battle-caption, #race:not(.hide-tools) .battle-caption { display: none; }
#camera-style { min-width: 0; min-height: 32px; max-width: 130px; }
.session-tabs, .session-compare { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.session-tabs button, .session-compare select, .damage-summary button { min-height: 44px; }
.session-tabs [aria-pressed="true"] { background: var(--cta); color: var(--cta-text); }
#modal [data-watch-driver], #modal [data-strategy-driver], #modal [data-session-driver]:not(.classification-data):not(.classification-status), #modal [data-repair-driver] { padding: 9px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 5px; background: var(--raised); color: var(--text); font: 700 12px var(--ui); }
#modal .session-tabs [aria-pressed="true"] { background: var(--cta); color: var(--cta-text); }
.session-compare select { background: var(--inset); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 5px 10px; max-width: 100%; }
.session-table { overflow-x: auto; max-width: 100%; }
.session-table table { width: 100%; font-variant-numeric: tabular-nums; border-collapse: collapse; white-space: nowrap; }
.session-table td, .session-table th { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.lap-chart { width: 100%; max-height: 140px; background: #111727; border-radius: 8px; }
.stint-list article { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 12px; margin: 8px 0; border-left: 4px solid var(--compound); background: var(--panel); }
.stint-list small { width: 100%; }
.damage-summary { padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.race-field [data-session-driver] { grid-column: 2 / 4; min-height: 36px; margin: 3px 0; }
#race .view-distance { flex-wrap: wrap; }
@media (max-width: 700px) and (orientation: portrait) {
  .battle-caption { left: 8px; right: 8px; max-width: none; font-size: 10px; }
}
.classification-row.cutoff-line { border-bottom: 2px dashed var(--amber); }
.classification-tyre::before { content: attr(data-code); width: 15px; height: 15px; border: 2px solid var(--compound); background: var(--rail); color: #fff; text-align: center; font: 700 9px/12px var(--ui); vertical-align: middle; }
#race .dock-speeds { display: inline-flex; gap: 1px; }
#race .dock-speeds .active { border-color: var(--ink); color: var(--ink); }
#race .dock-speed-picker { display: none; }
#locked-grid { padding: 12px; border: 1px solid var(--glass-line); border-radius: 4px; color: var(--text); background: var(--inset); }
#locked-grid p { font-variant-numeric: tabular-nums; margin: 6px 0; }
#race.qualifying-session .driver.locked-seat, #race.qualifying-session #race-clock,
#race.qualifying-session:not(.hide-ranking) .fallback-clock, #race.clean-broadcast #car-labels { display: none; }
#race.qualifying-session .tip { padding: 0; background: none; border: 0; box-shadow: none; }
#race.qualifying-session .commands { bottom: auto; max-height: calc(100% - var(--race-top) - var(--race-bottom)); }
#race.qualifying-session #race-classification { max-height: calc(100% - var(--race-top) - var(--race-bottom) - 80px); }
@media (min-width:601px) and (max-height:500px) {
  #race:not(.hide-ranking) #race-classification { max-height: calc(100% - var(--race-top) - var(--race-bottom)); }
  #race .classification-tyre::before { width: 15px; height: 15px; }
  #race:not(.hide-ranking) { --race-left: 222px; }
  #race:not(.hide-ranking) #race-classification { width: 204px; }
  #race .tower-team-table { font-size: 10px; }
  #race .tower-team-table :is(th, td) { padding-inline: 4px; }
}
@media (max-width:700px) and (min-height:501px), (max-width:600px) {
  .classification { --tower-bar-height: 42px; }
  #race.qualifying-session .commands { top: auto; bottom: var(--commands-bottom); max-height: calc(100% - var(--commands-bottom) - 126px); }
  #race:not(.hide-ranking) #race-classification { top: auto; bottom: var(--commands-bottom); left: 8px; width: calc(100% - 16px); max-height: min(36dvh, calc(100% - var(--commands-bottom) - 180px)); }
  #race:not(.hide-ranking) #race-classification.tower-expanded { max-height: min(46dvh, calc(100% - var(--commands-bottom) - 180px)); }
  #race .hud-dock button, .classification .tower-top button, .classification [data-gap-mode], #race .classification [data-gap-mode], #race .tower-expand, #race .classification-row { min-height: 36px; }
  #locked-grid:has(#watch-contender:not([hidden])) { grid-column: 1 / -1; }
  #race #qualifying-help { margin-left: auto; }
  #race.qualifying-session .race-home { margin-left: 0; }
  #race .track > #race-minimap { top: 76px; width: 112px; height: 67px; }
  #race .hud-dock { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; bottom: max(8px, env(safe-area-inset-bottom)); }
  #race .hud-dock button, #race .dock-speed-picker { grid-column: span 3; min-height: 44px; padding: 6px 4px; font-size: 12px; white-space: nowrap; }
  #race .hud-dock .dock-speeds { display: none; }
  #race .hud-dock #start { grid-column: span 4; }
  #race .hud-dock #advance-prep { grid-column: 1 / -1; order: 1; }
  #race .hud-dock .dock-speed-picker { grid-column: span 2; }
  #race .dock-speed-picker { display: block; width: 100%; min-width: 0; pointer-events: auto; border: 1px solid var(--glass-line); border-radius: 3px; background: var(--raised); color: var(--text); font-family: var(--ui); font-weight: 700; }
  #race .hud-dock [data-panel="tools"], #race .hud-dock [data-panel="info"], #race #clean-view { grid-column: span 4; }
  #race .hud-dock:has(#radio-history:not([hidden])) :is([data-panel="tools"], [data-panel="info"], #clean-view, #radio-history) { grid-column: span 3; }
  #race, #race.hide-tools { --dock-space: calc(8px + max(8px, env(safe-area-inset-bottom)) + var(--height-hud-dock, 94px)); }
}
@media (min-width:1101px) and (min-height:640px) {
  #race-classification .classification-row { min-height: 26px; padding-block: 3px; font-size: 11px; }
  #race-classification .classification-row button { min-height: 24px; }
}
@media (max-width:1000px) {
  #race:not(.hide-ranking) #race-classification { display: flex; flex-direction: column; overflow: hidden; }
  #race-classification .tower-heading, #race-classification .tower-expand { flex-shrink: 0; }
  #race-classification .tower-rows, #race-classification .tower-teams { min-height: 0; overflow-y: auto; }
  #race-classification .classification-follow { grid-template-columns: minmax(0, 1fr); gap: 1px; }
  #race-classification .classification-gap { padding-left: 34px; color: var(--muted); }
}
@media (max-width:700px) and (orientation:portrait) {
  #race-classification .classification-follow { grid-template-columns: minmax(0, 1fr) var(--tower-gap-width); gap: 4px; }
  #race-classification .classification-gap { padding-left: 0; }
}
@media (max-width:700px) and (orientation:portrait) and (max-height:700px) {
  #race:not(.hide-ranking) #race-classification:not(.tower-expanded) { max-height: 31dvh; }
}
@media (any-pointer:coarse) {
  #race-classification .classification-row button, .dialog-classification .classification-row button { min-height: 44px; }
  #race-classification .classification-head, #race-classification .classification-row,
  .dialog-classification .classification-head, .dialog-classification .classification-row {
    grid-template-columns: minmax(0, 1fr) 46px 48px 44px;
    --tower-gap-width: 46px;
  }
  #race-classification .classification-row, .dialog-classification .classification-row { padding-block: 0; }
}
