/* Trace Battle's original light, open battle screen. */
#traceBattle[hidden] { display: none !important; }
#traceBattle {
  position: fixed; inset: 0; z-index: 65; overflow: auto;
  background: #fafbf9; color: #28342e; color-scheme: light;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}
#traceBattle *, #traceBattle *::before, #traceBattle *::after { box-sizing: border-box; }
#traceBattle button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; box-shadow: none; text-shadow: none; }
#traceBattle button:focus-visible, .trace-board:focus-visible { outline: 2px solid #568b77; outline-offset: 4px; }
#traceBattle [hidden] { display: none !important; }
#traceBattle .trace-window.game {
  position: relative; max-width: 860px; width: 100%; margin: 0 auto;
  padding: 17px 32px 12px; background: none; border: 0; border-radius: 0;
  box-shadow: none; backdrop-filter: none; min-height: 0;
}
#traceBattle .encounter { position: relative; height: 240px; }
.trace-enemy { position: absolute; inset: 12px 0 20px; }
.trace-enemy .scene { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 310px; height: 185px; overflow: visible; color: #252e2b; pointer-events: none; }
.trace-enemy-hp { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: block; width: 184px; height: 3px; border: 0; border-radius: 9px; overflow: hidden; appearance: none; -webkit-appearance: none; background: #28342e12; }
.trace-enemy-hp::-webkit-meter-bar { height: 3px; border: 0; border-radius: 9px; background: #28342e12; }
.trace-enemy-hp::-webkit-meter-optimum-value, .trace-enemy-hp::-webkit-meter-suboptimum-value, .trace-enemy-hp::-webkit-meter-even-less-good-value { background: #45634d; transition: width .42s ease; }
.trace-enemy-hp::-moz-meter-bar { background: #45634d; }
.trace-target { position: absolute; bottom: 0; left: calc(50% - 3px); width: 6px; height: 6px; border: 1px solid #839e88; border-radius: 50%; }
#traceBattle .board-top { position: relative; display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 18px 10px; }
#traceBattle .player { display: flex; align-items: center; gap: 13px; width: 100%; padding-right: 53px; }
.trace-player { font-size: 16px; font-weight: 500; color: #6e7c74; font-variant-numeric: tabular-nums; }
.trace-hp-track { flex: 1; height: 5px; background: #28342e12; border-radius: 9px; overflow: hidden; }
.trace-hp-track i { display: block; height: 100%; background: #72a38a; transition: width .25s ease; }
.trace-shield { position: absolute; left: 58px; top: 29px; color: #477b9c; font-size: 12px; line-height: 14px; }
#traceBattle .board-wrap { position: relative; }
.trace-board { display: block; width: 100%; height: min(47svh, 420px); background: none; border: 0; border-radius: 0; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; overflow: visible; cursor: crosshair; }
.trace-line { fill: none; stroke: #4a7963; stroke-width: 1.2; opacity: .6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; vector-effect: non-scaling-stroke; }
.trace-cursor { fill: #fafbf9; fill-opacity: .68; stroke: #809c89; stroke-width: 1; vector-effect: non-scaling-stroke; }
.trace-distance-track { fill: #28342e18; }
.trace-distance-fill { fill: #909c94; }
.trace-danger :is(rect,circle) { fill: #bb6c61; fill-opacity: .075; stroke: #b7756a; stroke-opacity: .34; stroke-width: 1; vector-effect: non-scaling-stroke; }
.trace-loops polygon { fill: #4a7963; fill-opacity: .035; stroke: #4a7963; stroke-opacity: .4; stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.trace-pieces g { transition: opacity .2s; }
.trace-picked { opacity: .12; }
#traceBattle .action-area { height: 64px; display: flex; align-items: center; justify-content: center; gap: 25px; position: relative; }
.trace-feedback { margin: 0; font-size: 12px; color: #7d8c80; line-height: 1.8; }
#traceBattle .tech-button { position: absolute; right: 17px; top: -4px; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 6px; border: 1px solid #b6a06a; border-radius: 50%; background: #fafbf9; z-index: 5; overflow: hidden; }
.trace-tech svg { width: 30px; height: 30px; color: #a48b50; fill: currentColor; z-index: 1; }
.trace-tech-fill { position: absolute; inset: 0; opacity: .28; pointer-events: none; background: #c8ac67; transition: transform .25s ease-out; }
#traceBattle .tech-button.armed { border-color: #997832; box-shadow: 0 0 0 3px #c8ac6724; }
#traceBattle .tech-button:disabled { opacity: .45; cursor: default; }
#traceBattle .armory { position: fixed; right: 24px; bottom: 17px; border: 0; border-radius: 0; background: none; color: #98a49b; font-size: 25px; line-height: 1; letter-spacing: 2px; padding: 7px; width: 44px; height: 44px; z-index: 2; }
.trace-actions { position: fixed; right: 24px; bottom: 68px; min-width: 195px; padding: 14px 22px; z-index: 3; }
#traceBattle .trace-actions button { display: block; width: 100%; min-height: 48px; padding: 14px 6px; border: 0; border-radius: 0; text-align: left; background: none; color: inherit; font-size: 15px; }
#traceBattle dialog { position: fixed; inset: 0; margin: auto; width: 430px; max-width: calc(100vw - 36px); max-height: calc(100svh - 54px); overflow-y: auto; padding: 29px; }
#traceBattle dialog::backdrop { background: #eef2eec9; backdrop-filter: blur(7px); }
#traceBattle dialog h2 { font-size: 19px; font-weight: 500; margin: 0 0 19px; }
#traceBattle dialog p { font-size: 13px; color: inherit; line-height: 1.9; }
#traceBattle .close { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border: 0; background: none; color: inherit; font-size: 24px; }
#traceBattle .skill-card { display: flex; gap: 18px; width: 100%; text-align: left; border: 0; border-top: 1px solid #ffffff26; border-radius: 0; background: none; padding: 20px 0; }
.trace-skill svg { width: 37px; height: 37px; flex: 0 0 37px; color: #a48b50; }
.trace-skill strong { font-size: 16px; font-weight: 500; }
.trace-skill small { display: block; margin-top: 8px; font-size: 13px; line-height: 1.8; color: inherit; opacity: .8; }
.trace-skill.selected strong::after { content: ' ·'; color: #5b9675; }
.trace-skill:disabled { opacity: .55; cursor: default; }
.trace-legend p { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.trace-legend svg { width: 26px; height: 26px; flex-shrink: 0; }
.trace-sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0 !important; }
body.trace-battle-active { background: #fafbf9; }
body.trace-battle-active #center, body.trace-battle-active #MAPUI, body.trace-battle-active #statusWindow, body.trace-battle-active #directionPad, body.trace-battle-active #gameMenu, body.trace-battle-active #specialActionShortcut { visibility: hidden; }
.trace-resolving .trace-board { opacity: .55; pointer-events: none; }
.trace-enemy-threatening { animation: trace-cue-horizontal 4s linear infinite; }
@keyframes trace-cue-horizontal { 0%,58%,88%,100% { translate: 0 0; } 60%,68%,76%,84% { translate: 1.4px 0; } 64%,72%,80% { translate: -1.4px 0; } }
@media (max-width: 650px) {
  #traceBattle .trace-window.game { padding: 12px 10px 10px; max-width: 460px; }
  #traceBattle .encounter { height: 215px; }
  .trace-enemy { inset: 12px 0 20px; }
  .trace-enemy .scene { top: 12px; width: 270px; height: 175px; }
  .trace-enemy-hp { width: 204px; }
  .trace-board { height: auto; aspect-ratio: 1; }
  #traceBattle .board-top { padding: 0 18px 10px; }
  #traceBattle .action-area { height: 64px; gap: 15px; }
  #traceBattle .armory { right: 14px; bottom: 14px; font-size: 23px; }
  .trace-actions { right: 14px; }
  #traceBattle dialog { padding: 25px; }
}
@media (max-height: 640px) and (min-width: 651px) {
  #traceBattle .encounter { height: 180px; }
  .trace-enemy .scene { top: 3px; height: 145px; }
}
@media (prefers-reduced-motion: reduce) { .trace-enemy-threatening { animation: none; } #traceBattle * { transition: none !important; } }
.trace-glass-large{filter:drop-shadow(0 .7px .8px #42615a25)}.trace-glass-art path{stroke-linejoin:round}.trace-glass-small{shape-rendering:geometricPrecision}.grain{pointer-events:none}.grain-body{transform-box:fill-box;transform-origin:center;transition:opacity .2s}
/* The current area remains a quiet landscape behind the original paper layout. */
.trace-landscape { position: fixed; inset: 0; pointer-events: none; opacity: .25; overflow: hidden; }
.trace-landscape svg { display: block; width: 100%; height: min(94svh, 850px); }
#traceBattle .trace-window.game { z-index: 1; }
.trace-combat-fx { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 310px; height: 185px; overflow: visible; pointer-events: none; z-index: 3; }
.trace-slash { fill: none; stroke: #b1843d; stroke-linecap: round; stroke-dasharray: 0 500; animation: trace-slash .38s ease-out forwards; }
.trace-enemy-number { position: absolute; left: 50%; top: 68px; transform: translateX(-50%); color: #273b30; font-size: 43px; font-weight: 600; letter-spacing: -.05em; text-shadow: 0 2px 12px #fafbf9, 0 1px 2px #fafbf9; z-index: 4; pointer-events: none; }
.trace-number-pop { animation: trace-number-pop .22s ease-out; }
#traceBattle .player { position: relative; }
.trace-player-delta { position: absolute; right: 61px; top: -2px; font-size: 20px; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; color: #a64e4e; text-shadow: 0 1px 6px #fafbf9; }
.trace-player-delta[data-kind="heal"] { color: #5b9678; }
.trace-player-delta[data-kind="guard"] { color: #578eb9; font-size: 14px; }
.trace-delta-pop { animation: trace-delta-pop .22s ease-out; }
.trace-enemy .scene.trace-hit { animation: trace-shudder .18s ease-out; }
.trace-enemy .scene.trace-lunge { animation: trace-enemy-lunge .65s ease-in-out; }
.trace-enemy .scene.trace-defeated { opacity: 0; filter: blur(3px); translate: 0 10px; transition: opacity .65s, filter .65s, translate .65s; }
.trace-enemy .scene.trace-escaped { opacity: 0; translate: 50px 0; transition: opacity .4s, translate .4s; }
.trace-player-hit .player { animation: trace-shudder .22s ease-out; }
.trace-playing .trace-board { pointer-events: none; }
@keyframes trace-slash { from { stroke-dasharray: 0 500; opacity: 0; } 25% { opacity: .85; stroke-dasharray: 350 500; } to { opacity: 0; stroke-dasharray: 350 500; } }
@keyframes trace-number-pop { from { opacity: .5; scale: .86; } to { opacity: 1; scale: 1; } }
@keyframes trace-delta-pop { from { opacity: 0; translate: 0 5px; } to { opacity: 1; translate: 0 0; } }
@keyframes trace-shudder { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
@keyframes trace-enemy-lunge { 0%,100% { translate: 0 0; } 30% { translate: 7px -5px; } 60% { translate: -20px 27px; } 80% { translate: -10px 12px; } }
@media (max-width: 650px) { .trace-combat-fx { top: 12px; width: 270px; height: 175px; } .trace-enemy-number { top: 64px; font-size: 38px; } }
@media (prefers-reduced-motion: reduce) { .trace-slash, .trace-number-pop, .trace-delta-pop, .trace-enemy .scene.trace-hit, .trace-enemy .scene.trace-lunge, .trace-player-hit .player { animation: none; } .trace-enemy .scene.trace-defeated { filter: none; translate: none; } }
:where(#traceBattle) .scene[data-motion="breathe"] { animation: none; }
:where(#traceBattle) .scene[data-motion="tremble"] { animation: trace-cue-horizontal 4s linear infinite; }
:where(#traceBattle) .scene[data-motion="scale"] { animation: trace-cue-vertical 4.3s linear infinite; }
:where(#traceBattle) .scene[data-motion="float"] { animation: trace-cue-float 5.5s ease-in-out infinite; }
:where(#traceBattle) .scene[data-motion="shade"] { animation: trace-cue-shade 6.1s linear infinite; }
@keyframes trace-cue-vertical { 0%,58%,88%,100% { translate: 0 0; } 60%,68%,76%,84% { translate: 0 1.4px; } 64%,72%,80% { translate: 0 -1.4px; } }
@keyframes trace-cue-float { 50% { translate: 0 -7px; } }
@keyframes trace-cue-shade { 0%,63%,65%,78%,80%,100% { opacity: 1; } 64%,79% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { :where(#traceBattle) .scene[data-motion] { animation: none !important; } }
