:root {
  --panel: linear-gradient(180deg, rgba(9, 20, 44, 0.86), rgba(9, 20, 44, 0.7));
  --edge: rgba(255, 255, 255, 0.09);
  --text: #f8fafc;
  --muted: #93a4bf;
  --accent: #fbbf24;
  --blue: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b1324; color: var(--text); overflow: hidden;
  font-family: Inter, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(4, 10, 24, 0.32) 100%); }
.panel { position: fixed; background: var(--panel); border: 1px solid var(--edge); border-radius: 14px;
  padding: 12px 16px; box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35); backdrop-filter: blur(6px); }
#left { top: 16px; left: 16px; min-width: 210px; }
#right { top: 16px; right: 16px; min-width: 210px; }
#left::before, #right::before { content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--accent); }
#center { top: 16px; left: 50%; transform: translateX(-50%); text-align: center; padding: 8px 20px; border-radius: 999px; }
#courseName { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
#nextCp { display: block; margin: 2px 0 0; font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: 0.02em; }
.big { font-size: 46px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.unit { font-size: 13px; color: var(--muted); margin-left: 6px; font-weight: 600; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; margin-top: 7px;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.row span:first-child { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
#left > div:first-child, #right > div:first-child { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--edge); }
.ahead { color: var(--green); }
.behind { color: var(--red); }
#bottom { left: 16px; right: 16px; bottom: 16px; height: 118px; padding: 6px 10px; }
#profile { width: 100%; height: 100%; display: block; }
#mapbox { right: 16px; bottom: 150px; width: 190px; height: 190px; padding: 6px; }
#map { width: 100%; height: 100%; display: block; }
#sim { left: 16px; bottom: 150px; width: 260px; display: none; }
#sim strong { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
#sim label { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; }
#sim input { width: 100%; accent-color: var(--accent); }
#start { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(500px, calc(100% - 32px)); padding: 28px; text-align: center;
  background: linear-gradient(180deg, rgba(9, 20, 44, 0.94), rgba(9, 20, 44, 0.88)); border-radius: 18px; }
#start h1 { margin: 0 0 6px; font-size: 28px; font-weight: 800; letter-spacing: -0.01em; }
#start p { margin: 8px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
button { font: inherit; font-weight: 700; border: 1px solid var(--edge); border-radius: 10px; padding: 11px 18px; margin: 6px 4px;
  cursor: pointer; background: rgba(255, 255, 255, 0.06); color: var(--text); transition: background 0.15s, transform 0.1s; }
button:hover { background: rgba(255, 255, 255, 0.12); }
button:active { transform: translateY(1px); }
button.primary { background: var(--blue); border-color: transparent; }
button.go { background: var(--accent); color: #111827; border-color: transparent; font-size: 17px; padding: 13px 34px; }
button:disabled { opacity: 0.4; cursor: default; }
#status { min-height: 20px; font-weight: 600; }
#status.on { color: var(--green); }
#status.off { color: var(--red); }
.field { margin: 12px 0; color: var(--muted); font-size: 13px; }
.field input { width: 72px; font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--edge); background: rgba(255,255,255,0.06); color: var(--text); }
#countdown { position: fixed; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 128px; font-weight: 800;
  text-shadow: 0 6px 30px rgba(2, 6, 23, 0.55); pointer-events: none; }
#toast { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--edge);
  border-left: 4px solid var(--accent); padding: 10px 18px; border-radius: 10px; font-size: 17px; font-weight: 600;
  opacity: 0; transition: opacity 0.4s; pointer-events: none; }
#toast.show { opacity: 1; }
#attrib { position: fixed; right: 18px; bottom: 3px; font-size: 10px; color: rgba(15, 23, 42, 0.7); text-shadow: 0 0 3px rgba(255,255,255,0.8); }
.hidden { display: none !important; }
@media (max-width: 700px) {
  .big { font-size: 30px; }
  #left, #right { min-width: 0; padding: 8px 10px; font-size: 13px; }
  #center { display: none; }
  #mapbox { width: 120px; height: 120px; }
  #bottom { height: 90px; }
  #mapbox, #sim { bottom: 116px; }
}
/* phones (upright, or sideways where the screen is short): only the key numbers on top (watts, pace, speed |
   time, km left), a small map, profile and simulator, so the skier and the trail stay visible. */
@media (max-width: 600px) and (orientation: portrait), (max-height: 500px) {
  .panel { padding: 6px 9px; border-radius: 11px; }
  #left { top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); min-width: 0; }
  #right { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); min-width: 0; }
  #left::before, #right::before { left: 10px; right: 10px; }
  #left .row, #right .row { display: none; }
  #left .row.trail, #left .row.hrrow, #right .row:nth-of-type(2), #right .row:nth-of-type(3) { display: flex; margin-top: 3px; font-size: 13px; }
  #left > div:first-child, #right > div:first-child { padding-bottom: 3px; margin-bottom: 2px; }
  #left .erg-head { font-size: 10px; margin-bottom: 2px; }
  #left .erg-main { gap: 10px; padding-bottom: 3px; margin-bottom: 2px; }
  .big, #left .erg-main .big, #right .big { font-size: 24px; }
  .unit { font-size: 10px; margin-left: 3px; }
  #forceBox { display: none !important; }
  #left, #right { box-sizing: border-box; min-height: 112px; }
  #right { display: flex; flex-direction: column; justify-content: space-between; }
  #right .row { font-size: 15px !important; }
  #sim { left: max(8px, env(safe-area-inset-left)); bottom: 96px; padding: 6px 10px; }
  #sim strong { font-size: 10px; }
  #sim label { font-size: 11px; margin-top: 3px; }
  #mapbox { right: max(8px, env(safe-area-inset-right)); bottom: 96px; width: 84px; height: 84px; padding: 4px; }
  #bottom { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right));
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 12px); height: 68px; padding: 4px 8px; }
  #attrib { font-size: 8px; left: 10px; right: 10px; bottom: max(2px, env(safe-area-inset-bottom)); text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 600px) and (orientation: portrait) {
  #left { max-width: calc(58vw - 12px); }
  #right { max-width: calc(42vw - 12px); }
  #sim { width: calc(58vw - 12px); }
}
@media (max-height: 500px) and (orientation: landscape) {
  #center { display: block; padding: 4px 14px; top: max(8px, env(safe-area-inset-top)); }
  #courseName { font-size: 12px; }
  #nextCp { font-size: 10px; }
  #sim { width: 200px; bottom: 90px; }
  #mapbox { width: 76px; height: 76px; bottom: 90px; }
  #bottom { height: 62px; }
}
@media (max-width: 600px) and (orientation: portrait), (max-height: 500px) {
  body #menuBtn { top: auto; bottom: 186px; left: auto; right: max(8px, env(safe-area-inset-right)); transform: none; padding: 6px 10px; font-size: 13px; }
}
@media (max-height: 500px) and (orientation: landscape) { body #menuBtn { bottom: 172px; } }
/* panels.css loads after this file, so phone overrides of its rules need the extra body selector */
@media (max-width: 600px) and (orientation: portrait), (max-height: 500px) {
  body #chat { top: calc(max(8px, env(safe-area-inset-top)) + 120px); right: max(8px, env(safe-area-inset-right)); }
}
