:root {
  color-scheme: dark;
  --bg: #100b16;
  --panel: #171021;
  --panel-2: #21162c;
  --line: #70573b;
  --line-hot: #d7ae66;
  --text: #eadfc8;
  --muted: #a78f72;
  --accent: #e5c17d;
  --danger: #d45f55;
  --water: #78b9cf;
  --fire: #e3784d;
  --air: #c8d9ce;
  --earth: #bb9562;
  --magic: #a878d1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -15%, rgba(115, 68, 139, .24), transparent 42%),
    repeating-linear-gradient(0deg, rgba(229, 193, 125, .018) 0 1px, transparent 1px 5px),
    linear-gradient(135deg, #0e0913, var(--bg) 55%, #09070d);
  color: var(--text);
  font-family: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
}

button, select { font: inherit; }

button {
  border: 1px solid var(--line);
  background: #1c1325;
  color: var(--text);
  padding: .7rem .9rem;
  cursor: pointer;
  text-transform: uppercase;
}

button:hover:not(:disabled), button:focus-visible {
  border-color: var(--line-hot);
  color: var(--accent);
  outline: none;
  box-shadow: 0 0 18px rgba(215, 174, 102, .13);
}

button:disabled { opacity: .35; cursor: not-allowed; }

.shell { width: min(1320px, calc(100% - 24px)); margin: 0 auto; padding: 10px 0 32px; }

.masthead { display: flex; align-items: center; min-height: 22px; margin-bottom: 6px; }
h1 { margin: 0; color: #f0d8a5; font-family: Georgia, serif; font-size: clamp(.95rem, 1.6vw, 1.2rem); font-weight: 500; letter-spacing: .08em; text-shadow: 0 0 16px rgba(168, 120, 209, .3); }
.mode-button { min-width: 150px; }
.mode-button.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }

.grid { display: grid; gap: 16px; }
.panel {
  position: relative;
  border: 3px double var(--line);
  background:
    linear-gradient(135deg, rgba(39, 25, 48, .94), rgba(17, 12, 24, .98)),
    var(--panel);
  padding: 18px;
  min-width: 0;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .35), 0 10px 34px rgba(0, 0, 0, .18);
}
.panel::before, .panel::after { position: absolute; color: var(--line-hot); background: var(--panel); padding: 0 6px; }
.panel::before { content: "◆"; left: -8px; top: -12px; }
.panel::after { content: "◆"; right: -8px; bottom: -12px; }
.panel-title { color: var(--accent); letter-spacing: .14em; font-size: .75rem; margin-bottom: 14px; text-align: center; }
.floor-label { color: var(--muted); letter-spacing: .18em; font-size: .58rem; margin: 10px 0 5px; text-transform: uppercase; }
.log-panel { margin: 16px 0; }

.battle-panel {
  overflow: hidden;
  padding: 8px 18px 10px;
  background:
    radial-gradient(circle at 18% 42%, rgba(108, 55, 164, .2), transparent 28%),
    radial-gradient(circle at 82% 42%, rgba(217, 70, 151, .14), transparent 30%),
    linear-gradient(135deg, rgba(39, 25, 48, .96), rgba(17, 12, 24, .99));
}
.battle-stage { display: grid; grid-template-columns: minmax(270px, .85fr) minmax(190px, .5fr) minmax(360px, 1.25fr); gap: 18px; align-items: stretch; }
.actor { position: relative; min-width: 0; text-align: center; padding: 10px 16px 4px; border-top: 1px solid rgba(215, 174, 102, .28); border-bottom: 1px solid rgba(215, 174, 102, .28); }
.enemy-roster-panel { min-width: 0; }
.enemy-side { height: 100%; display: flex; flex-direction: column; gap: 10px; }
.enemy-roster { height: 100%; display: grid; grid-template-columns: repeat(var(--enemy-columns, 1), minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.enemy-count-2 { --enemy-columns: 2; }
.enemy-unit { width: 100%; padding: 10px 9px 4px; border: 0; color: var(--text); text-transform: none; background: transparent; box-shadow: none; }
.enemy-unit:hover:not(:disabled), .enemy-unit:focus-visible { border: 0; box-shadow: none; }
.enemy-unit.targeted {
  background: radial-gradient(ellipse at 50% 44%, rgba(226,151,255,.38) 0%, rgba(154,86,186,.25) 35%, rgba(74,39,92,.11) 58%, transparent 76%);
  box-shadow: none;
}
.enemy-unit.defeated { opacity: .3; filter: grayscale(1); }
.enemy-unit.hidden-enemy { opacity: .62; filter: saturate(.65) hue-rotate(145deg); }
.enemy-glyph { display: grid; height: 260px; place-items: center; font-size: clamp(6rem,12vw,10rem); filter: drop-shadow(0 15px 15px rgba(0,0,0,.46)) drop-shadow(0 0 18px rgba(73,172,255,.24)); }
.enemy-unit .stat-row { grid-template-columns: 34px 1fr auto; gap: 6px; font-size: .72rem; }
.enemy-count-2 .actor-art-frame { min-height: 155px; }
.enemy-count-2 .actor-art { height: 155px; }
.enemy-count-2 .actor-name { min-height: 2.3em; font-size: .83rem; }
.enemy-count-2 .actor-caption { font-size: .58rem; }
.enemy-count-2 .intent { font-size: .86rem; }
.enemy-count-2 .enemy-intent-tag { padding-inline: 6px; font-size: .57rem; }
.enemy-count-2 .status-token { min-width: 36px; height: 30px; padding-inline: 5px; }
.actor-caption { color: var(--muted); font-size: .68rem; letter-spacing: .18em; }
.actor-name { color: var(--accent); font-family: Georgia, serif; font-size: 1.08rem; letter-spacing: .09em; margin: 4px 0 8px; }
.enemy-unit.targeted .actor-name::before {
  content: "☞";
  display: inline-block;
  margin-right: .55em;
  color: #fff0bd;
  font-size: 1.45em;
  transform: translateY(.06em);
  filter: drop-shadow(0 0 10px rgba(255,215,139,.75));
}
.enemy-unit.targeted .actor-name {
  color: #fff0bd;
  text-shadow: 0 0 8px rgba(255,220,155,.62), 0 0 18px rgba(194,112,231,.62);
}
.actor-art-frame { position: relative; isolation: isolate; min-height: 220px; display: flex; align-items: end; justify-content: center; margin: 2px 0 0; }
.actor-art-frame::before { content: ""; position: absolute; z-index: -1; width: 72%; aspect-ratio: 1; left: 50%; bottom: 4%; transform: translateX(-50%); border-radius: 50%; filter: blur(20px); opacity: .52; }
.player-art-frame::before { background: radial-gradient(circle, rgba(137, 74, 217, .55), rgba(137, 74, 217, 0) 68%); }
.enemy-art-frame::before { background: radial-gradient(circle, rgba(231, 55, 164, .45), rgba(73, 172, 255, .15) 45%, transparent 70%); }
.actor-art { display: block; width: 100%; height: 220px; object-fit: contain; object-position: center bottom; user-select: none; -webkit-user-drag: none; animation: arcane-float 4.8s ease-in-out infinite alternate; }
.player-actor .actor-art { filter: drop-shadow(0 15px 15px rgba(0, 0, 0, .46)) drop-shadow(0 0 13px rgba(156, 89, 232, .24)); }
.enemy-actor .actor-art { filter: drop-shadow(0 15px 15px rgba(0, 0, 0, .46)) drop-shadow(0 0 15px rgba(236, 61, 177, .24)); animation-delay: -2.2s; }
.enemy-unit.targeted .actor-art { filter: brightness(1.12) saturate(1.12) drop-shadow(0 16px 16px rgba(0,0,0,.5)) drop-shadow(0 0 22px rgba(226,151,255,.5)); }
@keyframes arcane-float { from { transform: translateY(2px); } to { transform: translateY(-5px); } }
.versus-panel { align-self: center; height: 190px; display: grid; place-items: center; overflow: hidden; text-align: center; padding: 12px 10px; border: 1px solid rgba(215, 174, 102, .32); background: radial-gradient(circle, rgba(117, 69, 142,.18), transparent 70%); }
.versus-rune { color: var(--magic); font-family: Georgia, serif; font-size: 1.35rem; margin-bottom: 14px; }
.ascii-title { color: var(--accent); margin-bottom: 12px; letter-spacing: .1em; }
.stat-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; margin: 8px 0; }
.bar { height: 12px; border: 1px solid var(--line); padding: 2px; }
.bar > i { display: block; height: 100%; background: #7bb58d; transition: width .28s ease-out; }
.bar.enemy > i { background: var(--danger); }
.status-list { min-height: 38px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; margin-top: 11px; }
.status-token { min-width: 42px; height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 3px 7px; color: var(--accent); border: 1px solid rgba(215,174,102,.42); background: rgba(8,5,12,.52); box-shadow: inset 0 0 12px rgba(168,120,209,.08); }
.status-token strong { font-size: .72rem; }
.status-icon { font: 1.05rem/1 Georgia, serif; }
.status-burn, .status-heated, .status-magma { color: #e88758; }.status-wet { color: #79c8ed; }.status-slow, .status-frozen { color: #bce8ee; }.status-erosion { color: #d1a574; }.status-regeneration { color: #8bcf9f; }.status-weakened { color: #c58aa0; }
.status-empty { color: rgba(167,143,114,.5); font-size: .9rem; }
.turn-counter { color: var(--muted); margin-top: 8px; font-size: .78rem; letter-spacing: .1em; }
.intent { margin-top: 12px; padding: 11px 4px 4px; border-top: 1px dashed rgba(215,174,102,.32); color: #f2cb83; font-family: Georgia, serif; font-size: 1.06rem; font-weight: 600; letter-spacing: .04em; line-height: 1.35; }
.intent-name { display: block; margin-bottom: 7px; color: #f2cb83; }
.enemy-intent-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.enemy-intent-tag { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 7px; border: 1px solid rgba(215,174,102,.4); border-radius: 999px; background: rgba(10,7,14,.65); font: 600 .63rem/1.1 "Cascadia Mono", Consolas, monospace; letter-spacing: .025em; white-space: nowrap; }
.intent-damage, .intent-hits, .intent-self-damage { color: #f0a581; border-color: rgba(227,120,77,.58); background: rgba(108,43,29,.28); }
.intent-defense { color: #98d0dc; border-color: rgba(120,185,207,.58); background: rgba(29,69,85,.28); }
.intent-status { color: #c89ee6; border-color: rgba(168,120,209,.58); background: rgba(73,43,91,.3); }
.intent-power { color: #e5c17d; border-color: rgba(215,174,102,.6); background: rgba(91,66,31,.3); }
.intent-steal { color: #efca75; border-color: rgba(215,174,102,.62); background: rgba(87,61,24,.32); }
.intent-special { color: #d5c2df; border-color: rgba(168,120,209,.5); background: rgba(62,43,75,.3); }
.intent-escape { color: #ef8f86; border-color: rgba(212,95,85,.62); background: rgba(91,35,40,.32); }
.selectable-objects { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.object-section-title { grid-column: 1/-1; color: var(--muted); font-size: .58rem; letter-spacing: .15em; text-align: center; }
.selectable-object { min-width: 0; display: grid; grid-template-columns: 34px 1fr auto; gap: 7px; align-items: center; padding: 7px 8px; text-align: left; text-transform: none; background: rgba(9,6,13,.6); }
.selectable-object.targeted { border-color: var(--line-hot); box-shadow: inset 0 0 14px rgba(215,174,102,.12); }
.selectable-object.incoming-object { color: #ffaaa1; border-color: rgba(212,95,85,.7); animation: incoming-pulse 1.2s ease-in-out infinite alternate; }
.object-glyph { color: var(--accent); font: 1.4rem/1 Georgia,serif; text-align: center; }
.object-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.object-copy strong { overflow: hidden; color: var(--text); font-size: .64rem; letter-spacing: .04em; text-overflow: ellipsis; white-space: nowrap; }
.object-copy small { color: var(--muted); font-size: .52rem; }
.object-hp { color: var(--accent); font-size: .58rem; }
@keyframes incoming-pulse { from { box-shadow: 0 0 0 rgba(212,95,85,0); } to { box-shadow: 0 0 16px rgba(212,95,85,.25); } }

.source-block { min-height: 50px; padding: 7px 9px 6px; border: 1px solid rgba(112,87,59,.62); border-bottom: 0; color: var(--muted); background: linear-gradient(180deg, rgba(41,27,51,.92), rgba(18,12,24,.9)); text-align: left; }
.source-heading { display: flex; justify-content: space-between; gap: 8px; color: var(--accent); font-size: .72rem; letter-spacing: .1em; }
.source-state { color: #81b28d; font-size: .62rem; }
.pool { margin-top: 4px; color: var(--muted); font-size: .64rem; letter-spacing: .14em; overflow-wrap: anywhere; }
.debug-select { width: 100%; margin-top: 9px; background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: .45rem; }
.debug-tools { margin: 12px auto 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; text-align: center; }
.debug-win { color: #ef9d91; border-color: rgba(212,95,85,.72); }

.hand-panel { margin-top: 10px; padding: 10px 14px 12px; }
.hand { display: grid; grid-template-columns: repeat(3, minmax(140px, 200px)); justify-content: center; gap: 14px; min-height: 150px; }
.altar-slot { min-width: 0; display: grid; grid-template-rows: 50px 164px; }
.resin { position: relative; overflow: hidden; width: 100%; min-width: 0; height: 164px; min-height: 164px; padding: 8px 10px 9px; display: flex; flex-direction: column; font-size: .82rem; background: radial-gradient(circle at 50% 38%, rgba(255,255,255,.045), transparent 54%), rgba(10, 7, 14, .45); }
.resin.selected { background: rgba(229, 193, 125, .14); color: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 24px rgba(215, 174, 102, .1), 0 0 18px rgba(168, 120, 209, .16); }
.resin-art { flex: 0 0 84px; margin: 0 auto 6px; height: 84px; display: flex; align-items: center; justify-content: center; font: 700 .78rem/1.05 "Cascadia Mono", Consolas, monospace; white-space: pre; }
.resin-art-image img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; filter: drop-shadow(0 8px 8px rgba(0,0,0,.42)) drop-shadow(0 0 8px currentColor); transition: transform .18s ease, filter .18s ease; }
.resin:hover:not(:disabled) .resin-art-image img, .resin.selected .resin-art-image img { transform: translateY(-3px) scale(1.045); filter: drop-shadow(0 10px 10px rgba(0,0,0,.48)) drop-shadow(0 0 13px currentColor); }
.resin-art-ascii { min-height: 84px; }
.resin-label { min-height: 31px; display: flex; align-items: flex-start; justify-content: center; border-top: 1px solid currentColor; padding-top: 6px; letter-spacing: .07em; }
.resin-fire { color: var(--fire); }.resin-water { color: var(--water); }.resin-air { color: var(--air); }.resin-earth { color: var(--earth); }
.resin-defective { color: #866f79; border-style: dashed; filter: saturate(.55); }
.resin-defective:disabled { opacity: .7; }
.resin-warning { display: block; margin-top: auto; color: #b37c85; font-size: .6rem; letter-spacing: .1em; }
.selection { width: min(720px,100%); height: 132px; margin: 10px auto 8px; padding: 8px 12px; overflow-y: auto; background: rgba(0,0,0,.18); border: 1px solid rgba(112, 87, 59, .55); text-align: center; scrollbar-width: thin; scrollbar-color: rgba(215,174,102,.45) transparent; }
.selection > .empty { min-height: 100%; display: grid; place-items: center; }
.recipe-name { color: var(--accent); }
.recipe-target { margin-top: 3px; color: var(--magic); font-size: .62rem; letter-spacing: .08em; }
.recipe-effects { display: grid; gap: 4px; margin-top: 6px; }
.recipe-effect-row { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.recipe-effect-label { flex: 0 0 86px; font-size: .66rem; letter-spacing: .08em; text-align: right; }
.attack-label { color: #e7a16f; }
.defense-label { color: #85c5d5; }
.effect-tags { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.effect-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border: 1px solid rgba(168,120,209,.42); border-radius: 999px; color: #cbb6d8; background: rgba(74,45,91,.28); font-size: .62rem; line-height: 1.1; letter-spacing: .025em; white-space: nowrap; }
.effect-damage { color: #f2b181; border-color: rgba(227,120,77,.58); background: rgba(116,48,30,.3); }
.effect-defense { color: #9dd4df; border-color: rgba(120,185,207,.58); background: rgba(33,78,94,.3); }
.effect-fire { color: #ef926b; border-color: rgba(227,120,77,.52); background: rgba(108,43,29,.25); }
.effect-water { color: #8dcede; border-color: rgba(120,185,207,.52); background: rgba(29,69,85,.25); }
.effect-status { color: #c49be4; border-color: rgba(168,120,209,.58); background: rgba(73,43,91,.3); }
.effect-earth { color: #d0a875; border-color: rgba(187,149,98,.58); background: rgba(83,61,34,.3); }
.has-tooltip { position: relative; cursor: help; }
.has-tooltip::after { content: attr(data-tooltip); position: absolute; z-index: 120; left: 50%; bottom: calc(100% + 9px); width: max-content; max-width: min(290px, 78vw); padding: 8px 10px; border: 1px solid rgba(215,174,102,.7); border-radius: 4px; color: var(--text); background: rgba(12,8,17,.97); box-shadow: 0 8px 24px rgba(0,0,0,.55), 0 0 16px rgba(168,120,209,.16); font: .68rem/1.45 "Cascadia Mono", Consolas, monospace; letter-spacing: .01em; text-align: left; white-space: normal; opacity: 0; pointer-events: none; transform: translate(-50%, 5px); transition: opacity .14s ease, transform .14s ease; }
.has-tooltip::before { content: ""; position: absolute; z-index: 121; left: 50%; bottom: calc(100% + 4px); border: 5px solid transparent; border-top-color: rgba(215,174,102,.7); opacity: 0; pointer-events: none; transform: translateX(-50%); transition: opacity .14s ease; }
.has-tooltip:hover::after, .has-tooltip:focus-visible::after, .has-tooltip:hover::before, .has-tooltip:focus-visible::before { opacity: 1; }
.has-tooltip:hover::after, .has-tooltip:focus-visible::after { transform: translate(-50%, 0); }
.primary-actions { display: grid; grid-template-columns: repeat(2, minmax(180px, 290px)); justify-content: center; gap: 14px; }
.primary-action { min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: Georgia, serif; font-size: .95rem; letter-spacing: .1em; border-width: 2px; }
.primary-action .action-icon { font-size: 1.55rem; line-height: 1; }
.attack-action { color: #f0c47d; background: linear-gradient(135deg, rgba(107,45,32,.48), rgba(34,18,29,.9)); border-color: #9e6544; }
.defend-action { color: #a9d9e2; background: linear-gradient(135deg, rgba(33,70,91,.52), rgba(27,20,39,.9)); border-color: #547f90; }
.secondary-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; }
.reset-action { min-width: 118px; padding: .28rem .65rem; color: var(--muted); border-color: rgba(112,87,59,.62); font-size: .64rem; }
.end-turn { padding: .22rem .55rem; color: #806f5b; border-color: rgba(112,87,59,.38); background: transparent; font-size: .56rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 12px; }

.combat-animating .hand, .combat-animating .primary-actions, .combat-animating .secondary-actions { pointer-events: none; }
.turn-overlay { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; pointer-events: none; background: radial-gradient(circle, rgba(34,18,45,.44), rgba(5,3,8,.78)); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s ease; }
.turn-overlay[hidden] { display: none; }
.turn-overlay.is-visible { opacity: 1; }
.turn-overlay-card { width: min(560px, calc(100% - 36px)); padding: 34px 24px; border-block: 1px solid rgba(215,174,102,.72); background: linear-gradient(90deg, transparent, rgba(23,14,31,.94) 16%, rgba(23,14,31,.94) 84%, transparent); text-align: center; box-shadow: 0 0 70px rgba(168,120,209,.25); transform: scale(.94); animation: turn-card-arrives .45s ease-out forwards; }
.turn-overlay-rune { color: var(--magic); font: 2rem/1 Georgia,serif; text-shadow: 0 0 20px currentColor; }
.turn-overlay-label { margin-top: 12px; color: var(--accent); font: 500 clamp(1.65rem,5vw,3rem)/1 Georgia,serif; letter-spacing: .16em; text-shadow: 0 0 22px rgba(215,174,102,.35); }
.turn-overlay-caption { margin-top: 12px; color: var(--muted); font-size: .72rem; letter-spacing: .18em; }
.turn-overlay.is-enemy { background: radial-gradient(circle, rgba(92,20,30,.34), rgba(5,3,8,.82)); }
.turn-overlay.is-enemy .turn-overlay-rune, .turn-overlay.is-enemy .turn-overlay-label { color: #ef8e84; }
@keyframes turn-card-arrives { from { opacity: 0; transform: translateY(12px) scale(.94); } to { opacity: 1; transform: none; } }
.combat-result { min-height: 138px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.event-rune { color: var(--magic); font-family: Georgia, serif; font-size: 2rem; text-shadow: 0 0 18px currentColor; }
.event-kicker { margin-top: 8px; color: var(--muted); font-size: .65rem; letter-spacing: .18em; }
.event-title { max-width: 180px; margin-top: 7px; color: var(--accent); font-family: Georgia, serif; font-size: 1rem; letter-spacing: .08em; }
.event-damage { margin-top: 5px; color: #ed766d; font: 2.35rem/1 Georgia, serif; text-shadow: 0 0 18px rgba(237,118,109,.4); }
.event-caption { margin-top: 5px; color: var(--muted); font-size: .62rem; letter-spacing: .14em; }
.event-shield .event-damage { color: #8bcdd9; }.event-status .event-rune { color: var(--accent); }
.event-victory .event-rune, .event-victory .event-title { color: #e9c875; text-shadow: 0 0 18px rgba(233,200,117,.4); }
.event-pulse .combat-result { animation: result-arrives .4s ease-out both; }
.actor.is-attacking-right .actor-art { animation: attack-right .46s ease-in-out; }
.actor.is-attacking-left .actor-art { animation: attack-left .46s ease-in-out; }
.actor.is-hit .actor-art { animation: receive-hit .46s ease-out; }
.actor.is-defending .actor-art { animation: defend-pulse .56s ease-out; }
.actor.is-statused .actor-art { animation: status-pulse .52s ease-out; }
@keyframes result-arrives { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes attack-right { 0%,100% { transform: translateX(0); } 48% { transform: translateX(34px) scale(1.025); } }
@keyframes attack-left { 0%,100% { transform: translateX(0); } 48% { transform: translateX(-34px) scale(1.025); } }
@keyframes receive-hit { 0%,100% { transform: translateX(0); } 28% { transform: translateX(5px); filter: sepia(.42) saturate(2.2) brightness(1.08) drop-shadow(0 0 18px #e34040); } 52% { transform: translateX(-4px); } }
@keyframes defend-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(.97); filter: drop-shadow(0 0 22px #74c9df); } }
@keyframes status-pulse { 0%,100% { filter: inherit; } 50% { filter: drop-shadow(0 0 20px #b38ae1) brightness(1.15); } }

.combat-log { height: 230px; overflow-y: auto; font-size: .82rem; line-height: 1.6; scrollbar-color: var(--line) var(--bg); }
.log-line { border-bottom: 1px solid rgba(45, 91, 73, .25); padding: 2px 0; }
.log-line::before { content: "› "; color: var(--accent); }
.log-line.system { color: var(--muted); }.log-line.damage { color: #ffb1aa; }.log-line.good { color: #a5ffd0; }
.empty { color: var(--muted); }

.reward-overlay { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(7,4,10,.82); backdrop-filter: blur(7px); }
.reward-dialog { width: min(820px, 100%); max-height: calc(100vh - 48px); overflow-x: hidden; overflow-y: auto; padding: 28px; border-color: var(--line-hot); box-shadow: 0 20px 80px rgba(0,0,0,.62), 0 0 42px rgba(168,120,209,.18); }
.reward-ornament { color: var(--magic); text-align: center; letter-spacing: .3em; }
.reward-dialog h2 { margin: 8px 0 10px; color: var(--accent); font: 500 clamp(1.25rem,3vw,1.8rem)/1.2 Georgia, serif; letter-spacing: .12em; text-align: center; }
.reward-copy { max-width: 620px; margin: 0 auto 20px; color: var(--muted); line-height: 1.55; text-align: center; }
.reward-choices { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.reward-choice { min-height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; background: radial-gradient(circle, rgba(168,120,209,.1), transparent 60%), rgba(12,8,17,.55); }
.reward-choice img { width: 128px; height: 128px; object-fit: contain; filter: drop-shadow(0 8px 9px rgba(0,0,0,.42)) drop-shadow(0 0 8px currentColor); }
.reward-choice span:last-child { font-size: .78rem; letter-spacing: .09em; }
.reward-remove { color: #b999a3; border-style: dashed; }
.reward-choices.single-reward { grid-template-columns: minmax(220px, 340px); justify-content: center; }
.reward-remove-icon { font: 4rem/1 Georgia,serif; }
.reward-generators { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.reward-generator { min-height: 120px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.reward-generator > span { color: var(--accent); }.reward-generator b { color: #9bd1a9; }
.current-pool { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-style: normal; }
.current-pool span { font-size: .55rem; letter-spacing: .13em; }
.current-pool strong { color: var(--text); font-size: 1.12rem; font-weight: 400; letter-spacing: .08em; }
.reward-remove-list { display: grid; gap: 11px; }
.reward-remove-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 11px; border: 1px solid rgba(112,87,59,.5); background: rgba(10,7,14,.32); }
.reward-remove-row > span { color: var(--accent); font-size: .75rem; }
.reward-remove-row > div { display: flex; flex-wrap: wrap; gap: 7px; }
.reward-resin-chip { width: 38px; height: 38px; padding: 0; font-weight: 700; }
.reward-back { display: block; margin: 18px auto 0; padding: .45rem .75rem; color: var(--muted); font-size: .7rem; }
.event-kicker { margin: 8px 0; color: var(--danger); font-size: .78rem; letter-spacing: .16em; text-align: center; }
.event-resin-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.event-resin-choice { min-height: 170px; }
.event-resin-choice img { width: 92px; height: 92px; }
.event-resin-symbol { display: grid; width: 92px; height: 92px; place-items: center; font-size: 2.2rem; border: 1px dashed currentColor; }
.event-found-resin { display: grid; place-items: center; margin: 4px auto 18px; }
.event-found-resin img { width: 150px; height: 150px; object-fit: contain; filter: drop-shadow(0 10px 12px rgba(0,0,0,.5)); }
.event-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.event-actions > button { min-height: 82px; }
.sanctuary-actions > button { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.sanctuary-actions strong { color: var(--accent); font-size: 1rem; }
.sanctuary-actions span { color: var(--muted); font-size: .7rem; }
.rest-actions { grid-template-columns: minmax(240px, 420px); justify-content: center; }
.rest-actions > button { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.rest-actions strong { color: #a5ffd0; font-size: 1.15rem; }
.rest-actions span { color: var(--muted); font-size: .72rem; }
.route-room-placeholder { height: 100%; display: grid; place-content: center; gap: 12px; text-align: center; }
.event-fusion { overflow: visible; }
.fusion-stage { position: relative; width: min(210px,100%); height: 88px; margin: 0 auto 5px; display: grid; place-items: center; }
.fusion-ingredients { position: absolute; inset: 0; display: grid; place-items: center; }
.fusion-ingredient { position: absolute; z-index: 2; font-size: 2.35rem; transform: translateX(var(--fusion-offset)) scale(.78); filter: drop-shadow(0 0 8px rgba(215,174,102,.3)); animation: resin-converge .72s cubic-bezier(.55,.05,.35,1) forwards; }
.fusion-flash { z-index: 3; color: #fff4c9; font-size: 1.8rem; opacity: 0; animation: fusion-flash .32s ease-out .58s forwards; }
.fusion-result { position: absolute; z-index: 4; font-size: 3.6rem; opacity: 0; transform: scale(.15) rotate(-18deg); filter: drop-shadow(0 0 16px rgba(205,139,255,.8)); animation: fusion-reveal .36s cubic-bezier(.2,1.5,.45,1) .62s forwards; }
@keyframes resin-converge {
  0% { opacity: 1; transform: translateX(var(--fusion-offset)) scale(.78) rotate(-8deg); }
  72% { opacity: 1; transform: translateX(0) scale(1.05) rotate(8deg); }
  100% { opacity: 0; transform: translateX(0) scale(.15) rotate(22deg); }
}
@keyframes fusion-flash {
  0% { opacity: 0; transform: scale(.2); }
  45% { opacity: 1; transform: scale(3.2); text-shadow: 0 0 25px #fff, 0 0 45px #a878d1; }
  100% { opacity: 0; transform: scale(5); }
}
@keyframes fusion-reveal {
  from { opacity: 0; transform: scale(.15) rotate(-18deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@media (max-width: 780px) {
  .battle-stage { grid-template-columns: 1fr; }
  .versus-panel { order: 2; }
  .enemy-actor { order: 3; }
  .enemy-roster-panel { order: 3; }
  .actor-art-frame { min-height: 200px; }
  .actor-art { height: 200px; }
  .hand { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .masthead { align-items: stretch; flex-direction: column; }
  .mode-button { align-self: flex-start; }
  .reward-choices, .reward-generators, .event-resin-list, .event-actions { grid-template-columns: 1fr; }
  .reward-choice { min-height: 130px; }
  .reward-choice img { width: 84px; height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .actor-art, .event-pulse .combat-result { animation: none !important; }
}

@media (max-width: 480px) {
  .hand { grid-template-columns: 1fr; }
  .primary-actions { grid-template-columns: 1fr; }
  .enemy-roster { grid-template-columns: 1fr; }
  .battle-panel { padding-inline: 12px; }
}
