/* Cache Requiem — house palette, terminal-devotional. */
:root {
  --ink: #08071a;
  --deep: #11102e;
  --indigo: #1b1942;
  --periwinkle: #8d88e8;
  --lavender: #beb9f2;
  --pale: #efedff;
  --dawn: #f7d9a8;
  --rose: #efb9d6;
  --bloomgreen: #b9e6c2;
  --line: rgba(160, 152, 235, 0.38);
  --line-soft: rgba(160, 152, 235, 0.16);
  --serif: "Cormorant Garamond", serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(247, 217, 168, 0.10), transparent 55%),
    linear-gradient(180deg, #0a0920 0%, var(--ink) 60%);
  color: var(--pale);
  font-family: var(--mono);
  overflow: hidden;
}

#frame { height: 100%; display: grid; place-items: center; padding: 14px; }
#stagewrap { width: min(100%, 174vh); }
#stageborder {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  outline: 1px solid var(--line-soft);
  outline-offset: 5px;
  overflow: hidden;
  background: var(--ink);
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* always-available exit back to the arcade, overlaid in the stage corner */
#exit-arcade {
  position: absolute; top: 10px; left: 12px; z-index: 90;
  display: inline-flex; align-items: center; line-height: 1.1;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--lavender); text-decoration: none;
  padding: 5px 10px; border: 1px solid var(--line-soft); border-radius: 3px;
  background: rgba(8, 7, 26, 0.6); opacity: 0.5;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}
#exit-arcade:hover, #exit-arcade:focus-visible {
  opacity: 1; color: var(--dawn); border-color: var(--dawn); outline: none;
}
/* keep the overworld region label clear of the exit control */
.hud-left { padding-top: 22px; }

/* chrome bar */
.chrome-bar {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 2px 0; font-size: 11px; letter-spacing: 0.14em;
  color: var(--periwinkle); text-transform: lowercase;
}
.chrome-bar span:first-child { letter-spacing: 0.3em; }
.site-return { color: var(--dawn); text-decoration: none; }
.site-return:hover { text-decoration: underline; }

/* HUD */
#hud {
  position: absolute; inset: 12px 14px auto; display: flex;
  justify-content: space-between; align-items: flex-start;
  pointer-events: none; font-size: 12px; letter-spacing: 0.08em;
}
.hud-region { font-family: var(--serif); font-size: 21px; letter-spacing: 0.04em; color: var(--lavender); }
.hud-region::after {
  content: ''; display: block; width: 44px; height: 2px; margin-top: 3px;
  background: var(--region-accent, var(--lavender));
  opacity: 0.85; transition: background 0.5s ease;
}
.hud-bars { margin-top: 7px; display: grid; gap: 4px; }
.bar { display: flex; align-items: center; gap: 7px; }
.bar-label { width: 62px; color: var(--periwinkle); font-size: 10px; }
.bar-track { width: 150px; height: 5px; background: rgba(141, 136, 232, 0.18); border: 1px solid var(--line-soft); }
.bar-fill { height: 100%; width: 100%; transition: width 0.25s ease; }
.bar-fill.hp { background: linear-gradient(90deg, var(--lavender), var(--pale)); }
.bar-fill.sp { background: linear-gradient(90deg, #6f61da, var(--periwinkle)); }
.bar-track.cres { width: 96px; height: 4px; }
.bar-fill.meter { width: 0; background: linear-gradient(90deg, #c76d9e, var(--dawn)); }
.cres-pip {
  font-size: 10px; color: rgba(160, 152, 235, 0.4);
  transition: color 0.3s ease, text-shadow 0.3s ease;
}
.cres-pip.ready {
  color: var(--dawn); text-shadow: 0 0 9px rgba(247, 217, 168, 0.9);
  animation: pip-pulse 1.5s ease-in-out infinite;
}
@keyframes pip-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.hud-progress { margin-top: 7px; font-size: 10px; letter-spacing: 0.14em; color: var(--dawn); opacity: 0.9; }
.hud-right { text-align: right; display: grid; gap: 4px; color: var(--dawn); }

/* battle UI */
#battle-ui { position: absolute; inset: 0; pointer-events: none; }

/* top-center stack: boss bar · enemy status chips · initiative strip */
#topstack {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#initiative-strip { display: flex; gap: 6px; font-size: 10px; letter-spacing: 0.1em; }
#initiative-strip .chip {
  padding: 3px 8px; border: 1px solid var(--line-soft);
  background: rgba(17, 16, 46, 0.72); color: var(--periwinkle);
}
#initiative-strip .chip.now { border-color: var(--dawn); color: var(--dawn); }
#initiative-strip .chip.charge { border-color: var(--rose); color: var(--rose); }

/* boss integrity bar */
#boss-bar { text-align: center; }
#boss-bar-name {
  font-family: var(--serif); font-size: 17px; letter-spacing: 0.12em;
  color: var(--pale); text-shadow: 0 0 12px rgba(190, 185, 242, 0.4);
}
#boss-bar-track {
  width: 320px; height: 3px; margin: 4px auto 0;
  background: rgba(141, 136, 232, 0.15); border: 1px solid var(--line-soft);
}
#boss-bar-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--periwinkle), var(--lavender));
  transition: width 0.35s ease, background 0.6s ease;
}
#boss-bar.phase2 #boss-bar-name { color: var(--rose); text-shadow: 0 0 14px rgba(239, 185, 214, 0.55); }
#boss-bar.phase2 #boss-bar-fill { background: linear-gradient(90deg, #c76d9e, var(--rose)); }

/* status chips (party + enemies) */
.st {
  padding: 1px 6px; border: 1px solid var(--line-soft); font-size: 9px;
  letter-spacing: 0.08em; background: rgba(17, 16, 46, 0.7); white-space: nowrap;
}
.st-static { color: var(--periwinkle); }
.st-drift { color: var(--lavender); }
.st-silence { color: var(--rose); }
.st-overclock { color: var(--dawn); }
.st-bloom { color: var(--bloomgreen); }
#enemy-chips { display: flex; gap: 10px; justify-content: center; }
#enemy-chips:empty { display: none; }
#enemy-chips .grp { display: flex; gap: 4px; align-items: center; }
#enemy-chips .grp i {
  font-style: normal; font-size: 8px; letter-spacing: 0.1em;
  color: var(--periwinkle); opacity: 0.6;
}
#party-chips { margin-top: 4px; display: flex; gap: 5px; flex-wrap: wrap; }

#boss-banner {
  position: absolute; top: 104px; left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-size: 24px; color: var(--rose);
  letter-spacing: 0.08em; text-shadow: 0 0 18px rgba(239, 185, 214, 0.5);
}

#battle-log {
  position: absolute; left: 14px; top: 12px; max-width: 300px;
  font-size: 11px; line-height: 1.7; color: var(--lavender);
  text-shadow: 0 1px 8px rgba(8, 7, 26, 0.9);
}
#battle-log .dim { opacity: 0.55; }
#battle-log .num { color: var(--pale); }
#battle-log .el-signal { color: var(--lavender); }
#battle-log .el-static { color: var(--periwinkle); }
#battle-log .el-bloom { color: var(--bloomgreen); }
#battle-log .el-resonance { color: var(--dawn); }

/* target picker — floating strip above the command dock */
#target-picker {
  position: absolute; left: 50%; bottom: 132px; transform: translateX(-50%);
  display: flex; gap: 10px; font-size: 11px; letter-spacing: 0.12em;
}
#target-picker .pick {
  padding: 4px 12px; border: 1px solid var(--line-soft);
  background: rgba(17, 16, 46, 0.82); color: var(--lavender);
}
#target-picker .pick.sel { border-color: var(--dawn); color: var(--dawn); }
#target-picker .pick.sel::before { content: '▸ '; }

#command-dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 16px 14px; pointer-events: auto;
  display: flex; gap: 18px; align-items: flex-end;
  background: linear-gradient(180deg, transparent, rgba(8, 7, 26, 0.88) 40%);
}
.party-col { min-width: 210px; }
#party-status { font-size: 12px; line-height: 1.8; }
#party-status b { font-family: var(--serif); font-size: 17px; letter-spacing: 0.05em; font-weight: 500; }
#party-status .num { color: var(--dawn); }
#party-status .cres-ready { color: var(--dawn); text-shadow: 0 0 8px rgba(247, 217, 168, 0.6); }
ul#command-ring, ul#command-sub { list-style: none; display: flex; gap: 10px; flex-wrap: wrap; }
#command-ring li, #command-sub li {
  padding: 7px 14px; border: 1px solid var(--line-soft); font-size: 12px;
  letter-spacing: 0.12em; color: var(--lavender); background: rgba(17, 16, 46, 0.6);
  cursor: pointer;
}
#command-ring li { display: flex; align-items: baseline; gap: 7px; }
#command-ring li .cmd-icon { font-size: 10px; color: var(--periwinkle); }
#command-ring li.sel .cmd-icon { color: var(--dawn); }
#command-ring li.sel, #command-sub li.sel { border-color: var(--dawn); color: var(--dawn); }
#command-ring li.off, #command-sub li.off { opacity: 0.35; }
#command-ring li .why { font-size: 8px; letter-spacing: 0.06em; color: var(--rose); opacity: 0.85; }
#command-sub { position: absolute; bottom: 58px; left: 244px; }
#command-sub li {
  display: grid; grid-template-columns: 1fr auto; column-gap: 16px;
  align-items: baseline; min-width: 190px;
}
#command-sub li .note { font-size: 9px; opacity: 0.65; letter-spacing: 0.06em; text-align: right; }
#command-sub li .why {
  grid-column: 1 / -1; font-size: 8px; letter-spacing: 0.06em;
  color: var(--rose); opacity: 0.85;
}

/* damage popups — element tints: signal lavender · static periwinkle ·
   bloom rose-green · resonance dawn; crit/weak read larger. */
#popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dmg {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--serif); font-size: 26px; color: var(--pale);
  opacity: 0; text-shadow: 0 0 14px rgba(190, 185, 242, 0.7);
  animation: dmg-float 0.9s ease-out forwards;
}
.dmg.signal { color: var(--lavender); }
.dmg.static { color: var(--periwinkle); }
.dmg.bloom { color: var(--bloomgreen); text-shadow: 0 0 14px rgba(239, 185, 214, 0.6); }
.dmg.resonance { color: var(--dawn); text-shadow: 0 0 16px rgba(247, 217, 168, 0.7); }
.dmg.heal { color: var(--bloomgreen); }
.dmg.weak, .dmg.crit { font-size: 34px; }
.dmg.weak { color: var(--dawn); }
.dmg.resist { color: var(--periwinkle); font-size: 20px; }
@keyframes dmg-float {
  0% { opacity: 0; translate: 0 10px; }
  15% { opacity: 1; }
  100% { opacity: 0; translate: 0 -34px; }
}

/* dialog + toast */
#dialog {
  position: absolute; left: 50%; bottom: 56px; transform: translateX(-50%);
  width: min(620px, 84%); padding: 14px 18px; border: 1px solid var(--line);
  background: rgba(8, 7, 26, 0.92); font-size: 13px; line-height: 1.75;
}
#dialog-text { min-height: 1.75em; }
.dialog-hint { text-align: right; font-size: 10px; color: var(--periwinkle); }
#toast {
  position: absolute; top: 16%; left: 50%; transform: translateX(-50%);
  text-align: center; pointer-events: none;
}
#toast b { display: block; font-size: 11px; letter-spacing: 0.4em; color: var(--dawn); }
#toast span { font-family: var(--serif); font-size: 26px; color: var(--pale); }

/* screens */
#overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.screen {
  text-align: center; padding: 24px; width: 100%;
  background: radial-gradient(70% 70% at 50% 45%, rgba(8, 7, 26, 0.85), rgba(8, 7, 26, 0.4) 75%, transparent);
}
.kicker { font-size: 11px; letter-spacing: 0.42em; color: var(--dawn); }
.screen h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(38px, 7vw, 64px); letter-spacing: 0.04em; margin: 8px 0 4px; }
.subtitle { color: var(--lavender); font-size: 13px; letter-spacing: 0.12em; }
.tagline { margin-top: 14px; color: var(--periwinkle); font-size: 12px; line-height: 1.8; }
.controls { margin-top: 16px; font-size: 10px; letter-spacing: 0.18em; color: var(--periwinkle); opacity: 0.8; }
.press { margin-top: 22px; font-size: 12px; letter-spacing: 0.2em; color: var(--pale); animation: blink 1.8s ease-in-out infinite; }
.smallnote { margin-top: 8px; font-size: 10px; color: var(--periwinkle); }
.stats { margin: 16px auto 0; font-size: 12px; line-height: 2; color: var(--lavender); }
.stats b { color: var(--dawn); font-weight: 500; }
.stats .vic-line { font-size: 11px; letter-spacing: 0.1em; }
.stats .dim { opacity: 0.6; }
@keyframes blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* title screen — slow gradient breath + faint scanline/grain overlay */
#scr-title { position: relative; overflow: hidden; }
#scr-title > * { position: relative; z-index: 2; }
#scr-title::before {
  content: ''; position: absolute; inset: -30%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(55% 45% at 50% 38%, rgba(141, 136, 232, 0.16), transparent 70%),
    radial-gradient(45% 40% at 62% 72%, rgba(239, 185, 214, 0.10), transparent 70%),
    radial-gradient(40% 35% at 34% 66%, rgba(247, 217, 168, 0.07), transparent 70%);
  animation: title-breath 11s ease-in-out infinite;
}
#scr-title::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(190, 185, 242, 0.028) 0 1px, transparent 1px 3px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  animation: title-scan 9s linear infinite;
}
@keyframes title-breath {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes title-scan {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 0 96px, 0 0; }
}

/* mute hint */
#mute-hint {
  position: absolute; right: 10px; bottom: 8px; z-index: 6;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  color: var(--periwinkle); background: none; border: none; cursor: pointer;
  opacity: 0.55; pointer-events: auto; padding: 2px 4px;
}
#mute-hint:hover { opacity: 0.9; }
#mute-hint.muted { color: var(--rose); }

/* fade layer for transitions */
#fader {
  position: absolute; inset: 0; background: var(--ink);
  opacity: 0; pointer-events: none; transition: opacity 0.45s ease;
}
#fader.show { opacity: 1; }
#fader.flash { background: var(--pale); transition: opacity 0.12s ease; }

/* ── title screen love ─────────────────────────────────────────────── */
.title-screen { animation: title-in 1.1s ease both; }
@keyframes title-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
.title-screen h1 {
  text-shadow: 0 0 26px rgba(190, 185, 242, 0.35);
  animation: title-breathe 5.5s ease-in-out infinite;
}
@keyframes title-breathe {
  0%, 100% { text-shadow: 0 0 22px rgba(190, 185, 242, 0.28); }
  50% { text-shadow: 0 0 38px rgba(190, 185, 242, 0.5); }
}
.jp-glyph {
  margin: 2px 0 6px; font-size: 11px; letter-spacing: 0.55em;
  color: var(--periwinkle); opacity: 0.75;
}
.title-screen .controls {
  margin-top: 22px; font-size: 9px; letter-spacing: 0.22em;
  color: var(--periwinkle); opacity: 0.6;
}
.title-sig {
  margin-top: 14px; font-size: 9px; letter-spacing: 0.34em;
  color: var(--dawn); opacity: 0.65;
}
.title-sig span { color: var(--periwinkle); letter-spacing: 0.18em; }

/* ── parry cue ─────────────────────────────────────────────────────── */
#parry-cue {
  position: absolute; left: 50%; bottom: 32%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 15px; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--dawn); opacity: 0; pointer-events: none; white-space: nowrap;
  text-shadow: 0 0 14px rgba(247, 217, 168, 0.65);
}
#parry-cue.open { opacity: 0.92; animation: parry-pulse 0.42s ease-in-out infinite alternate; }
#parry-cue.good { color: var(--pale); animation: parry-flash 0.6s ease-out forwards; }
@keyframes parry-pulse {
  from { opacity: 0.5; transform: translateX(-50%) scale(1); }
  to   { opacity: 1;   transform: translateX(-50%) scale(1.09); }
}
@keyframes parry-flash {
  0%   { opacity: 1; transform: translateX(-50%) scale(1.35); }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ── field menu ────────────────────────────────────────────────────── */
#field-menu {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(430px, 82%); padding: 18px 22px 14px;
  background: rgba(8, 7, 26, 0.94); border: 1px solid var(--line);
  outline: 1px solid var(--line-soft); outline-offset: 4px;
}
.fm-kicker { font-size: 10px; letter-spacing: 0.42em; color: var(--dawn); margin-bottom: 8px; }
#field-menu-tabs {
  display: flex; gap: 16px; align-items: baseline; margin-bottom: 12px;
  font-size: 11px; letter-spacing: 0.2em; text-transform: lowercase;
  border-bottom: 1px solid var(--line-soft); padding-bottom: 8px;
}
#field-menu-tabs span { color: var(--periwinkle); opacity: 0.5; padding-bottom: 4px; border-bottom: 1px solid transparent; }
#field-menu-tabs span.on { color: var(--dawn); opacity: 1; border-bottom-color: var(--dawn); }
#field-menu-tabs em { margin-left: auto; font-style: normal; color: var(--dawn); letter-spacing: 0.12em; }
#field-menu-status { font-size: 12px; line-height: 1.8; margin-bottom: 12px; color: var(--lavender); }
#field-menu-status b { font-family: var(--serif); font-size: 17px; letter-spacing: 0.05em; font-weight: 500; color: var(--pale); }
#field-menu-status .num { color: var(--dawn); }
#field-menu-items { list-style: none; display: grid; gap: 6px; }
#field-menu-items li {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  padding: 7px 12px; border: 1px solid var(--line-soft);
  font-size: 12px; letter-spacing: 0.1em; color: var(--lavender);
  background: rgba(17, 16, 46, 0.6);
}
#field-menu-items li em { font-style: normal; color: var(--dawn); }
#field-menu-items li small { grid-column: 1 / -1; font-size: 9px; opacity: 0.55; letter-spacing: 0.06em; }
#field-menu-items li.sel { border-color: var(--dawn); color: var(--dawn); }
#field-menu-items li.off { opacity: 0.35; }
.fm-hint { margin-top: 12px; font-size: 9px; letter-spacing: 0.2em; color: var(--periwinkle); opacity: 0.7; text-align: right; }
