/* Original blocky side-scrolling scene; Chinese text keeps Madmi's normal font. */
body[data-route="runner"] #app {
  width: 100%; max-width: none; min-height: 100dvh; border: 0; box-shadow: none;
}
body[data-route="runner"] #app-header,
body[data-route="runner"] #bottom-nav { display: none !important; }
body[data-route="runner"] #view { padding: 0 !important; min-height: 100dvh; overflow: hidden; }

.hwr-game, .hwr-setup { font-family: system-ui, sans-serif; color: #152129; }
.hwr-game { position: relative; display: grid; grid-template-rows: 50% 50%; width: 100%; height: 100dvh; overflow: hidden; }
body[data-route="runner"] #view > .hwr-game { padding: 0 !important; max-width: none; }
.hwr-world { position: relative; overflow: hidden; background: linear-gradient(#69baf5, #99d8fa 78%); }
.hwr-hud { position: absolute; z-index: 6; inset: max(env(safe-area-inset-top), 10px) clamp(12px, 3vw, 40px) auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hwr-level, .hwr-pause, .hwr-word-meta > span, .hwr-coverage { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 900; }
.hwr-level, .hwr-pause, .hwr-word-meta > span { border: 3px solid #384049; background: #ecf0ee; box-shadow: 3px 3px 0 #66717b, inset 2px 2px 0 #fff; padding: 5px 10px; }
.hwr-level { font-size: clamp(15px, 2.1vw, 22px); white-space: nowrap; }
.hwr-hearts { display: flex; align-items: center; gap: clamp(4px, 1.5vw, 16px); white-space: nowrap; }
.hwr-heart { color: #273746; font-size: clamp(22px, 3.2vw, 34px); line-height: 1; text-shadow: 2px 2px 0 #101820; }
.hwr-heart.is-full { color: #ed3d3d; }
.hwr-pause { cursor: pointer; min-width: 44px; min-height: 44px; font-size: 20px; line-height: 1; }
.hwr-target { position: absolute; z-index: 4; top: clamp(58px, 13%, 100px); left: 50%; transform: translateX(-50%); display: flex; justify-content: center; max-width: calc(100% - 32px); white-space: nowrap; font-family: "Noto Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: clamp(42px, min(8vw, 7vh), 82px); font-weight: 700; line-height: 1.15; letter-spacing: .025em; color: #101820; text-shadow: 0 2px 0 #ffffff80; }
.hwr-target > span { padding: 0 .015em .025em; border-bottom: .06em solid transparent; }
.hwr-target > span.is-active { border-bottom-color: #193740; }
.hwr-target > span.is-done { color: #315c57; }
.hwr-meaning { position: absolute; z-index: 4; top: clamp(122px, 27%, 188px); left: 50%; transform: translateX(-50%); max-width: min(82vw, 680px); overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(11px, 1.7vw, 17px); font-weight: 600; }
.hwr-word-meta { position: absolute; z-index: 4; top: clamp(133px, 34%, 210px); left: 50%; display: flex; align-items: center; gap: 10px; transform: translateX(-50%); white-space: nowrap; }
.hwr-word-meta > span { font-size: clamp(12px, 1.8vw, 18px); }
.hwr-cloud { position: absolute; width: 80px; height: 22px; background: #fff; opacity: .72; box-shadow: 18px -14px #fff, 42px -10px #fff, 62px 0 #fff; }
.hwr-cloud-one { top: 24%; left: 7%; transform: scale(.8); }
.hwr-cloud-two { top: 21%; right: 10%; transform: scale(.58); }
.hwr-scene { position: absolute; z-index: 2; inset: 0 0 calc(20% - 18px); height: auto; pointer-events: none; }
.hwr-motion-canvas { display: block; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
.hwr-stickman { --hwr-run-cycle: 1.6s; position: absolute; left: 13%; bottom: 0; width: clamp(120px, 18vw, 170px); height: clamp(120px, 18vw, 170px); background: url('./hsk-writing-runner-sprites.v1.png') 0 0 / 400% 400% no-repeat; image-rendering: pixelated; animation: hwr-run-frames var(--hwr-run-cycle) steps(1, end) infinite; transform-origin: 50% 90%; }
.hwr-game[data-hwr-paused="true"] .hwr-stickman { animation-play-state: paused; }
.hwr-ground { position: absolute; z-index: 1; inset: auto 0 0; height: 20%; padding: 5px clamp(12px, 3vw, 40px) 7px; background: repeating-linear-gradient(90deg, #8c6646 0 20px, #9e7955 20px 40px); border-top: clamp(11px, 2vw, 18px) solid #4f953e; box-shadow: inset 0 7px #6fb24b; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px; }
.hwr-coverage { color: #fff; text-shadow: 2px 2px #453220; font-size: clamp(11px, 1.4vw, 16px); white-space: nowrap; }
.hwr-progress-track { display: block; width: min(80%, 580px); height: clamp(8px, 1.4vw, 15px); border: 2px solid #384049; background: #e3e7e4; box-shadow: 2px 2px #443429; }
.hwr-progress-fill { display: block; height: 100%; background: #63ca45; }
.hwr-message { position: absolute; z-index: 7; bottom: 1%; left: 50%; width: min(90%, 560px); transform: translateX(-50%); margin: 0; text-align: center; font-size: clamp(10px, 1.5vw, 15px); line-height: 1.2; font-weight: 700; color: #fff; text-shadow: 1px 2px #453220; pointer-events: none; }
.hwr-ground { padding-top: calc(20px - clamp(11px, 2vw, 18px)); gap: 2px; }
.hwr-coverage { line-height: 1.15; }
.hwr-progress-track { height: clamp(8px, 1.4vh, 10px); }
.hwr-writing { display: flex; flex-direction: column; min-height: 0; padding: clamp(8px, 1.4vh, 16px) clamp(12px, 3vw, 40px) max(env(safe-area-inset-bottom), 12px); background: #eaf0ec; }
.hwr-canvas { display: block; flex: 1; min-height: 0; width: 100%; height: 0; overflow: hidden; background: #fff; touch-action: none; overscroll-behavior: contain; }
.hwr-writing-controls { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.hwr-writing-controls button { min-height: 44px; border: 3px solid #35414b; padding: 7px 18px; font: 800 14px system-ui, sans-serif; box-shadow: 3px 3px 0 #b2bcb5; cursor: pointer; }
.hwr-clear { background: #fff; color: #152129; }
.hwr-check { background: #328c50; color: #fff; }
.hwr-overlay { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: #0e1c28ac; }
.hwr-overlay[hidden] { display: none; }
.hwr-overlay-card { width: min(100%, 420px); padding: 24px; border: 4px solid #35414b; background: #f6f6ed; box-shadow: 7px 7px 0 #20313b; text-align: center; }
.hwr-overlay-card h2 { margin: 0; font-size: 26px; font-weight: 900; }
.hwr-overlay-card p { margin: 10px 0 20px; font-size: 14px; line-height: 1.5; }
.hwr-overlay-actions { display: grid; gap: 10px; }
.hwr-primary, .hwr-secondary { min-height: 46px; border: 3px solid #35414b; padding: 9px 16px; font-size: 15px; font-weight: 900; cursor: pointer; }
.hwr-primary { color: #fff; background: #328c50; box-shadow: 3px 3px #235839; }
.hwr-secondary { color: #152129; background: #e6e9e0; box-shadow: 3px 3px #b2bcb5; }
.hwr-primary:disabled { opacity: .55; cursor: progress; }
.hwr-setup { min-height: 100dvh; background: #88c9f4; }
.hwr-setup-top { display: flex; align-items: center; justify-content: space-between; padding: max(env(safe-area-inset-top), 16px) clamp(16px, 4vw, 42px); font-weight: 900; }
.hwr-setup-top a { display: grid; place-items: center; width: 42px; height: 42px; border: 3px solid #35414b; background: #fff; font-size: 23px; text-decoration: none; color: inherit; }
.hwr-setup-scene { position: relative; height: min(20vh, 155px); overflow: hidden; }
.hwr-setup-runner { bottom: 23px; left: 28%; width: 120px; height: 120px; }
.hwr-setup-ground { position: absolute; inset: auto 0 0; height: 26px; border-top: 8px solid #4f953e; background: repeating-linear-gradient(90deg, #8c6646 0 20px, #9e7955 20px 40px); }
.hwr-setup-panel { width: min(100% - 28px, 520px); margin: 0 auto; padding: clamp(22px, 4vw, 36px); border: 4px solid #35414b; background: #fff; box-shadow: 6px 6px #405a62; }
.hwr-eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 900; color: #367b53; }
.hwr-setup-panel h1 { margin: 4px 0 8px; font-size: clamp(27px, 5vw, 38px); font-weight: 1000; }
.hwr-setup-copy, .hwr-setup-note { font-size: 14px; line-height: 1.5; color: #47545b; }
.hwr-setup-panel label, .hwr-setup-panel legend { display: block; margin: 19px 0 8px; font-weight: 800; font-size: 14px; }
.hwr-setup-panel select { width: 100%; min-height: 48px; padding: 8px 12px; border: 2px solid #49595c; background: #fff; font: inherit; }
.hwr-setup-panel fieldset { border: 0; margin: 0; padding: 0; }
.hwr-time-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hwr-time-options label { margin: 0; cursor: pointer; }
.hwr-time-options input { position: absolute; opacity: 0; }
.hwr-time-options span { display: grid; place-items: center; min-height: 50px; border: 2px solid #49595c; background: #f1f4f0; font-weight: 900; }
.hwr-time-options input:checked + span { color: #fff; background: #328c50; box-shadow: inset 0 0 0 2px #328c50; }
.hwr-time-options input:focus-visible + span { outline: 3px solid #0b4d9a; outline-offset: 2px; }
.hwr-setup-panel > .hwr-primary { width: 100%; margin-top: 14px; }
.hwr-setup-error { min-height: 22px; margin: 10px 0 0; color: #b1322a; font-size: 13px; }
@keyframes hwr-run-frames {
  0% { background-position: 0% 0%; }
  6.25% { background-position: 33.333% 0%; }
  12.5% { background-position: 66.667% 0%; }
  18.75% { background-position: 100% 0%; }
  25% { background-position: 0% 33.333%; }
  31.25% { background-position: 33.333% 33.333%; }
  37.5% { background-position: 66.667% 33.333%; }
  43.75% { background-position: 100% 33.333%; }
  50% { background-position: 0% 66.667%; }
  56.25% { background-position: 33.333% 66.667%; }
  62.5% { background-position: 66.667% 66.667%; }
  68.75% { background-position: 100% 66.667%; }
  75% { background-position: 0% 100%; }
  81.25% { background-position: 33.333% 100%; }
  87.5% { background-position: 66.667% 100%; }
  93.75% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}
@media (prefers-reduced-motion: reduce) {
  .hwr-stickman, .hwr-setup-runner { animation: none !important; }
  .hwr-game[data-hwr-action] .hwr-stickman { animation: none !important; }
}
@media (max-height: 650px) { .hwr-meaning { display: none; } .hwr-setup-scene { height: 75px; } }
