:root {
  color-scheme: dark;
  font: 16px/1.55 system-ui, "Malgun Gothic", sans-serif;
  --ink: #f4e9d8;
  --muted: #c2b19a;
  --gold: #edd397;
  --line: #594b39;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(ellipse at 48% 0, #30271a, #15130f 65%); min-height: 100vh; }
main { width: min(100% - 32px, 1160px); margin: 0 auto; padding: clamp(14px, 3.3vw, 43px) 0; }
.chapter-header { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; align-items: end; margin-bottom: 13px; }
nav { grid-column: 1 / -1; display: flex; gap: 20px; font-size: .9rem; margin-bottom: 5px; }
a { color: var(--gold); text-underline-offset: 4px; }
h1, h2, p, figure { margin: 0; }
h1 { font: 600 clamp(2.15rem, 4vw, 3.7rem)/1.25 "Batang", "Malgun Gothic", Georgia, serif; }
.chapter-header p { color: var(--muted); padding-bottom: .25rem; }
.chapter { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #221c15; box-shadow: 0 17px 52px #0a0906a0; }
.stage { position: relative; aspect-ratio: 16 / 9; isolation: isolate; background: #282017; touch-action: manipulation; }
.stage > canvas, .cover { position: absolute; inset: 0; width: 100%; height: 100%; }
#effects { pointer-events: none; }
.cover { display: grid; place-items: center; background: #10100c65; text-align: center; padding: 12px; }
.cover > div { border: 1px solid #a1835c; padding: clamp(13px, 2.8vw, 30px) clamp(26px, 5vw, 55px); border-radius: 7px; background: #241b13ed; }
.cover p { color: var(--muted); margin-bottom: 10px; }
.start-options, .settings { display: flex; flex-wrap: wrap; gap: .45rem; }
.start-options { justify-content: center; }
.settings { margin-left: auto; }
#auto-mode { font-size: .875rem; }
#auto-mode[aria-pressed="true"] { color: #27200f; background: #e0c489; border-color: #f4dca5; }
.cover h2 { margin: 0 0 16px; font: 600 clamp(1.7rem,3vw,2.7rem)/1.25 "Batang", Georgia, serif; }
.ending { animation: fade-in 740ms ease-out both; place-items: end; background: linear-gradient(0deg,#15130fe0, #15130f00 59%); }
.ending > div { padding: clamp(10px, 2vw, 18px) clamp(14px, 3vw, 34px); text-align: left; }
.ending h2 { margin-bottom: 9px; }
.ending p { margin-bottom: 3px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.calendar { position: absolute; left: clamp(8px,2vw,20px); top: clamp(8px,2vw,20px); padding: .34rem .65rem; display: grid; border: 1px solid #bb9a69a3; border-radius: 4px; background: #19170fea; pointer-events: none; }
.combo { position: absolute; right: clamp(8px,2vw,20px); top: clamp(8px,2vw,20px); padding: .35rem .65rem; display: grid; text-align: right; border-radius: 4px; background: #19170fea; color: #ffe1a1; pointer-events: none; }
.combo strong { font-size: clamp(1rem,2vw,1.24rem); }
.combo span { font-size: .875rem; color: var(--ink); }
.combo :empty { display: none; }
#phase { font-size: clamp(.9rem,1.75vw,1.16rem); color: var(--gold); font-weight: 700; }
#age { font-size: .875rem; color: var(--ink); }
figcaption { min-height: 3rem; padding: 9px 20px; text-align: center; display: grid; align-content: center; background: #272017; }
#caption { font-size: 1rem; font-weight: 550; }
.controls { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); }
#training-progress { flex: 1 1 100px; max-width: 270px; display: grid; gap: 3px; color: var(--muted); font-size: .9rem; }
progress { inline-size: 100%; block-size: 9px; accent-color: #e7bc73; }
button, .button { font: inherit; cursor: pointer; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: .45rem .8rem; min-height: 44px; display: inline-flex; align-items: center; gap: .55rem; background: #35291d; text-decoration: none; }
.primary { background: #dcb87a; color: #261907; border-color: #eed698; font-weight: 750; }
[data-phase="bash"] ~ figcaption #caption, [data-bash-stage="strike"] ~ figcaption #caption { color: #bdf4ff; }
.chapter:has([data-phase="bash"]) #bash { background: #a6eafa; color: #152a30; border-color: #ebfbff; }
.sword-forms { display: flex; flex-wrap: wrap; gap: 6px; }
.form { border-color: #8e724b; }
.form small { display: block; font-size: .74em; line-height: 1; text-align: left; color: #ddd0b6; }
.form[data-two-handed] small { color: #f2ce8e; }
.form[data-queued] small { color: inherit; }
.form[data-current] { background: #6a4d29; border-color: #d4a75e; }
.form[data-queued] { background: #dcb87a; color: #261907; border-color: #eed698; opacity: 1; }
button:disabled { opacity: .6; cursor: default; }
button:hover, .button:hover { filter: brightness(1.14); }
a:focus-visible, button:focus-visible { outline: 2px solid #ffdc8b; outline-offset: 3px; }
kbd { font: 700 .8rem/1 ui-monospace, monospace; border: 1px solid #35221090; border-radius: 4px; padding: .24rem .35rem; }
.sound { font-size: .875rem; }
[hidden] { display: none !important; }
@media (min-width: 700px) and (min-height: 530px) {
  main {
    width: min(100% - 32px, 1160px, max(520px, calc((100svh - 242px) * 1.7778)));
    padding-block: clamp(12px, 2.2vh, 30px);
  }
}
@media (max-width: 550px) {
  main { width: calc(100% - 16px); }
  .chapter-header p { font-size: .8rem; }
  figcaption { padding-inline: 8px; }
  .controls { padding-inline: 8px; }
  .sword-forms { flex: 1 1 100%; display: grid; grid-template-columns: repeat(2,1fr); }
  .form { padding-inline: .35rem; justify-content: center; gap: .28rem; white-space: nowrap; font-size: .875rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ending { animation: none; }
}
