:root {
  --ink: #1d2340;
  --ink2: #3a4170;
  --snow: #fff8f2;
  --paper: #fffdfb;
  --ember: #ff6b3d;
  --ember-dark: #d9481c;
  --mint: #2fd6a3;
  --violet: #8b5cf6;
  --sun: #ffc53d;
  --line: #e7e1ee;
  --display: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --top: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.6 var(--text);
  color: var(--ink);
  background: linear-gradient(180deg, #f4ecf6 0, var(--snow) 420px);
}
a { color: #c23f12; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.top {
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--ink);
  color: #fff;
  position: relative;
  z-index: 5;
}
.logo {
  font: italic 900 22px/1 var(--display);
  letter-spacing: -0.02em;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo svg { width: 28px; height: 28px; }
.logo span { color: var(--ember); }
.top nav { margin-left: auto; display: flex; gap: 4px; }
.top nav a { color: #e9e6ff; text-decoration: none; font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.top nav a:hover, .top nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* ---------- stage ---------- */
.stage {
  position: relative;
  height: min(78vh, 58vw);
  min-height: 420px;
  max-height: 820px;
  overflow: hidden;
  background: linear-gradient(180deg, #2b3f86 0%, #c9809a 55%, #ffd2a6 82%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage.playing { touch-action: none; }
@media (max-width: 760px), (pointer: coarse) {
  .stage { height: calc(100svh - var(--top)); max-height: none; min-height: 360px; }
}
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font: italic 800 20px var(--display);
  text-align: center;
  padding: 24px;
  z-index: 4;
}
.loading .spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; animation: rot 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- panels ---------- */
.panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: linear-gradient(90deg, rgba(29, 35, 64, 0.78) 0%, rgba(29, 35, 64, 0.42) 55%, rgba(29, 35, 64, 0.1) 100%);
  overflow-y: auto;
}
.card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  color: #fff;
  padding: 6px 4px;
}
.menu { justify-content: flex-start; padding-left: max(14px, 5vw); }
.title {
  margin: 0;
  font: italic 900 clamp(44px, 9vw, 76px)/0.9 var(--display);
  letter-spacing: -0.04em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}
.title span { color: var(--ember); }
.tag { margin: 6px 0 16px; font-weight: 600; color: #f6e9ff; }
.daily {
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  padding: 14px 16px 16px;
  box-shadow: 0 10px 30px rgba(10, 10, 40, 0.3);
  border-bottom: 5px solid var(--ember);
}
.daily .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.daily .day { font: italic 900 20px var(--display); }
.daily .date { font-weight: 700; color: var(--ink2); font-size: 14px; }
.daily .park { font-size: 15px; font-weight: 700; color: var(--ember-dark); margin: 2px 0 6px; }
.daily .best { font-size: 14px; margin: 0 0 12px; color: var(--ink2); }
.streak { font-weight: 800; font-size: 14px; color: var(--ember-dark); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  border-radius: 14px;
  font: italic 900 18px var(--display);
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 0.08s;
}
.btn:active { transform: translateY(2px); }
.btn-go { background: var(--ember); color: #fff; box-shadow: 0 4px 0 var(--ember-dark); width: 100%; }
.btn-go:hover { background: #ff7d55; color: #fff; }
.btn-alt { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #c9c3dc; }
.btn-ghost { background: rgba(255, 255, 255, 0.14); color: #fff; border: 2px solid rgba(255, 255, 255, 0.4); min-height: 44px; font-size: 15px; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.24); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.board-h { margin: 16px 0 6px; font: italic 900 15px var(--display); text-transform: uppercase; letter-spacing: 0.06em; color: #ffe6d6; }
.board { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.board li { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.14); }
.board li.muted { display: block; color: #e7e3ff; border: 0; }
.board .rk { font-weight: 900; color: var(--sun); }
.board .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .tr { color: #d9d4ff; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.board li.me .nm { color: var(--mint); }
.prefs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.swatches { display: flex; gap: 6px; margin-right: 6px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.5); background: var(--c); padding: 0; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px #fff; }
.chip { background: rgba(255, 255, 255, 0.14); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; min-height: 32px; }
.chip[aria-pressed="false"] { opacity: 0.65; }

/* results */
.results { justify-content: center; background: rgba(29, 35, 64, 0.62); }
.results .card { width: min(500px, 100%); background: var(--paper); color: var(--ink); border-radius: 22px; padding: 18px 18px 16px; box-shadow: 0 16px 40px rgba(10, 10, 40, 0.35); }
.r-title { margin: 0; font: italic 900 16px var(--display); color: var(--ink2); }
.r-score { font: italic 900 clamp(46px, 11vw, 64px)/1 var(--display); letter-spacing: -0.03em; margin: 6px 0 2px; color: var(--ink); }
.r-score small { font-size: 18px; color: var(--ink2); letter-spacing: 0; }
.r-emoji { font-size: 22px; margin: 4px 0; line-height: 1.3; display: flex; flex-wrap: wrap; gap: 0 3px; }
.r-meta { margin: 2px 0; font-size: 14px; color: var(--ink2); }
.r-meta b { color: var(--ink); }
.r-rank { font-weight: 800; color: var(--ember-dark); min-height: 1.5em; }
.r-list { list-style: none; padding: 0; margin: 10px 0; max-height: 180px; overflow-y: auto; border-top: 1px solid var(--line); font-size: 14px; }
.r-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline; padding: 5px 2px; border-bottom: 1px solid var(--line); }
.r-list small { color: #6b6f8e; font-size: 12px; }
.r-list li.ld1 small { color: #a86400; }
.r-list li.ld2 { color: #9a93ad; }
.r-list li.ld2 small { color: #c0392b; }
.r-list li.muted { display: block; color: var(--ink2); }
.name-row { display: flex; gap: 8px; margin: 8px 0 4px; }
.name-row label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.name-row input { flex: 1; min-width: 0; min-height: 44px; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; font: 600 16px var(--text); color: var(--ink); }
.name-row button { min-height: 44px; border-radius: 12px; border: 0; background: var(--ink); color: #fff; font-weight: 800; padding: 0 16px; }
.r-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.r-btns .btn-go { grid-column: 1 / -1; }

/* tutorial */
.tut .card { width: min(620px, 100%); background: var(--paper); color: var(--ink); border-radius: 22px; padding: 18px; }
.tut h2 { margin: 0 0 4px; font: italic 900 26px var(--display); }
.tut p.sub { margin: 0 0 10px; color: var(--ink2); font-size: 14px; }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.steps li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; background: #f6f1fa; border-radius: 14px; padding: 9px 10px; font-size: 14px; line-height: 1.45; }
.steps li b.n { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font: italic 900 15px var(--display); }
.steps strong { display: block; font-size: 15px; }
kbd { display: inline-block; min-width: 24px; padding: 0 6px; border-radius: 6px; background: #fff; border: 1px solid #cfc8de; border-bottom-width: 3px; font: 700 12px/20px var(--text); text-align: center; color: var(--ink); }
.only-touch { display: none; }
html.is-touch .only-touch { display: inline; }
html.is-touch .only-keys { display: none; }

.pause .card { text-align: center; }
.pause h2 { font: italic 900 34px var(--display); margin: 0 0 14px; }
.pause .btn { width: 100%; margin-bottom: 10px; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; color: #fff; font-family: var(--display); }
.hud-score { position: absolute; left: 14px; top: 10px; text-shadow: 0 2px 6px rgba(20, 20, 60, 0.45); }
.hud-score b { display: block; font: italic 900 34px/1 var(--display); letter-spacing: -0.02em; }
.hud-score span { font-weight: 800; font-size: 13px; color: var(--sun); }
.hud-top { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); text-align: center; width: min(300px, 46vw); text-shadow: 0 1px 4px rgba(20, 20, 60, 0.5); }
.hud-top .m { font: italic 900 13px var(--display); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-top .p { font-size: 12px; font-weight: 700; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-prog { height: 6px; background: rgba(255, 255, 255, 0.3); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.hud-prog i { display: block; height: 100%; background: var(--mint); transform-origin: left; transform: scaleX(0); }
.hud-btns { position: absolute; right: 10px; top: 8px; display: flex; gap: 6px; pointer-events: auto; }
.hud-btns button { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(29, 35, 64, 0.55); color: #fff; font-weight: 900; font-size: 16px; }
.hud-speed { position: absolute; left: 14px; top: 58px; font-weight: 800; font-size: 13px; opacity: 0.85; text-shadow: 0 1px 4px rgba(20, 20, 60, 0.5); }
.hud-trick { position: absolute; left: 0; right: 0; top: 22%; text-align: center; opacity: 0; }
.hud-trick b { display: block; font: italic 900 clamp(26px, 5.4vw, 46px)/1.05 var(--display); letter-spacing: -0.02em; text-shadow: 0 3px 0 rgba(29, 35, 64, 0.35), 0 0 18px rgba(29, 35, 64, 0.35); padding: 0 10px; }
.hud-trick span { display: inline-block; margin-top: 6px; font: italic 900 20px var(--display); background: var(--mint); color: var(--ink); padding: 2px 12px; border-radius: 999px; }
.hud-trick.ld1 span { background: var(--sun); }
.hud-trick.ld2 span { background: #ff4d6d; color: #fff; }
.hud-trick.show { animation: trick 1.9s ease-out forwards; }
@keyframes trick {
  0% { opacity: 0; transform: translateY(14px) scale(0.85); }
  10% { opacity: 1; transform: translateY(0) scale(1.06); }
  18% { transform: scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}
.hud-live { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font: italic 900 24px var(--display); color: #fff; text-shadow: 0 2px 8px rgba(20, 20, 60, 0.6); }
.hud-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: min(560px, 92%); text-align: center; font: 700 14px/1.3 var(--text); background: rgba(29, 35, 64, 0.72); padding: 7px 14px; border-radius: 999px; }
.hud-hint:empty { display: none; }
.hud-hint[data-tone="good"] { background: rgba(20, 120, 90, 0.85); }
.hud-hint[data-tone="warn"] { background: rgba(200, 70, 30, 0.9); }
.hud-bal { position: absolute; left: 50%; top: 52%; transform: translateX(-50%); width: 120px; height: 14px; border-radius: 7px; background: linear-gradient(90deg, #ff4d6d 0, #ffc53d 22%, #2fd6a3 40%, #2fd6a3 60%, #ffc53d 78%, #ff4d6d 100%); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.hud-bal i { position: absolute; left: 56px; top: -5px; width: 8px; height: 24px; border-radius: 4px; background: #fff; box-shadow: 0 0 0 2px var(--ink); }
.ready-prompt { position: absolute; left: 50%; top: 56%; transform: translateX(-50%); z-index: 2; text-align: center; color: #fff; pointer-events: none; }
.ready-prompt b { display: block; font: italic 900 26px var(--display); text-shadow: 0 2px 10px rgba(20, 20, 60, 0.6); animation: pulse 1.4s ease-in-out infinite; }
.ready-prompt span { font-weight: 700; font-size: 14px; text-shadow: 0 1px 6px rgba(20, 20, 60, 0.7); }
@keyframes pulse { 50% { transform: scale(1.06); } }
html.is-touch .hud-hint { bottom: 150px; }
html.is-touch .ready-prompt { top: 44%; }

/* ---------- touch controls ---------- */
.touch { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.stick-zone { position: absolute; left: 0; top: 64px; bottom: 0; width: 58%; pointer-events: auto; touch-action: none; }
.stick { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity 0.1s; }
.stick.on { opacity: 1; }
.stick::before { content: ""; position: absolute; left: -50px; top: -50px; width: 100px; height: 100px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.7); background: rgba(29, 35, 64, 0.25); }
.stick i { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); }
.stick-hint { position: absolute; left: 18px; bottom: 22px; color: #fff; font: 700 12px var(--text); opacity: 0.75; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.85); color: #fff; font: italic 900 15px var(--display); display: grid; place-items: center; -webkit-tap-highlight-color: transparent; }
.tbtn.jump { right: 18px; bottom: 26px; width: 96px; height: 96px; background: rgba(255, 107, 61, 0.78); font-size: 18px; }
.tbtn.grab { right: 128px; bottom: 34px; width: 74px; height: 74px; background: rgba(139, 92, 246, 0.72); }
.tbtn.on { transform: scale(0.94); filter: brightness(1.15); }

.toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 6; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; max-width: 90%; }

/* ---------- content ---------- */
.content { max-width: 760px; margin: 0 auto; padding: 28px 18px 10px; }
.content h1 { font: italic 900 clamp(28px, 5vw, 40px)/1.1 var(--display); letter-spacing: -0.02em; margin: 0 0 12px; }
.content h2 { font: italic 900 24px/1.2 var(--display); margin: 30px 0 8px; }
.content h3 { font-size: 17px; margin: 18px 0 4px; }
.content p, .content li { color: #2b3156; }
.lede { font-size: 18px; }
.cta { display: inline-flex; margin: 4px 0 8px; width: auto; }
.faq details { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.faq summary { font-weight: 800; cursor: pointer; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 8px 0 16px; background: #fff; border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--ink); color: #fff; font-weight: 800; }
.links { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.links a { display: inline-block; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; font-weight: 700; color: var(--ink); }
.foot { margin-top: 30px; padding: 22px 18px 30px; text-align: center; font-size: 14px; color: #555b80; border-top: 1px solid var(--line); }
.foot a { color: var(--ink2); }
.foot p { margin: 4px 0; }

/* contact form */
.fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fb-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.fb-field label { font-weight: 700; font-size: 14px; }
.fb-field input, .fb-field textarea { font: 16px var(--text); padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.fb-field textarea { min-height: 140px; resize: vertical; }
.fb-hint { font-weight: 400; color: #6b6f8e; }
form[data-feedback-form] button[type="submit"] { min-height: 46px; padding: 0 26px; border: 0; border-radius: 12px; background: var(--ember); color: #fff; font: italic 900 17px var(--display); }
@media (max-width: 560px) { .fb-row { grid-template-columns: 1fr; } }

@media (max-width: 760px) {
  .menu { padding-left: 14px; align-items: flex-end; background: linear-gradient(180deg, rgba(29, 35, 64, 0.1) 0%, rgba(29, 35, 64, 0.55) 35%, rgba(29, 35, 64, 0.85) 100%); }
  .title { font-size: 48px; }
  .tag { margin-bottom: 10px; }
  .hud-score b { font-size: 26px; }
  .hud-top { width: 40vw; }
  .top nav a { padding: 6px 7px; font-size: 13px; }
}
@media (max-width: 380px) { .top nav a.opt { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .hud-trick.show { animation: fade 1.9s linear forwards; }
  .ready-prompt b, .loading .spin { animation: none; }
  @keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
}
