/* Trackside information, not a second screen in front of the sport.
   This sheet deliberately changes only active play; account and menu flows stay separate. */
body[data-screen="race"] .scrim {
  background: linear-gradient(180deg, #10201865, transparent 105px),
    linear-gradient(0deg, #10201885, transparent 160px);
}

body[data-screen="race"] .masthead {
  inset: max(25px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) auto auto;
  width: auto;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
}
body[data-screen="race"] .masthead .brand,
body[data-screen="race"] .masthead .build-pill,
body[data-screen="race"] #account-button,
body[data-screen="race"] #fullscreen,
body[data-screen="race"] #sound { display: none; }
body[data-screen="race"] .mast-right { gap: 5px; }
body[data-screen="race"] .masthead .icon-button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: #14251c66;
  border: 0;
  font-size: 18px;
}

body[data-screen="race"] .race {
  inset: max(27px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right))
    max(26px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  text-shadow: 0 1px 3px #0b1b16ba;
}
body[data-screen="race"] .race-top { display: flex; align-items: flex-start; gap: 24px; }
body[data-screen="race"] .event-label { max-width: min(42vw, 430px); }
body[data-screen="race"] .event-label .eyebrow {
  font: 700 8px/1.4 Arial, sans-serif;
  letter-spacing: 1.9px;
  margin: 0 0 4px;
}
body[data-screen="race"] .event-label > strong {
  font: 25px/1.05 Impact, 'Arial Narrow', sans-serif;
  letter-spacing: .4px;
}
body[data-screen="race"] #race-instructions,
body[data-screen="race"] #race-room { display: none; }
body[data-screen="race"] .race-numbers {
  display: flex;
  align-items: flex-start;
  gap: 25px;
  padding: 0 92px 0 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
  backdrop-filter: none;
  text-align: right;
}
body[data-screen="race"] .race-numbers small {
  font: 700 8px/1.4 Arial, sans-serif;
  letter-spacing: 1.5px;
  margin: 0 0 3px;
  color: #e9eddf;
}
body[data-screen="race"] .race-numbers strong {
  display: block;
  font: 39px/1 Impact, 'Arial Narrow', sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: .4px;
}
body[data-screen="race"] .race-numbers em { font-size: 14px; }
body[data-screen="race"] .race-numbers .leave {
  position: fixed;
  right: max(28px, env(safe-area-inset-right));
  top: max(69px, calc(env(safe-area-inset-top) + 44px));
  width: 36px;
  height: 36px;
  border: 0;
  background: #14251c66;
  font-size: 24px;
}

body[data-screen="race"] .standings {
  display: grid;
  top: 88px;
  right: 0;
  width: 154px;
  gap: 3px;
}
body[data-screen="race"] .standing {
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 7px;
  padding: 3px 0;
  border: 0;
  border-radius: 0;
  background: none;
  font: 700 9px/1.35 Arial, sans-serif;
  color: #f1f1df;
}
body[data-screen="race"] .standing i { width: 4px; height: 13px; border-radius: 0; }
body[data-screen="race"] .standing.self { color: var(--lime); background: none; }
body[data-screen="race"] .standing.self strong { color: var(--lime); }
body[data-screen="race"] .standing strong { font: 700 10px/1.35 Arial, sans-serif; }

body[data-screen="race"] .race-bottom {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 24px;
}
body[data-screen="race"] .telemetry {
  flex: 0 0 auto;
  width: 238px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  backdrop-filter: none;
}
body[data-screen="race"] .speed { display: flex; float: none; margin: 0 0 10px; gap: 7px; }
body[data-screen="race"] .speed strong { font-size: 49px; line-height: .9; }
body[data-screen="race"] .speed span { font-size: 8px; letter-spacing: 1px; }
body[data-screen="race"] .distance-row {
  display: block;
  margin: 0 0 7px;
  font: 700 9px/1.6 Arial, sans-serif;
  letter-spacing: .65px;
}
body[data-screen="race"] .distance-row b { font-weight: 700; }
body[data-screen="race"] #feedback { display: none; }
body[data-screen="race"] .progress { height: 2px; border-radius: 0; background: #fff7e64d; }
body[data-screen="race"] .rhythm { gap: 9px; margin: 11px 0 0; padding: 0; font-size: 8px; }
body[data-screen="race"] .rhythm > span { display: none; }
body[data-screen="race"] .rhythm strong { min-width: 75px; text-align: right; font-size: 8px; }
body[data-screen="race"] #rhythm-meter { height: 4px; }
body[data-screen="race"] #rhythm-meter b { height: 10px; }
body[data-screen="race"] .skill-meter { margin: 11px 0 0; padding: 0; border: 0; }
body[data-screen="race"] .skill-meter > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
}
body[data-screen="race"] .skill-meter small { font: 700 9px Arial, sans-serif; letter-spacing: 1px; }
body[data-screen="race"] .skill-meter strong { font: 18px/1 Impact, 'Arial Narrow', sans-serif; }
body[data-screen="race"] .skill-track { height: 7px; border-radius: 0; background: #fff7e63d; }
body[data-screen="race"] .skill-track i { border-radius: 0; }
body[data-screen="race"] .skill-track b { top: -3px; height: 13px; border-radius: 0; }
body[data-screen="race"] .skill-meter[data-mode="direction"] .skill-track i { height: 15px; }
body[data-screen="race"] #skill-detail { display: none; }
body[data-screen="race"][data-event="tug"] #skill-detail {
  display: block;
  min-height: 0;
  margin: 8px 0 0;
  font: 700 8px/1.4 Arial, sans-serif;
}
/* These events already carry power, score or stamina in their dedicated meter. */
body[data-screen="race"]:is([data-event="shotput"], [data-event="basketball"],
  [data-event="archery"], [data-event="fencing"], [data-event="tug"]) .speed { display: none; }
body[data-screen="race"][data-event="discus"] .speed strong { font-size: 25px; }
body[data-screen="race"][data-event="discus"] .speed { margin-bottom: 8px; }
body[data-screen="race"]:is([data-event="shotput"], [data-event="discus"], [data-event="basketball"],
  [data-event="archery"], [data-event="curling"], [data-event="fencing"]) .telemetry > .progress { display: none; }

body[data-screen="race"] .input-panel { width: auto; max-width: min(52vw, 560px); }
body[data-screen="race"] #action-hint { display: none; }
body[data-screen="race"] .input-buttons { justify-content: flex-end; gap: 12px; }
body[data-screen="race"] .input-buttons button {
  min-width: 65px;
  width: auto;
  height: 51px;
  padding: 3px 5px;
  gap: 7px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  transition: color .08s;
}
body[data-screen="race"] .input-buttons button:not(:disabled):hover { color: var(--lime); background: none; }
body[data-screen="race"] .input-buttons .action-button,
body[data-screen="race"] .input-panel.single-action .action-button {
  min-width: 105px;
  max-width: 210px;
  margin-left: 6px;
  background: none;
  border: 0;
}
body[data-screen="race"] .input-buttons kbd {
  min-width: 29px;
  padding: 4px 8px;
  font-size: 11px;
  background: #14251c88;
  border: 1px solid #faf4df9c;
  border-bottom-width: 2px;
  border-radius: 2px;
}
body[data-screen="race"] .input-buttons span,
body[data-screen="race"] .input-panel.single-action .input-buttons span {
  font: 700 8px/1.2 Arial, sans-serif;
  letter-spacing: .8px;
  max-width: 180px;
}
body[data-screen="race"] .input-buttons button.active {
  color: var(--lime);
  background: none;
  box-shadow: none;
  transform: none;
}
body[data-screen="race"] .input-buttons button.active kbd {
  color: #1f2d1e;
  background: var(--lime);
  border-color: var(--lime);
  text-shadow: none;
}
body[data-screen="race"] .input-buttons button:disabled { opacity: .33; }

body[data-screen="race"] .countdown { top: 37%; }
body[data-screen="race"] .countdown small { background: none; padding: 0; font: 700 9px Arial, sans-serif; }
body[data-screen="race"] .countdown strong { font-size: 138px; margin-top: 12px; }
body[data-screen="race"] .event-callout { top: 20%; }
body[data-screen="race"] .event-callout strong { font-size: 36px; }
body[data-screen="race"] .event-callout span {
  background: none;
  padding: 0;
  margin-top: 6px;
  font: 700 9px/1.4 Arial, sans-serif;
}
body[data-screen="race"] .finish-wait {
  top: 21%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font: 700 10px/1.5 Arial, sans-serif;
}

/* Touch needs actual finger targets; desktop keeps a light key legend. */
@media (pointer: coarse) {
  body[data-screen="race"] .masthead .icon-button,
  body[data-screen="race"] .race-numbers .leave {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  body[data-screen="race"] .input-buttons { gap: 8px; }
  body[data-screen="race"] .input-buttons button {
    min-width: 62px;
    height: 68px;
    padding: 8px;
    background: #14251c9c;
    border-bottom: 2px solid #fff7e68c;
  }
  body[data-screen="race"] .input-buttons .action-button,
  body[data-screen="race"] .input-panel.single-action .action-button {
    min-width: 105px;
    background: #14251c9c;
    border-bottom: 2px solid var(--lime);
  }
  body[data-screen="race"] .input-buttons button.active { background: #def46830; }
}

@media (max-width: 700px) {
  body[data-screen="race"] .race {
    inset: max(19px, env(safe-area-inset-top)) max(17px, env(safe-area-inset-right))
      max(19px, env(safe-area-inset-bottom)) max(17px, env(safe-area-inset-left));
  }
  body[data-screen="race"] .masthead { top: max(16px, env(safe-area-inset-top)); right: 15px; }
  body[data-screen="race"] .race-top { gap: 10px; }
  body[data-screen="race"] .event-label { max-width: calc(100% - 85px); }
  body[data-screen="race"] .event-label .eyebrow { font-size: 7px; letter-spacing: 1.3px; }
  body[data-screen="race"] .event-label > strong { font-size: 23px; }
  body[data-screen="race"] .race-numbers {
    position: absolute;
    top: 61px;
    left: 0;
    padding: 0;
    gap: 23px;
    text-align: left;
  }
  body[data-screen="race"] .race-numbers small { font-size: 7px; letter-spacing: 1px; }
  body[data-screen="race"] .race-numbers strong { font-size: 31px; }
  body[data-screen="race"] .race-numbers .leave { top: max(60px, calc(env(safe-area-inset-top) + 44px)); right: 15px; }
  body[data-screen="race"] .standings { display: none; }
  body[data-screen="race"] .race-bottom { display: flex; flex-direction: column; gap: 18px; align-items: stretch; }
  body[data-screen="race"] .telemetry { width: min(238px, 77%); }
  body[data-screen="race"] .speed strong { font-size: 41px; }
  body[data-screen="race"] .distance-row { font-size: 8px; }
  body[data-screen="race"] .input-panel { width: 100%; max-width: none; }
  body[data-screen="race"] .input-buttons { gap: 5px; }
  body[data-screen="race"] .input-buttons button { min-width: 47px; padding: 3px; }
  body[data-screen="race"] .input-buttons .action-button,
  body[data-screen="race"] .input-panel.single-action .action-button { min-width: 80px; margin-left: 2px; }
  body[data-screen="race"] .input-buttons span { font-size: 7px; letter-spacing: .35px; }
  body[data-screen="race"] .input-panel.single-action .input-buttons span { font-size: 8px; }
  body[data-screen="race"] .event-callout { top: 25%; }
  body[data-screen="race"] .event-callout strong { font-size: 30px; }
  body[data-screen="race"] .finish-wait { top: 25%; max-width: 80%; font-size: 9px; }
  body[data-screen="race"] .countdown { top: 39%; }
}

@media (max-height: 500px) {
  body[data-screen="race"] .race { inset: 15px max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left)); }
  body[data-screen="race"] .masthead { top: 12px; right: max(20px, env(safe-area-inset-right)); }
  body[data-screen="race"] .event-label > strong { font-size: 21px; }
  body[data-screen="race"] .race-numbers { position: static; padding-right: 92px; gap: 20px; text-align: right; }
  body[data-screen="race"] .race-numbers strong { font-size: 31px; }
  body[data-screen="race"] .race-numbers .leave { top: 54px; right: max(20px, env(safe-area-inset-right)); }
  body[data-screen="race"] .standings { display: none; }
  body[data-screen="race"] .race-bottom { flex-direction: row; gap: 18px; align-items: flex-end; }
  body[data-screen="race"] .telemetry { width: 208px; }
  body[data-screen="race"] .speed strong { font-size: 35px; }
  body[data-screen="race"] .speed { margin-bottom: 7px; }
  body[data-screen="race"] .input-panel { width: auto; max-width: 55%; }
  body[data-screen="race"] .input-buttons { gap: 5px; }
  body[data-screen="race"] .input-buttons button { height: 51px; min-width: 47px; }
  body[data-screen="race"] .input-buttons .action-button,
  body[data-screen="race"] .input-panel.single-action .action-button { min-width: 85px; }
  body[data-screen="race"] .event-callout { top: 28%; }
  body[data-screen="race"] .event-callout strong { font-size: 29px; }
  body[data-screen="race"] .finish-wait { top: 28%; }
  body[data-screen="race"] .countdown { top: 43%; }
  body[data-screen="race"] .countdown strong { font-size: 88px; }
}

/* Deliberate no-HUD inspection mode. Settings dialogs remain reachable with Escape. */
body[data-screen="race"][data-hud="hidden"] .race,
body[data-screen="race"][data-hud="hidden"] .masthead,
body[data-screen="race"][data-hud="hidden"] .scrim,
body[data-screen="race"][data-hud="hidden"] .performance,
body[data-screen="race"][data-hud="hidden"] .notice { visibility: hidden; pointer-events: none; }
/* A pause belongs to the game, with clear live-match semantics. */
#pause-dialog{width:min(480px,calc(100vw - 40px));border:0;border-left:4px solid #dcf460;background:rgba(22,31,29,.96);color:#f5f1df;padding:36px;box-shadow:0 25px 90px #0008}
#pause-dialog::backdrop{background:#12201db3;backdrop-filter:blur(5px)}
.pause-actions{display:flex;flex-direction:column;align-items:stretch;gap:12px;margin-top:28px}
.pause-actions .text-button{text-align:left;padding:12px 0}
.controller-status{position:fixed;bottom:10px;right:18px;font-size:10px;font-weight:700;letter-spacing:.08em;color:#e8ecd3;z-index:3;pointer-events:none;text-shadow:0 1px 5px #000}
body[data-screen=race] .controller-status,body[data-hud=hidden] .controller-status{display:none}
body[data-input-device=controller] :focus-visible{outline:3px solid #dcf460;outline-offset:5px}
@media(max-height:500px){#pause-dialog{padding:20px}.pause-actions{gap:3px;margin-top:15px}.pause-actions .text-button{padding:7px 0}}
