.ski {
  --ink: #0e1b2a;
  --ink-2: #41546a;
  --snow: #f6f9fc;
  --ice: #d9e8f5;
  --flag: #e4032e;
  --flag-2: #0b5fd7;
  --sun: #ffb400;
  position: relative;
  width: 100%;
  height: min(78vh, 760px);
  min-height: 460px;
  background: #cfe3f3;
  border-radius: 14px;
  overflow: hidden;
  color: var(--ink);
  font-family: "Barlow", "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.ski:fullscreen { height: 100vh; border-radius: 0; }
.ski > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ski [hidden] { display: none !important; }

/* HUD */
.ski-hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; }
.hud-box { background: rgba(14, 27, 42, .78); color: #fff; border-radius: 10px; padding: 6px 12px; min-width: 92px; display: flex; flex-direction: column; align-items: center; }
.hud-speed { flex-direction: row; align-items: baseline; gap: 6px; }
.hud-l { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.hud-v { font-family: "Barlow Condensed", "Barlow", Arial, sans-serif; font-weight: 700; font-size: 28px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hud-speed .hud-v { font-size: 36px; }
.hud-course { position: absolute; top: 78px; left: 12px; font-size: 13px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.hud-pitch { position: absolute; top: 100px; left: 12px; font-size: 13px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); font-variant-numeric: tabular-nums; }
.hud-map { position: absolute; right: 30px; bottom: 12px; width: 120px; height: 152px; border-radius: 10px; background: rgba(14, 27, 42, .55); }
.hud-msg { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 800; font-size: 34px; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .55); min-height: 40px; }
.hud-msg.bad { color: #ffd0d0; }
.hud-count { position: absolute; top: 36%; left: 0; right: 0; text-align: center; font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 800; font-size: 120px; color: #fff; text-shadow: 0 4px 24px rgba(0, 0, 0, .5); }
.hud-prog { position: absolute; right: 12px; top: 96px; bottom: 96px; width: 8px; border-radius: 4px; background: rgba(14, 27, 42, .35); overflow: hidden; }
#hud-prog-fill { position: absolute; left: 0; right: 0; top: 0; height: 0; background: var(--sun); }
.hud-alt { position: absolute; right: 28px; top: 96px; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); font-variant-numeric: tabular-nums; }
.hud-btns { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; pointer-events: auto; }
.hud-btn { font: inherit; font-size: 12px; font-weight: 600; color: #fff; background: rgba(14, 27, 42, .6); border: 1px solid rgba(255, 255, 255, .35); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.hud-btn:hover { background: rgba(14, 27, 42, .85); }
.hud-flow { position: absolute; top: 124px; left: 12px; display: flex; align-items: center; gap: 8px; color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); font-variant-numeric: tabular-nums; }
.hud-flow[hidden], .hud-gap[hidden] { display: none; }
.hud-mult { font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 800; font-size: 24px; line-height: 1; color: var(--sun); }
.hud-boost { position: relative; width: 96px; height: 10px; border-radius: 5px; background: rgba(14, 27, 42, .55); border: 1px solid rgba(255, 255, 255, .5); overflow: hidden; }
.hud-boost i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 255, 255, .55); }
.hud-flow.ready .hud-boost i { background: var(--sun); }
.hud-style b { font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 700; font-size: 18px; }
.hud-gap { position: absolute; top: 78px; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 70%; padding: 3px 12px; border-radius: 14px; font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 700; font-size: 18px; color: #fff; background: rgba(14, 27, 42, .7); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-gap:empty { display: none; }
.hud-gap.ahead { background: rgba(10, 122, 62, .88); }
.hud-gap.behind { background: rgba(190, 20, 45, .88); }
.touch-mid { display: flex; gap: 8px; align-items: flex-end; }
.touch-btn.touch-pill { width: 78px; height: 58px; border-radius: 29px; font-size: 14px; letter-spacing: .08em; }
.touch-btn[hidden] { display: none; }
.gear { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; }
.gear-l { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.gear-btn { font: inherit; font-size: 15px; font-weight: 700; padding: 7px 16px; border-radius: 999px; border: 2px solid var(--ice); background: #fff; color: var(--ink); cursor: pointer; }
.gear-btn.on { border-color: var(--flag-2); background: var(--flag-2); color: #fff; }
.gear-btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.modes { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.touch { position: absolute; left: 0; right: 0; bottom: 54px; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 14px; pointer-events: auto; }
.touch-btn { width: 84px; height: 84px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); background: rgba(14, 27, 42, .45); color: #fff; font-size: 30px; font-weight: 700; touch-action: none; }
.touch-tuck { width: 96px; height: 64px; border-radius: 32px; font-size: 16px; letter-spacing: .1em; }
.touch-btn.on { background: rgba(255, 180, 0, .85); color: var(--ink); }

/* panels */
.ski-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92%, 520px); max-height: 92%; overflow: auto;
  background: rgba(246, 249, 252, .96); border-radius: 16px; padding: 22px 24px;
  box-shadow: 0 18px 60px rgba(14, 27, 42, .35);
  user-select: text; -webkit-user-select: text; touch-action: auto;
}
.ski-panel.wide { width: min(94%, 720px); }
.ski-panel h2 { font-family: "Barlow Condensed", "Barlow", Arial, sans-serif; font-weight: 800; font-size: clamp(30px, 5vw, 44px); line-height: 1.02; margin: 2px 0 6px; letter-spacing: .01em; text-wrap: balance; }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--flag); }
.meta { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.facts { margin: 0 0 12px; padding-left: 18px; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.facts:empty { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.btn { font: inherit; font-weight: 700; font-size: 15px; padding: 11px 16px; border-radius: 10px; border: 2px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--ice); }
.btn.primary { background: var(--flag); border-color: var(--flag); color: #fff; font-size: 17px; padding: 12px 22px; }
.btn.primary:hover { background: #c20226; border-color: #c20226; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.ski button:focus-visible, .ski input:focus-visible { outline: 3px solid var(--flag-2); outline-offset: 2px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 0; font-size: 13px; color: var(--ink-2); }
kbd { display: inline-block; min-width: 20px; text-align: center; font: inherit; font-size: 12px; font-weight: 700; padding: 1px 5px; border: 1px solid var(--ink-2); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--ink); }
.best, .challenge, .place, .toast { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); min-height: 1.3em; }
.challenge { color: var(--ink); font-weight: 600; background: var(--ice); border-radius: 8px; padding: 8px 10px; }
.score { margin: 0; font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 800; font-size: 64px; line-height: 1; font-variant-numeric: tabular-nums; }
.score small { font-size: 20px; font-weight: 600; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 0; }
.stats div { background: #fff; border: 1px solid var(--ice); border-radius: 10px; padding: 8px; text-align: center; }
.stats dt { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.stats dd { margin: 2px 0 0; font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }

/* course list */
.course-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.course { text-align: left; font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--ice); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.course:hover { border-color: var(--ink); }
.course.today { border-color: var(--flag); }
.course b { display: block; font-family: "Barlow Condensed", Arial, sans-serif; font-size: 22px; line-height: 1.1; }
.course span { display: block; font-size: 13px; color: var(--ink-2); }
.course em { display: inline-block; margin-top: 4px; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--flag); }

/* leaderboard */
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; }
.name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.name input { font: inherit; font-size: 15px; padding: 6px 8px; border: 2px solid var(--ice); border-radius: 8px; width: 160px; color: var(--ink); background: #fff; }
.board { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.board li { display: grid; grid-template-columns: 38px 1fr auto; gap: 8px; align-items: baseline; padding: 6px 8px; border-bottom: 1px solid var(--ice); font-size: 15px; }
.board li.me { background: #fff6d6; font-weight: 700; }
.board .pos { font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 700; font-size: 18px; color: var(--ink-2); }
.board .pts { font-family: "Barlow Condensed", Arial, sans-serif; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.ski-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--snow); font-size: 16px; }

@media (max-width: 560px) {
  .ski { height: 82vh; border-radius: 0; }
  .hud-box { min-width: 70px; padding: 5px 8px; }
  .hud-v { font-size: 22px; }
  .hud-speed .hud-v { font-size: 28px; }
  .hud-map { width: 84px; height: 106px; right: 26px; bottom: 150px; }
  .hud-gap { top: 144px; left: 12px; right: auto; margin: 0; font-size: 16px; }
  .hud-flow { top: 118px; }
  .hud-boost { width: 70px; }
  .touch { padding: 0 8px; }
  .touch-btn { width: 68px; height: 68px; font-size: 24px; }
  .touch-btn.touch-pill { width: 62px; height: 50px; font-size: 12px; letter-spacing: .04em; }
  .touch-mid { gap: 5px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .ski-panel { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-count { font-size: 72px; }
}
