/* Phone and small-tablet layout. Timing transport and race data stay unchanged. */
@media (max-width:1180px) {
  html { scroll-padding-top:12px; }
  body[data-view] { min-width:0; }
  body[data-view] button, body[data-view] input, body[data-view] select, body[data-view] textarea {
    min-height:44px;
  }
  body[data-view] input, body[data-view] select, body[data-view] textarea { font-size:16px; }
  body[data-view] button { touch-action:manipulation; }
  body[data-view] .app-shell, body[data-view=live] .app-shell {
    display:flex; flex-direction:column; gap:10px;
    width:100%; max-width:100%; height:auto; min-height:100svh;
    padding:max(12px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(18px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
  }
  body[data-view=live] { overflow:auto; }
  body[data-view] .app-shell>*, body[data-view] .dashboard, body[data-view] .analysis-rail { min-width:0; max-width:100%; }
  body[data-view] .masthead { order:0; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px; margin:0; }
  body[data-view] .identity>div { display:none; }
  body[data-view] .identity { min-width:0; }
  body[data-view] .product-logo { width:clamp(120px,38vw,160px); height:36px; padding:4px 7px; }
  body[data-view] .view-switch { min-width:0; }
  body[data-view] .view-switch button { min-width:65px; padding:8px; font-size:11px; }
  body[data-view] .header-actions { grid-column:1/-1; width:100%; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
  body[data-view] .portal-session-bar { margin-right:auto; gap:6px; }
  body[data-view] .portal-session-bar .portal-home { padding:8px 10px; font-size:12px; }
  body[data-view] .portal-user-badge { width:32px; height:32px; }
  body[data-view] .voice-toggle { font-size:12px; padding:8px 10px; }
  body[data-view] .voice-settings-button { width:44px; height:44px; }
  body[data-view] .header-actions .connection-pill { display:flex; flex:0 1 110px; justify-content:flex-end; padding:2px; min-height:44px; border:0; background:transparent; font-size:9px; line-height:1.3; }
  body[data-view] .control-deck, body[data-view=live] .control-deck.event-connected {
    order:1; display:grid; grid-template-columns:minmax(0,1fr); gap:6px;
    padding:8px; margin:0; overflow:visible;
  }
  body[data-view] .connected-event-controls { min-width:0; justify-content:space-between; gap:5px; }
  body[data-view] .connected-event-controls>span { font-size:11px; white-space:normal; }
  body[data-view] #eventRaceBrowseButton { min-height:44px; font-size:12px; padding:8px; }
  body[data-view] .source-meta, body[data-view] #eventCategoryHelp { display:none!important; }
  body[data-view] .category-switch { width:100%; min-width:0; padding:3px; overflow-x:auto; }
  body[data-view] .category-switch [role=tab] { min-width:82px; max-width:220px; padding:8px 12px; font-size:12px; }
  body[data-view] .race-hero { order:2; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:10px; padding:14px 12px 16px; margin:0; }
  body[data-view] .race-title h1 { font-size:clamp(18px,4.6vw,25px); line-height:1.12; letter-spacing:-.6px; white-space:normal; display:block; margin:6px 0; overflow-wrap:anywhere; }
  body[data-view] .eyebrow { font-size:10px; letter-spacing:1.5px; }
  body[data-view] .race-title p { font-size:11px; line-height:1.4; overflow-wrap:anywhere; }
  body[data-view] .track-reference { display:none; }
  body[data-view] .session-facts { gap:4px 8px; font-size:9px; line-height:1.4; letter-spacing:.2px; }
  body[data-view] .session-facts span:nth-child(n+4) { display:none; }
  body[data-view] .race-clock { min-width:76px; max-width:130px; text-align:right; }
  body[data-view] .race-clock strong { font-size:clamp(30px,9vw,48px); line-height:1; letter-spacing:-1.5px; margin-top:6px; overflow-wrap:anywhere; }
  body[data-view] .race-clock>span { font-size:8px; padding:5px; letter-spacing:.7px; }
  body[data-view] .race-clock small { display:block; margin-top:5px; font-size:8px; letter-spacing:.5px; }

  /* Classification comes before the map/story, regardless of DOM source order. */
  body[data-view=live] .dashboard { order:3; display:block; margin:0; }
  body[data-view=live] .timing-panel { display:flex; flex-direction:column; height:auto; max-height:72svh; min-height:300px; }
  body[data-view] .timing-panel>.section-head { flex:0 0 auto; padding:12px; gap:8px; align-items:center; }
  body[data-view] .timing-panel>.section-head h2 { font-size:18px; }
  body[data-view] .timing-panel .kicker { font-size:9px; letter-spacing:1.2px; }
  body[data-view] .legend { font-size:10px; gap:8px; flex-wrap:wrap; }
  body[data-view] .timing-head { display:none; }
  body[data-view=live] .timing-tower { flex:1 1 auto; min-height:0; max-height:none; overflow-y:auto; overscroll-behavior-y:contain; }
  body[data-view] .panel-foot { flex:0 0 auto; padding:8px 10px; gap:8px; font-size:10px; line-height:1.4; flex-wrap:wrap; }
  body[data-view] .timing-row {
    display:grid; grid-template-columns:34px minmax(0,1fr) minmax(0,1fr) 52px;
    grid-template-areas:"position driver driver laps" "interval interval preceding preceding" "last last best best";
    align-items:center; gap:8px 6px; min-width:0; min-height:0; padding:12px 10px;
  }
  body[data-view][data-session-type=practice] .timing-row {
    grid-template-columns:34px minmax(0,1fr) minmax(0,1fr) 52px;
    grid-template-areas:"driver driver driver laps" "last last best best";
  }
  body[data-view] .timing-row>.position-cell { grid-area:position; align-self:start; min-width:0; }
  body[data-view] .position-cell strong { font-size:25px; }
  body[data-view] .position-cell em { font-size:10px; }
  body[data-view] .timing-row>.driver-cell { grid-area:driver; min-width:0; }
  body[data-view] .driver-cell.with-fuel { grid-template-columns:minmax(0,1fr) 26px; gap:7px; }
  body[data-view] .driver-copy { min-width:0; }
  body[data-view] .driver-cell strong { font-size:14px; line-height:1.3; white-space:normal; overflow-wrap:anywhere; }
  body[data-view] .driver-source-meta { font-size:10px; margin-top:3px; }
  body[data-view] .pilot-meter { grid-template-columns:44px minmax(0,1fr); gap:5px; margin-top:5px; }
  body[data-view] .pilot-meter>span { font-size:8px; letter-spacing:.5px; }
  body[data-view] .fuel-widget { grid-template-rows:auto 36px auto; gap:2px; min-width:0; }
  body[data-view] .fuel-tank { height:36px; width:18px; }
  body[data-view] .fuel-widget>span, body[data-view] .fuel-widget>small { font-size:7px; }
  body[data-view] .timing-row>.gap-col { grid-area:interval; display:block; }
  body[data-view] .timing-row>.preceding-col { grid-area:preceding; display:block; text-align:right; }
  body[data-view] .timing-row>.last-col { grid-area:last; display:block; }
  body[data-view] .timing-row>.best-col { grid-area:best; display:block; }
  body[data-view] .timing-row .timing-value { min-width:0; }
  body[data-view] .timing-value strong { font-size:16px; overflow-wrap:anywhere; }
  body[data-view] .timing-value small { font-size:10px; line-height:1.3; letter-spacing:.2px; }
  body[data-view] .gap-col strong, body[data-view] .preceding-col strong { font-size:13px; }
  body[data-view] .timing-row>.laps-cell { grid-area:laps; align-self:start; min-width:0; font-size:23px; }
  body[data-view] .laps-cell:before { content:"VUELTAS"; display:block; margin-bottom:3px; color:var(--muted); font-size:8px; letter-spacing:.5px; }
  body[data-view] .laps-cell small { font-size:9px; }
  body[data-view][data-session-type=practice] .timing-row>.gap-col,
  body[data-view][data-session-type=practice] .timing-row>.preceding-col { display:none; }
  body[data-view] .timing-row .session-fastest { padding:5px 8px; border-radius:9px; }
  body[data-view] .timing-row>.lap-history { grid-column:1/-1; min-width:0; max-width:100%; }
  body[data-view] .lap-history-head, body[data-view] .lap-history-item { grid-template-columns:32px minmax(0,.9fr) minmax(0,1fr) 28px; gap:4px; }
  body[data-view] .lap-history-list.practice-rounds .lap-history-head,
  body[data-view] .lap-history-list.practice-rounds .lap-history-item { grid-template-columns:40px minmax(0,1fr) minmax(0,1fr); }
  body[data-view] .lap-history-item { font-size:12px; min-height:36px; padding:7px 4px; }
  body[data-view] .lap-history-item b em { font-size:7px; }
  body[data-view] .lap-history-summary strong, body[data-view] .lap-history-summary span,
  body[data-view] .lap-history-note { font-size:11px; }

  body[data-view=live] .track-map-card { order:4; margin:0; }
  body[data-view=live] .track-map-layout { display:block; }
  body[data-view=live] .track-stage { height:clamp(210px,56vw,330px); min-height:0; }
  body[data-view=live] .track-stage svg { width:100%; height:100%; min-height:0; }
  body[data-view=live] .track-legend { display:none; }
  body[data-view=live] .track-map-card[data-collapsed=true] { height:50px; min-height:50px; }
  body[data-view] .track-map-toggle { min-height:44px; padding:8px 10px; font-size:11px; }
  body[data-view] .track-incident-dock { max-width:calc(100% - 16px); overflow-x:auto; overscroll-behavior-x:contain; }
  body[data-view] .track-map-note { font-size:9px; }
  body[data-view=live] .live-general-card[data-panel] { order:5; height:55svh; min-height:280px; max-height:520px; margin:0; }
  body[data-view] .live-lower-tabs { gap:4px; padding:4px; }
  body[data-view] .live-lower-tabs button { min-height:44px; padding:7px 9px; font-size:11px; letter-spacing:.4px; }
  body[data-view] .live-lower-tabs button span { min-width:21px; height:21px; font-size:10px; }
  body[data-view] .live-story-head { padding:10px; align-items:flex-start; gap:6px; }
  body[data-view] .live-story-head>div { flex-wrap:wrap; gap:5px; }
  body[data-view] .live-story-head strong { font-size:15px; }
  body[data-view] .live-story-head .kicker, body[data-view] .live-story-head>span { font-size:10px; }
  body[data-view] .live-story-entry { grid-template-columns:52px minmax(0,1fr); gap:8px; padding:11px 10px; }
  body[data-view] .live-story-entry time { font-size:10px; line-height:1.4; }
  body[data-view] .live-story-entry span { font-size:10px; }
  body[data-view] .live-story-entry p { font-size:14px; line-height:1.45; overflow-wrap:anywhere; }
  body[data-view] .empty-compact, body[data-view] .empty-state { font-size:13px; line-height:1.5; padding:14px; }
  body[data-view] .live-general-head, body[data-view] .live-general-row { grid-template-columns:42px minmax(0,1fr) 42px 74px; gap:5px; padding:10px; }
  body[data-view] .live-general-row>strong { font-size:18px; }
  body[data-view] .live-general-row b { font-size:13px; white-space:normal; }
  body[data-view] .live-general-row>span, body[data-view] .live-general-row>em { font-size:12px; }
  body[data-view] .demo-replay-controls { position:relative; inset:auto; display:flex; flex-wrap:wrap; gap:7px; padding:10px; }
  body[data-view] .demo-replay-controls[hidden] { display:none!important; }
  body[data-view] .demo-replay-controls>div { flex:1 0 100%; }
  body[data-view] .demo-replay-controls button, body[data-view] .demo-replay-controls select, body[data-view] .demo-replay-controls label, body[data-view] .demo-replay-controls a { font-size:12px; }
  body[data-view] .demo-replay-controls .demo-seek { grid-template-columns:38px minmax(0,1fr) 38px; }

  /* All consultation windows stay inside the phone's safe area. */
  body[data-view] #eventRaceBrowser[open], body[data-view] .event-reports-dialog[open], body[data-view] .portal-modal[open] {
    width:calc(100% - 20px); max-width:820px; max-height:calc(100svh - 28px); padding:14px; overflow:auto;
  }
  body[data-view] #eventRaceBrowser .event-race-browser-head { flex-wrap:wrap; gap:8px; }
  body[data-view] #eventRaceBrowser .event-race-browser-head>div { flex:1 0 calc(100% - 55px); order:-2; }
  body[data-view] #eventRaceBrowserClose { order:-1; width:44px; min-height:44px; }
  body[data-view] #eventRaceBrowser .event-race-tabs { display:grid; grid-template-columns:minmax(0,1fr); max-height:48svh; }
  body[data-view] #eventRaceBrowser .event-race-tab { width:100%; min-width:0; }
  body[data-view] #eventRaceBrowser .event-race-tab b { white-space:normal; }
  body[data-view] .event-reports-dialog>header { align-items:flex-start; gap:8px; }
  body[data-view] .event-reports-dialog h2 { font-size:20px; overflow-wrap:anywhere; }
  body[data-view] .event-reports-dialog p, body[data-view] .event-reports-dialog a { font-size:13px; line-height:1.5; }
  body[data-view] .event-report-table { max-width:100%; overscroll-behavior-x:contain; }
  body[data-view] .event-report-table table, body[data-view] .event-report-table tbody { display:block; width:100%; }
  body[data-view] .event-report-table thead { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); }
  body[data-view] .event-report-table tr { display:grid; grid-template-columns:28px minmax(0,1fr); gap:3px 8px; padding:12px 0; border-bottom:1px solid var(--line); }
  body[data-view] .event-report-table td { display:block; min-width:0; padding:3px; border:0; overflow-wrap:anywhere; }
  body[data-view] .event-report-table td:first-child { grid-column:1; grid-row:1/3; font-weight:850; }
  body[data-view] .event-report-table td:nth-child(2), body[data-view] .event-report-table td:nth-child(3) { grid-column:2; }
  body[data-view] .event-report-table td:nth-child(2) { font-weight:800; }
  body[data-view] .event-report-table td:nth-child(3):before { content:"Resultado · "; color:var(--muted); }
  body[data-view] .event-report-table .event-report-heats { grid-column:1/-1; min-width:0; }
  body[data-view] .voice-panel { position:fixed; inset:12px 10px auto; width:auto; max-height:calc(100svh - 24px); overflow:auto; }
  body[data-view] .voice-field, body[data-view] .voice-pilot-list label, body[data-view] .voice-event-settings label { font-size:13px; }

  /* Analysis: one readable column, with large details kept collapsed. */
  body[data-view=analysis] .dashboard { order:3; display:block; }
  body[data-view=analysis] .analysis-rail { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; }
  body[data-view=analysis] .registration-strip, body[data-view=analysis] .session-rules-card,
  body[data-view=analysis] .intelligence-center, body[data-view=analysis] .championship-section,
  body[data-view=analysis] .rules-center { order:3; margin:0; }
  body[data-view=analysis] .registration-overview { display:grid; grid-template-columns:minmax(0,1fr) auto; padding:12px; gap:10px; }
  body[data-view=analysis] .registration-summary { grid-column:1/-1; }
  body[data-view=analysis] .registration-overview h2 { font-size:17px; }
  body[data-view=analysis] .registration-counts { gap:12px; }
  body[data-view=analysis] .registration-counts strong { font-size:20px; }
  body[data-view=analysis] .registration-counts span, body[data-view=analysis] .disclosure-label { font-size:10px; }
  body[data-view=analysis] .intelligence-overview { grid-template-columns:minmax(0,1fr); padding:12px; }
  body[data-view=analysis] .secured-positions { flex-wrap:wrap; }
  body[data-view=analysis] .intelligence-summary>strong { font-size:18px; }
  body[data-view=analysis] .section-head { padding:14px 12px; gap:10px; flex-wrap:wrap; }
  body[data-view=analysis] .section-head h2 { font-size:20px; }
  body[data-view=analysis] .kicker { font-size:10px; letter-spacing:1.5px; }
  body[data-view=analysis] .standings-head, body[data-view=analysis] .standing-row { grid-template-columns:36px minmax(0,1fr) 54px 76px; gap:5px; padding:10px; }
  body[data-view=analysis] .standing-row strong { font-size:14px; overflow-wrap:anywhere; }
  body[data-view=analysis] .standing-row .driver { font-size:13px; overflow-wrap:anywhere; }
  body[data-view=analysis] .standing-row small { font-size:10px; }
  body[data-view=analysis] .standing-row .points { font-size:12px; }
  body[data-view=analysis] .standing-row .range, body[data-view=analysis] .standings-head span:last-child { display:none; }
  body[data-view=analysis] .scenario-selectors, body[data-view=analysis] .intelligence-grid, body[data-view=analysis] .swing-feed { grid-template-columns:minmax(0,1fr); }
  body[data-view=analysis] .scenario-selectors label { min-width:0; }
  body[data-view=analysis] .scenario-selectors select { width:100%; min-width:0; }
  body[data-view=analysis] .objective-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-view=analysis] .objective-grid article { min-width:0; padding:12px; }
  body[data-view=analysis] .objective-grid strong { font-size:18px; }
  body[data-view=analysis] .objective-grid small, body[data-view=analysis] #titlePaths p, body[data-view=analysis] #rivalThresholds { font-size:13px; line-height:1.5; overflow-wrap:anywhere; }
  body[data-view=analysis] .broadcast-copy { padding:14px 12px; font-size:15px; line-height:1.5; }
  body[data-view=analysis] #broadcastContext { font-size:12px; line-height:1.4; overflow-wrap:anywhere; }
  body[data-view=analysis] .insight-stack { padding:12px; gap:9px; }
  body[data-view=analysis] .insight { font-size:13px; line-height:1.5; padding:12px; }
  body[data-view=analysis] .session-rules-card { padding:14px 12px; }
  body[data-view=analysis] .session-rules-clocks { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-view=analysis] .session-rules-card p { font-size:13px; overflow-wrap:anywhere; }
  body[data-view=analysis] .session-rules-card summary, body[data-view=analysis] .rules-overview { min-height:44px; }
  body[data-view=analysis] .session-rules-card #sessionRulesRows p { grid-template-columns:minmax(0,1fr); gap:3px; }
  body[data-view=analysis] .session-rules-driver { min-width:0; grid-template-columns:minmax(0,1fr) 38px 38px 42px; gap:6px; font-size:12px; }
  body[data-view=analysis] .session-rules-driver>:last-child { grid-column:1/-1; font-size:12px; line-height:1.4; }
  body[data-view=analysis] .session-rules-driver.head>:last-child { display:none; }

  /* Home, garage and private-result forms use the same touch-sized controls. */
  body[data-view] .portal-wrap { width:100%; min-width:0; padding:18px max(12px,env(safe-area-inset-right)) 30px max(12px,env(safe-area-inset-left)); }
  body[data-view] .portal-brand { gap:12px; flex-wrap:wrap; padding-bottom:16px; }
  body[data-view] .portal-brand span { font-size:10px; }
  body[data-view] .portal-dashboard { padding-top:24px; }
  body[data-view] .portal-dashboard-head { align-items:stretch; flex-direction:column; gap:16px; margin-bottom:22px; }
  body[data-view] .portal-dashboard-head h1 { font-size:38px; line-height:1.05; letter-spacing:-1.5px; }
  body[data-view] .portal-dashboard-actions { justify-content:flex-start; flex-wrap:wrap; gap:8px; }
  body[data-view] .portal-dashboard-shortcut { width:72px; min-height:64px; }
  body[data-view] .portal-action-grid, body[data-view] .portal-primary-grid { display:grid; grid-template-columns:minmax(0,1fr); overflow:visible; gap:12px; }
  body[data-view] .portal-primary-grid>.portal-action, body[data-view] .portal-primary-grid>.portal-circuit-browser { min-height:0; width:100%; }
  body[data-view] .portal-action, body[data-view] .portal-circuit-browser { padding:18px; min-width:0; }
  body[data-view] .portal-action>p { min-height:0; font-size:14px; line-height:1.5; }
  body[data-view] .portal-circuit-browser-head { align-items:stretch; flex-direction:column; gap:14px; }
  body[data-view] .portal-circuit-search { width:100%; flex-basis:auto; }
  body[data-view] .portal-circuit-grid { grid-template-columns:minmax(0,1fr); }
  body[data-view] .portal-circuit-copy strong { font-size:18px; }
  body[data-view] .portal-circuit-copy small { font-size:12px; }
  body[data-view] .portal-circuit-actions { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  body[data-view] .portal-circuit-open, body[data-view] .portal-circuit-map, body[data-view] .portal-show-all { min-height:44px; font-size:13px; }
  body[data-view] .result-import-layout, body[data-view] .result-metadata-grid,
  body[data-view] .result-participant-fields, body[data-view] .result-link-row { grid-template-columns:minmax(0,1fr); }
  body[data-view] .result-import-card, body[data-view] .result-review { min-width:0; padding:16px; }
  body[data-view] .result-review-head, body[data-view] .result-import-card-head { flex-wrap:wrap; gap:10px; }
  body[data-view] .result-file-queue>li { grid-template-columns:28px minmax(0,1fr); }
  body[data-view] .result-file-queue>li>div { grid-column:1/-1; justify-content:flex-end; }
  body[data-view] .result-file-queue button { width:44px; height:44px; }
  body[data-view] .garage-add-card, body[data-view] .garage-car-grid { grid-template-columns:minmax(0,1fr); }
  body[data-view] .garage-detail-head, body[data-view] .garage-detail-grid { grid-template-columns:minmax(0,1fr); }
  body[data-view] .garage-detail-head { flex-wrap:wrap; }
  body[data-view] .garage-setup-row button, body[data-view] .garage-timing-connect summary { min-height:44px; }
  body[data-view] .portal-legal a { display:inline-flex; align-items:center; min-height:44px; }
}
@media (max-width:360px) {
  body[data-view] .product-logo { width:120px; }
  body[data-view] .view-switch button { min-width:60px; font-size:10px; }
  body[data-view] .voice-toggle { font-size:11px; padding:8px; }
  body[data-view] .race-title h1 { font-size:18px; }
  body[data-view] .header-actions .connection-pill { flex:1 0 100%; min-height:20px; }
  body[data-view=analysis] .objective-grid { grid-template-columns:minmax(0,1fr); }
}
@media (max-width:1180px) and (orientation:landscape) {
  body[data-view] .masthead { grid-template-columns:auto auto minmax(0,1fr); }
  body[data-view] .header-actions { grid-column:auto; width:auto; }
  body[data-view] .header-actions .connection-pill { display:flex; flex:0 1 110px; min-height:44px; }
  body[data-view=live] .control-deck.event-connected { grid-template-columns:auto minmax(0,1fr); }
  body[data-view] .race-hero { padding:10px 12px; }
  body[data-view=live] .timing-panel { max-height:85svh; }
}
@media (hover:none) and (pointer:coarse) {
  button:hover, .portal-circuit-card:hover { transform:none; }
}
