:root {
  --paper: #F2F1EC;
  --ink: #141414;
  --cobalt: #2B5FA8;
  --meta: #6E6C64;
  --rule: 1px solid var(--ink);
  --display: "Archivo Black", "Arial Black", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --body: "Archivo", "Helvetica Neue", Arial, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans TC", monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }

.mast {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  margin: 0 16px; padding: 10px 0 8px; border-bottom: var(--rule); position: relative; z-index: 20; background: var(--paper);
}
.word { margin: 0; font-family: var(--display); font-weight: 900; text-transform: uppercase; font-size: 22px; letter-spacing: -.01em; line-height: 1; }
.brand { border: 0; padding: 0; background: none; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; text-align: left; flex: 0 1 auto; min-width: 0; min-height: 44px; }
.brand svg { width: 21px; height: 21px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; }
.mast-nav { display: flex; gap: 0; flex: 0 0 auto; }
.mono-link {
  font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  background: none; border: 0; color: var(--ink); text-decoration: none; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
}
.mono-link:focus-visible, .btn:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px 40px; }
.sheet { padding-top: 8px; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; padding: 4px 0 6px; border-bottom: var(--rule); }
.tally b { font-family: var(--display); font-weight: 900; font-size: 18px; letter-spacing: 0; }
.tally .slash { color: var(--meta); }
.say { margin: 8px 0 8px; min-height: 24px; font-size: 16px; line-height: 1.35; }
.say.fail { font-weight: 600; }
.say.fail::before { content: "\25AA\00a0"; color: var(--ink); }

.board-wrap { position: relative; display: flex; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
#board { display: block; max-width: 100%; overflow: visible; -webkit-tap-highlight-color: transparent; }
#board .mover { transition: transform 220ms cubic-bezier(.22,.78,.25,1); }
#board.instant .mover { transition: none; }
.preview-pin { opacity: 1; }
/* The squash runs on the inner art, never on the mover: an animation on the mover's own transform replaced its
   translate and threw the pin to the board's top-left corner for 160 ms (seen on loop 6, 2026-10-23). */
.pin-art { transform-box: fill-box; transform-origin: center; }
.preview-pin.caught .pin-art { animation: pin-squash 160ms ease-out; }
.catch-ring { fill: none; stroke: var(--cobalt, #2B5FA8); stroke-width: 3; }
.catch-ring.far { stroke-dasharray: 5 5; stroke-width: 2; opacity: .7; }
.catch-ring.flash { animation: ring-flash 520ms ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes ring-flash { 0% { stroke-width: 8; transform: scale(.7); } 60% { transform: scale(1.12); } 100% { stroke-width: 3; transform: scale(1); } }
.missed-pin { fill: none; stroke: var(--ink, #141414); stroke-width: 2.5; stroke-dasharray: 4 4; }
.missed-text { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 700; fill: var(--ink, #141414); paint-order: stroke; stroke: #F2F1EC; stroke-width: 4px; }
.pin-line { margin: 0 0 8px; min-height: 32px; font-size: 22px; line-height: 1.45; font-weight: 600; }
.pin-line .pf { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 700; color: var(--cobalt, #2B5FA8); }
#strip .fr.missed .ic { outline: 2px dashed var(--ink, #141414); outline-offset: 1px; }
.map-daily { display: flex; width: 100%; min-height: 56px; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; padding: 10px 14px; font-size: 20px; }
.pin-blink { display: none; }
.caught .pin-blink { display: block; }
.tile-art { filter: drop-shadow(2px 2px 0 var(--ink)); transform-box: fill-box; transform-origin: center; }
.tile-art.lean.up { animation: lean-up 360ms ease-out; }
.tile-art.lean.down { animation: lean-down 360ms ease-out; }
.tile-art.lean.left { animation: lean-left 360ms ease-out; }
.tile-art.lean.right { animation: lean-right 360ms ease-out; }
.tile-art.flinch { animation: flinch 200ms ease-out; }
@keyframes pin-squash { 0% { transform: scale(1); } 45% { transform: scale(1.15,.86); } 100% { transform: scale(1); } }
@keyframes lean-up { 0% { transform: rotate(-3deg); } 100% { transform: none; } }
@keyframes lean-down { 0% { transform: rotate(3deg); } 100% { transform: none; } }
@keyframes lean-left { 0% { transform: rotate(-3deg); } 100% { transform: none; } }
@keyframes lean-right { 0% { transform: rotate(3deg); } 100% { transform: none; } }
@keyframes flinch { 0%,100% { transform: none; } 35% { transform: translateX(-2px); } 70% { transform: translateX(2px); } }
.failure-line { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3 5; stroke-linecap: round; }
.demo-tile { filter: drop-shadow(2px 2px 0 var(--ink)); transform-box: fill-box; transform-origin: center; }
.demo-slide { animation: demo-pop 220ms ease-out; }
@keyframes demo-pop { 0% { opacity: .35; transform: scale(.88); } 100% { opacity: 1; transform: scale(1); } }
.demo-hand { pointer-events: none; }
.pulse { animation: pulse 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.tip {
  position: absolute; z-index: 3; pointer-events: none; background: var(--ink); color: var(--paper);
  padding: 6px 8px; font-size: 12px; max-width: 220px; line-height: 1.3; text-transform: none; letter-spacing: .02em;
}

.strip { display: grid; align-items: stretch; gap: 0; margin: 12px 0 4px; border-left: var(--rule); }
.fr {
  min-width: 0; max-width: none; height: 52px; overflow: hidden; border: var(--rule); border-left: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 2px 0 4px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0; color: var(--meta);
}
.fr .ic { width: min(20px, calc(100% - 6px)); height: min(20px, calc(100% - 18px)); display: block; }
.fr.on { color: var(--ink); }
.fr.now { box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.fr.play { background: var(--ink); color: var(--paper); }
.fr.preview { background: var(--cobalt); color: #fff; }
.fr.preview .ic { filter: brightness(0) invert(1); }
.fr.loopback { max-width: none; min-width: 0; padding: 2px 2px 4px; color: var(--ink); }
.strip.dense .loopback span:last-child { display: none; }
@media (max-width: 359px) { .fr { font-size: 9px; } }
.strip-cap { display: flex; justify-content: space-between; color: var(--meta); font-size: 10px; margin-bottom: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--meta); margin: 2px 0 10px; min-height: 18px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend svg { width: 14px; height: 14px; }

.controls { display: flex; gap: 10px; padding: 10px 0 2px; border-top: var(--rule); }
.btn {
  min-height: 46px; padding: 0 16px; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 0;
  box-shadow: 3px 3px 0 var(--ink); cursor: pointer; font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  transition: transform 80ms, box-shadow 80ms;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled, .btn.muted { color: var(--meta); border-color: var(--meta); box-shadow: none; }
.btn.cta { background: var(--cobalt); color: #fff; border-color: var(--ink); }
.btn.lit { box-shadow: 3px 3px 0 var(--cobalt); border-color: var(--cobalt); color: var(--cobalt); }

.result { border-top: var(--rule); padding: 10px 0 4px; }
.res-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.res-title { font-family: var(--display); text-transform: uppercase; font-size: 22px; line-height: 1.05; }
.res-num b { font-family: var(--display); font-size: 30px; line-height: 1; }
.res-line { margin: 4px 0 12px; }
.playback-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; }
.res-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.map {
  display: none; position: fixed; z-index: 10; top: 8px; bottom: 8px; left: 50%; width: min(calc(100% - 16px), 560px);
  margin: 0; padding: 10px 16px 24px; overflow: auto; background: var(--paper); border: 2px solid var(--ink);
  transform: translateX(-50%);
}
.map.open { display: block; pointer-events: auto; }
.map-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: var(--rule); }
.map-head h2 { margin: 0; font-family: var(--display); text-transform: uppercase; font-size: 20px; font-weight: 900; }
.ch { display: grid; grid-template-columns: 7.5em 1fr; border-bottom: var(--rule); }
.ch-name { padding: 8px 8px 8px 0; border-right: var(--rule); }
.ch-name b { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--meta); font-weight: 400; }
.ch-name span { font-weight: 600; font-size: 14px; line-height: 1.2; display: block; }
.ch-cells { display: grid; grid-template-columns: repeat(4, 1fr); }
.cell {
  min-height: 56px; border: 0; border-right: var(--rule); background: none; cursor: pointer; padding: 4px 6px; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cell:last-child { border-right: 0; }
.cell .n { font-family: var(--display); font-size: 18px; line-height: 1; }
.cell .s { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; color: var(--meta); }
.cell.cur { background: var(--ink); color: var(--paper); }
.cell.cur .s { color: var(--paper); }
.cell.locked { cursor: default; color: var(--meta); }
.cell.atpar .s { color: var(--cobalt); }
.cell.cur.atpar .s { color: #9DB7E0; }
.foot { margin-top: 18px; color: var(--meta); font-size: 13px; }
.foot p { margin: 0; max-width: 36em; }
.book-note { margin: 8px 0; color: var(--meta); font-size: 14px; }
.song-row { width: 100%; min-height: 58px; border: 0; border-bottom: var(--rule); background: none; padding: 7px 0; text-align: left; cursor: pointer; display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: center; }
.song-row:focus-visible { outline: 2px solid var(--cobalt); outline-offset: -2px; }
.song-row[disabled] { cursor: default; color: var(--meta); }
.song-name { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; }
.staff { height: 34px; position: relative; background: repeating-linear-gradient(to bottom, transparent 0 5px, var(--meta) 5px 6px, transparent 6px 7px); opacity: .7; }
.staff .note-dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--cobalt); border: 1px solid var(--ink); transform: translate(-50%, -50%); }
.song-row.playing .staff { opacity: 1; }

.howto-card { position: fixed; z-index: 30; inset: 0; padding: 18px 16px; display: grid; place-items: center; background: rgba(20,20,20,.38); }
.howto-inner { width: min(100%, 360px); background: var(--paper); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 16px; }
.howto-inner h2 { margin: 0 0 10px; font-family: var(--display); font-size: 22px; text-transform: uppercase; }
.howto-pictures { display: flex; justify-content: center; margin: 2px 0 10px; }
.howto-pictures img { width: min(100%, 200px); height: auto; max-height: 30vh; display: block; }
.howto-kicker { margin: 0 0 4px; font-size: 12px; color: var(--meta); letter-spacing: .04em; text-transform: uppercase; }
.howto-nav { display: flex; gap: 10px; align-items: center; }
.howto-nav .btn { min-height: 44px; }
.howto-dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.howto-dots i { width: 8px; height: 8px; border: 1.5px solid var(--ink); display: block; }
.howto-dots i.on { background: var(--cobalt); border-color: var(--cobalt); }
.ha-t { font-family: var(--mono); font-size: 9px; fill: var(--ink); }
.ha-cap { font-family: var(--mono); font-size: 10px; fill: var(--ink); text-anchor: middle; }
.ha-cap.good { fill: var(--cobalt); }
.howto-inner ul { margin: 0 0 14px; padding-left: 20px; font-size: 16px; line-height: 1.35; }
.howto-inner li + li { margin-top: 4px; }
.howto-start { min-width: 112px; }

@media (max-width: 359px) {
  main { padding: 0 10px 32px; }
  .mast { margin: 0 10px; }
  .word { font-size: 16px; }
  .brand svg { width: 18px; height: 18px; }
  .mono-link { min-width: 44px; padding: 0 5px; font-size: 11px; }
  .btn { padding: 0 12px; }
  .ch { grid-template-columns: 6.2em 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  #board .mover { transition: none; }
  .pulse, .preview-pin.caught .pin-art, .catch-ring.flash, .tile-art.lean, .tile-art.flinch, .demo-slide { animation: none; }
  .btn { transition: none; }
}

.credit { margin: 14px 0 0; font-size: 12px; line-height: 1.45; opacity: .65; }
