:root {
  --pink: #ff8fd6; --cyan: #8fe2ff; --gold: #f3d48a; --ink: #f4eeff; --dim: #b5a8dc;
  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Songti SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05040f; color: var(--ink); font-family: var(--font); user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: none; }
.hidden { opacity: 0 !important; pointer-events: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity .6s; }
#player-panel { position: absolute; left: 36px; bottom: 34px; width: 330px; }
#player-panel .name { font-size: 26px; font-weight: 700; letter-spacing: 3px; text-shadow: 0 0 12px rgba(255,143,214,.8); margin-bottom: 8px; }
#player-panel .name .sub { font-size: 14px; margin-left: 12px; padding: 2px 10px; border-radius: 99px; background: rgba(143,226,255,.18); color: var(--cyan); letter-spacing: 2px; vertical-align: middle; }
.bar { height: 12px; border-radius: 99px; background: rgba(20,10,50,.6); border: 1px solid rgba(255,255,255,.25); overflow: hidden; margin-top: 6px; position: relative; box-shadow: 0 0 14px rgba(140,110,255,.35); }
.bar i, .bar b { position: absolute; inset: 0; width: 100%; transform-origin: left; transition: transform .25s; display: block; }
.bar.hp i { background: linear-gradient(90deg, #ff6fb8, #ffc1e6); }
.bar.mp { height: 8px; } .bar.mp i { background: linear-gradient(90deg, #6fc9ff, #d2f4ff); }
#boss-panel { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); width: min(820px, 70vw); text-align: center; transition: opacity .8s; }
.boss-name { font-size: 24px; letter-spacing: 8px; font-weight: 700; text-shadow: 0 0 14px rgba(190,90,255,.9); margin-bottom: 8px; }
#boss-name span { font-size: 12px; letter-spacing: 4px; color: var(--dim); margin-left: 8px; }
.bar.boss { height: 14px; }
.bar.boss i { background: linear-gradient(90deg, #6b2bd1, #c85cff, #ff7ad6); z-index: 2; }
.bar.boss b { background: rgba(255,255,255,.65); transition: transform 1.1s .35s; z-index: 1; }
/* poise: fills as blows are guarded; full, the guard breaks. Hidden while empty. */
.bar.poise { height: 6px; opacity: 0; transition: opacity .3s; box-shadow: 0 0 10px rgba(243,212,138,.35); }
.bar.poise.on { opacity: 1; }
.bar.poise i { background: linear-gradient(90deg, #f3d48a, #fff3c9); transition: transform .12s; }
.bar.poise.danger i { background: linear-gradient(90deg, #ff8a5c, #ff4f6a); }
.bar.poise.danger { animation: danger .5s infinite; }
@keyframes danger { 50% { box-shadow: 0 0 16px rgba(255,90,90,.9); } }
#boss-poise-bar { height: 7px; width: 62%; margin: 7px auto 0; opacity: 1; }
#boss-pips { margin-left: 14px; letter-spacing: 6px; font-size: 15px; vertical-align: 3px; color: rgba(255,255,255,.22); }
#boss-pips b { color: #ffd6f4; text-shadow: 0 0 10px #ff6fd0; font-weight: 400; }
/* bars over enemies in the fight */
#foes .foe { position: absolute; left: 0; top: 0; width: 92px; opacity: 0; transition: opacity .25s; text-align: center; will-change: transform; }
#foes .foe.on { opacity: 1; }
#foes .foe em { display: block; font-style: normal; font-size: 11px; letter-spacing: 2px; color: var(--ink); text-shadow: 0 0 6px #000, 0 0 2px #000; margin-bottom: 3px; white-space: nowrap; }
#foes .foe .bar { height: 5px; margin-top: 3px; box-shadow: none; border-color: rgba(255,255,255,.35); }
#foes .foe .bar i { transition: transform .15s; }
#foes .foe .bar.h i { background: linear-gradient(90deg, #b06bff, #ff7ad6); }
#foes .foe .bar.p { height: 4px; opacity: 1; }
#foes .foe.elite { width: 150px; }
#foes .foe .hint { display: none; margin-top: 7px; font-size: 13px; letter-spacing: 2px; color: #fff; text-shadow: 0 0 8px #ff6fd0, 0 0 2px #000; white-space: nowrap; animation: hint .7s infinite; }
#foes .foe.open .hint { display: block; }
#foes .foe .hint kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin-right: 5px; border-radius: 6px; background: #fff; color: #3a2070; font-weight: 800; font-family: var(--font); text-shadow: none; }
@keyframes hint { 50% { transform: scale(1.12); } }
/* lock-on reticle: four corner ticks turning slowly round the target */
#lock { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity .2s; will-change: transform; }
#lock.on { opacity: 1; }
#lock i { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; animation: lockspin 5s linear infinite;
  background:
    linear-gradient(#fff, #fff) left top / 9px 2px no-repeat, linear-gradient(#fff, #fff) left top / 2px 9px no-repeat,
    linear-gradient(#fff, #fff) right top / 9px 2px no-repeat, linear-gradient(#fff, #fff) right top / 2px 9px no-repeat,
    linear-gradient(#fff, #fff) left bottom / 9px 2px no-repeat, linear-gradient(#fff, #fff) left bottom / 2px 9px no-repeat,
    linear-gradient(#fff, #fff) right bottom / 9px 2px no-repeat, linear-gradient(#fff, #fff) right bottom / 2px 9px no-repeat;
  filter: drop-shadow(0 0 5px var(--pink)); }
#lock::after { content: ''; position: absolute; left: -2.5px; top: -2.5px; width: 5px; height: 5px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px var(--pink); }
@keyframes lockspin { to { transform: rotate(360deg); } }
/* a perilous attack is coming: the edges of the screen flare crimson */
#peril { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 52%, rgba(255,30,70,.5) 100%); }
#peril.on { animation: peril .75s ease-out; }
@keyframes peril { 0% { opacity: 0; } 14% { opacity: 1; } 100% { opacity: 0; } }
body.cine #peril { display: none; }
#skills { position: absolute; right: 36px; bottom: 30px; display: flex; gap: 12px; }
.skill { width: 66px; height: 66px; border-radius: 16px; background: radial-gradient(circle at 50% 35%, rgba(170,140,255,.35), rgba(20,12,50,.75)); border: 1px solid rgba(255,255,255,.3);
  position: relative; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 16px rgba(140,110,255,.4); transition: transform .15s, box-shadow .15s; }
.skill .ico { font-size: 28px; color: #fff; text-shadow: 0 0 10px var(--pink); }
.skill span { position: absolute; bottom: -20px; font-size: 12px; color: var(--dim); white-space: nowrap; }
.skill::after { content: attr(data-key); position: absolute; top: 3px; right: 6px; font-size: 11px; color: var(--gold); font-weight: 700; }
.skill .cd { position: absolute; inset: 0; border-radius: 16px; background: conic-gradient(rgba(5,3,20,.75) var(--p, 0%), transparent 0); }
.skill.fire { transform: scale(1.12); box-shadow: 0 0 30px rgba(255,143,214,.95); }
.skill.locked { filter: grayscale(1) brightness(.5); }
.skill.gap { margin-left: 14px; }
.skill.held { box-shadow: 0 0 26px rgba(143,226,255,.95); border-color: #bff0ff; }
.skill .n { position: absolute; left: 6px; bottom: 3px; font-size: 13px; font-weight: 800; color: #d8fff0; text-shadow: 0 0 6px #2ad0a0; }
.skill.empty .ico, .skill.empty .n { opacity: .35; }
#objective { position: absolute; left: 36px; top: 34px; font-size: 16px; letter-spacing: 2px; padding: 10px 18px; border-left: 3px solid var(--pink);
  background: linear-gradient(90deg, rgba(30,15,70,.7), transparent); text-shadow: 0 0 8px rgba(0,0,0,.8); transition: opacity .5s; }
#objective:empty { opacity: 0; }
#prompt { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); font-size: 22px; letter-spacing: 4px; padding: 12px 30px; border-radius: 99px;
  background: rgba(40,20,90,.55); border: 1px solid rgba(255,255,255,.4); box-shadow: 0 0 30px rgba(255,143,214,.6); animation: pulse 1.2s infinite; transition: opacity .4s; }
#prompt kbd { display: inline-block; min-width: 34px; padding: 2px 8px; margin: 0 4px; border-radius: 8px; background: #fff; color: #3a2070; font-weight: 800; font-family: var(--font); }
@keyframes pulse { 50% { box-shadow: 0 0 50px rgba(255,143,214,.95); } }
#prompt .charge { display: inline-block; vertical-align: middle; width: 160px; height: 8px; margin-left: 14px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
#prompt .charge i { display: block; height: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, #9fe8ff, #ffc2ee, #fff1c4);
  box-shadow: 0 0 12px rgba(255,214,244,.9); }

/* ---------- cinematic layers ---------- */
#letterbox i { position: fixed; left: 0; right: 0; height: 12vh; background: #000; z-index: 5; transition: transform .8s cubic-bezier(.2,.8,.2,1); pointer-events: none; }
#letterbox .top { top: 0; transform: translateY(-100%); } #letterbox .bottom { bottom: 0; transform: translateY(100%); }
body.cine #letterbox .top, body.cine #letterbox .bottom { transform: none; }
body.cine #hud > *:not(#prompt) { opacity: 0; transition: opacity .6s; }
#prompt { z-index: 6; }
#subtitle { position: fixed; left: 50%; bottom: 4.5vh; transform: translateX(-50%); z-index: 6; font-size: 26px; letter-spacing: 2px; text-align: center; max-width: 80vw;
  text-shadow: 0 0 10px rgba(0,0,0,.9), 0 0 20px rgba(120,60,200,.6); transition: opacity .35s; pointer-events: none; }
#subtitle .who { display: block; font-size: 15px; color: var(--pink); letter-spacing: 6px; margin-bottom: 4px; }
#subtitle:empty { opacity: 0; }
#title-card { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .8s; }
#title-card.show { opacity: 1; }
#title-card .big { font-size: 76px; font-weight: 800; letter-spacing: 18px; background: linear-gradient(180deg, #fff, #ffd2f0 45%, #a7e6ff); -webkit-background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(255,143,214,.9)); animation: rise 1.4s cubic-bezier(.2,.8,.2,1); }
#title-card .small { font-size: 18px; letter-spacing: 10px; color: var(--ink); margin-top: 10px; text-shadow: 0 0 12px rgba(143,226,255,.9); animation: rise 1.8s cubic-bezier(.2,.8,.2,1); }
#title-card .line { width: 0; height: 2px; background: linear-gradient(90deg, transparent, #fff, transparent); margin: 16px 0; animation: grow 1.4s .2s forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.96); letter-spacing: 40px; } }
@keyframes grow { to { width: 520px; } }
#damage-layer { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.dmg { position: absolute; font-weight: 900; font-size: 28px; color: #fff; text-shadow: 0 0 8px #ff6fd0, 0 0 2px #000; transform: translate(-50%, -50%); animation: dmg .9s forwards; white-space: nowrap; }
.dmg.big { font-size: 44px; color: #fff6c8; text-shadow: 0 0 14px #ffb84a, 0 0 2px #000; }
.dmg.hurt { color: #ffd1e8; text-shadow: 0 0 10px #ff2a6a; font-size: 24px; }
.dmg.parry { font-size: 22px; letter-spacing: 5px; color: #fff8dc; text-shadow: 0 0 12px #ffc94a, 0 0 2px #000; }
.dmg.parry.big { font-size: 34px; letter-spacing: 9px; color: #fff; text-shadow: 0 0 16px #ff8fd6, 0 0 2px #000; }
.dmg.heal { font-size: 26px; color: #d8fff0; text-shadow: 0 0 10px #2ad0a0, 0 0 2px #000; }
@keyframes dmg { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 8; }
#director { position: fixed; right: 16px; top: 16px; z-index: 20; font-size: 12px; line-height: 1.7; background: rgba(10,6,30,.82); border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px; padding: 10px 14px; color: var(--dim); transition: opacity .3s; }
#director b { color: var(--gold); }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #2b1d63 0%, #0b0822 60%, #05040f 100%); transition: opacity 1.2s; }
#loading .logo { text-align: center; }
#loading .moon { width: 120px; height: 120px; margin: 0 auto 26px; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #fff, #f2ecff 50%, #c9bdf5);
  box-shadow: 0 0 60px rgba(200,180,255,.9), 0 0 140px rgba(255,140,220,.5); position: relative; animation: float 4s ease-in-out infinite; }
#loading .moon::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 70% 35%, #2b1d63 0 45%, transparent 46%); }
@keyframes float { 50% { transform: translateY(-10px); } }
#loading h1 { margin: 0; font-size: 64px; letter-spacing: 22px; font-weight: 800; background: linear-gradient(180deg, #fff, #ffd2f0 50%, #a7e6ff); -webkit-background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(255,143,214,.7)); }
#loading h2 { margin: 6px 0 0; font-size: 16px; letter-spacing: 14px; color: var(--dim); font-weight: 500; }
#loading .progress { width: 360px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.12); margin-top: 48px; overflow: hidden; }
#loading .progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .2s; box-shadow: 0 0 12px var(--pink); }
#load-text { margin-top: 14px; font-size: 13px; color: var(--dim); letter-spacing: 3px; }
#start { margin-top: 30px; font: 700 20px var(--font); letter-spacing: 10px; color: #fff; padding: 14px 44px; border-radius: 99px; border: 1px solid rgba(255,255,255,.5);
  background: linear-gradient(90deg, rgba(255,143,214,.35), rgba(143,226,255,.35)); cursor: pointer; box-shadow: 0 0 30px rgba(255,143,214,.6); transition: opacity .6s, transform .2s; }
#start:hover { transform: scale(1.06); }
#loading .credit { position: absolute; bottom: 28px; font-size: 13px; letter-spacing: 2px; color: var(--dim); }
#loading .credit b { color: var(--gold); }
#lang { position: absolute; top: 24px; right: 28px; font: 600 13px var(--font); letter-spacing: 2px; color: var(--dim); cursor: pointer;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.25); border-radius: 99px; padding: 6px 16px; }
#lang:hover { color: #fff; border-color: rgba(255,255,255,.6); }
/* English sets tighter than the CJK tracking above; Japanese flavour lines get a Japanese face */
html[lang=en] #prompt, html[lang=en] #objective { letter-spacing: 1px; }
html[lang=en] #subtitle { letter-spacing: .5px; }
html[lang=en] #title-card .big { letter-spacing: 8px; }
html[lang=en] #loading h1 { letter-spacing: 10px; }
html[lang=en] .boss-name { letter-spacing: 6px; }
[lang=ja] { font-family: "Hiragino Mincho ProN", "Hiragino Sans", "Yu Mincho", serif; }
