* { box-sizing: border-box; }

:root {
  color-scheme: dark;
  background: #0a1518;
  color: #edeadb;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --gold: #f1d391;
  --muted: #bac7c2;
  --edge: #526564;
  --ink: #081719;
  --serif: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 52% 18%, #172b2b, transparent 69%);
}

[hidden] { display: none !important; }
.frame { width: min(100% - 4rem, 79rem); margin: auto; padding-bottom: 1.75rem; }
.masthead { display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: .8rem; }
.brand, .quick { display: flex; align-items: center; gap: .75rem; }
.mark { display: grid; place-items: center; width: 23px; height: 23px; flex: none; rotate: 45deg; border: 1px solid #bda97d; }
.mark::after { content: ""; width: 10px; height: 10px; box-shadow: 0 0 11px #e9b4538a; background: var(--gold); }
h1 { margin: 0 .18rem; font: 400 clamp(1.2rem, 2vw, 1.65rem)/1.1 var(--serif); letter-spacing: .14em; white-space: nowrap; }
button, select { font: inherit; color: inherit; }
button { background: #192d30; border: 1px solid #61706b; cursor: pointer; border-radius: 6px; }
button:hover:enabled { background: #293c3e; }
button:disabled { opacity: .52; cursor: default; }
button:focus-visible, input:focus-visible + span, select:focus-visible { outline: 2px solid #f6d693; outline-offset: 3px; }
.quick { gap: .5rem; }
.quick button { min-height: 42px; padding: .25rem .72rem; font-size: .87rem; white-space: nowrap; }
#sound-state { margin-left: .42rem; color: #b8cbc4; }
kbd { color: #e8e5d6; font-family: inherit; font-size: .78rem; line-height: 1.1; padding: .14em .4em; border: 1px solid #586966; border-radius: 3px; white-space: nowrap; }
.quick kbd { margin-left: .15rem; }

.game {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(410px, calc(100svh - 155px), 692px);
  min-width: 0;
  border: 1px solid var(--edge);
  border-radius: 11px;
  background: #113638 url("assets/forest.webp") 50% 64% / cover no-repeat;
  box-shadow: 0 18px 50px #030a0c96;
  outline: none;
}

canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hud { position: absolute; inset: 0 0 auto; display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; background: linear-gradient(#050f15cc, #050f1560, transparent); pointer-events: none; }
.hud-left, .hud-right { display: flex; align-items: center; gap: .8rem; }
.chapter { color: #fff3d2; font-size: .92rem; white-space: nowrap; letter-spacing: .06em; }
.health { display: flex; gap: 5px; align-items: center; }
.health i { width: 12px; height: 15px; background: #ffb987; clip-path: polygon(50% 0, 100% 31%, 82% 77%, 50% 100%, 18% 77%, 0 31%); }
.health i.lost { background: #5b5d57; }
.lantern-count { display: flex; gap: .42rem; align-items: center; font-size: .89rem; white-space: nowrap; color: #ffdfa2; }
.lantern-count i { width: 9px; height: 9px; background: var(--gold); rotate: 45deg; box-shadow: 0 0 9px #fdd891a0; }
.element { min-width: 2.25rem; text-align: center; padding: .25rem .5rem; border: 1px solid currentColor; border-radius: 999px; font-size: .85rem; font-weight: 700; background: #0e202a; }
.element[data-element="frost"] { color: #b5efff; }
.element[data-element="ember"] { color: #ffc097; }
.dash-meter { width: 43px; height: 4px; background: #546c6b; border-radius: 8px; }
.dash-meter i { display: block; height: 100%; border-radius: 8px; background: #cdede2; transform: scaleX(1); transform-origin: left; }
.boss { position: absolute; top: 3.7rem; left: 50%; translate: -50%; display: flex; align-items: center; gap: .6rem; color: #ffe3c7; font-size: .83rem; white-space: nowrap; }
.boss progress { accent-color: #e49877; width: min(24vw, 195px); height: 10px; }
.banner { position: absolute; bottom: 6%; left: 50%; translate: -50%; width: max-content; max-width: 92%; margin: 0; padding: .56rem .85rem; border: 1px solid #b6b68a; border-radius: 6px; background: #0b1b1eed; color: #ffe3a3; font-size: .9rem; text-align: center; pointer-events: none; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; min-height: 0; overflow: auto; }
.camp { background: linear-gradient(90deg, #071719f5, #091b20d8 34%, #091b2070 62%, #091b2023 83%), linear-gradient(0deg,#0817199c,transparent 40%); }
.menu { width: min(100%, 43rem); padding: 1.4rem clamp(1.6rem, 6vw, 5.5rem); }
.menu h2 { margin: 0; color: #fbefd1; font: 400 clamp(3rem, 6.3vw, 6.2rem)/1.09 var(--serif); letter-spacing: .08em; text-wrap: balance; }
.menu p { margin: .9rem 0 1.4rem; color: #dfdbca; line-height: 1.6; font-size: 1rem; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { margin-bottom: .42rem; color: #dad5bf; font-size: .87rem; }
.options { display: flex; flex-wrap: wrap; gap: .4rem; }
.options label { position: relative; cursor: pointer; }
.options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.options span { display: inline-flex; min-height: 42px; min-width: 65px; align-items: center; justify-content: center; padding: .34rem .7rem; border: 1px solid #6c7871; border-radius: 5px; background: #1a2a2c; color: #e8e7d6; font-size: .9rem; }
.options label:hover span { background: #283a3b; }
.options input:checked + span { color: #ffe1a1; background: #39403a; border-color: #ecd097; }
.menu .difficulty-note { margin: .55rem 0 1.25rem; color: #d4d0ba; font-size: .87rem; line-height: 1.5; }
.choose-chapter { display: flex; align-items: center; gap: .55rem; margin-bottom: .7rem; font-size: .89rem; }
.choose-chapter select { min-height: 36px; padding-inline: .52rem; background: #14272a; border: 1px solid #72847c; border-radius: 5px; }
.primary { min-height: 46px; padding: .48rem 1rem; background: #efd49a; color: #222217; border: 1px solid #ffdd9c; font-weight: 700; }
.primary:hover:enabled { background: #ffe7b1; }
.interrupted { background: #091719dd; justify-content: center; text-align: center; }
.state-menu { padding-inline: 1rem; }
.state-menu h2 { font-size: clamp(2.3rem, 5.2vw, 4.25rem); }
.state-menu p { margin-inline: auto; max-width: 32ch; }
.state-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
.state-actions button { min-height: 45px; padding: .5rem .85rem; font-size: .93rem; }

.under-stage { display: flex; justify-content: space-between; align-items: center; gap: .9rem; min-height: 65px; }
.hint { margin: 0; color: var(--muted); font-size: .91rem; line-height: 1.5; }
.keys { display: flex; justify-content: flex-end; gap: .7rem; flex-wrap: wrap; flex: none; color: #d0d7cc; font-size: .83rem; }
.keys span { white-space: nowrap; }
.keys kbd { margin-right: .15rem; }
.touch-controls { display: none; gap: .38rem; align-items: center; justify-content: space-between; }
.touch-group { display: flex; align-items: center; gap: .3rem; }
.touch-group button { min-height: 46px; min-width: 44px; padding: 0 .25rem; touch-action: none; user-select: none; -webkit-tap-highlight-color: transparent; font-size: .82rem; }
.touch-group .touch-jump { background: #e8cc8f; color: #212619; border-color: #ffe9b2; }
.touch-group button.held { background: #394b46; box-shadow: inset 0 0 0 1px #eed49d; }
.touch-group .touch-jump.held { background: #ffdf9e; }

@media (max-width: 950px) {
  .under-stage { flex-wrap: wrap; align-content: center; justify-content: flex-start; gap: .35rem 1rem; }
}
@media (max-width: 720px) {
  .frame { width: calc(100% - 1.45rem); }
  .masthead { min-height: 59px; }
  .brand, .quick { gap: .45rem; }
  .mark { width: 17px; height: 17px; margin-left: 3px; }
  .mark::after { width: 7px; height: 7px; }
  .quick button { min-height: 40px; padding-inline: .51rem; }
  .quick kbd { display: none; }
  .game { height: clamp(328px, 55svh, 535px); }
  .camp { background: linear-gradient(90deg, #08181bef, #08181b9c 88%); }
  .menu { padding: .92rem 1rem; }
  .menu h2 { font-size: clamp(2.35rem, 8.5vw, 3.75rem); }
  .menu p { margin: .6rem 0 .78rem; font-size: .9rem; }
  .menu .difficulty-note { margin-bottom: .8rem; }
  .hud { padding: .5rem; }
  .hud-left, .hud-right { gap: .45rem; }
  .chapter, .lantern-count { font-size: .78rem; }
  .health { gap: 3px; }
  .health i { width: 9px; height: 12px; }
  .dash-meter { width: 28px; }
  .under-stage { min-height: 52px; }
  .hint { font-size: .84rem; }
  .touch-controls { display: flex; }
  .keys { display: none; }
}
@media (pointer: coarse) { .touch-controls { display: flex; } .keys { display: none; } }
@media (orientation: landscape) and (pointer: coarse) and (max-height: 550px) {
  .frame { padding-bottom: .5rem; }
  .masthead { min-height: 46px; }
  .game { height: max(240px, calc(100svh - 126px)); }
  .menu h2 { font-size: 2.25rem; }
  .menu p { margin: .4rem 0 .55rem; }
  .under-stage { min-height: 30px; }
}
