:root {
  color-scheme: dark;
  --background: #102621;
  --panel: #17322a;
  --ink: #122b24;
  --text: #f2faf1;
  --muted: #a7bdb1;
  --lime: #d9fa69;
  --line: #37534a;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at 50% 0%, #254239, var(--background) 76%); color: var(--text); }
button { font: inherit; border: 0; cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #f6ffd5; outline-offset: 4px; }
.app { width: min(100%, 1540px); min-height: 100svh; margin: 0 auto; padding-inline: clamp(16px, 3vw, 52px); display: flex; flex-direction: column; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 19px; font-weight: 900; letter-spacing: -.055em; line-height: 1; }
.brand-icon { width: 36px; height: 36px; padding: 4px; border-radius: 10px; background: var(--lime); color: var(--ink); }
.brand-accent { color: var(--lime); margin-left: 2px; }
.top-actions { display: flex; gap: 10px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; background: #ffffff09; border: 1px solid #ffffff27; border-radius: 11px; }
.icon-button:hover, .developer-button:hover { background: #ffffff18; }
.developer-button { display: flex; align-items: center; gap: 7px; padding: 0 9px; background: #ffffff09; border: 1px solid #ffffff27; border-radius: 11px; color: #e1eade; font-size: 13px; font-weight: 800; }
.developer-button > span:first-child { color: #e2f8ae; font: 800 11px/1 system-ui, sans-serif; border: 1px solid #c9e87b59; background: #bceb741a; border-radius: 5px; padding: 4px; }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-button[aria-pressed="false"] .on, .icon-button[aria-pressed="true"] .off { display: none; }
.stage { position: relative; flex: 1; isolation: isolate; overflow: hidden; min-height: 540px; border-radius: 22px; border: 1px solid #78938880; background: #669998; box-shadow: 0 22px 70px #06161185; touch-action: none; user-select: none; }
#scene, .vignette { position: absolute; width: 100%; height: 100%; inset: 0; }
#scene { display: block; }
.vignette { pointer-events: none; background: linear-gradient(#0b2a2b69, transparent 20%, transparent 80%, #132e2773); transition: background .25s ease; }
.stage[data-view="intro"] .vignette { background: linear-gradient(90deg, #112920fa 0%, #112c24e8 24%, #162c2480 44%, transparent 73%), linear-gradient(0deg, #14352b70, transparent 30%); }
.overlay { position: absolute; inset: 0; display: grid; }
.intro { align-items: center; justify-items: start; pointer-events: none; padding: 20px 7%; }
.intro-content { pointer-events: auto; }
.eyebrow { width: fit-content; margin: 0 0 22px; display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 800; letter-spacing: .065em; color: #e4f9c1; border: 1px solid #d6f88c4d; background: #a6d75815; border-radius: 7px; padding: 6px 11px; }
.eyebrow i, .footer-dot { width: 7px; height: 7px; border-radius: 50%; background: #cbf36c; box-shadow: 0 0 12px #c3ed72a0; }
h1 { margin: 0; font-family: "Arial Black", "Avenir Next", system-ui, sans-serif; font-size: clamp(70px, 9.4vw, 145px); font-weight: 950; line-height: .77; letter-spacing: -.092em; text-shadow: 0 6px 13px #0b211d80; }
h1 > span { display: block; }
h1 > span + span { color: var(--lime); margin-top: .105em; }
.period { color: #f0ffbb; }
.intro-copy { margin: 25px 0 22px; font-size: clamp(16px, 1.6vw, 20px); color: #ecf4e9; line-height: 1.62; font-weight: 680; letter-spacing: .025em; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--lime); color: var(--ink); border: 1px solid #ebffab; border-radius: 10px; padding: 0 25px; min-height: 51px; min-width: 172px; font-size: 16px; font-weight: 900; box-shadow: 0 4px 0 #7fa344, 0 8px 18px #0b201b5e; transition: background .15s, transform .15s, box-shadow .15s; }
.primary:hover { background: #e9ff9d; transform: translateY(-1px); }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #7fa344; }
.primary svg { width: 18px; height: 18px; }
.run-time { margin-top: 15px; display: flex; align-items: center; gap: 6px; color: #c3d3c0; font-size: 13px; font-weight: 650; }
.run-time svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.5; }
.footer { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; min-height: 56px; color: var(--muted); font-size: 14px; font-weight: 680; }
.controls, .footer-stage, .auto { display: flex; align-items: center; gap: 7px; }
.touch-controls { display: none; }
.footer-stage { gap: 10px; justify-self: center; white-space: nowrap; }
.footer-stage strong { color: #e6f3e8; font-weight: 800; }
.auto { justify-self: end; white-space: nowrap; }
.auto span { color: var(--lime); }
kbd { display: inline-grid; min-width: 24px; height: 24px; place-items: center; background: #ffffff09; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: #e6f3e8; font-family: inherit; }
.or { color: #7e9b8d; margin-inline: 2px; }

.hud { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.route, .boss-hud { border: 1px solid #ccefe05e; background: #15322bee; border-radius: 12px; box-shadow: 0 4px 10px #1b3d3455; }
.route { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; width: 63px; height: clamp(223px, 69%, 470px); padding: 13px 4px 11px; gap: 7px; color: #edf4df; background: linear-gradient(120deg, #203f37, #132d28); border-color: #9aa77e90; box-shadow: inset 0 0 0 3px #1b352b, 0 5px 13px #263e3675; }
.route-caption { font-weight: 780; font-size: 12px; line-height: 1; }
#route-text { font-weight: 900; font-size: 24px; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.route-debug { display: none; color: #dfff93; font: 850 9px/1 system-ui, sans-serif; }
.stage[data-debug="true"] .route-debug { display: block; }
#progress-text { font-weight: 850; font-size: 12px; line-height: 1.05; }
.progress-track { position: relative; flex: 1; width: 11px; margin: 12px 0 3px; background: #274840; border: 1px solid #7e997660; border-radius: 4px; }
.progress-track i { position: absolute; inset: 1px; border-radius: 2px; background: linear-gradient(#e1ee9b, #74b876); transform: scaleY(0); transform-origin: center bottom; }
.progress-track span { position: absolute; bottom: var(--mark); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: #234134; border: 1px solid #8ea782; color: #bacbaa; left: 50%; transform: translate(-50%, 50%); }
.progress-track span b { font: 850 11px/1 system-ui, sans-serif; }
.progress-track span[data-state="next"] { background: #e4c37e; color: #263934; border-color: #fff0b2; }
.progress-track span[data-state="clear"] { background: #7da772; color: #132f27; border-color: #b9e18c; }
.progress-track span:last-child[data-state="ahead"] { border-color: #c69c75; color: #e1aa86; }
.boss-hud { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); width: min(385px, calc(100% - 96px)); background: #302f38f1; border-color: #f29b826e; padding: 7px 11px 8px; }
.boss-heading { display: flex; align-items: center; justify-content: space-between; gap: 7px; white-space: nowrap; }
#boss-name { font-weight: 900; font-size: 14px; color: #ffe8cb; }
#boss-state { font-weight: 800; font-size: 12px; color: #e2ff9b; }
.boss-hud[data-guard="true"] #boss-state { color: #a6edfa; }
.boss-track { position: relative; height: 15px; margin-top: 4px; overflow: hidden; background: #653f46; border-radius: 4px; }
.boss-track i { position: absolute; inset: 0; background: linear-gradient(90deg, #c65e60, #f0a16d); transform: scaleX(0); transform-origin: left; }
#boss-value { position: absolute; inset: 0; color: #fff0dc; font-weight: 850; font-size: 11px; line-height: 15px; text-align: center; text-shadow: 0 1px 3px #402625; white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.question { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.target-number, .gate { position: absolute; transform: translate(-50%, -50%); }
.target-number { display: grid; place-items: center; min-width: 48px; min-height: 45px; padding: 0 8px; border-radius: 10px; border: 2px solid #d4aeff; background: #332650; color: #fff1b1; font: 950 clamp(25px, 4vw, 38px)/1 system-ui, sans-serif; box-shadow: 0 5px 0 #291b44, 0 7px 14px #15273760; }
.target-number::after { content: ""; position: absolute; top: 100%; left: calc(50% - 6px); border: 6px solid transparent; border-top-color: #d4aeff; }
.gate { --gate-ink: #d5fff6; --gate-bg: #164f51; --gate-border: #5af0d1; pointer-events: auto; display: grid; place-items: center; white-space: nowrap; min-height: 49px; min-width: clamp(109px, 12vw, 166px); border-radius: 10px; padding: 4px 10px; background: var(--gate-bg); color: var(--gate-ink); border: 2px solid var(--gate-border); box-shadow: 0 5px 0 #0f302b, 0 8px 12px #203e3155; font: 900 clamp(17px, 3.6vw, 30px)/1.05 system-ui, sans-serif; }
.gate-right { --gate-ink: #ffefd7; --gate-bg: #695037; --gate-border: #ffd286; }
.gate:hover, .gate[data-selected="true"] { filter: brightness(1.23); }
.gate[data-selected="true"]::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; bottom: -13px; background: var(--gate-border); }
.gate[data-long="true"] { font-size: clamp(14px, 3.1vw, 25px); }
.rune-overlay { z-index: 2; }
.rune-stone, .rune-number { position: absolute; transform: translate(-50%, -50%); text-align: center; }
.rune-number { padding: 3px 8px 5px; min-width: 65px; color: #fff1b7; background: #322a4a; border: 2px solid #d2b2fa; border-radius: 8px; box-shadow: 0 3px 0 #221a355e; }
.rune-number small { display: block; font-weight: 850; font-size: 11px; line-height: 1.12; white-space: nowrap; }
.rune-number strong { display: block; font: 950 clamp(18px, 4.5vw, 27px)/1 system-ui, sans-serif; }
.rune-stone { pointer-events: auto; min-width: 90px; padding: 5px 8px 6px; background: #3f4249; color: #fff1bc; border: 2px solid #d9c09a; border-radius: 8px; box-shadow: 0 3px 0 #302d36a8; white-space: nowrap; font: 900 clamp(16px, 3.65vw, 25px)/1.05 system-ui, sans-serif; }
.rune-overlay[data-kind="dragon"] .rune-stone { background: #652e37; border-color: #ffa470; }
.rune-stone i { display: block; height: 3px; border-radius: 4px; margin-top: 4px; background: #ffcc86; transform-origin: left; }
.rune-stone[data-aim="true"] { border-color: #f6fbd3; box-shadow: 0 0 12px #ffdd9280; }
.rune-stone[data-blocked="true"] { color: #d3cebd; border-color: #8d8977; filter: saturate(.62); }
.rune-stone[data-danger="true"] { color: #ffe6c7; border-color: #f5916e; background: #593a37; }
.rune-stone[data-danger="true"] i { background: #ed8e70; }
.feedback, .announcement { position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); pointer-events: none; text-align: center; white-space: nowrap; font-weight: 900; }
.feedback { bottom: 41%; color: #13372a; padding: 7px 16px 8px; background: #e4ff89; border: 2px solid #f6ffc3; border-radius: 10px; box-shadow: 0 4px 0 #8ab34a, 0 0 26px #e1ff85ad; font-size: clamp(21px, 3.4vw, 34px); line-height: 1.1; transform-origin: center; }
.feedback[data-correct="false"] { border-color: #ffbca8; color: #fff1e7; background: #613b46; box-shadow: 0 4px 0 #432831, 0 0 19px #e8726188; }
.announcement { top: 26%; padding: 9px 15px; border: 1px solid #ffc18090; background: #4b3437; color: #ffe0a8; border-radius: 8px; line-height: 1.3; }
.reward-toast { position: absolute; z-index: 2; left: 50%; bottom: 7.5%; transform: translateX(-50%); padding: 6px 11px; color: #ffe9b4; background: #493d2cec; border: 1px solid #e9bb6d; border-radius: 7px; font-weight: 850; font-size: 14px; text-align: center; white-space: nowrap; pointer-events: none; }
.reward-toast[data-boost="true"] { color: #293223; background: #ffdb86; border-color: #fff2bb; box-shadow: 0 4px 0 #ac783e, 0 0 18px #ffc76575; }
.announcement[data-kind="warning"] { top: auto; bottom: 53%; }
.announcement[data-kind="stage"] {
  top: 35%;
  padding: 10px 17px;
  color: #ecffb6;
  background: #244836;
  border-color: #cce880a8;
}
.gate-flash { position: absolute; z-index: 1; inset: 0; pointer-events: none; opacity: 0; }
.gate-flash[data-flash="up"] {
  background: radial-gradient(ellipse at 50% 61%, transparent 49%, #eaff8299 100%);
  animation: edge-flash .65s ease-out both;
}
.gate-flash[data-flash="down"] {
  background: radial-gradient(ellipse at 50% 62%, transparent 53%, #ff82677a 100%);
  animation: edge-flash .50s ease-out both;
}
.feedback:not([hidden]) { animation: gate-pop .44s cubic-bezier(.21,.68,.28,1.2) both; }
@keyframes gate-pop {
  0% { transform: translate(-50%, 12px) scale(.75); opacity: 0; }
  38% { transform: translate(-50%, -2px) scale(1.10); opacity: 1; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
@keyframes edge-flash { 0% { opacity: .85; } 100% { opacity: 0; } }

.modal-overlay { z-index: 4; align-items: center; justify-items: center; padding: 15px; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; background: #0f2822ae; backdrop-filter: blur(6px); }
.result-panel { width: min(650px, 100%); border: 1px solid #5d8371; border-radius: 19px; background: linear-gradient(#284a3d, #152e27); padding: clamp(18px, 4vw, 36px); text-align: center; box-shadow: 0 16px 50px #07191185; }
.result-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 12px; border: 1px solid #d9fa6970; background: #d9fa6919; border-radius: 16px; color: var(--lime); font: 900 34px/1 system-ui, sans-serif; }
.developer-overlay { z-index: 5; }
.developer-panel { position: relative; max-width: 460px; text-align: left; }
.developer-panel p { margin-bottom: 20px; padding-right: 12px; line-height: 1.5; }
.developer-close { position: absolute; right: 12px; top: 12px; font-size: 23px; }
.developer-panel label { display: block; margin: 0 0 6px; color: #d9ecdf; font-weight: 750; font-size: 14px; }
.debug-stage-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.debug-stage-row input { width: 97px; min-height: 43px; padding: 7px 9px; background: #102920; color: #f1fae7; border: 1px solid #729481; border-radius: 7px; font: 850 18px/1 system-ui, sans-serif; }
.debug-stage-row input:focus-visible { outline: 2px solid #d9fa69; outline-offset: 2px; }
.debug-quick { display: flex; gap: 5px; }
.debug-quick button, .secondary { background: #24463a; color: #f2faf1; border: 1px solid #7fa08c; border-radius: 8px; font-weight: 850; }
.debug-quick button { min-width: 39px; min-height: 41px; }
.debug-quick button[aria-pressed="true"], .debug-quick button:hover, .secondary:hover { border-color: #d9fa69; }
.developer-panel .debug-arsenal { display: flex; align-items: center; gap: 6px; margin: 13px 0 0; }
.debug-arsenal input { width: 16px; height: 16px; accent-color: #cbdf8a; }
.debug-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.debug-actions .primary, .debug-actions .secondary { min-width: 0; padding-inline: 6px; min-height: 48px; }
.developer-exit { margin-top: 15px; padding: 8px 0 3px; background: transparent; color: #e6eece; font-weight: 750; text-decoration: underline; text-underline-offset: 4px; }
.result-panel h2 { margin: 0; font-size: clamp(27px, 5vw, 41px); font-weight: 900; letter-spacing: -.035em; }
.result-panel p { color: #c6dcd0; font-size: 15px; margin: 8px 0 22px; }
.loot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
#result[data-workbench="true"] .result-panel { max-width: 760px; border: 1px solid #91a17c; background: #203b32; box-shadow: inset 0 0 0 5px #263f35, 0 16px 52px #0b211b95; }
#result[data-workbench="true"] .result-panel h2 { color: #f2eccd; }
.loot-card { --reward: #a1dccc; display: grid; grid-template-rows: auto auto 1fr; gap: 8px; min-width: 0; padding: 7px 7px 13px; background: #162e29; border: 1px solid #75917f; border-radius: 9px; text-align: left; color: #ecf2e0; transition: transform .15s, border-color .15s, background .15s; }
.loot-card:hover { transform: translateY(-4px); border-color: var(--reward); background: #28443a; }
.loot-soldier { --reward: #f3cc88; }
.loot-power { --reward: #e9cf95; }
.loot-rate { --reward: #c5dec2; }
.loot-art { display: block; aspect-ratio: 1.68; overflow: hidden; border: 1px solid #75917f73; border-radius: 5px; background-color: #395c50; background-image: linear-gradient(#b8c6a41a 1px, transparent 1px), linear-gradient(90deg, #b8c6a41a 1px, transparent 1px); background-size: 12px 12px; }
.loot-art > canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.loot-card strong { margin: 0 3px; font-size: 16px; color: var(--reward); line-height: 1.2; }
.loot-card > span:last-child { margin: 0 3px; font-size: 13px; line-height: 1.35; }

@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .desktop-controls { display: none; }
}
@media (max-width: 690px) {
  .app { padding-inline: 8px; }
  .touch-controls { display: flex; }
  .desktop-controls { display: none; }
  .topbar { height: 54px; padding-inline: 4px; }
  .brand { font-size: 17px; gap: 8px; }
  .brand-icon { width: 31px; height: 31px; }
  .icon-button { width: 35px; height: 35px; }
  .stage { border-radius: 15px; min-height: 470px; }
  .stage[data-view="intro"] .vignette { background: linear-gradient(180deg, #102b23f8 0%, #142e27d8 30%, #182f2650 58%, #132e2759 100%); }
  .intro { align-items: start; justify-items: center; text-align: center; padding-top: clamp(17px, 6.4svh, 62px); }
  .eyebrow { margin: 0 auto 13px; font-size: 13px; }
  h1 { font-size: clamp(57px, 14vw, 92px); }
  .intro-copy { margin: 17px 0 13px; font-size: 15px; }
  .run-time { margin-top: 9px; justify-content: center; }
  .footer { min-height: 53px; font-size: 12px; padding-inline: 4px; }
  .footer-stage { gap: 6px; }
  .route { left: 4px; width: 43px; height: clamp(197px, 65%, 400px); padding-inline: 2px; }
  .route-caption { font-size: 9px; }
  #route-text { font-size: 18px; }
  .progress-track span { width: 17px; height: 17px; }
  .progress-track span b { font-size: 10px; }
  .boss-hud { top: 7px; width: min(300px, calc(100% - 69px)); }
  .boss-heading { gap: 4px; }
  #boss-name { font-size: 13px; }
  #boss-state { font-size: 11px; }
  .rune-stone, .gate[data-long="true"] { padding-inline: 6px; }
  .debug-actions button { font-size: 13px; }
}
@media (max-width: 690px) and (max-height: 700px) {
  .intro { padding-top: 18px; }
  h1 { font-size: clamp(46px, 12vw, 79px); }
}
@media (max-width: 385px) {
  .top-actions { gap: 5px; }
  .developer-label { display: none; }
  .developer-button { padding-inline: 5px; }
}
@media (max-width: 500px) {
  .loot { grid-template-columns: 1fr; gap: 8px; }
  .loot-card { grid-template-columns: 83px 1fr; grid-template-rows: auto auto; align-items: center; gap: 2px 7px; padding: 5px; }
  .loot-art { grid-row: span 2; }
  .loot-card strong { align-self: end; }
  .loot-card > span:last-child { align-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.target-number small { font: 800 13px/1.3 system-ui; padding-top: 3px; white-space: nowrap; }
.feedback strong, .feedback small { display:block; }
.feedback small { font: 800 clamp(13px,2vw,17px)/1.5 system-ui; }

.target-number em { font: 800 13px/1.4 system-ui; padding: 1px 5px 3px; color:#bdffe1; white-space:nowrap; }
.feedback small { white-space:pre-line; }

.rune-overlay[data-kind="dragon"] .rune-stone { min-width: 54px; }
.rune-number strong { white-space: nowrap; }

.build-choice { display:grid; gap:5px; margin:12px 0; font-size:14px; font-weight:750; text-align:left; color:#edf3dd; }
.build-choice select { width:100%; padding:8px; color:#f3f4dc; background:#203e36; border:1px solid #83a391; border-radius:6px; font:inherit; }
.build-choice small { color:#bdd0c0; font-weight:500; }
.modal-overlay { overflow-y:auto; }
.modal-overlay .result-panel { margin-block:auto; }

.starter {display:grid;gap:4px;margin:0 0 14px;font-size:14px;font-weight:800;color:#e8fbd7}
.starter select {max-width:100%;border:1px solid #92afa0;border-radius:6px;background:#213c35;color:#f1f7dd;padding:9px;font:inherit}
@media(max-height:650px){.intro-content .eyebrow,.intro-content .run-time{display:none}.intro-content h1{font-size:54px}.intro-copy{margin:10px 0}}
