/* Pagesworn — battle screen. Layout contract: 390×844 target, 360px floor. */

.screen.battle { padding-bottom: 0; background: var(--panel); }

/* ---------- banner: ~90px during questions, ~280px during action commands ---------- */
.banner {
  position: relative;
  flex: 0 0 auto;
  height: 90px;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 30%, rgba(255,255,255,.7) 0 7px, rgba(255,244,180,.35) 8px, transparent 16px),
    linear-gradient(#c5e6f6 0 46%, #8ec8e6 46% 62%, #4f9a46 62% 78%, #2c6a32 78% 100%);
  border-bottom: 3px solid var(--accent-deep);
  transition: height .25s ease-out, background .6s;
  animation: sky-drift 18s ease-in-out infinite alternate;
  z-index: 3;
}
@keyframes sky-drift { to { background-position: 16px 0, 0 0; } }
.theme-lair .banner {
  background:
    radial-gradient(circle at 72% 78%, rgba(255,140,40,.55) 0 14px, rgba(180,30,10,.25) 28px, transparent 70px),
    radial-gradient(circle at 20% 20%, rgba(255,80,40,.18), transparent 42%),
    linear-gradient(#140306 0 42%, #4a100e 42% 60%, #2a0c0a 60% 78%, #0c0404 78% 100%);
}
.banner.expanded { height: 280px; }
.phase-read .banner { height: 0; border-bottom-width: 0; }
.banner .scene {
  position: absolute; left: 0; right: 0; bottom: 0; height: 40%;
  background:
    radial-gradient(ellipse 28% 90% at 12% 100%, rgba(0,0,0,.22), transparent 72%),
    radial-gradient(ellipse 22% 80% at 86% 110%, rgba(0,0,0,.18), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 12px, transparent 12px 26px);
}
.banner .scene::before,
.banner .scene::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 14px;
  height: 26px;
  border-radius: 8px 8px 3px 3px;
  background: #1b4e24;
  box-shadow:
    8px -16px 0 -4px #143d1c,
    22px 2px 0 -1px #216032,
    46px -6px 0 0 #174822;
}
.banner .scene::before { left: 6%; }
.banner .scene::after { right: 8%; box-shadow: -18px 4px 0 0 #1d5830, -40px -8px 0 -2px #143d1c; }
.banner .scene::before,
.banner .scene::after { transform-origin: 50% 100%; animation: tree-sway 3.6s ease-in-out infinite alternate; }
.banner .scene::before { animation-delay: -1.4s; }
@keyframes tree-sway { to { transform: rotate(2.5deg); } }
.theme-lair .banner .scene::before,
.theme-lair .banner .scene::after { display: none; }
.theme-chapel .banner {
  background:
    radial-gradient(circle at 70% 28%, rgba(255,244,190,.85) 0 10px, rgba(255,220,120,.25) 22px, transparent 40px),
    linear-gradient(#d7f0c8 0 48%, #7dba6a 48% 64%, #3e7a40 64% 80%, #1d4a28 80% 100%);
}
.theme-chapel .banner .scene::before,
.theme-chapel .banner .scene::after {
  width: 18px; height: 22px; border-radius: 10px 10px 4px 4px;
  background: #1f8a45;
  box-shadow: 6px -8px 0 -2px #d23b32, 14px 2px 0 0 #146332, -8px 4px 0 -2px #49c56e;
}
.theme-hunt .banner {
  background:
    radial-gradient(circle at 78% 22%, #f4e4c1 0 7px, rgba(244,228,193,.35) 12px, transparent 22px),
    linear-gradient(#2a2458 0 46%, #6a4a78 46% 62%, #8a7a48 62% 78%, #4a6230 78% 100%);
}
.theme-hunt .banner .scene::before,
.theme-hunt .banner .scene::after {
  width: 4px; height: 28px; border-radius: 2px; background: #c6a24a;
  box-shadow: 10px 4px 0 0 #b8923a, 20px -2px 0 0 #d4b45a, 32px 6px 0 0 #a88430;
}
.theme-lake .banner {
  background:
    radial-gradient(circle at 22% 24%, rgba(255,244,210,.7) 0 6px, rgba(255,244,210,.2) 14px, transparent 22px),
    linear-gradient(#b9d4e4 0 42%, #6aa4c4 42% 58%, #2f6f8a 58% 74%, #143848 74% 100%);
}
.theme-lake .banner .scene::before,
.theme-lake .banner .scene::after {
  width: 5px; height: 26px; border-radius: 3px; background: #1d5a48;
  box-shadow: 12px 6px 0 0 #247056, 24px 2px 0 0 #1a4a3c, 36px 8px 0 0 #2f8a68;
}
.embers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.theme-chapel .embers i { background: #8fd48a; box-shadow: 0 0 6px #d7f0c8; border-radius: 0 8px 0 8px; }
.theme-hunt .embers i { background: #f4e4c1; box-shadow: 0 0 8px #fff2a8; }
.theme-lake .embers i { background: #d7f4ff; box-shadow: 0 0 6px #ffffff; border-radius: 50%; }
.theme-frost .banner {
  background:
    radial-gradient(circle at 80% 18%, rgba(255,255,255,.9) 0 5px, rgba(255,255,255,.25) 12px, transparent 20px),
    linear-gradient(#d5e0e8 0 46%, #9aafbc 46% 62%, #e8eef2 62% 78%, #6d8494 78% 100%);
}
.theme-frost .banner .scene::before,
.theme-frost .banner .scene::after {
  width: 16px; height: 26px; border-radius: 8px 8px 2px 2px;
  background: #2c4a3a;
  box-shadow: 14px -4px 0 0 #243e32, 28px 2px 0 -2px #1c3228;
}
.theme-frost .embers i {
  background: #fff; box-shadow: 0 0 4px #fff; border-radius: 50%;
  animation-name: snow-fall;
}
.theme-crown .banner {
  background:
    radial-gradient(circle at 72% 16%, rgba(255,226,150,.95) 0 8px, rgba(255,170,60,.4) 20px, transparent 46px),
    linear-gradient(#2a1248 0 40%, #8a3a48 40% 56%, #c47a3a 56% 72%, #2a1810 72% 100%);
}
.theme-crown .banner .scene::before,
.theme-crown .banner .scene::after {
  width: 16px; height: 30px; border-radius: 2px 2px 0 0; background: #2a1810;
  box-shadow: 14px -12px 0 0 #1a100c, 30px 2px 0 -2px #3a2418;
}
.theme-crown .embers i {
  background: #ffe680; box-shadow: 0 0 8px #e2b52c; border-radius: 50%;
  animation-name: ember-rise;
}
@keyframes snow-fall {
  0% { transform: translateY(-78px); opacity: 0; }
  20% { opacity: .85; }
  100% { transform: translateY(18px); opacity: 0; }
}
.embers i {
  position: absolute; bottom: 18px; width: 4px; height: 4px; border-radius: 50%;
  background: #efe2c4; box-shadow: none; opacity: .7;
  animation: dust-drift 3.4s linear infinite;
}
.theme-lair .embers i {
  width: 5px; height: 5px; border-radius: 2px;
  background: #ffb15a; box-shadow: 0 0 6px #ff7a32; opacity: .85;
  animation-name: ember-rise;
}
.theme-chapel .embers i,
.theme-hunt .embers i,
.theme-lake .embers i { animation-name: ember-rise; }
@keyframes ember-rise {
  0% { transform: translateY(8px); opacity: 0; }
  15% { opacity: .9; }
  100% { transform: translateY(-78px); opacity: 0; }
}
@keyframes dust-drift {
  0% { transform: translate(0, 4px); opacity: 0; }
  25% { opacity: .5; }
  100% { transform: translate(-14px, -22px); opacity: 0; }
}
.hud {
  position: absolute; top: 4px; left: 8px; right: 8px; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start;
}
.hp { display: grid; grid-template-columns: 1fr auto; column-gap: 4px; min-width: 0; }
.hp-name {
  font: 700 12px/1.25 var(--font-head); color: var(--white);
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hp-num { grid-row: 1; grid-column: 2; font: 700 12px/1.25 var(--font-body); color: var(--white); text-shadow: 0 1px 2px #000; }
.hp-bar, .armor-bar { grid-column: 1 / -1; height: 10px; border-radius: 6px; background: rgba(0,0,0,.45); border: 2px solid rgba(0,0,0,.55); overflow: hidden; }
.armor-bar { height: 7px; margin-top: 2px; }
.hp-fill { height: 100%; width: 100%; background: var(--hp-good); transition: width .35s ease-out; }
.hp-fill.low { background: var(--hp-low); }
.hp.enemy .hp-fill { background: #e0533a; }
.armor-fill { height: 100%; background: linear-gradient(#d8dde2, #7d858f); transition: width .35s; }
.hp.enemy { text-align: right; }

.streak {
  display: flex; align-items: center; gap: 1px;
  padding: 2px 6px; border-radius: 10px; background: rgba(0,0,0,.4);
}
.streak .pip svg { width: 12px; height: 16px; display: block; }
.streak .pip:not(.on) { opacity: .35; }
.streak-n { font: 700 12px var(--font-body); color: var(--white); margin-left: 3px; }
.streak.charged { box-shadow: 0 0 8px #fff, 0 0 16px var(--gold-bright); animation: glow .9s ease-in-out infinite alternate; }
@keyframes glow { from { background: rgba(0,0,0,.4); } to { background: rgba(242,207,91,.55); } }

.fighters {
  position: absolute; left: 0; right: 0; bottom: 3px; top: 36px;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 16%;
  transition: top .25s, padding .25s;
  min-width: 0;
}
.banner.expanded .fighters { top: 70px; bottom: 10px; padding: 0 6%; }
/* Pixel heights: a percentage height on the svg collapses to 0 once the
   sprite has no width/height attributes (the flex parent has no definite
   content height). Question banner ~90px, action banner ~280px. */
.fighter {
  position: relative;
  height: 48px; width: auto; max-width: 46vw; min-width: 0;
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden; transition: filter .08s;
  animation: idle 2.6s ease-in-out infinite;
}
.fighter.enemy { animation-delay: -1.3s; }
.fighter::after {
  content: ''; position: absolute; left: 12%; right: 12%; bottom: 0; height: 5px;
  border-radius: 50%; background: rgba(0,0,0,.32); pointer-events: none;
}
.banner.expanded .fighter { height: 150px; }
.fighter svg { height: 100%; width: auto; max-width: 100%; display: block; }
.fighter.knight svg { aspect-ratio: 19 / 33; }
.fighter.enemy.goblin { height: 44px; }
.fighter.enemy.goblin svg { aspect-ratio: 20 / 25; }
.banner.expanded .fighter.enemy.goblin { height: 132px; }
.fighter.shattering { overflow: visible; animation: none; }
.fighter.enemy.dragon { height: 52px; }
.fighter.enemy.dragon svg { aspect-ratio: 48 / 33; }
.banner.expanded .fighter.enemy.dragon { height: 132px; }
.fighter.enemy.green-knight { height: 56px; }
.fighter.enemy.green-knight svg { aspect-ratio: 22 / 36; }
.banner.expanded .fighter.enemy.green-knight { height: 168px; }
.fighter.enemy.beast { height: 48px; }
.fighter.enemy.beast svg { aspect-ratio: 48 / 28; }
.banner.expanded .fighter.enemy.beast { height: 120px; }
.fighter.enemy.forester { height: 52px; }
.fighter.enemy.forester svg { aspect-ratio: 18 / 32; }
.banner.expanded .fighter.enemy.forester { height: 156px; }
.fighter.enemy.caller { height: 50px; }
.fighter.enemy.caller svg { aspect-ratio: 18 / 30; }
.banner.expanded .fighter.enemy.caller { height: 150px; }
.fighter.enemy.reaper { height: 50px; }
.fighter.enemy.reaper svg { aspect-ratio: 20 / 28; }
.banner.expanded .fighter.enemy.reaper { height: 140px; }
.fighter.enemy.fisher { height: 50px; }
.fighter.enemy.fisher svg { aspect-ratio: 18 / 28; }
.banner.expanded .fighter.enemy.fisher { height: 140px; }
.fighter.enemy.serpent { height: 48px; }
.fighter.enemy.serpent svg { aspect-ratio: 46 / 24; }
.banner.expanded .fighter.enemy.serpent { height: 112px; }
.fighter.enemy.sentry { height: 52px; }
.fighter.enemy.sentry svg { aspect-ratio: 18 / 32; }
.banner.expanded .fighter.enemy.sentry { height: 150px; }
.fighter.enemy.pale-knight { height: 54px; }
.fighter.enemy.pale-knight svg { aspect-ratio: 20 / 32; }
.banner.expanded .fighter.enemy.pale-knight { height: 150px; }
.fighter.enemy.giant { height: 62px; }
.fighter.enemy.giant svg { aspect-ratio: 24 / 40; }
.banner.expanded .fighter.enemy.giant { height: 196px; }
.fighter .cloak { transform-box: fill-box; transform-origin: 50% 0%; animation: sway 2.8s ease-in-out infinite alternate; }
.fighter .tail { transform-box: fill-box; transform-origin: 0% 80%; animation: wag 1.1s ease-in-out infinite alternate; }
@keyframes sway { to { transform: rotate(4deg); } }
@keyframes wag { to { transform: rotate(12deg); } }
@keyframes idle { 50% { transform: translateY(-3px); } }
.enemy.goblin { animation: fidget 1.35s ease-in-out infinite; }
.enemy.dragon { animation: dragon-breathe 2.6s ease-in-out infinite; }
.enemy.beast { animation: beast-crouch 1.7s ease-in-out infinite; }
.enemy.serpent { animation: serpent-sway 3.1s ease-in-out infinite; }
.enemy.giant { animation: giant-stand 2.8s ease-in-out infinite; }
.fighter.shattering, .enemy.defeated { animation: none; }
@keyframes fidget {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-2px) rotate(-1.5deg); }
  50% { transform: translateY(-4px) rotate(1deg); }
  75% { transform: translateY(-1px) rotate(-1deg); }
}
@keyframes dragon-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes beast-crouch {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(3px); }
  62% { transform: translateY(-5px); }
}
@keyframes serpent-sway {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-4px); }
  70% { transform: translateY(2px); }
}
@keyframes giant-stand {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.fighter .wing { transform-box: fill-box; transform-origin: 20% 80%; animation: flap 1.5s ease-in-out infinite alternate; }
.fighter .fire rect:first-child { animation: ember .7s ease-in-out infinite alternate; }
@keyframes flap { to { transform: translateY(-5px) rotate(-7deg); } }
@keyframes ember { to { fill: #ffe36b; } }
.vial-btn {
  align-self: stretch; width: 52px; min-height: 52px; padding: 4px;
  border-radius: 14px; border: 3px solid #2a5c8a; background: #d8eef8;
  display: grid; place-items: center; position: relative; cursor: pointer;
}
.vial-btn svg { width: 26px; height: 32px; }
.vial-btn[disabled] { opacity: .45; }
.vial-n { position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--white); color: var(--ink); font: 700 12px/20px var(--font-body); text-align: center; }

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* ---------- stage: question panel with the passage sliding over it ---------- */
.stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; transition: opacity .2s; }
.phase-action .stage { opacity: .45; }
.qpanel { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 12px 14px 12px; }
.qview { display: flex; flex-direction: column; flex: 1 0 auto; }
.q-type { font: 700 12px var(--font-head); letter-spacing: .12em; text-transform: uppercase; color: var(--text-soft); }
.q-part { display: inline-block; font: 700 12px var(--font-head); letter-spacing: .08em; padding: 2px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--panel-edge); margin-right: 6px; }
.q-prompt { margin: 6px 0 4px; font-size: 19px; line-height: 1.4; font-weight: 600; }
.q-how { display: block; font-size: 15px; font-weight: 700; color: var(--accent-deep); }
.q-hint { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: #fff3c4; border: 2px solid var(--gold); font-size: 17px; line-height: 1.45; }
.q-done { display: grid; gap: 6px; }
.q-done:empty { display: none; }
.q-done-row { padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-size: 15px; line-height: 1.35; }
.q-choices { display: grid; gap: 10px; margin-top: auto; padding-top: 14px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; padding: 10px 14px;
  text-align: left; font-size: 17px; line-height: 1.3; font-family: var(--font-body);
  border: 3px solid var(--panel-edge); border-radius: 14px; background: var(--white); color: var(--ink);
  box-shadow: 0 3px 0 rgba(0,0,0,.12); cursor: pointer;
}
.choice:active { transform: translateY(1px); }
.choice .mark { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 3px solid var(--panel-edge); background: var(--white); }
.choice[role="checkbox"] .mark { border-radius: 6px; }
.choice[aria-checked="true"] { border-color: var(--accent-deep); background: #fff1b8; box-shadow: inset 0 0 0 2px var(--accent), 0 3px 0 rgba(0,0,0,.12); }
.choice[aria-checked="true"] .mark { background: var(--accent); border-color: var(--accent-deep); box-shadow: inset 0 0 0 3px var(--white); }
.choice.quote { font-size: 16px; line-height: 1.4; align-items: flex-start; }
.choice.quote .mark { margin-top: 2px; }
.choice.open-passage { justify-content: center; font-weight: 700; background: var(--panel-2); }
.qview.locked .choice { pointer-events: none; }
.hot-preview { padding: 10px 12px; border-radius: 12px; border: 2px dashed var(--panel-edge); color: var(--text-soft); font-size: 16px; line-height: 1.45; }
.hot-preview blockquote { margin: 0; color: var(--ink); }
.hot-preview .sn, .s .sn { font: 700 11px var(--font-body); color: var(--text-soft); vertical-align: super; line-height: 0; margin-right: 3px; }

.q-explain { padding: 14px; border-radius: 14px; background: var(--white); border: 3px solid var(--panel-edge); font-size: 17px; line-height: 1.5; }
.q-explain h3 { margin: 0 0 8px; font-size: 20px; }
.q-explain p { margin: 0 0 8px; }
.ex-part + .ex-part { border-top: 2px dashed var(--panel-edge); padding-top: 10px; margin-top: 4px; }
.ex-answer { font-size: 16px; }
.ex-dmg { font-weight: 700; color: var(--accent-deep); }

.ppanel {
  position: absolute; inset: 0; z-index: 2;
  background: var(--panel);
  transform: translateY(102%);
  visibility: hidden;
  transition: transform .25s ease-out, visibility 0s linear .25s;
  box-shadow: 0 -6px 16px rgba(0,0,0,.25);
}
.passage-open .ppanel { transform: none; visibility: visible; transition: transform .25s ease-out, visibility 0s; }
.passage { height: 100%; display: flex; flex-direction: column; }
.p-strip { flex: 0 0 auto; padding: 10px 14px; font-size: 16px; line-height: 1.4; border-bottom: 2px solid var(--panel-edge); background: var(--panel-2); }
.p-strip.hint { background: #fff3c4; }
.p-strip.flavor { background: var(--chrome); color: var(--chrome-text); border-bottom-color: var(--accent-deep); }
.p-strip.task { background: #e6f0dc; }
.strip-task { color: var(--text-soft); }
.p-scroll { flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: auto; }
.p-article { max-width: 34em; margin: 0 auto; padding: 16px 18px 48px; font-size: 18px; line-height: 1.6; color: var(--ink); }
.p-title { margin: 0 0 12px; font-size: 22px; line-height: 1.25; }
.p-para { margin: 0 0 1em; }
.p-source { font-size: 13px; color: var(--text-soft); line-height: 1.4; }
.s { border-radius: 4px; transition: background .3s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.s.hl-hint { background: #ffe680; box-shadow: 0 0 0 2px #ffe680; }
.s.hl-evidence { background: rgba(201,162,39,.32); box-shadow: 0 0 0 2px rgba(201,162,39,.32); }

/* A button draws as prose until it is a card. iPhone delivers a tap to a button
   inside the scrolling page, and drops that tap on a plain span. */
button.s {
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; padding: 0; margin: 0;
  -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.passage.selecting .p-scroll { cursor: pointer; }

/* hot-text: selectable sentences become ≥48px tap cards, 8px apart */
.selecting .s.selectable {
  display: block; width: 100%; box-sizing: border-box;
  margin: 8px 0; padding: 10px 12px; min-height: 48px;
  border: 2px dashed var(--accent-deep); border-radius: 12px; background: rgba(255,255,255,.55);
  cursor: pointer; touch-action: manipulation;
}
.selecting .s.selectable.hl-hint { background: #ffe680; }
.selecting .s.selectable.picked { border-style: solid; border-width: 3px; border-color: var(--accent-deep); background: #fff1b8; box-shadow: inset 0 0 0 2px var(--accent); }
.passage.locked .s.selectable { pointer-events: none; }

/* ---------- bottom bar: Passage toggle + primary action ---------- */
.bottombar {
  flex: 0 0 auto; z-index: 4;
  display: grid; grid-template-columns: 2fr 3fr; gap: 10px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: var(--chrome);
  border-top: 3px solid var(--accent-deep);
}
.bottombar.has-vial { grid-template-columns: 52px 2fr 3fr; }
.phase-read .bottombar { grid-template-columns: 1fr; }
.phase-explain .bottombar.has-vial { grid-template-columns: 2fr 3fr; }
.phase-read .vial-btn, .phase-explain .vial-btn, .phase-action .vial-btn { display: none; }
.phase-read .bar-toggle, .phase-action .bar-toggle { display: none; }
.phase-action .bottombar { visibility: hidden; }
.reward .bar-toggle, .reward .vial-btn { display: none; }
.reward .bottombar { grid-template-columns: 1fr; }
.bar-toggle { font-size: 17px; }
.bar-toggle .tg-icon { width: 20px; height: 16px; border: 3px solid currentColor; border-radius: 3px; position: relative; }
.bar-toggle .tg-icon::after { content: ''; position: absolute; left: 50%; top: -1px; bottom: -1px; border-left: 2px solid currentColor; }
.bar-toggle[aria-pressed="true"] { background: var(--gold-bright); border-color: var(--gold-deep); }
.bar-primary { font-size: 20px; }

/* ---------- action commands ---------- */
.tap-layer { position: absolute; inset: 0; z-index: 25; outline: none; touch-action: none; }
.meter-wrap { position: absolute; z-index: 30; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); pointer-events: none; padding: 10px 10px 12px; border-radius: 18px; background: rgba(24,16,8,.88); box-shadow: 0 -4px 18px rgba(0,0,0,.35); }
.meter-label { text-align: center; font: 700 17px/1.25 var(--font-head); color: var(--white); text-shadow: 0 2px 3px #000; margin-bottom: 8px; }
.meter { position: relative; height: 48px; border-radius: 14px; background: #3a2f22; border: 3px solid #120d07; overflow: hidden; box-shadow: inset 0 4px 8px rgba(0,0,0,.5); }
.meter-zone { position: absolute; top: 0; bottom: 0; background: linear-gradient(#fff2a8, #e2b52c); box-shadow: 0 0 12px #f2cf5b; }
.meter-marker { position: absolute; top: -3px; bottom: -3px; left: 0; width: 8px; margin-left: -4px; background: #fff; border-radius: 4px; box-shadow: 0 0 8px #fff; }
.meter.hit-crit { border-color: var(--gold-bright); box-shadow: 0 0 18px var(--gold-bright); }
.parry { position: absolute; z-index: 26; transform: translate(-50%, -50%); pointer-events: none; }
.parry-target { position: absolute; inset: 0; border-radius: 50%; border: 4px solid rgba(255,255,255,.85); }
.parry-ring { position: absolute; left: 50%; top: 50%; width: 100%; height: 100%; border-radius: 50%; border: 6px solid #ff6a45; transform: translate(-50%, -50%) scale(3.2); }
.parry.window .parry-ring { border-color: var(--gold-bright); box-shadow: 0 0 12px var(--gold-bright); }
.parry.ok .parry-target { border-color: var(--gold-bright); background: rgba(242,207,91,.35); }
.parry.miss { opacity: .5; }
.parry-label, .meter-label { pointer-events: none; }
.parry-label { position: absolute; z-index: 26; left: 16px; right: 16px; top: calc(var(--safe-t) + 300px); text-align: center; border-radius: 14px; background: rgba(24,16,8,.85); padding: 10px 12px !important; font: 700 21px var(--font-head); color: var(--white); text-shadow: 0 2px 3px #000, 0 0 8px #000; padding: 0 12px; }
.parry-label.excal { color: var(--gold-bright); }
.swipe-guide { position: absolute; z-index: 26; height: 6px; border-radius: 3px; pointer-events: none;
  background: repeating-linear-gradient(90deg, #fff 0 14px, transparent 14px 24px); transform: rotate(-18deg); animation: guide .8s linear infinite; opacity: .9; }
@keyframes guide { from { background-position: 0 0; } to { background-position: 48px 0; } }

/* ---------- feedback ---------- */
.dmg {
  --rot: 0deg;
  position: absolute; transform: translate(-50%, -50%);
  font: 700 28px/1 var(--font-head); color: var(--white); white-space: nowrap;
  -webkit-text-stroke: 1.5px #000; text-shadow: 0 3px 0 #000;
  animation: dmg-up .6s ease-out forwards; pointer-events: none;
}
.dmg.crit { --rot: -10deg; font-size: 40px; color: var(--gold-bright); }
.dmg.excal { --rot: -6deg; font-size: 56px; color: #fff; text-shadow: 0 0 14px var(--gold-bright), 0 3px 0 #000; }
.dmg.hurt { color: #ff9a8a; }
.dmg.parried { color: #cfe8ff; font-size: 24px; }
.dmg.heal { color: #9dffad; }
.dmg.armor { color: #d8dde2; font-size: 20px; }
@keyframes dmg-up {
  0% { opacity: 0; transform: translate(-50%, -20%) rotate(var(--rot)) scale(.6); }
  18% { opacity: 1; transform: translate(-50%, -70%) rotate(var(--rot)) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -190%) rotate(var(--rot)) scale(1); }
}
.flash-white svg { filter: brightness(0) invert(1); }
.knight.lunge { animation: lunge-r .38s ease-in-out; }
.enemy.lunge { animation: lunge-l .38s ease-in-out; }
@keyframes lunge-r { 50% { transform: translateX(45%); } }
@keyframes lunge-l { 50% { transform: translateX(-45%); } }
.fighter.striking, .fighter.plating, .fighter.blocking { overflow: visible; }
.fighter .rig { transform-box: fill-box; }
.knight .rig.weapon { transform-origin: 40% 92%; animation: sword-rest 3.2s ease-in-out infinite; }
.knight .rig.shield { transform-origin: 8% 55%; animation: knight-shield 3.5s ease-in-out infinite; }
@keyframes sword-rest {
  0%, 100% { transform: rotate(6deg); }
  50% { transform: rotate(-14deg); }
}
@keyframes knight-shield {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(5deg); }
}
.knight.striking { animation: knight-step .38s ease-in-out; }
@keyframes knight-step { 40% { transform: translateX(14%); } }
.knight.striking .rig.weapon {
  transform-box: fill-box; transform-origin: 40% 92%;
  animation: sword-arc .38s ease-in-out;
}
@keyframes sword-arc {
  0% { transform: rotate(18deg); }
  45% { transform: rotate(-28deg); }
  100% { transform: rotate(0deg); }
}
.knight.striking.crit .rig.weapon,
.knight.striking.excalibur .rig.weapon {
  filter: drop-shadow(0 0 3px #f2cf5b) drop-shadow(0 0 6px #f2cf5b);
}
.knight.blocking { animation: none; }
.knight.blocking .rig.shield {
  transform-box: fill-box; transform-origin: 0% 50%;
  animation: shield-up .26s ease-out forwards;
}
@keyframes shield-up { to { transform: translateX(110%); } }
.knight.rocked { animation: rock-back .2s ease-out; }
@keyframes rock-back { 50% { transform: translateX(-10%) rotate(-6deg); } }
.enemy.striking {
  --reach: -18%;
  --spin: 0deg;
  overflow: visible;
  animation: foe-arc .38s ease-in-out;
}
.enemy.striking.atk-swipe { --spin: -10deg; }
.enemy.striking.atk-jab,
.enemy.striking.atk-thrust { animation-name: foe-poke; }
.enemy.striking.atk-thrust { --reach: -22%; }
.enemy.striking.atk-shot { animation-name: foe-draw; --reach: 6%; }
.enemy.striking.atk-axe,
.enemy.striking.atk-sickle { animation-name: foe-chop; --spin: -16deg; }
.enemy.striking.atk-oar { animation-name: foe-chop; --spin: -10deg; --reach: -12%; }
.enemy.striking.atk-bash { --spin: -4deg; --reach: -14%; }
.enemy.striking.atk-bite { animation-name: foe-bite; }
.enemy.striking.atk-pounce { animation-name: foe-pounce; }
.enemy.striking.atk-coil { animation-name: foe-coil; --spin: -18deg; }
.enemy.striking.glanced { --reach: -8%; animation-duration: .26s; }
.enemy.striking.glanced.atk-shot { --reach: 3%; }
@keyframes foe-arc { 45% { transform: translateX(var(--reach)) rotate(var(--spin)); } }
@keyframes foe-poke {
  28% { transform: translateX(8%); }
  55% { transform: translateX(var(--reach)); }
}
@keyframes foe-draw { 40% { transform: translateX(var(--reach)); } }
@keyframes foe-chop {
  30% { transform: translateX(5%) rotate(12deg); }
  62% { transform: translateX(var(--reach)) rotate(var(--spin)); }
}
@keyframes foe-bite {
  35% { transform: translateX(-8%) rotate(6deg); }
  58% { transform: translateX(var(--reach)) rotate(-4deg); }
}
@keyframes foe-pounce { 50% { transform: translateX(var(--reach)) translateY(-8%); } }
@keyframes foe-coil {
  30% { transform: rotate(10deg); }
  65% { transform: translateX(var(--reach)) rotate(var(--spin)); }
}
.enemy.chip { animation: chip-nudge .22s ease-out; }
.enemy.chip svg { filter: brightness(1.8); }
@keyframes chip-nudge { 40% { transform: translateX(4%); } }
.bolt {
  position: absolute; left: 0; top: 0; width: 16px; height: 3px; border-radius: 2px;
  background: #f4e7c5; box-shadow: 0 0 6px #f2cf5b;
}
.spark {
  position: absolute; width: 8px; height: 8px; border-radius: 2px;
  background: #fff; box-shadow: 0 0 8px #f2cf5b;
  animation: spark-pop .28s ease-out forwards;
}
@keyframes spark-pop { to { opacity: 0; transform: translate(-6px, -10px) scale(1.4); } }
.enemy.windup { animation: windup .5s ease-in-out infinite alternate; }
@keyframes windup { to { transform: translateX(8%) rotate(4deg); } }
.knight.fallen { transform: rotate(-80deg) translateY(30%); transition: transform .5s; }
.enemy.defeated { opacity: 0; transition: opacity .6s .2s; }
.excal-slash .banner::after {
  content: ''; position: absolute; z-index: 6; left: 40%; right: 2%; top: 50%; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, transparent, #fff 30%, #fff 70%, transparent); box-shadow: 0 0 22px #fff;
  transform: rotate(-20deg); animation: slash .3s ease-out;
}
@keyframes slash { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.enemy.exposed .weakpoint rect:first-child { animation: gem 1s ease-in-out infinite alternate; }
@keyframes gem { to { fill: #ffffff; } }

/* Living foes. The weapon moves while the question is up. Angles, not lunges,
   so a 90px banner and a 280px one both read and nothing walks off the phone. */
.enemy .rig.weapon { transform-origin: 50% 90%; }
.enemy .rig.jaw { transform-origin: 92% 64%; }
.enemy .rig.shield { transform-origin: 88% 82%; }
.enemy.goblin .rig.weapon { transform-origin: 46% 96%; animation: club-ready 1.45s ease-in-out infinite; }
.enemy.giant .rig.weapon { transform-origin: 42% 96%; animation: giant-club 2.2s ease-in-out infinite; }
.enemy.forester .rig.weapon { transform-origin: 42% 82%; animation: bow-breathe 2.3s ease-in-out infinite; }
.enemy.caller .rig.weapon { transform-origin: 100% 0%; animation: horn-lift 2.6s ease-in-out infinite; }
.enemy.reaper .rig.weapon { transform-origin: 46% 100%; animation: sickle-ready 1.85s ease-in-out infinite; }
.enemy.fisher .rig.weapon { transform-origin: 48% 90%; animation: oar-tip 2.5s ease-in-out infinite; }
.enemy.sentry .rig.weapon { transform-origin: 50% 96%; animation: spear-dip 2.7s ease-in-out infinite; }
.enemy.green-knight .rig.weapon { transform-origin: 30% 88%; animation: axe-rest 2.45s ease-in-out infinite; }
.enemy.pale-knight .rig.shield { animation: shield-breathe 2.6s ease-in-out infinite; }
.enemy.dragon .rig.jaw { transform-origin: 84% 72%; animation: jaw-breathe 2.15s ease-in-out infinite; }
.enemy.beast .rig.jaw { transform-origin: 100% 70%; animation: sniff 1.35s ease-in-out infinite; }
.enemy.serpent .rig.jaw { transform-origin: 100% 62%; animation: jaw-hunt 2.35s ease-in-out infinite; }
.fighter .eye, .fighter .tooth, .fighter .ear, .fighter .hat, .fighter .quiver, .fighter .crown, .fighter .fire {
  transform-box: fill-box; transform-origin: 50% 60%;
}
.fighter .eye { animation: blink 4.4s ease-in-out infinite; }
.fighter.enemy .eye { animation-duration: 3.5s; animation-delay: -1.2s; }
.fighter .tooth { transform-origin: 50% 0%; animation: chatter 2.6s ease-in-out infinite; }
.fighter .ear { transform-origin: 50% 100%; animation: ear-twitch 2.4s ease-in-out infinite; }
.fighter .hat, .fighter .crown { transform-origin: 50% 100%; animation: hat-tip 3.2s ease-in-out infinite; }
.fighter .quiver { transform-origin: 50% 100%; animation: quiver-bob 2.2s ease-in-out infinite; }
.fighter .fire { transform-origin: 100% 50%; animation: fire-lick .65s ease-in-out infinite alternate; }
@keyframes giant-club {
  0%, 100% { transform: rotate(-16deg); }
  40% { transform: rotate(6deg); }
  68% { transform: rotate(-20deg); }
}
@keyframes club-ready {
  0%, 100% { transform: rotate(-8deg); }
  20% { transform: rotate(8deg); }
  34% { transform: rotate(-2deg); }
  52% { transform: rotate(16deg); }
  74% { transform: rotate(2deg); }
}
@keyframes bow-breathe {
  0%, 100% { transform: rotate(0deg); }
  58% { transform: rotate(10deg); }
  76% { transform: rotate(4deg); }
}
@keyframes horn-lift {
  0%, 14%, 100% { transform: rotate(8deg); }
  38%, 72% { transform: rotate(-34deg); }
}
@keyframes sickle-ready {
  0%, 100% { transform: rotate(14deg); }
  38% { transform: rotate(-4deg); }
  56% { transform: rotate(-20deg); }
  78% { transform: rotate(-6deg); }
}
@keyframes oar-tip {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(12deg); }
}
@keyframes spear-dip {
  0%, 100% { transform: rotate(6deg); }
  46% { transform: rotate(-1deg); }
  64% { transform: rotate(-8deg); }
}
@keyframes axe-rest {
  0%, 100% { transform: rotate(9deg); }
  32% { transform: rotate(2deg); }
  54% { transform: rotate(-13deg); }
  74% { transform: rotate(-3deg); }
}
@keyframes shield-breathe {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-8deg); }
}
@keyframes jaw-breathe {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(5deg); }
  48% { transform: rotate(13deg); }
  62% { transform: rotate(3deg); }
  78% { transform: rotate(11deg); }
}
@keyframes sniff {
  0%, 100% { transform: rotate(0deg); }
  24% { transform: rotate(10deg); }
  42% { transform: rotate(2deg); }
  60% { transform: rotate(14deg); }
  78% { transform: rotate(4deg); }
}
@keyframes jaw-hunt {
  0%, 100% { transform: rotate(0deg); }
  34% { transform: rotate(6deg); }
  52% { transform: rotate(15deg); }
  70% { transform: rotate(4deg); }
}
@keyframes blink {
  0%, 44%, 54%, 100% { transform: scaleY(1); }
  49% { transform: scaleY(0.08); }
}
@keyframes chatter {
  0%, 64%, 100% { transform: scaleY(1); }
  72% { transform: scaleY(0.3); }
  80% { transform: scaleY(1); }
  88% { transform: scaleY(0.45); }
}
@keyframes ear-twitch {
  0%, 72%, 100% { transform: rotate(0deg); }
  80% { transform: rotate(-12deg); }
  88% { transform: rotate(8deg); }
}
@keyframes hat-tip {
  0%, 100% { transform: rotate(2deg); }
  50% { transform: rotate(-5deg); }
}
@keyframes quiver-bob {
  0%, 100% { transform: rotate(3deg); }
  50% { transform: rotate(-7deg); }
}
@keyframes fire-lick { to { transform: scaleX(1.45); } }
@keyframes weapon-rebound {
  0% { transform: rotate(0deg); }
  38% { transform: rotate(24deg); }
  100% { transform: rotate(-6deg); }
}
@keyframes jaw-snap {
  0% { transform: rotate(10deg); }
  40% { transform: rotate(-9deg); }
  100% { transform: rotate(0deg); }
}
@keyframes shield-knock {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(14deg); }
  100% { transform: rotate(-3deg); }
}
.enemy:is(.striking, .windup):is(.goblin, .giant, .forester, .caller, .reaper, .fisher, .sentry, .green-knight) .rig.weapon,
.enemy:is(.striking, .windup):is(.dragon, .beast, .serpent) .rig.jaw,
.enemy:is(.striking, .windup).pale-knight .rig.shield { animation: none; }
.knight:is(.shattering, .defeated) .rig.weapon,
.knight:is(.shattering, .defeated) .rig.shield,
.enemy:is(.shattering, .defeated):is(.goblin, .giant, .forester, .caller, .reaper, .fisher, .sentry, .green-knight) .rig.weapon,
.enemy:is(.shattering, .defeated):is(.dragon, .beast, .serpent) .rig.jaw,
.enemy:is(.shattering, .defeated).pale-knight .rig.shield { animation: none; }
.enemy.striking.glanced:is(.goblin, .giant, .forester, .caller, .reaper, .fisher, .sentry, .green-knight) .rig.weapon { animation: weapon-rebound .26s ease-out; }
.enemy.striking.glanced:is(.dragon, .beast, .serpent) .rig.jaw { animation: jaw-snap .26s ease-out; }
.enemy.striking.glanced.pale-knight .rig.shield { animation: shield-knock .26s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .knight.lunge, .enemy.lunge, .enemy.windup, .streak.charged, .swipe-guide,
  .fighter, .fighter .wing, .fighter .cloak, .fighter .tail, .fighter .fire, .fighter .fire rect:first-child, .embers i,
  .fighter .eye, .fighter .tooth, .fighter .ear, .fighter .hat, .fighter .quiver, .fighter .crown,
  .knight .rig.weapon, .knight .rig.shield,
  .knight.striking, .knight.striking .rig.weapon, .knight.blocking .rig.shield, .knight.rocked,
  .enemy:is(.goblin, .dragon, .beast, .serpent, .giant),
  .enemy:is(.goblin, .giant, .forester, .caller, .reaper, .fisher, .sentry, .green-knight) .rig.weapon,
  .enemy:is(.dragon, .beast, .serpent) .rig.jaw,
  .enemy.pale-knight .rig.shield,
  .enemy.striking.glanced:is(.goblin, .giant, .forester, .caller, .reaper, .fisher, .sentry, .green-knight) .rig.weapon,
  .enemy.striking.glanced:is(.dragon, .beast, .serpent) .rig.jaw,
  .enemy.striking.glanced.pale-knight .rig.shield,
  .enemy.striking, .enemy.striking.atk-swipe, .enemy.striking.atk-shot, .enemy.striking.atk-jab,
  .enemy.striking.atk-sickle, .enemy.striking.atk-oar, .enemy.striking.atk-thrust,
  .enemy.striking.atk-axe, .enemy.striking.atk-bash, .enemy.striking.atk-bite,
  .enemy.striking.atk-pounce, .enemy.striking.atk-coil, .enemy.chip, .bolt, .spark,
  .banner, .banner .scene::before, .banner .scene::after { animation: none; }
  .embers { display: none; }
  .knight.fallen { transition: none; }
  .banner, .fighters, .ppanel, .passage-open .ppanel { transition: none; }
  .dmg { animation-name: dmg-fade; }
  @keyframes dmg-fade { 0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
}

@media (max-width: 370px) {
  .p-article { padding-left: 14px; padding-right: 14px; }
  .bottombar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .fighters { padding: 0 10%; }
}

.map-node.next .disc { overflow: hidden; }
.map-node.next .disc .fighter.enemy {
  height: 44px; max-width: 46px; width: auto; overflow: hidden;
}
.map-node.next .disc .fighter.enemy svg {
  width: auto; height: 100%; max-width: 100%;
}
.map-node.home .map-you { width: 32px; top: -12px; right: -2px; }
.map-node.home .map-you .fighter.knight {
  height: 46px; max-width: 30px; width: auto; overflow: hidden;
}
.map-node.home .map-you .fighter.knight svg { width: auto; height: 100%; max-width: 100%; }

/* First ride: three beats, then the map. The stage reuses the battle banner. */
.overlay.intro {
  justify-content: flex-start;
  padding: var(--safe-t) 0 0 0;
  background: #10140f;
  animation: none;
}
.intro-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.intro-stage { flex: 0 0 auto; }
.intro-stage .banner.expanded { height: 220px; border-bottom: 0; }
.intro-stage .banner.expanded .fighters { top: 28px; bottom: 6px; }
.intro-stage .banner.expanded .fighter.knight { height: 140px; }
.intro-stage .banner.expanded .fighter.enemy.goblin { height: 112px; }
.intro-stage .banner.expanded .fighter.enemy.giant { height: 168px; }
.intro-copy {
  flex: 1; min-height: 0; overflow: auto;
  padding: 16px 16px calc(14px + var(--safe-b));
  background: var(--parchment); color: var(--ink);
}
.intro-copy h2 { margin: 0 0 8px; font-size: 26px; }
.intro-copy p { margin: 0 0 14px; font-size: 18px; line-height: 1.45; }
.intro-actions { display: grid; gap: 8px; }
.intro-stage.demo-read .fighter.knight .rig.weapon { animation: sword-show 2.2s ease-in-out infinite; }
.intro-stage.demo-block .fighter.knight .rig.shield { animation: knight-guard 1.7s ease-in-out infinite; }
.intro-stage.demo-block .fighter.enemy .rig.weapon { animation: club-taunt 1.7s ease-in-out infinite; }
.intro-stage.demo-gate .fighter.enemy.giant { animation: giant-loom 2.8s ease-in-out infinite; }
@keyframes sword-show {
  0%, 100% { transform: rotate(8deg); }
  45% { transform: rotate(-48deg); }
}
@keyframes knight-guard {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(28deg); }
}
@keyframes club-taunt {
  0%, 100% { transform: rotate(-14deg); }
  35% { transform: rotate(32deg); }
  55% { transform: rotate(-8deg); }
}
@keyframes giant-loom {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) {
  .intro-stage.demo-read .fighter.knight .rig.weapon,
  .intro-stage.demo-block .fighter.knight .rig.shield,
  .intro-stage.demo-block .fighter.enemy .rig.weapon,
  .intro-stage.demo-gate .fighter.enemy.giant,
  .intro-stage .embers i,
  .intro-stage .banner,
  .intro-stage .banner .scene::before,
  .intro-stage .banner .scene::after,
  .map-node.home .fighter.knight,
  .map-node.home .fighter.knight .rig.weapon,
  .map-node.home .fighter.knight .rig.shield { animation: none; }
}
