:root {
  color-scheme: dark;
  --bg: #000;
  --text: #f2f7f4;
  --text-soft: #d8e4df;
  --muted: #b8c6c0;
  --muted-dim: #84928d;
  --cyan: #56b4e9;
  --blue: #0072b2;
  --amber: #e69f00;
  --red: #ff4d5d;
  --backplate: rgba(105, 114, 117, 0.36);
  --backplate-soft: rgba(86, 94, 97, 0.3);
  --outline: rgba(255, 255, 255, 0.92);
  --edge: rgba(255, 255, 255, 0.18);
  --shadow: 0 0 12px rgba(0, 0, 0, 0.86), 0 0 18px rgba(86, 180, 233, 0.12);
  font-family:
    B612, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
  touch-action: manipulation;
}

h1,
h2,
p {
  margin: 0;
}

button {
  font: inherit;
}

.hud-shell {
  position: relative;
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.hud-layout {
  position: absolute;
  inset: clamp(10px, 2.1vw, 34px);
  isolation: isolate;
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    #000 0%,
    #000 70%,
    rgba(0, 0, 0, 0.7) 86%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse at center,
    #000 0%,
    #000 70%,
    rgba(0, 0, 0, 0.7) 86%,
    transparent 100%
  );
}

.hud-layout::before {
  content: "";
  position: absolute;
  inset: 30% 36%;
  border: 1px solid transparent;
  pointer-events: none;
}

.hud-backplate,
.hud-chip,
.metric,
.plate-card {
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--backplate);
  box-shadow: var(--shadow);
}

.future-slot {
  visibility: hidden;
  pointer-events: none;
}

.rotate-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  gap: 18px;
  padding: 32px;
  background: var(--bg);
  text-align: center;
}

.rotate-gate p {
  max-width: 18rem;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}

.rotate-mark {
  position: relative;
  width: 128px;
  height: 78px;
  border: 3px solid var(--cyan);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(86, 180, 233, 0.24);
}

.rotate-mark span {
  position: absolute;
  right: -26px;
  bottom: -16px;
  width: 46px;
  height: 46px;
  border-right: 4px solid var(--amber);
  border-bottom: 4px solid var(--amber);
  border-radius: 0 0 24px 0;
}

.entry-panel {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(570px, calc(100vw - 32px));
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--backplate);
  box-shadow: var(--shadow);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.entry-panel h2 {
  margin-top: 2px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
}

.entry-panel .label {
  font-size: 0.68rem;
}

.entry-button,
.entry-link {
  min-height: 40px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--backplate-soft);
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
}

.entry-button {
  padding: 0 16px;
  color: var(--text);
}

.entry-link {
  padding: 0 12px;
  color: var(--cyan);
}

.entry-status {
  max-width: 13rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
}

:root[data-hud-entered="true"] .entry-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.label,
.section-head,
.hud-footer,
.metric span,
.plate-metric span,
.plate-detail span {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.master-warning-slot {
  position: absolute;
  top: clamp(54px, 13svh, 132px);
  left: 50%;
  width: clamp(220px, 24vw, 380px);
  height: clamp(46px, 7svh, 76px);
  transform: translateX(-50%);
}

.heading-track {
  position: absolute;
  top: clamp(16px, 5.2svh, 56px);
  left: 50%;
  display: grid;
  grid-template-columns: auto auto minmax(130px, 18vw);
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  transform: translateX(-50%);
}

.hud-chip {
  display: grid;
  min-height: clamp(48px, 6.5svh, 66px);
  min-width: clamp(92px, 9.5vw, 132px);
  align-content: center;
  gap: 6px;
  padding: 8px 12px;
}

.hud-chip strong {
  color: var(--text);
  font-family: "B612 Mono", B612, ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(1.28rem, 3svh, 1.72rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
}

.clock-chip strong {
  color: var(--cyan);
}

.nav-reserve {
  width: clamp(130px, 18vw, 260px);
  height: clamp(48px, 6.5svh, 66px);
}

.speed-cluster {
  position: absolute;
  top: 50%;
  left: clamp(24px, 7.4vw, 126px);
  display: grid;
  width: clamp(158px, 17vw, 248px);
  gap: clamp(8px, 1.3svh, 12px);
  justify-items: start;
  transform: translateY(-48%);
}

.speed-limit-reserve {
  width: clamp(62px, 7.8vw, 112px);
  height: clamp(28px, 4.2svh, 42px);
  justify-self: end;
}

.speed-readout {
  min-width: clamp(150px, 15.6vw, 224px);
  padding: clamp(8px, 1.4svh, 13px) clamp(11px, 1.5vw, 17px);
}

.speed-value {
  display: flex;
  align-items: baseline;
  gap: 9px;
  color: var(--text);
  font-family: "B612 Mono", B612, ui-monospace, SFMono-Regular, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.speed-value span {
  min-width: 2.1ch;
  color: var(--text);
  font-size: clamp(4rem, 12.4svh, 6.25rem);
  font-weight: 800;
  line-height: 0.88;
}

.speed-value span[data-mode="status"] {
  display: inline-block;
  min-width: 0;
  max-width: 9ch;
  color: var(--amber);
  font-family: B612, Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(1.18rem, 3.6svh, 2.05rem);
  line-height: 1;
  white-space: normal;
}

.speed-value small {
  color: var(--muted);
  font-size: clamp(0.78rem, 1.9svh, 1rem);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 104px;
  min-height: 32px;
  padding: 7px 10px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.right-rail {
  position: absolute;
  top: 50%;
  right: clamp(24px, 7.2vw, 126px);
  display: grid;
  width: clamp(176px, 18vw, 250px);
  gap: clamp(10px, 1.8svh, 16px);
  transform: translateY(-50%);
}

.power-tape-reserve {
  width: 100%;
  height: clamp(112px, 24svh, 250px);
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.45svh, 13px);
  width: 100%;
}

.metric {
  min-width: 0;
  min-height: clamp(54px, 7.4svh, 74px);
  overflow: hidden;
  padding: 9px 10px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: var(--text);
  font-family: "B612 Mono", B612, ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(0.98rem, 2.25svh, 1.24rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-void {
  position: absolute;
  left: clamp(24px, 7.4vw, 126px);
  bottom: clamp(26px, 8.4svh, 86px);
  width: clamp(286px, 29vw, 430px);
  min-width: 0;
  min-height: 0;
}

.info-card {
  padding: 0;
}

.plate-card {
  min-width: 0;
  max-height: min(47svh, 360px);
  overflow: hidden;
  padding: clamp(9px, 1.35svh, 13px) clamp(10px, 1.3vw, 15px);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head strong {
  overflow: hidden;
  color: var(--amber);
  font-family: "B612 Mono", B612, ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plate-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: clamp(7px, 1vw, 12px);
  margin-top: clamp(9px, 1.5svh, 13px);
}

.plate-title-row h2 {
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1.08rem, 2.8svh, 1.55rem);
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plate-title-row strong {
  color: var(--cyan);
  font-family: "B612 Mono", B612, ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(0.72rem, 1.55svh, 0.92rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.plate-card p {
  display: -webkit-box;
  min-height: 1.15em;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: clamp(0.68rem, 1.48svh, 0.84rem);
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.plate-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(5px, 0.8vw, 9px);
  margin-top: clamp(9px, 1.45svh, 12px);
}

.plate-metric,
.plate-detail {
  min-width: 0;
}

.plate-metric strong,
.plate-detail strong {
  display: block;
  min-height: 1.1em;
  overflow: hidden;
  color: var(--text);
  font-family: "B612 Mono", B612, ui-monospace, SFMono-Regular, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plate-metric span,
.plate-detail span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plate-metric span {
  font-size: clamp(0.45rem, 0.92svh, 0.54rem);
}

.plate-metric strong {
  margin-top: 4px;
  font-size: clamp(0.6rem, 1.36svh, 0.8rem);
  line-height: 1;
}

.plate-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1svh, 9px) clamp(7px, 0.9vw, 11px);
  margin-top: clamp(9px, 1.45svh, 12px);
}

.plate-detail span {
  font-size: clamp(0.42rem, 0.84svh, 0.5rem);
}

.plate-detail strong {
  margin-top: 3px;
  font-size: clamp(0.54rem, 1.16svh, 0.68rem);
  line-height: 1.05;
}

.plate-card[data-plate-state="idle"] .plate-title-row,
.plate-card[data-plate-state="idle"] p,
.plate-card[data-plate-state="idle"] .plate-metrics,
.plate-card[data-plate-state="idle"] .plate-detail-grid,
.plate-card[data-plate-state="unavailable"] .plate-title-row,
.plate-card[data-plate-state="unavailable"] p,
.plate-card[data-plate-state="unavailable"] .plate-metrics,
.plate-card[data-plate-state="unavailable"] .plate-detail-grid {
  display: none;
}

.plate-card[data-plate-state="loading"] .section-head strong,
.plate-card[data-plate-state="empty"] .section-head strong {
  color: var(--amber);
}

.plate-card[data-plate-state="found"] .section-head strong {
  color: var(--cyan);
}

.plate-card[data-plate-state="error"] .section-head strong,
.plate-card[data-plate-state="unavailable"] .section-head strong {
  color: var(--red);
}

@media (max-height: 720px) and (orientation: landscape) {
  .plate-card {
    max-height: min(32svh, 190px);
  }

  .plate-detail-grid {
    display: none;
  }
}

.media-toast-reserve {
  position: absolute;
  right: clamp(24px, 7.2vw, 126px);
  bottom: clamp(54px, 10svh, 100px);
  width: clamp(220px, 24vw, 370px);
  height: clamp(48px, 7.6svh, 76px);
}

.bottom-strip {
  position: absolute;
  bottom: clamp(14px, 3.8svh, 42px);
  left: 50%;
  display: grid;
  grid-template-columns: clamp(80px, 9vw, 136px) minmax(260px, 32vw);
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  transform: translateX(-50%);
}

.gear-reserve {
  width: clamp(80px, 9vw, 136px);
  height: clamp(36px, 5.5svh, 56px);
}

.hud-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  min-height: clamp(36px, 5.5svh, 56px);
  padding: 8px 11px;
  color: var(--text-soft);
  font-size: 0.64rem;
}

.hud-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.soft {
  color: var(--muted);
}

:root[data-connection="offline"] .hud-footer,
:root:not([data-connection="online"]) [data-location],
:root[data-connection="offline"] [data-location] {
  color: var(--amber);
}

@media (orientation: portrait) {
  body {
    overflow: hidden;
  }

  .rotate-gate {
    display: grid;
  }

  .hud-shell {
    visibility: hidden;
    pointer-events: none;
  }

  .entry-panel {
    display: none;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .hud-layout {
    inset: 8px 12px;
  }

  .heading-track {
    top: 8px;
    grid-template-columns: auto auto minmax(92px, 16vw);
    gap: 7px;
  }

  .hud-chip {
    min-height: 42px;
    min-width: 78px;
    gap: 4px;
    padding: 7px 9px;
  }

  .hud-chip strong {
    font-size: clamp(1rem, 3.6svh, 1.24rem);
  }

  .nav-reserve {
    width: clamp(92px, 16vw, 160px);
    height: 42px;
  }

  .master-warning-slot {
    top: 58px;
    height: 38px;
  }

  .speed-cluster {
    left: max(12px, env(safe-area-inset-left));
    width: clamp(130px, 18vw, 170px);
    gap: 6px;
    transform: translateY(-44%);
  }

  .speed-limit-reserve {
    width: 66px;
    height: 24px;
  }

  .speed-readout {
    min-width: clamp(128px, 17vw, 166px);
    padding: 7px 10px;
  }

  .speed-value span {
    font-size: clamp(2.85rem, 11svh, 3.9rem);
  }

  .speed-value span[data-mode="status"] {
    max-width: 8ch;
    font-size: clamp(1rem, 4.2svh, 1.45rem);
  }

  .status-pill {
    min-height: 28px;
    min-width: 94px;
    padding: 6px 9px;
    font-size: 0.68rem;
  }

  .right-rail {
    right: max(12px, env(safe-area-inset-right));
    width: clamp(150px, 23vw, 200px);
    gap: 8px;
  }

  .power-tape-reserve {
    height: clamp(72px, 18svh, 112px);
  }

  .telemetry-grid {
    gap: 7px;
  }

  .metric {
    min-height: 45px;
    padding: 7px 8px;
  }

  .metric strong {
    margin-top: 6px;
    font-size: clamp(0.82rem, 2.8svh, 1rem);
  }

  .primary-void {
    left: max(12px, env(safe-area-inset-left));
    bottom: 12px;
    width: clamp(244px, 34vw, 310px);
  }

  .plate-card {
    max-height: 32svh;
    padding: 8px 10px;
  }

  .plate-title-row {
    margin-top: 7px;
  }

  .plate-title-row h2 {
    font-size: clamp(0.94rem, 3.5svh, 1.2rem);
  }

  .plate-card p,
  .plate-metrics,
  .plate-detail-grid {
    margin-top: 7px;
  }

  .plate-metrics {
    gap: 4px;
  }

  .plate-metric strong {
    font-size: clamp(0.52rem, 1.7svh, 0.66rem);
  }

  .plate-detail-grid {
    gap: 5px 7px;
  }

  .plate-detail strong {
    font-size: clamp(0.48rem, 1.4svh, 0.58rem);
  }

  .media-toast-reserve {
    right: max(12px, env(safe-area-inset-right));
    bottom: 48px;
    width: clamp(176px, 25vw, 250px);
    height: 42px;
  }

  .bottom-strip {
    bottom: 8px;
    right: max(12px, env(safe-area-inset-right));
    left: auto;
    grid-template-columns: 70px minmax(210px, 38vw);
    gap: 7px;
    transform: none;
  }

  .gear-reserve,
  .hud-footer {
    min-height: 34px;
  }

  .hud-footer {
    gap: 9px;
    padding: 7px 9px;
    font-size: 0.56rem;
  }

  .entry-panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    min-height: 48px;
    padding: 8px 10px;
  }

  .entry-status {
    display: none;
  }
}

@media (max-height: 420px) and (orientation: landscape) {
  .plate-card {
    max-height: 26svh;
  }

  .plate-card p {
    display: none;
  }

  .plate-metrics {
    margin-top: 6px;
  }
}
