:root { --paper: #f3e7cf; --ink: #2b211c; --soft: #6d5d4f; --brick: #b4553c; --water: #5d9fc9; --gold: #e0a316; --card: #fffaf0; --line: #d9c8a6; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 Prompt, 'Atkinson Hyperlegible', system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
.top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; max-width: 760px; margin: 0 auto; }
.top h1 { margin: 0 auto 0 0; font-size: 22px; font-weight: 600; letter-spacing: .01em; }
.home { color: var(--brick); text-decoration: none; font-weight: 600; font-size: 14px; border: 1.5px solid var(--brick); border-radius: 999px; padding: 1px 9px; }
.modes, .lang { display: flex; gap: 2px; background: #e8d9bb; border-radius: 999px; padding: 2px; }
.modes button, .lang button { border: 0; background: none; border-radius: 999px; padding: 5px 12px; font-size: 15px; min-height: 36px; }
.modes button[aria-pressed=true], .lang button[aria-pressed=true] { background: var(--ink); color: var(--paper); }
main { max-width: 760px; margin: 0 auto; padding: 0 12px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.lvl { display: flex; gap: 2px; background: #e8d9bb; border-radius: 999px; padding: 2px; }
.lvl button { border: 0; background: none; border-radius: 999px; padding: 4px 12px; font-size: 15px; min-height: 34px; }
.lvl button[aria-pressed=true] { background: var(--gold); color: var(--ink); font-weight: 600; }
.hintb { background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 14px; font-size: 15px; min-height: 34px; }
.stagewrap { position: relative; border-radius: 14px 14px 0 0; overflow: hidden; border: 2px solid var(--ink); border-bottom: 0; }
#stage { display: block; width: 100%; height: clamp(130px, 30vw, 210px); }
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 10px; pointer-events: none; }
.hud > * { background: rgba(255, 250, 240, .92); border: 1.5px solid var(--ink); border-radius: 10px; padding: 2px 9px; }
.clk b { font-size: 20px; font-variant-numeric: tabular-nums; }
.clk small { display: block; font-size: 12px; color: var(--soft); margin-top: -3px; }
.baht { font-size: 20px; font-variant-numeric: tabular-nums; }
.box { display: flex; gap: 4px; padding: 6px 8px !important; }
.box i { width: 18px; height: 18px; border: 1.5px dashed var(--ink); border-radius: 4px; display: block; }
.box i[style*="#"] { border-style: solid; }
.cond { position: absolute; left: 10px; bottom: 8px; font-size: 13px; color: #fff; text-shadow: 0 1px 2px #000; }
.mapwrap { position: relative; border: 2px solid var(--ink); border-radius: 0 0 14px 14px; overflow: hidden; }
#map { display: block; width: 100%; height: min(72vh, 560px); touch-action: manipulation; }
.panel { position: absolute; left: 8px; right: 8px; bottom: 8px; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; box-shadow: 0 4px 0 rgba(43, 33, 28, .25); }
.panel .pk { grid-column: 1; font-size: 13px; color: var(--soft); display: flex; gap: 6px; align-items: center; }
.panel .pn { grid-column: 1; font-weight: 600; font-size: 17px; line-height: 1.25; }
.panel .pn small { display: block; font-weight: 400; font-size: 13px; color: var(--brick); }
.panel .pm { grid-column: 1; font-size: 14px; }
.panel .go { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
.go { background: var(--ink); color: var(--paper); border: 0; border-radius: 12px; padding: 12px 22px; font-size: 18px; font-weight: 600; min-width: 84px; min-height: 48px; }
.ghost { background: none; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 18px; font-size: 16px; min-height: 48px; }
.bad { color: var(--brick); }
.dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; border: 1.5px solid var(--ink); flex: none; }
.toast { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); border-radius: 12px; padding: 8px 14px; font-size: 15px; max-width: 90%; text-align: center; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.toast b { color: var(--gold); }
.end { position: absolute; inset: 0; background: rgba(243, 231, 207, .97); padding: 16px; overflow: auto; text-align: center; }
.end h2 { margin: 4px 0 0; font-size: 22px; }
.stars { font-size: 46px; color: var(--gold); letter-spacing: 4px; line-height: 1.1; }
.stars span { color: #cdbb98; }
.big { font-size: 30px; font-weight: 600; margin: 4px 0; }
.big small { display: block; font-size: 14px; font-weight: 400; color: var(--soft); }
.help { font-size: 14px; color: var(--soft); margin: 8px 2px 4px; }
.note { font-size: 14px; color: var(--brick); margin: 0 2px; min-height: 0; }
.orders { list-style: none; margin: 6px 0 20px; padding: 0; display: grid; gap: 6px; }
.orders li { display: grid; grid-template-columns: auto 1fr auto; gap: 0 8px; align-items: center; background: var(--card); border: 1.5px solid var(--line); border-left: 6px solid var(--c); border-radius: 10px; padding: 7px 10px; }
.orders .nm { font-size: 15px; line-height: 1.25; }
.orders .tm { grid-column: 2; font-size: 13px; color: var(--soft); }
.orders .st { grid-column: 3; grid-row: 1 / span 2; font-size: 14px; font-weight: 600; text-align: right; }
.orders li.in { border-color: var(--ink); border-left-color: var(--c); }
.orders li.done { opacity: .6; }
.album h2 { font-size: 22px; margin: 10px 0; }
.album h2 small { font-size: 15px; font-weight: 400; color: var(--soft); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; text-align: left; margin: 10px 0; }
.card { background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; box-shadow: 0 3px 0 rgba(43, 33, 28, .2); }
.card .kind { font-size: 12px; color: var(--brick); font-weight: 600; letter-spacing: .02em; }
.album .left { font-size: 14px; color: var(--soft); }
.card h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.25; }
.card h3 small { font-size: 12px; background: var(--gold); border-radius: 999px; padding: 1px 7px; vertical-align: middle; }
.card p { margin: 0 0 6px; font-size: 15px; }
.card .src { font-size: 12px; color: var(--soft); }
.card.locked { border-style: dashed; border-color: #b9a785; box-shadow: none; background: transparent; }
.card.locked h3 { color: #b9a785; }
.card.gold { border-color: var(--gold); box-shadow: 0 3px 0 var(--gold); }
@media (max-width: 480px) {
  .top { gap: 6px; padding: 6px 10px; }
  .top h1 { font-size: 19px; }
  .home { display: none; }
  .modes button, .lang button { padding: 4px 9px; font-size: 14px; min-height: 34px; }
  .lvl button { padding: 4px 9px; font-size: 14px; }
  .hintb { padding: 3px 10px; font-size: 14px; }
  main { padding: 0 8px; }
  #map { height: 62vh; }
}
.foot { max-width: 760px; margin: 0 auto; padding: 10px 12px 30px; font-size: 12px; color: var(--soft); }
.foot a { color: inherit; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* the 1200×630 share card: ?card */
body.cardshot { width: 1200px; height: 630px; overflow: hidden; }
body.cardshot .bar, body.cardshot .top, body.cardshot .help, body.cardshot .note, body.cardshot .orders, body.cardshot .foot, body.cardshot .hud, body.cardshot .cond { display: none !important; }
body.cardshot main { max-width: none; padding: 0; position: relative; }
body.cardshot .stagewrap, body.cardshot .mapwrap { border: 0; border-radius: 0; }
body.cardshot #stage { height: 230px; }
body.cardshot #map { height: 400px; }
body.cardshot main::after { content: 'ไรเดอร์ · Rider'; position: absolute; left: 36px; top: 262px; font: 600 58px/1 Prompt, sans-serif; color: var(--ink); background: var(--card); border: 3px solid var(--ink); border-radius: 18px; padding: 14px 24px; box-shadow: 0 6px 0 rgba(43, 33, 28, .3); }
.coach { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 7px 12px; font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; box-shadow: 0 3px 0 rgba(43, 33, 28, .2); }
.coach .dot { margin-left: 2px; }
.coach small { color: var(--soft); margin-left: auto; }
.ok { color: #1f7a45; }
.review { text-align: left; max-width: 520px; margin: 6px auto; }
.review p { text-align: center; margin: 4px 0; }
.review h3 { font-size: 15px; margin: 10px 0 4px; }
.review h3 small { font-weight: 400; color: var(--soft); }
.route { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.route li { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 2px 8px 2px 3px; font-size: 13px; }
.route li small { color: var(--soft); }
.route li.miss { border-color: var(--brick); }

/* the ground: the site's own tiles under the game map */
.mapwrap .ground { position: absolute; inset: 0; }
#map { position: relative; z-index: 1; }
.mapwrap .ground .maplibregl-ctrl-bottom-right { z-index: 2; }
body.grounded .mapwrap { background: #f3e7cf; }
.cardshot { margin: 10px auto 0; max-width: 560px; }
.cardshot img { display: block; width: 100%; border: 2px solid var(--ink); border-radius: 10px; }
.cardshot figcaption { margin-top: 6px; font-size: 14px; }
/* the map canvas sits above the tiles; everything the game puts over the map sits above both */
.mapwrap .panel, .mapwrap .coach, .mapwrap .toast, .mapwrap .end, .mapwrap .marks { z-index: 3; }
.mapwrap .marks { position: absolute; top: 8px; left: 8px; font: 600 13px Prompt, system-ui, sans-serif; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: #fffaf0; color: var(--ink); cursor: pointer; }
.mapwrap .marks[aria-pressed="true"] { background: var(--ink); color: #fffaf0; }
body.cardshot .marks { display: none; }
/* the ride view and the map fit the screen together, so a tapped stop's panel and its Go button are in sight */
#map { height: max(300px, calc(100vh - clamp(130px, 30vw, 210px) - 120px)); }
@supports (height: 100dvh) { #map { height: max(300px, calc(100dvh - clamp(130px, 30vw, 210px) - 120px)); } }
