:root { --bg: #0d0f14; --ink: #1c1512; --text: #fffaf0; --orange: #ff7a1c; --orange2: #cf4f0c; --muted: #c9cfdb; }
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 600 16px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#game { position: fixed; inset: 0; overflow: hidden; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Studio touch policy (leotoby templates/game-input): pan-y on the page and menus, none on the game while
   playing, and a recovery override when the page is already enlarged. */
html, body, .game-menu { touch-action: pan-y; }
body.game-playing, body.game-playing #game, body.game-playing #hud, body.game-playing canvas { touch-action: none; }
button { touch-action: manipulation; }
html.page-zoomed, html.page-zoomed body, html.page-zoomed body * { touch-action: pan-x pan-y pinch-zoom !important; }

/* HUD */
#hud {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  pointer-events: none; text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(0,0,0,.4);
}
#hud[hidden] { display: none; }
.hud-left { display: flex; flex-direction: column; font-size: 15px; letter-spacing: .04em; }
#hud-name { color: var(--muted); font-size: 13px; }
.hud-score { font: italic 900 clamp(22px, 4.2vw, 40px)/1 system-ui, sans-serif; letter-spacing: .02em; margin-right: auto; margin-left: 24px; }
.hud-btn {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(255,255,255,.5);
  background: rgba(16,18,26,.45); color: var(--text); font-size: 14px; cursor: pointer;
}
#btn-sound { margin-right: 10px; font-size: 18px; }
#btn-sound[aria-pressed="false"] { opacity: .6; }

/* Feedback colours: green worked, amber fine but could be better, red didn't work. Each also has its own
   symbol (✓ ~ ✗), so the colour is never the only signal. Orange is kept for "do it now" prompts. */
:root { --pass: #4fd07a; --meh: #ffc83d; --fail: #ff5a4a; }

/* Check rows (tutorial result card and the lines' jump report) */
.checks { list-style: none; margin: 0; padding: 0; text-align: left; }
.checks li { display: grid; grid-template-columns: 1.5em 1fr; column-gap: .45em; align-items: baseline; margin: .35em 0; }
.checks li > i { grid-row: span 3; font-style: normal; font-weight: 900; text-align: center; border-radius: 50%; width: 1.4em; height: 1.4em; line-height: 1.4em; color: #10131a; }
.checks li > span { font-weight: 800; }
.checks li > small { grid-column: 2; display: block; font-weight: 600; margin-top: .15em; }
.checks li > .meter { grid-column: 2; }
.checks li.ok > i { background: var(--pass); }
.checks li.meh > i { background: var(--meh); }
.checks li.no > i { background: var(--fail); }
.checks li.no > small { color: #ffd0c9; }
.checks li.meh > small { color: #ffe9b0; }
.checks li.skip { opacity: .45; }
.checks li.skip > i { background: rgba(255,255,255,.25); }

/* The lines' summary on the result card */
.res-jumps { max-width: 460px; margin: 4px auto 6px; padding: 8px 14px; font-size: 15px; background: rgba(16,18,26,.7); border: 3px solid var(--ink); border-radius: 14px; }
.res-jumps[hidden], .practise[hidden] { display: none; }
.practise { margin: 6px auto 10px; max-width: 460px; color: #ffe27a; font-weight: 700; font-size: 16px; text-shadow: 0 1px 0 var(--ink); }
@media (max-height: 430px) { .res-jumps { font-size: 12px; padding: 4px 10px; } .res-jumps li { margin: .1em 0; } .practise { font-size: 13px; margin: 2px auto 4px; } }

/* Pop timing bar */
.meter { position: relative; width: min(100%, 320px); height: 14px; margin: .45em 0 1.4em; border-radius: 7px; background: rgba(255,255,255,.12); border: 2px solid var(--ink); }
.meter span { position: absolute; top: 0; bottom: 0; }
.meter .okz { background: rgba(255,200,61,.45); }
.meter .sweet { background: var(--pass); }
.meter b { position: absolute; top: -6px; bottom: -6px; width: 6px; margin-left: -3px; background: #fff; border: 2px solid var(--ink); border-radius: 3px; }
.meter em { position: absolute; top: 16px; font: 700 11px/1 system-ui, sans-serif; font-style: normal; color: var(--muted); white-space: nowrap; letter-spacing: .03em; }
.meter .l { left: 0; } .meter .r { right: 0; } .meter .c { left: 50%; transform: translateX(-50%); color: var(--pass); }

/* The lines' jump report: one panel per jump, top left under the HUD */
#report { position: absolute; left: max(14px, env(safe-area-inset-left)); top: calc(max(10px, env(safe-area-inset-top)) + 52px); width: min(330px, 46vw);
  padding: 8px 12px 6px; border-radius: 12px; background: rgba(16,18,26,.78); border: 3px solid rgba(255,255,255,.18); pointer-events: none;
  font-size: clamp(13px, 1.7vw, 16px); transition: opacity .35s ease; }
#report[hidden] { display: none; }
#report.fade { opacity: 0; }
#report.good { border-color: var(--pass); } #report.meh { border-color: var(--meh); } #report.bad { border-color: var(--fail); }
#report .r-head { display: flex; justify-content: space-between; margin: 0 0 2px; color: var(--muted); font-size: .85em; letter-spacing: .05em; text-transform: uppercase; }
#report .r-head b { color: var(--text); font-size: 1.2em; }
#report.bad .r-head b { color: var(--fail); }
#report .meter { margin-bottom: 1.3em; }

/* Tutorial result card */
.card.verdict { min-width: min(92vw, 420px); max-width: 560px; background: rgba(16,18,26,.85); border: 4px solid var(--ink); border-radius: 18px; padding: 16px 22px 12px; box-shadow: 6px 6px 0 var(--ink); }
.verdict.pass { border-color: var(--pass); }
.verdict.fail { border-color: var(--fail); }
.verdict .chip { display: inline-block; margin: 0 0 6px; padding: 2px 10px; border-radius: 99px; background: rgba(255,255,255,.12); color: var(--muted); font-size: 13px; letter-spacing: .06em; }
.verdict.pass h2 { color: var(--pass); }
.verdict.fail h2 { color: var(--fail); }
.verdict .checks { font-size: clamp(15px, 2.3vw, 19px); margin: 4px auto 6px; max-width: 440px; }
.verdict .next { margin: 6px 0 6px; color: var(--muted); font-size: 15px; }
.verdict .next:empty { display: none; }
.verdict.fail button.go { background: #3a3f4f; }

/* Coaching prompt (tutorial) and tips (tutorial retries, stuck hints) */
#coach { position: absolute; left: 50%; top: 20%; transform: translateX(-50%) skewX(-8deg); pointer-events: none; white-space: nowrap; text-align: center;
  font: italic 900 clamp(34px, 8vw, 88px)/1 system-ui, sans-serif; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); }
#coach small { display: block; font-size: .32em; margin-top: .3em; letter-spacing: .06em; -webkit-text-stroke: 2px var(--ink); color: #ffe27a; }
#coach[hidden], #tip[hidden] { display: none; }
#tip { position: absolute; left: 50%; top: max(9%, 52px); transform: translateX(-50%); max-width: min(92vw, 720px); pointer-events: none; text-align: center;
  padding: 8px 16px; border-radius: 12px; background: rgba(16,18,26,.72); border: 2px solid rgba(255,255,255,.25);
  font-size: clamp(15px, 2.4vw, 21px); text-shadow: 0 1px 0 var(--ink); }
#hud.tutorial .hud-score { visibility: hidden; }
#coach.go { color: var(--orange); animation: go .35s ease-out; }
#coach.air { left: 28%; top: 36%; font-size: clamp(30px, 6.5vw, 76px); }
@keyframes go { 0% { transform: translateX(-50%) skewX(-8deg) scale(1.6); } 100% { transform: translateX(-50%) skewX(-8deg) scale(1); } }

/* Touch lean guide, shown only on touch screens while in the air */
#touch-guide { position: absolute; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom)); display: none; justify-content: space-between; padding: 0 18px; pointer-events: none; font-size: 13px; color: rgba(255,255,255,.75); text-shadow: 0 1px 0 var(--ink); letter-spacing: .05em; }
@media (pointer: coarse) { body.in-air #touch-guide { display: flex; } }

/* PEDAL button: touch screens, on the run-in of Learn to Jump (and its pedalling stops) */
#btn-pedal { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: none;
  width: 104px; height: 104px; border-radius: 50%; border: 4px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); background: rgba(255,122,28,.85);
  color: #fff; font: italic 900 20px/1 system-ui, sans-serif; letter-spacing: .04em; touch-action: none; user-select: none; -webkit-user-select: none; z-index: 2; }
#btn-pedal:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); background: var(--orange2); }
@media (pointer: coarse) { body.can-pedal #btn-pedal { display: block; } }
/* TRICK button: touch screens, in the air on the Tricks level, where PEDAL sits on the ground */
#btn-trick { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: none;
  width: 104px; height: 104px; border-radius: 50%; border: 4px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); background: rgba(47,155,224,.9);
  color: #fff; font: italic 900 20px/1 system-ui, sans-serif; letter-spacing: .04em; touch-action: none; user-select: none; -webkit-user-select: none; z-index: 2; }
#btn-trick:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
@media (pointer: coarse) { body.can-trick #btn-trick { display: block; } }

/* Menus */
.game-menu {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow-y: auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at center, rgba(8,10,16,.25), rgba(8,10,16,.6));
}
.game-menu[hidden] { display: none; }
.card { text-align: center; max-width: 560px; }
h1 {
  margin: 0; font: italic 900 clamp(46px, 12vw, 120px)/0.95 system-ui, sans-serif; letter-spacing: .01em; color: var(--orange);
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 6px 6px 0 var(--ink); transform: skewX(-8deg);
}
h2 { margin: 0 0 8px; font: italic 900 clamp(34px, 7vw, 64px)/1 system-ui, sans-serif; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); }
.tag { margin: 10px 0 12px; font-size: clamp(15px, 2.4vw, 20px); text-shadow: 0 2px 0 var(--ink); }
.big { margin: 4px 0; font: italic 900 clamp(44px, 10vw, 96px)/1 system-ui, sans-serif; color: #ffe27a; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); }
.keys { list-style: none; padding: 0; margin: 0 0 14px; font-size: clamp(13px, 2vw, 16px); color: var(--muted); text-shadow: 0 1px 0 var(--ink); }
.keys li { margin: 4px 0; }
.keys b { color: var(--text); background: rgba(16,18,26,.6); border: 1px solid rgba(255,255,255,.3); border-radius: 6px; padding: 1px 7px; margin-right: 6px; }
.k-touch { display: none; }
@media (pointer: coarse) { .k-touch { display: inline; } .k-key { display: none; } }
button.go, button.ghost {
  display: inline-block; min-width: 180px; min-height: 52px; margin: 6px; padding: 10px 28px; border-radius: 14px; cursor: pointer;
  font: italic 900 24px/1 system-ui, sans-serif; letter-spacing: .04em; color: var(--text);
  background: var(--orange); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}
button.ghost { background: rgba(16,18,26,.7); font-size: 18px; min-width: 150px; }
button[hidden] { display: none; }

/* Level list on the title card */
#level-list { display: flex; flex-direction: column; align-items: stretch; gap: 8px; max-width: 420px; margin: 0 auto; }
button.lvl { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 52px; padding: 9px 16px; border-radius: 14px; cursor: pointer; text-align: left;
  color: var(--text); background: rgba(16,18,26,.72); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
button.lvl b { font: italic 900 21px/1.05 system-ui, sans-serif; letter-spacing: .03em; }
button.lvl small { font-size: 13px; color: var(--muted); font-weight: 600; }
button.lvl.rec { background: var(--orange); }
button.lvl.rec small { color: #fff3e6; }
button.lvl.locked { opacity: .55; cursor: default; box-shadow: none; }
button.lvl:not(.locked):active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* Tutorial step card */
.card.lesson { max-width: 600px; background: rgba(16,18,26,.78); border: 3px solid var(--ink); border-radius: 18px; padding: 18px 22px 14px; box-shadow: 6px 6px 0 var(--ink); }
.lesson .chip { display: inline-block; margin: 0 0 6px; padding: 2px 10px; border-radius: 99px; background: rgba(255,255,255,.12); color: var(--muted); font-size: 13px; letter-spacing: .06em; }
.lesson h2 { color: var(--orange); }
.lesson .body { margin: 4px 0 10px; font-size: clamp(16px, 2.5vw, 21px); }
.lesson .how { margin: 0 0 10px; font-size: clamp(14px, 2.1vw, 17px); color: #ffe27a; }
.big:empty { display: none; }

/* Picture tips: the right way (✓) next to the common mistake (✗), drawn with the film's rider */
.pics { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; margin: 8px 0 10px; }
.pic-pair { display: flex; gap: 8px; }
.pic-seq { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pic { position: relative; margin: 0; width: 120px; }
.pic img { display: block; width: 120px; height: 75px; border-radius: 10px; border: 3px solid var(--ink); }
.pic.good img { border-color: var(--pass); }
.pic.bad img { border-color: var(--fail); }
.pic > i { position: absolute; top: -7px; left: -7px; width: 24px; height: 24px; line-height: 24px; border-radius: 50%; text-align: center;
  font-style: normal; font-weight: 900; font-size: 14px; color: #10131a; border: 2px solid var(--ink); }
.pic.good > i { background: var(--pass); }
.pic.bad > i { background: var(--fail); }
.pic figcaption { margin-top: 3px; font-size: 12px; line-height: 1.2; color: var(--muted); text-align: center; }
.pic-seq .pic, .pic-seq .pic img { width: 96px; }
.pic-seq .pic img { height: 60px; }
.checks li > .pic-pair { grid-column: 2; margin: 6px 0 2px; }
button.go:active, button.ghost:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.portrait-note { display: none; color: var(--muted); font-size: 14px; margin-top: 10px; }
@media (orientation: portrait) and (max-width: 700px) { .portrait-note { display: block; } }
@media (max-height: 430px) {
  h1 { font-size: 54px; } .tag { margin: 6px 0 8px; } .keys { margin-bottom: 8px; } button.go { min-height: 46px; }
  #level-list { gap: 6px; } button.lvl { min-height: 44px; padding: 6px 14px; } button.lvl b { font-size: 18px; }
  .card.lesson { padding: 10px 16px 8px; } .lesson h2 { font-size: 34px; } .lesson .body { margin: 2px 0 6px; }
  .pic, .pic img { width: 88px; } .pic img { height: 55px; } .pic figcaption { font-size: 11px; } .pics { margin: 4px 0 6px; gap: 6px 12px; }
  .pic-seq .pic, .pic-seq .pic img { width: 72px; } .pic-seq .pic img { height: 45px; }
  .lesson .body { font-size: 14px; } .lesson .how { font-size: 13px; margin-bottom: 4px; }
  .card.verdict { padding: 8px 16px 6px; } .verdict h2 { font-size: 32px; margin-bottom: 2px; } .verdict .checks { font-size: 14px; } .verdict .next { margin: 2px 0; }
}

/* Coaching stop: the ride freezes under a short tip, high on the screen so the rider stays in view */
#stop { position: absolute; left: 0; right: 0; top: max(46px, env(safe-area-inset-top)); display: flex; justify-content: center; padding: 0 16px; }
/* In the air the rider is high on the right and the landing low on the left: the tip goes top left. */
#stop.air { justify-content: flex-start; } #stop.air .card.stop-card { max-width: min(50vw, 500px); }
#stop[hidden] { display: none; }
body.stopped .hud-left { visibility: hidden; }   /* the tip sits where the step name is */
.card.stop-card { max-width: 620px; background: rgba(16,18,26,.84); border: 3px solid var(--ink); border-radius: 18px; padding: 12px 20px 8px; box-shadow: 6px 6px 0 var(--ink); animation: stop-in .18s ease-out; }
.stop-card h2 { color: var(--orange); font-size: clamp(28px, 5vw, 48px); margin-bottom: 4px; }
.stop-card .body { margin: 2px 0 6px; font-size: clamp(16px, 2.4vw, 21px); line-height: 1.35; }
.stop-card .how { margin: 0 0 4px; font-size: clamp(14px, 2.1vw, 18px); color: #ffe27a; font-weight: 700; }
.stop-card .how[hidden] { display: none; }
.stop-card button.go { min-height: 46px; min-width: 140px; margin: 4px; }
.stop-card .hint { margin: 0 0 2px; font-size: 13px; color: var(--muted); }
@keyframes stop-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-height: 430px) {
  /* Short landscape phones: a compact strip, text on the left and OK on the right, above the rider */
  #stop { top: 6px; padding: 0 10px; }
  .card.stop-card { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; text-align: left; max-width: 780px; padding: 5px 12px 5px 16px; }
  .stop-card h2 { grid-column: 1; font-size: 22px; margin: 0; }
  .stop-card .body { grid-column: 1; font-size: 13px; line-height: 1.3; margin: 1px 0 2px; }
  .stop-card .how { grid-column: 1; font-size: 12px; margin: 0; }
  .stop-card button.go { grid-column: 2; grid-row: 1 / span 3; min-height: 40px; min-width: 84px; padding: 6px 14px; font-size: 20px; }
  .stop-card .hint { display: none; }
  #stop.air .card.stop-card { max-width: min(62vw, 560px); }
}

#zoom-note { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(16,18,26,.85); padding: 8px 14px; border-radius: 10px; font-size: 14px; }
#zoom-note[hidden] { display: none; }
#debug { position: absolute; left: 8px; bottom: 8px; font: 12px/1.3 ui-monospace, Menlo, monospace; background: rgba(0,0,0,.55); padding: 6px 8px; border-radius: 6px; white-space: pre; pointer-events: none; }
#debug[hidden] { display: none; }
