/* Slalom: menu and results in the site's dark ink, the game screen filling the
   viewport while a run is on. The canvas is the only light surface (the snow). Every text
   uses the --fs-* scale (13 px floor) and every control is at least --target tall. */

body.slalom.playing {
  overflow: hidden;
}

.screen {
  padding-top: var(--space-4);
  padding-bottom: var(--space-14);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target);
  font-size: var(--fs-14);
  color: var(--text-2);
  text-decoration: none;
}
.back-link span {
  color: var(--cyan);
}

.title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-2) 0 var(--space-2);
  font-size: var(--fs-28);
  font-weight: 700;
  line-height: 1.2;
}
.title:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}
.lead {
  margin: 0 0 var(--space-6);
  font-size: var(--fs-17);
  color: var(--text-2);
}

/* Menu. */
.menu-form {
  display: grid;
  gap: var(--space-5);
  max-width: 640px;
}
fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
legend {
  padding: 0;
  margin-bottom: var(--space-2);
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.choices {
  display: grid;
  gap: var(--space-2);
}
.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-3);
  align-items: center;
  min-height: var(--target);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
}
.choice:has(input:checked) {
  border-color: var(--cyan);
  background: var(--raised);
}
.choice input {
  grid-row: span 2;
}
.choice-name {
  font-size: var(--fs-17);
  font-weight: 600;
}
.choice-note {
  font-size: var(--fs-14);
  color: var(--text-2);
}
input[type='radio'],
input[type='checkbox'] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--cyan);
}
input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.chips legend {
  width: 100%;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target);
  padding: 0 var(--space-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-15);
  cursor: pointer;
}
.chip:has(input:checked) {
  border-color: var(--cyan);
  background: var(--raised);
}
.daily-panel {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.bulletin {
  margin: 0;
  font-size: var(--fs-17);
  font-weight: 600;
}
.stage-line {
  margin: 0;
  font-size: var(--fs-15);
  color: var(--text-2);
}
.settings {
  display: grid;
  gap: var(--space-1);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--target);
  font-size: var(--fs-15);
  cursor: pointer;
}
.menu-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}
.btn-quiet {
  background: var(--raised);
  border-color: var(--line-2);
  color: var(--text);
}
.btn:disabled {
  cursor: progress;
  filter: none;
  opacity: 0.7;
}
.status {
  margin: 0;
  font-size: var(--fs-14);
  color: var(--text-2);
}
.help {
  max-width: 640px;
  margin-top: var(--space-8);
  color: var(--text-2);
  font-size: var(--fs-15);
}
.help h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-17);
  color: var(--text);
}
.help ul {
  margin: 0;
  padding-left: var(--space-5);
}

/* Game screen: HUD row, the play area (canvas), the thumb zone. */
.game {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.hud {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-2);
  min-height: calc(var(--target) + 8px);
  padding: 4px var(--space-2);
  padding-top: max(4px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.hud-stats {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  min-width: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hud-main {
  font-size: var(--fs-22);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hud-stat {
  font-size: var(--fs-15);
  color: var(--text-2);
}
.hud-buttons {
  display: flex;
  gap: 2px;
}
.hud-btn {
  display: inline-grid;
  place-items: center;
  width: var(--target);
  height: var(--target);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
}
.hud-btn:hover {
  background: var(--raised);
}
.hud-btn[aria-pressed='false'] {
  color: var(--text-3);
}
.hud-btn[aria-pressed='false'] .sound-waves {
  display: none;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#slope {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #f3f5f7;
  touch-action: none;
}
/* Below the skier (24 % from the top), or above it when the descent goes up the screen. */
.intro {
  position: absolute;
  inset: 40% var(--space-3) auto;
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  text-align: center;
  pointer-events: none;
}
#game[data-flip='true'] .intro {
  inset: var(--space-4) var(--space-3) auto;
}
.intro p {
  margin: 0;
}
.intro-stage,
.intro-bulletin {
  padding: 2px var(--space-3);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-15);
}
.intro-stage {
  font-weight: 700;
}
.countdown {
  margin-top: var(--space-4);
  min-height: 1.2em;
  color: #1b1d21;
  font-size: var(--fs-36);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Behind the skier (uphill), never over the piste ahead. */
.flash {
  position: absolute;
  left: 50%;
  top: var(--space-2);
  transform: translateX(-50%);
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-16);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.flash[data-tone='miss'] {
  color: var(--gold);
}
.pause-panel {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: rgb(17 19 29 / 0.82);
}
.pause-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-28);
}
.pause-panel .btn {
  min-width: 200px;
}
.pause-note {
  margin: 0;
  max-width: 320px;
  text-align: center;
  font-size: var(--fs-14);
  color: var(--text-2);
}

/* The thumb zone: two halves, each held by its own pointer. */
.thumbs {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: max(var(--target), 18vh);
  height: max(var(--target), 18dvh);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.thumb {
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-16);
  font-weight: 600;
  touch-action: none;
}
.thumb + .thumb {
  border-left: 1px solid var(--line-2);
}
.thumb.held {
  background: var(--raised);
  color: var(--text);
}
.thumb-label,
.thumbs-both {
  pointer-events: none;
}
.thumbs-both {
  position: absolute;
  left: 50%;
  bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  font-size: var(--fs-13);
  color: var(--text-3);
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .thumbs {
    height: 64px;
  }
}

#game[data-flip='true'] .flash {
  top: auto;
  bottom: var(--space-2);
}

/* A phone on its side: the thumb halves become side columns over the play row, so the
   piste keeps the screen's height. The middle column lets pointers through to nothing:
   only the halves take them. */
@media (orientation: landscape) and (max-height: 520px) {
  .game {
    display: grid;
    grid-template-columns: minmax(var(--target), 17vw) minmax(0, 1fr) minmax(var(--target), 17vw);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .hud {
    grid-column: 1 / -1;
  }
  .stage {
    grid-column: 2;
    grid-row: 2;
  }
  .thumbs {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: minmax(var(--target), 17vw) minmax(0, 1fr) minmax(var(--target), 17vw);
    height: auto;
    border-top: 0;
    pointer-events: none;
  }
  .thumb {
    pointer-events: auto;
  }
  #thumb-right {
    grid-column: 3;
  }
  .thumbs-both {
    display: none;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Results. */
.results-course {
  margin: 0;
  font-size: var(--fs-15);
  color: var(--text-2);
}
.headline {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--fs-36);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.detail,
.reference {
  margin: 0;
  font-size: var(--fs-16);
  color: var(--text-2);
}
.reference {
  margin-top: var(--space-1);
  color: var(--text);
  font-weight: 600;
}
.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-8);
}
.attempts-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-18);
}
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}
.attempts {
  border-collapse: collapse;
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.attempts th,
.attempts td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  text-align: right;
}
.attempts th {
  color: var(--text-3);
  font-weight: 600;
}
.attempts th:first-child,
.attempts td:first-child {
  text-align: left;
}
.attempts tr.current td {
  color: var(--text);
  font-weight: 600;
}
.attempts tr:not(.current) td {
  color: var(--text-2);
}
.attempts .best-mark {
  color: var(--gold);
}
.best {
  margin: var(--space-3) 0 0;
  font-size: var(--fs-15);
  color: var(--text-2);
}
.copy {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  margin-top: var(--space-8);
}
.summary-fallback {
  width: 100%;
  max-width: 640px;
  min-height: 160px;
  padding: var(--space-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font:
    400 var(--fs-13) / 1.4 ui-monospace,
    monospace;
}
