:root {
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  color: #254b45; background: #eef2e6; font-synthesis: none;
  --ink: #254b45; --muted: #688076; --paper: #fbfbef; --line: #d8e1d3;
  --orange: #c6683f; --mint: #88b8a2;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at 4% 5%, #faf8e5, transparent 55%); }
button { font: inherit; cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .48; cursor: default; }
button:focus-visible, canvas:focus-visible, summary:focus-visible { outline: 3px solid #ce7043; outline-offset: 4px; }
.app { width: min(1020px, calc(100% - 40px)); margin: 23px auto 12px; }
.masthead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 19px; gap: 12px; }
.eyebrow { margin: 0 0 7px; font: 700 10px/1.5 system-ui, sans-serif; letter-spacing: .15em; color: var(--muted); }
.eyebrow span { margin: 0 9px; color: #a6b3a1; }
h1 { margin: 0; font-size: clamp(27px, 4vw, 39px); letter-spacing: -.07em; line-height: 1.16; }
h1 span { margin-left: 6px; font-weight: 500; }
h1 i { color: var(--orange); font-style: normal; }
.header-actions { display: flex; gap: 9px; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #c6d3c2; border-radius: 50%; background: #f8f9ec; font: 700 19px/1 system-ui; }
.icon-button:hover:enabled { background: #e2ebd8; }
.game-shell { display: grid; grid-template-columns: minmax(0, 1fr) 278px; border: 1px solid #b7cbba; border-radius: 22px; overflow: hidden; background: var(--paper); box-shadow: 0 17px 45px #335e4510; }
.river-view { position: relative; min-width: 0; height: min(720px, calc(100svh - 157px)); min-height: 490px; background: #87bdad; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; outline-offset: -5px !important; }
.river-hud { position: absolute; top: 22px; left: 23px; right: 23px; display: flex; justify-content: space-between; pointer-events: none; }
.score-block { padding: 12px 17px 11px; background: #f8fbeced; border: 1px solid #eff7de; border-radius: 13px; box-shadow: 0 4px 13px #27595509; }
.score-block .eyebrow { display: block; margin: 0; font-size: 9px; }
.score-block strong { display: block; font: 500 37px/1.15 ui-monospace, "Cascadia Mono", monospace; letter-spacing: -.08em; font-variant-numeric: tabular-nums; }
.score-block small { display: block; margin-top: 3px; font: 600 9px/1.4 system-ui; letter-spacing: .1em; color: #6c8578; }
.flow-block { display: flex; flex-direction: column; align-items: end; gap: 8px; padding-top: 3px; }
.flow-block > span { padding: 7px 11px; border: 1px solid #e7f2e3ba; border-radius: 99px; background: #e7f5dece; font-size: 11px; font-weight: 700; }
.flow-block small { color: #315d52; font: 600 12px/1.4 ui-monospace, monospace; }
.start-cover { position: absolute; left: 50%; top: 48%; width: min(330px, calc(100% - 44px)); padding: 29px 27px 25px; transform: translate(-50%, -50%); border: 1px solid #e8f2ded9; border-radius: 18px; background: #f6faeaeF; box-shadow: 0 15px 55px #315d5220; text-align: center; }
.start-cover h2 { margin: 8px 0 15px; font-size: 27px; letter-spacing: -.07em; }
.start-cover > p:not(.eyebrow) { font-size: 12px; line-height: 1.9; margin: 0 0 22px; color: #526f62; }
.primary { width: 100%; min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; background: var(--ink); border: 1px solid var(--ink); border-radius: 10px; color: #f8f7e5; font-size: 14px; font-weight: 700; transition: background .15s; }
.primary:hover { background: #38685b; }
.primary span { font-size: 22px; font-weight: 400; }
.river-caption { position: absolute; left: 23px; bottom: 15px; font: 600 8px/1.4 system-ui; color: #39685a; letter-spacing: .22em; pointer-events: none; }
.flow-notice { position: absolute; left: 50%; top: 25%; transform: translateX(-50%); border: 1px solid #f5f4d4; border-radius: 99px; background: #f8f7e6ed; padding: 9px 19px; white-space: nowrap; font-size: 12px; font-weight: 700; pointer-events: none; }
.console { padding: 23px 23px 18px; display: flex; flex-direction: column; gap: 20px; border-left: 1px solid #b7cbba; }
.field-label { display: flex; justify-content: space-between; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.field-label b { font-size: 10px; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flight-track { height: 6px; position: relative; margin-top: 14px; border-radius: 6px; background: #e4eadc; }
.flight-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: #86b5a0; }
.flight-track > span { position: absolute; width: 8px; height: 8px; right: 0; top: -1px; border-radius: 50%; background: var(--ink); }
.charge-track { height: 24px; position: relative; margin: 13px 4px 12px; border-radius: 7px; background: linear-gradient(90deg, #e3eada, #edf0e4 50%, #e3eada); }
.charge-center { position: absolute; left: 50%; top: -3px; bottom: -3px; border-left: 1px solid #879982; }
.charge-track i { position: absolute; top: 5px; height: 14px; left: 50%; width: 0; background: #a6c3a5; border-radius: 3px; }
.charge-track b { position: absolute; left: 50%; top: 5px; width: 14px; height: 14px; border: 2px solid #f8f6e2; border-radius: 50%; transform: translateX(-50%); background: #cd7750; box-shadow: 0 1px 5px #315d5226; }
.direction-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.direction-buttons button { min-height: 60px; padding: 10px 3px; border: 1px solid #afc5af; border-bottom: 4px solid #a3bca4; border-radius: 12px; background: #eaf0df; font-size: 11px; font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; }
.direction-buttons button span { font-size: 20px; vertical-align: -1px; }
.direction-buttons button[aria-pressed="true"] { color: #fffdeb; background: #527e68; border-color: #386454; transform: translateY(2px); border-bottom-width: 2px; }
.control-note { margin: 10px 0 0; color: #6c806e; font-size: 10px; line-height: 1.7; text-align: center; }
.tally { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.tally > div + div { border-left: 1px solid var(--line); }
.tally span { display: block; font-size: 9px; font-weight: 600; white-space: nowrap; }
.tally b { display: block; margin: 6px 0 2px; font: 500 25px/1.2 ui-monospace, monospace; }
.tally small { font-size: 10px; color: var(--muted); }
.bonus-tally, .bonus-tally small { color: #9c6533; }
.rock-guide { display: grid; gap: 12px; }
.rock-guide p { display: flex; gap: 13px; align-items: center; margin: 0; font-size: 10px; line-height: 1.7; color: var(--muted); }
.rock-guide b { display: block; color: var(--ink); font-size: 11px; font-weight: 700; }
.rock-icon { flex: 0 0 31px; height: 19px; background: #bdac73; border-radius: 45% 46% 35% 35%; border-bottom: 5px solid #8e956c; box-shadow: 0 3px 0 #d9e6ca; }
.rock-icon.tall { height: 34px; clip-path: polygon(15% 100%, 0 46%, 29% 10%, 69% 0, 100% 37%, 89% 93%); border: 0; border-radius: 0; background: linear-gradient(65deg, #4c6866 50%, #87998b 51%); box-shadow: none; }
.keyboard-note { margin: auto 0 0; font-size: 10px; line-height: 1.8; color: var(--muted); }
.console.finished .keyboard-note { display: none; }
.footer-note { margin: 10px 0 0; text-align: right; font-size: 10px; color: #79917e; letter-spacing: .07em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
dialog { width: min(450px, calc(100% - 28px)); max-height: calc(100svh - 30px); margin: auto; padding: 29px; border: 1px solid #b3c5ad; border-radius: 21px; background: #fbfbef; color: var(--ink); box-shadow: 0 20px 100px #163d4330; overflow-y: auto; }
dialog::backdrop { background: #1c423e70; backdrop-filter: blur(4px); }
dialog h2 { margin: 8px 0 18px; font-size: 28px; letter-spacing: -.06em; }
dialog p, dialog li { font-size: 13px; line-height: 1.85; }
dialog ul { padding-left: 19px; margin: 15px 0; }
dialog li + li { margin-top: 8px; }
dialog .primary { margin-top: 22px; }
.help-steps { display: flex; justify-content: space-between; gap: 4px; padding: 14px 7px; border-radius: 10px; background: #e8efdd; font-size: 11px; font-weight: 700; }
.help-scoring { display: flex; justify-content: space-between; gap: 9px; padding: 15px 0; border-block: 1px solid var(--line); font-size: 12px; }
.help-scoring b { color: #a46436; margin-left: 5px; }
dialog .help-note { font-size: 11px; color: var(--muted); }
.result-score { display: flex; flex-direction: column; margin: 22px 0; }
.result-score strong { font: 500 64px/1.1 ui-monospace, monospace; letter-spacing: -.06em; }
.result-score span { margin-top: 4px; color: var(--muted); font: 700 10px/1.5 system-ui; letter-spacing: .2em; }
.record-notice { color: #a56534; font-weight: 700; }
.result-tally { padding: 12px 0; border-block: 1px solid var(--line); }
.result-tally > div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 12px; }
.result-tally dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-button { display: block; min-height: 44px; margin: 10px auto 0; border: 0; background: transparent; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 760px) {
  .app { width: min(560px, calc(100% - 20px)); margin: 12px auto 8px; }
  .masthead { margin-bottom: 12px; }
  .masthead .eyebrow { font-size: 8px; margin-bottom: 5px; }
  .eyebrow span { margin-inline: 4px; }
  h1 { font-size: clamp(26px, 6vw, 33px); }
  .header-actions { gap: 5px; }
  .game-shell { display: block; border-radius: 17px; }
  .river-view { height: clamp(295px, 54svh, 510px); min-height: 0; }
  .river-hud { top: 13px; left: 13px; right: 13px; }
  .score-block { padding: 8px 12px; border-radius: 10px; }
  .score-block strong { font-size: 28px; }
  .score-block .eyebrow, .score-block small { font-size: 8px; }
  .flow-block > span { padding: 5px 9px; font-size: 10px; }
  .flow-block small { font-size: 10px; }
  .river-caption { font-size: 7px; left: 14px; bottom: 10px; }
  .start-cover { padding: 22px; width: min(300px, calc(100% - 40px)); top: 53%; }
  .start-cover h2 { font-size: 26px; }
  .start-cover > p:not(.eyebrow) { margin-bottom: 17px; }
  .console { padding: 15px 16px 12px; border-left: 0; border-top: 1px solid #b7cbba; gap: 13px; }
  .rhythm { display: flex; align-items: center; gap: 15px; }
  .rhythm .field-label { flex: 0 0 auto; }
  .rhythm .field-label > span { display: none; }
  .flight-track { margin: 0; flex: 1; }
  .charge-track { height: 16px; margin: 9px 4px 12px; }
  .charge-track i { top: 3px; height: 10px; }
  .charge-track b { top: 1px; }
  .direction-buttons { gap: 11px; }
  .direction-buttons button { min-height: 54px; font-size: 13px; }
  .direction-buttons button span { margin-inline: 6px; }
  .control-note { margin-top: 8px; font-size: 10px; }
  .tally { padding: 11px 0 0; border-bottom: 0; }
  .tally > div { display: flex; align-items: baseline; justify-content: center; gap: 5px; flex-wrap: wrap; }
  .tally b { margin: 0; font-size: 18px; }
  .tally small { display: none; }
  .rock-guide, .keyboard-note { display: none; }
  .footer-note { margin-top: 8px; font-size: 9px; }
}
@media (max-width: 360px) {
  h1 { font-size: 24px; }
  h1 span { margin-left: 3px; }
  .icon-button { width: 44px; height: 44px; }
  .console { padding-inline: 12px; }
  .start-cover { padding-inline: 17px; }
  dialog { padding: 22px; }
  dialog h2 { font-size: 22px; }
  .help-steps { font-size: 9px; }
  .help-scoring { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
