/* Echoes of Eternity — classic JRPG window style */
:root {
  color-scheme: dark;
  --text-scale: 1;
  --win-a: #24306e;
  --win-b: #0d1336;
  --win-border: #d8def8;
  --win-border2: #5a68b0;
  --ink: #f2f0ff;
  --muted: #a8acd0;
  --gold: #ffd25a;
  --accent: #7fe0ff;
  --red: #ff5a6a;
  --green: #70f0a0;
  --focus: #ffe680;
  --display: "Pixelify Sans", "Courier New", monospace;
  --mono: "VT323", "Courier New", monospace;
  --fs: calc(22px * var(--text-scale));
}
body.high-contrast {
  --win-a: #000;
  --win-b: #000;
  --win-border: #fff;
  --ink: #fff;
  --muted: #e0e0e0;
  --focus: #ffff00;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #04050c; color: var(--ink); font: var(--fs)/1.15 var(--mono); }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
button { font: inherit; color: inherit; }

/* ---------- Windows ---------- */
.panel, .modal, .dlg-box, .b-cmd, .b-party, .b-enemies, .pause, .wm-panel, .garage-panel, .toast, #quest-tracker, #prompt {
  background: linear-gradient(180deg, var(--win-a), var(--win-b));
  border: 2px solid var(--win-border);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--win-border2), 0 6px 18px rgba(0, 0, 0, .55);
}
.modal-title, .panel-title, .b-cmd-title { font: 700 calc(20px * var(--text-scale)) var(--display); color: var(--gold); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; letter-spacing: .02em; }
.muted { color: var(--muted); font-size: .85em; }
.tl-title { font: 600 calc(17px * var(--text-scale)) var(--display); color: var(--accent); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.credits { color: var(--gold); font-size: .9em; }
.up { color: var(--green); }
.down { color: var(--red); }

/* ---------- Buttons ---------- */
.btn, .sk-row, .opt-row, .hero-card[data-nav], .titan-card, .loc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  background: transparent; border: 0; padding: 4px 10px 4px 22px; text-align: left; cursor: pointer; position: relative;
  border-radius: 4px; min-height: 30px; font-size: var(--fs);
}
.btn:hover, .btn.focus, .sk-row.focus, .opt-row.focus, .hero-card.focus, .titan-card.focus, .loc-row.focus { background: rgba(255, 255, 255, .1); }
.focus::before { content: '▶'; position: absolute; left: 4px; color: var(--focus); font-size: .8em; animation: blink .8s steps(2) infinite; }
.hero-card.focus::before, .titan-card.focus::before { top: 8px; }
.btn[disabled] { color: #6a6e90; cursor: default; }
.btn.on { color: var(--gold); }
.btn.primary { color: var(--gold); }
.btn-right { color: var(--muted); font-size: .85em; white-space: nowrap; }
.btn.done { color: var(--muted); }
@keyframes blink { 50% { opacity: .3; } }
.key { display: inline-block; min-width: 1.4em; padding: 0 5px; border: 1px solid var(--win-border); border-radius: 4px; background: #1a1f44; font-size: .85em; text-align: center; margin-right: 3px; }
.mini { background: transparent; border: 1px solid var(--win-border2); border-radius: 4px; padding: 0 6px; font-size: calc(16px * var(--text-scale)); cursor: pointer; color: var(--muted); }

/* ---------- Bars ---------- */
.bar { height: 7px; background: #0a0c20; border: 1px solid #4a5090; border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4ad06a, #a8ff8a); transition: width .3s; }
.bar.ep .bar-fill { background: linear-gradient(90deg, #4a7ad0, #8ac8ff); }
.bar.xp .bar-fill { background: linear-gradient(90deg, #c8a030, #ffe080); }
.bar.hull .bar-fill { background: linear-gradient(90deg, #4ad06a, #c8ff8a); }
.bar.fuel .bar-fill { background: linear-gradient(90deg, #d09030, #ffd060); }
.bar.heat .bar-fill { background: linear-gradient(90deg, #d05030, #ff9060); }
.bar.part .bar-fill { background: linear-gradient(90deg, #b06ad0, #e0a0ff); }
.bar.warn { border-color: var(--red); animation: blink .5s steps(2) infinite; }

/* ---------- Screens & modals ---------- */
#ui-layer { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.screen { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: center; padding: 16px; }
.screen.battle-menu { pointer-events: none; align-items: flex-end; justify-content: flex-end; padding: 0; }
.screen.battle-menu > * { pointer-events: auto; }
.modal-wrap { background: rgba(2, 3, 12, .45); }
.modal-wrap.dark { background: rgba(10, 0, 0, .75); }
.modal { padding: 14px 16px; min-width: min(360px, 92vw); max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal.wide { width: min(760px, 94vw); }
.choice-list { display: flex; flex-direction: column; gap: 2px; }
.desc-line, .cmp { min-height: 1.3em; color: var(--accent); font-size: .9em; margin-top: 6px; }

/* ---------- Title ---------- */
.title-wrap { justify-content: flex-start; padding-left: 7vw; }
.title-screen { display: flex; flex-direction: column; gap: 10px; max-width: 520px; }
.logo { display: flex; flex-direction: column; line-height: .9; }
.logo-main { font: 700 clamp(44px, 8vw, 92px) var(--display); color: #f6efe0; text-shadow: 0 0 18px rgba(255, 140, 60, .55), 3px 3px 0 #8a2a10; letter-spacing: .05em; }
.logo-of { font: 400 clamp(20px, 3vw, 30px) var(--display); color: var(--gold); margin-left: .4em; }
.logo-sub { color: var(--muted); font-size: 1em; margin-bottom: 14px; max-width: 420px; }
.title-menu { display: flex; flex-direction: column; width: 320px; max-width: 86vw; padding: 10px; background: rgba(8, 10, 30, .6); border: 1px solid #3a4280; border-radius: 6px; }
.title-foot { color: #6a6e98; font-size: .8em; margin-top: 10px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; display: none; }
#loc-name { position: absolute; left: 20px; top: 18px; font: 700 calc(26px * var(--text-scale)) var(--display); color: #fff; text-shadow: 2px 2px 0 #000, 0 0 12px rgba(0, 0, 0, .8); opacity: 0; }
#loc-name.show { animation: locname 3.6s ease forwards; }
@keyframes locname { 0% { opacity: 0; transform: translateX(-20px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#quest-tracker { position: absolute; right: 14px; top: 14px; padding: 6px 12px; max-width: 320px; font-size: .85em; }
#quest-tracker:empty, body.ui-open #quest-tracker, body.ui-open #prompt { display: none !important; }
.qt-title { color: var(--gold); font-family: var(--display); font-size: .9em; }
.qt-obj { color: var(--ink); }
#prompt { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 4px 14px; display: none; white-space: nowrap; }
#autosave-ico { position: absolute; right: 16px; bottom: 14px; color: var(--accent); font-size: .8em; opacity: 0; z-index: 60; pointer-events: none; }
#autosave-ico.show { animation: autosave 2s ease; }
@keyframes autosave { 0%, 100% { opacity: 0; } 20%, 70% { opacity: 1; } }

/* ---------- Toasts / fade / flash / cards ---------- */
#toast-layer { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 6px 16px; transition: opacity .5s, transform .5s; animation: toastin .3s ease; text-align: center; max-width: 90vw; }
.toast.quest { border-color: var(--gold); }
.toast.item { border-color: var(--accent); }
.toast.join { border-color: var(--green); }
.toast.warn { border-color: var(--red); color: #ffd0d0; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px); } }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 90; }
#flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 85; }
#flash.go { animation: flash .35s ease; }
@keyframes flash { 0% { opacity: .8; } 100% { opacity: 0; } }
#battle-flash { position: absolute; inset: 0; pointer-events: none; z-index: 88; opacity: 0; background: repeating-conic-gradient(from 0deg, #fff 0 10deg, #000 10deg 20deg); }
#battle-flash.go { animation: bflash .6s ease; }
@keyframes bflash { 0% { opacity: 0; transform: scale(.2) rotate(0); } 50% { opacity: .9; transform: scale(2) rotate(90deg); } 100% { opacity: 0; transform: scale(3) rotate(180deg); } }
body.reduce-motion #battle-flash.go { animation: none; }
.title-card { position: absolute; inset: 0; z-index: 95; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(10, 12, 40, .85), rgba(0, 0, 0, .95)); opacity: 0; transition: opacity .6s; cursor: pointer; text-align: center; padding: 16px; }
.title-card.in { opacity: 1; }
.tc-small { font: 400 calc(20px * var(--text-scale)) var(--display); color: var(--accent); letter-spacing: .3em; text-transform: uppercase; }
.tc-big { font: 700 clamp(32px, 6vw, 64px) var(--display); color: #fff; text-shadow: 0 0 20px rgba(127, 224, 255, .5); margin-top: 10px; }
.title-card.ending .tc-big { color: var(--gold); }
#game.shake { animation: shake .35s; }
body.reduce-motion #game.shake { animation: none; }
@keyframes shake { 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -2px); } }
#boot { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #04050c; z-index: 200; }
.boot-title { font: 700 40px var(--display); color: #f6efe0; }
.boot-msg { color: var(--muted); margin-top: 10px; }

/* ---------- Dialogue ---------- */
#dialog-layer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center; padding: 0 12px 14px; pointer-events: none; }
.dlg-box { pointer-events: auto; width: min(900px, 100%); min-height: 140px; display: none; gap: 14px; padding: 14px 16px 26px; position: relative; cursor: pointer; }
.dlg-box.narration { background: linear-gradient(180deg, #1a1a1a, #050505); }
.dlg-portrait { width: 112px; height: 112px; image-rendering: pixelated; border: 2px solid var(--win-border2); border-radius: 4px; flex-shrink: 0; background: #0a0a18; }
.dlg-main { flex: 1; min-width: 0; }
.dlg-name { font: 700 calc(21px * var(--text-scale)) var(--display); color: var(--gold); margin-bottom: 4px; }
.dlg-text { font-size: calc(25px * var(--text-scale)); line-height: 1.15; white-space: pre-wrap; min-height: 2.4em; }
.dlg-next { position: absolute; right: 16px; bottom: 6px; color: var(--focus); animation: blink .8s steps(2) infinite; }
.dlg-ctrl { position: absolute; left: 16px; bottom: 4px; display: flex; gap: 6px; }
.dlg-box.auto-on .dlg-ctrl button:first-child { color: var(--gold); border-color: var(--gold); }
.dlg-choices { display: flex; flex-direction: column; margin-top: 6px; }
.dlg-choice { background: transparent; border: 0; text-align: left; padding: 3px 8px; cursor: pointer; color: var(--ink); font-size: calc(23px * var(--text-scale)); border-radius: 4px; }
.dlg-choice.focus { background: rgba(255, 255, 255, .12); color: var(--focus); }
.log-list { max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.log-line b { color: var(--gold); font-weight: normal; }

/* ---------- Pause menu ---------- */
.pause { width: min(1040px, 96vw); height: min(680px, 92vh); display: flex; flex-direction: column; padding: 10px 14px; }
.tabs { display: flex; gap: 2px; align-items: center; border-bottom: 1px solid var(--win-border2); padding-bottom: 6px; overflow-x: auto; flex-shrink: 0; }
.tab { background: transparent; border: 0; padding: 4px 10px; cursor: pointer; color: var(--muted); font: 600 calc(17px * var(--text-scale)) var(--display); white-space: nowrap; border-radius: 4px; }
.tab.on { color: var(--gold); background: rgba(255, 255, 255, .08); }
.tab-key { font-size: .7em; color: var(--muted); border: 1px solid var(--win-border2); border-radius: 3px; padding: 0 4px; }
.pause-body { flex: 1; display: grid; grid-template-columns: 1fr 210px; gap: 12px; min-height: 0; padding-top: 8px; }
.pause-body > :first-child { overflow: auto; min-height: 0; padding-right: 6px; }
.menu-info { border-left: 1px solid var(--win-border2); padding-left: 10px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .9em; }
.hero-pick { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.hero-pick .btn { width: auto; }
.tab-status { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.hero-card { display: flex; gap: 10px; padding: 8px 8px 8px 22px; border: 1px solid #3a4280; border-radius: 6px; align-items: flex-start; }
.hero-card.reserve { opacity: .8; }
.portrait { image-rendering: pixelated; border: 1px solid var(--win-border2); border-radius: 4px; background: #0a0a18; flex-shrink: 0; }
.hc-body { flex: 1; min-width: 0; }
.hc-name { font: 700 calc(19px * var(--text-scale)) var(--display); }
.hc-lv { color: var(--ink); font-weight: 400; font-size: .85em; }
.hc-role { color: var(--muted); font-size: .8em; }
.hc-bars { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; align-items: center; font-size: .85em; margin: 4px 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0 10px; font-size: .85em; color: var(--muted); }
.stat-grid b { color: var(--ink); font-weight: normal; }
.stat-grid.big { font-size: 1em; margin-top: 10px; }
.synergy { grid-column: 1 / -1; color: var(--accent); font-size: .85em; }
.sk-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.sk-row.locked { color: #6a6e90; }
.ap-line { color: var(--muted); font-size: .85em; }
.item-list { display: flex; flex-direction: column; gap: 1px; }
.tab-quests { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; }
.quest-detail { border-left: 1px solid var(--win-border2); padding-left: 12px; }
.qd-title { font: 700 calc(19px * var(--text-scale)) var(--display); color: var(--gold); }
.qd-type { color: var(--accent); font-size: .8em; }
.qd-obj { margin: 2px 0; }
.qd-obj.done { color: var(--muted); text-decoration: line-through; }
.qd-rew { color: var(--gold); font-size: .85em; margin-top: 6px; }
.minimap { image-rendering: pixelated; border: 1px solid var(--win-border2); max-width: 100%; max-height: 46vh; background: #000; }
.map-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .8em; }
.lg::before { content: '■ '; }
.lg.exit::before { color: #ffe060; } .lg.save::before { color: #60ffa0; } .lg.shop::before { color: #60c0ff; } .lg.chest::before { color: #ffb040; } .lg.enemy::before { color: #ff4040; }
.titan-card { flex-direction: column; align-items: stretch; border: 1px solid #3a4280; border-radius: 6px; padding: 8px 8px 8px 22px; margin-bottom: 6px; }
.tc-name { font: 700 calc(19px * var(--text-scale)) var(--display); color: var(--gold); }
.tc-name small { color: var(--muted); font-weight: 400; font-size: .75em; }

/* ---------- Options ---------- */
.options .opt-scroll { max-height: 64vh; overflow: auto; padding-right: 6px; }
.opt-row { cursor: pointer; }
.opt-label { flex: 1; }
.opt-arrows { color: var(--gold); white-space: nowrap; }
.sl-bar { width: 140px; height: 10px; background: #0a0c20; border: 1px solid #4a5090; border-radius: 3px; overflow: hidden; }
.sl-fill { display: block; height: 100%; background: var(--accent); }
.sl-val { width: 70px; text-align: right; color: var(--gold); }

/* ---------- Save / shop / garage ---------- */
.save-list { display: flex; flex-direction: column; gap: 2px; max-height: 62vh; overflow: auto; }
.save-list .btn { flex-wrap: wrap; border-bottom: 1px solid rgba(90, 104, 176, .3); }
.save-info { width: 100%; color: var(--muted); font-size: .8em; }
.save-party { display: flex; gap: 2px; }
.save-tools { display: flex; gap: 6px; margin-top: 8px; }
.save-tools .btn { width: auto; }
.save-text { width: 100%; height: 160px; background: #05071a; color: var(--ink); border: 1px solid var(--win-border2); font: 14px monospace; margin-bottom: 8px; }
.shop-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-height: 58vh; min-height: 220px; }
.shop-body > * { overflow: auto; }
.shop-detail { border-left: 1px solid var(--win-border2); padding-left: 12px; font-size: .9em; }
.cmp-row { font-size: .9em; }
.garage-wrap { justify-content: flex-end; }
.garage-panel { width: min(430px, 96vw); max-height: 94vh; overflow: auto; padding: 12px 14px; }

/* ---------- World map ---------- */
.wm-wrap { justify-content: flex-start; align-items: stretch; pointer-events: none; }
.wm-panel { pointer-events: auto; width: min(320px, 92vw); padding: 12px; overflow: auto; align-self: center; max-height: 90vh; }
.wm-labels { position: absolute; inset: 0; pointer-events: none; }
.wm-label { position: absolute; transform: translate(-50%, -100%); font: 600 calc(15px * var(--text-scale)) var(--display); color: #fff; text-shadow: 1px 1px 0 #000, 0 0 6px #000; white-space: nowrap; }
.wm-label.here { color: var(--gold); }

/* ---------- Battle ---------- */
#battle-ui { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#battle-ui > * { pointer-events: auto; }
#fx-layer { position: absolute; inset: 0; z-index: 25; pointer-events: none; }
.b-msg { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); padding: 6px 18px; background: rgba(5, 8, 30, .85); border: 2px solid var(--win-border); border-radius: 6px; opacity: 0; transition: opacity .2s; white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis; pointer-events: none !important; }
.b-msg.show { opacity: 1; }
.b-msg.warn { border-color: var(--red); color: #ffd0d0; }
.b-banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font: 700 clamp(28px, 5vw, 52px) var(--display); color: var(--gold); text-shadow: 3px 3px 0 #6a2a00, 0 0 20px rgba(255, 200, 80, .7); opacity: 0; pointer-events: none !important; }
.b-banner.show { animation: banner 1.1s ease; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.6); } 20% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.b-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 8px; align-items: flex-end; pointer-events: none !important; }
.b-bottom > * { pointer-events: auto; }
.b-enemies { width: 30%; min-width: 200px; padding: 8px 10px; font-size: .9em; }
.b-party { flex: 1; padding: 6px 10px; max-width: 640px; }
.b-row { display: grid; grid-template-columns: 90px 40px 1fr 70px 90px; gap: 8px; align-items: center; padding: 2px 4px; border-radius: 4px; }
.b-row.active { background: rgba(255, 230, 128, .14); }
.b-row.ready .b-name::after { content: ' ●'; color: var(--focus); }
.b-row.ko { opacity: .5; }
.b-row.ko .b-name { text-decoration: line-through; }
.b-row.low .b-hp b { color: var(--red); }
.b-name { font-family: var(--display); font-size: .85em; white-space: nowrap; overflow: hidden; }
.b-st { font-size: .75em; }
.b-hp { position: relative; height: 18px; background: #0a0c20; border: 1px solid #4a5090; border-radius: 3px; overflow: hidden; }
.b-hp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #2a8a4a, #5ad07a); transition: width .3s; }
.b-hp b { position: relative; display: block; line-height: 16px; font-weight: normal; padding-left: 6px; font-size: .85em; text-shadow: 1px 1px 0 #000; }
.b-ep b { font-weight: normal; color: #8ac8ff; font-size: .85em; }
.b-atb { height: 8px; background: #0a0c20; border: 1px solid #4a5090; border-radius: 3px; overflow: hidden; }
.b-atb i { display: block; height: 100%; background: linear-gradient(90deg, #c8a030, #ffe680); }
.b-row.ready .b-atb i { background: #fff; }
.b-erow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px 0; cursor: pointer; }
.b-erow.boss > span:first-child { color: var(--red); }
.b-weak { font-size: .75em; color: var(--accent); }
.b-ehp { flex-basis: 100%; height: 5px; background: #0a0c20; border-radius: 2px; overflow: hidden; }
.b-ehp i { display: block; height: 100%; background: var(--red); transition: width .3s; }
.b-cmd { pointer-events: auto; width: 290px; max-height: 70vh; overflow: auto; padding: 10px; margin: 0 8px 8px 0; }
.screen.battle-menu .b-cmd { margin-bottom: calc(8px + var(--bottom-h, 150px)); }
.b-cursor { position: absolute; transform: translate(-50%, -100%); color: var(--focus); font-size: 28px; text-shadow: 2px 2px 0 #000; display: none; animation: bob .6s ease-in-out infinite alternate; pointer-events: none !important; }
@keyframes bob { to { margin-top: -8px; } }
.b-help { position: absolute; left: 50%; bottom: calc(var(--bottom-h, 150px) + 18px); transform: translateX(-50%); color: var(--accent); text-shadow: 1px 1px 0 #000; font-size: .9em; pointer-events: none !important; white-space: nowrap; }
.target-hint { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); padding: 4px 14px; background: rgba(5, 8, 30, .85); border: 1px solid var(--win-border); border-radius: 6px; }
.ap-pips { display: flex; gap: 4px; margin: 4px 0; }
.pip { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); background: var(--gold); }
.pip.used { background: transparent; opacity: .5; }
.combo-seq { display: flex; gap: 4px; min-height: 28px; align-items: center; margin: 4px 0; }
.cs { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 4px; font-family: var(--display); font-weight: 700; color: #000; }
.cs-L { background: #a8e0ff; } .cs-M { background: #ffe080; } .cs-H { background: #ff9a7a; }
.combo-match { color: var(--gold); min-height: 1.2em; font-family: var(--display); }
.combo-row { display: flex; flex-direction: column; }
.tech-list { margin-top: 6px; border-top: 1px solid var(--win-border2); padding-top: 4px; }
.btn.tech { font-size: .9em; }
.dmg-pop { position: absolute; transform: translate(-50%, 0); font: 700 calc(30px * var(--text-scale)) var(--display); color: #fff; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; animation: pop 1.1s ease forwards; white-space: nowrap; }
.dmg-pop.crit { color: #ffe040; font-size: calc(38px * var(--text-scale)); }
.dmg-pop.weak { color: #ff9a40; }
.dmg-pop.resist { color: #a0a0c0; }
.dmg-pop.heal { color: var(--green); }
.dmg-pop.ep { color: #8ac8ff; }
.dmg-pop.miss { color: #c0c0d0; font-size: calc(22px * var(--text-scale)); }
.dmg-pop.status { color: #d0b0ff; font-size: calc(20px * var(--text-scale)); }
.dmg-pop.tag { color: #ff9a40; font-size: calc(20px * var(--text-scale)); margin-top: -26px; }
.dmg-pop.dot { color: #c080ff; }
@keyframes pop { 0% { opacity: 0; margin-top: 10px; } 15% { opacity: 1; margin-top: -14px; } 30% { margin-top: -6px; } 80% { opacity: 1; } 100% { opacity: 0; margin-top: -30px; } }
/* Mech HUD */
.b-party.mech { max-width: 760px; }
.m-row { grid-template-columns: 120px 1fr 1fr 1fr auto; }
.m-row .b-name small { color: var(--muted); font-family: var(--mono); }
.m-stat { display: grid; grid-template-columns: auto 1fr auto; gap: 4px; align-items: center; font-size: .78em; }
.m-stat label { color: var(--muted); }
.m-stat b { font-weight: normal; min-width: 32px; text-align: right; }
.m-flag { color: var(--red); font-size: .75em; animation: blink .5s steps(2) infinite; }
.m-flag.ok { color: var(--accent); animation: none; }
.m-erow { flex-direction: column; align-items: stretch; }
.m-erow .bar { width: 100%; }
.m-part { display: grid; grid-template-columns: 1fr 80px; gap: 6px; align-items: center; font-size: .8em; color: #d0b0ff; padding-left: 8px; }
.m-part.broken { color: #6a6a80; text-decoration: line-through; display: block; }
.m-part.weak { color: #ffb070; }
.m-round { position: absolute; right: 14px; top: 14px; font: 700 18px var(--display); color: var(--gold); text-shadow: 2px 2px 0 #000; pointer-events: none !important; }
.b-cmd.mech { width: 330px; }

/* ---------- Results / game over / credits / tutorial ---------- */
.results { min-width: min(420px, 92vw); }
.res-line { display: flex; justify-content: space-between; gap: 16px; }
.res-line b { color: var(--gold); font-weight: normal; }
.lvup { color: var(--green); margin-top: 6px; }
.learned { color: var(--accent); font-size: .85em; }
.gameover { text-align: center; }
.go-title { font: 700 48px var(--display); color: var(--red); text-shadow: 3px 3px 0 #000; }
.credits-wrap { background: #000; }
.credits-screen { position: absolute; inset: 0; overflow: hidden; }
.credits-roll { position: absolute; left: 0; right: 0; top: 100%; text-align: center; animation: roll 60s linear forwards; display: flex; flex-direction: column; gap: 10px; padding: 0 16px; }
body.reduce-motion .credits-roll { animation-duration: 90s; }
@keyframes roll { to { transform: translateY(calc(-100% - 100vh)); } }
.cr-head { font: 700 calc(24px * var(--text-scale)) var(--display); color: var(--gold); margin-top: 26px; }
.cr-head.big { font-size: 40px; margin-top: 80px; }
.cr-line { color: var(--ink); }
.cr-skip { position: absolute; right: 16px; bottom: 12px; color: var(--muted); font-size: .8em; }
.tut-body { line-height: 1.3; margin-bottom: 10px; }

/* ---------- Touch controls ---------- */
#touch-ui { display: none; position: absolute; inset: auto 0 0 0; height: 0; z-index: 80; pointer-events: none; }
body.touch #touch-ui { display: block; }
#touch-ui b { position: absolute; pointer-events: auto; width: 54px; height: 54px; border-radius: 50%; background: rgba(20, 24, 60, .55); border: 2px solid rgba(216, 222, 248, .6); color: #fff; display: flex; align-items: center; justify-content: center; font: 700 20px var(--display); user-select: none; touch-action: none; }
#touch-ui b.on { background: rgba(255, 230, 128, .5); }
.t-pad { position: absolute; left: 14px; bottom: 14px; width: 170px; height: 170px; }
.t-pad [data-b=up] { left: 58px; top: 0; } .t-pad [data-b=down] { left: 58px; bottom: 0; } .t-pad [data-b=left] { left: 0; top: 58px; } .t-pad [data-b=right] { right: 0; top: 58px; }
.t-btns { position: absolute; right: 14px; bottom: 14px; width: 190px; height: 190px; }
.t-a { right: 0; bottom: 50px; width: 64px !important; height: 64px !important; } .t-b { right: 72px; bottom: 0; } .t-j { right: 80px; bottom: 80px; } .t-m { right: 0; top: -40px; } .t-l { right: 136px; top: -40px; } .t-r { right: 68px; top: -40px; }
body.touch #dialog-layer { padding-bottom: 10px; }
body.touch[data-mode=battle] #touch-ui, body.touch[data-mode=mech] #touch-ui, body.touch[data-mode=title] #touch-ui, body.touch.ui-open #touch-ui { display: none; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  :root { --fs: calc(19px * var(--text-scale)); }
  .pause-body { grid-template-columns: 1fr; }
  .menu-info { display: none; }
  .tab-quests, .shop-body { grid-template-columns: 1fr; }
  .b-enemies { display: none; }
  .b-row { grid-template-columns: 70px 24px 1fr 56px 50px; gap: 4px; }
  .m-row { grid-template-columns: 1fr; }
  .dlg-portrait { width: 64px; height: 64px; }
  .dlg-text { font-size: calc(21px * var(--text-scale)); }
  #quest-tracker { display: none; }
  .b-cmd { width: 240px; }
}
