:root {
  --bg: #07080c;
  --panel: #0d1018;
  --panel-2: #131826;
  --line: #1b2131;
  --line-2: #2a3349;
  --text: #eceef5;
  --muted: #8b93a9;
  --steel: #9fe3ff;
  --steel-soft: rgba(159, 227, 255, 0.14);
  --danger: #ff5f6d;
  --danger-soft: rgba(255, 95, 109, 0.16);
  --gold: #ffd166;
  --ink: #b18cff;
  --good: #5fe3a1;
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --foe-body: #1a1f2e;
  --foe-body-2: #262d42;
  --foe-line: #c9cfe0;
  --foe-glow: #ff5f6d;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 520px at 15% -10%, rgba(159, 227, 255, 0.06), transparent 60%),
    radial-gradient(900px 520px at 110% 110%, rgba(255, 95, 109, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

.app { max-width: 1040px; margin: 0 auto; padding: 20px 16px 28px; display: flex; flex-direction: column; gap: 14px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  width: 38px; height: 38px; border-radius: 10px; position: relative; flex: none;
  background: #000; border: 1px solid var(--line-2); overflow: hidden;
  box-shadow: 0 0 24px rgba(159, 227, 255, 0.16);
}
.mark::before, .mark::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 2px; border-radius: 2px;
}
.mark::before { background: var(--steel); transform: translate(-50%, -50%) rotate(45deg); }
.mark::after { background: var(--danger); transform: translate(-50%, -50%) rotate(-45deg); }
h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.hud { display: flex; gap: 6px; flex-wrap: wrap; }
.stat {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 12px; min-width: 76px;
}
.label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* arena */
.arena {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 620px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: #05060a;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px;
  padding: 14px 18px 18px;
  outline: none;
}
.arena__bg {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(420px 260px at 50% 30%, rgba(255, 95, 109, calc(0.05 + var(--heat, 0) * 0.16)), transparent 70%),
    linear-gradient(transparent 0 calc(100% - 1px), rgba(255, 255, 255, 0.025) 0) 0 0 / 100% 28px,
    radial-gradient(600px 300px at 50% 120%, rgba(159, 227, 255, 0.07), transparent 70%);
}
.arena.is-shake { animation: shake 0.32s cubic-bezier(.36, .07, .19, .97); }
.arena.is-shake-sm { animation: shake-sm 0.18s linear; }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-7px, 2px); }
  40%, 60% { transform: translate(7px, -1px); }
}
@keyframes shake-sm { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }

.arena__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.act { margin: 0; font-size: 13px; color: var(--muted); }
.act__n { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--steel); margin-right: 6px; }
.pips { list-style: none; margin: 0; padding: 0; display: flex; gap: 5px; align-items: center; }
.pips li { width: 18px; height: 6px; border-radius: 3px; background: var(--line-2); }
.pips li.gap { width: 4px; background: transparent; }
.pips li.done { background: var(--steel); }
.pips li.now { background: var(--gold); box-shadow: 0 0 10px rgba(255, 209, 102, 0.6); }
.pips li.boss { width: 26px; height: 9px; }

/* enemy */
.foe { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.foe__stage { width: 168px; height: 168px; position: relative; }
.foe__stage::after {
  content: ""; position: absolute; left: 15%; right: 15%; bottom: 2px; height: 14px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.7), transparent); z-index: -1;
}
.foe__art {
  width: 100%; height: 100%; display: block; overflow: visible;
  animation: idle 2.6s ease-in-out infinite;
  filter: drop-shadow(0 0 calc(4px + var(--heat, 0) * 22px) rgba(255, 95, 109, calc(0.15 + var(--heat, 0) * 0.65)));
  transition: filter 0.1s;
}
@keyframes idle { 50% { transform: translateY(-4px) scale(1.01); } }
.foe.is-hurt .foe__art { animation: hurt 0.28s ease-out; }
@keyframes hurt {
  0% { transform: translateX(0); filter: brightness(3) saturate(0); }
  30% { transform: translateX(10px) rotate(3deg); }
  60% { transform: translateX(-6px) rotate(-2deg); }
  100% { transform: none; }
}
.foe.is-lunge .foe__art { animation: lunge 0.34s cubic-bezier(.2, .8, .3, 1); }
@keyframes lunge { 35% { transform: translateY(46px) scale(1.18); } 100% { transform: none; } }
.foe.is-parried .foe__art { animation: recoil 0.36s ease-out; }
@keyframes recoil { 30% { transform: translateY(-14px) rotate(-6deg) scale(0.96); } 100% { transform: none; } }
.foe.is-dead .foe__art { animation: dissolve 0.9s ease-in forwards; }
@keyframes dissolve {
  0% { filter: brightness(3); }
  100% { transform: translateY(18px) scale(0.85); opacity: 0; filter: blur(6px) brightness(2); }
}
.foe__meta { display: flex; gap: 10px; align-items: baseline; }
.foe__name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.foe__phase { font: 600 11px var(--mono); color: var(--danger); text-transform: uppercase; letter-spacing: 0.1em; }

.hpbar {
  position: relative; height: 14px; border-radius: 7px; background: #0a0c12; border: 1px solid var(--line-2); overflow: hidden;
}
.hpbar--foe { width: min(360px, 80%); }
.hpbar span { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left center; }
.hpbar__lag { background: rgba(255, 255, 255, 0.35); transition: transform 0.6s 0.25s ease-out; }
.hpbar__fill { transition: transform 0.12s ease-out; }
.hpbar--foe .hpbar__fill { background: linear-gradient(90deg, #ff3d55, #ff8a6b); }
.hpbar--you .hpbar__fill { background: linear-gradient(90deg, #3ddc97, #9fe3ff); }
.hpbar--you.is-low .hpbar__fill { background: linear-gradient(90deg, #ff3d55, #ffb36b); }
.hpbar__text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }

/* incoming strikes */
.incoming {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 10px;
  min-height: 72px; padding-top: 18px;
}
.strike {
  position: relative; min-width: 120px; padding: 9px 16px 13px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 95, 109, 0.12), rgba(255, 95, 109, 0.04));
  border: 1px solid rgba(255, 95, 109, 0.45);
  animation: drop-in 0.22s ease-out;
  text-align: center;
}
.strike--curse { border-color: rgba(177, 140, 255, 0.6); background: linear-gradient(180deg, rgba(177, 140, 255, 0.15), rgba(177, 140, 255, 0.04)); }
.strike.is-locked { box-shadow: 0 0 0 2px var(--text), 0 0 24px rgba(255, 95, 109, 0.35); }
.strike.is-urgent { animation: urgent 0.3s ease-in-out infinite alternate; }
@keyframes urgent { to { box-shadow: 0 0 0 1px var(--danger), 0 0 26px rgba(255, 95, 109, 0.55); } }
.strike.is-locked.is-urgent { animation: urgent-l 0.3s ease-in-out infinite alternate; }
@keyframes urgent-l { to { box-shadow: 0 0 0 2px var(--text), 0 0 30px rgba(255, 95, 109, 0.7); } }
@keyframes drop-in { from { transform: translateY(-14px) scale(0.9); opacity: 0; } }
.strike__tag { position: absolute; top: -9px; left: 10px; font: 700 9.5px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; padding: 1px 6px; border-radius: 4px; background: var(--danger); color: #1a0306; }
.strike--curse .strike__tag { background: var(--ink); color: #12052b; }
.strike__dmg { position: absolute; top: -9px; right: 10px; font: 700 9.5px var(--mono); padding: 1px 6px; border-radius: 4px; background: #1a0306; color: var(--danger); border: 1px solid rgba(255, 95, 109, 0.5); }
.fuse { position: absolute; left: 10px; right: 10px; bottom: 5px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.fuse span { position: absolute; inset: 0; transform-origin: left center; background: linear-gradient(90deg, var(--danger), #ffb36b); }
.strike--curse .fuse span { background: linear-gradient(90deg, var(--ink), #f0b8ff); }
.strike.is-out { animation: shatter 0.35s ease-out forwards; }
.strike.is-landed { animation: landed 0.4s ease-in forwards; }
@keyframes shatter { to { transform: translateY(-20px) scale(1.25); opacity: 0; filter: brightness(2.5); } }
@keyframes landed { 40% { transform: translateY(30px) scale(1.1); } to { transform: translateY(80px) scale(0.7); opacity: 0; } }

/* words */
.word { font-family: var(--mono); font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.word .c { display: inline-block; position: relative; transition: color 0.08s; }
.word .c.done { color: var(--muted); opacity: 0.55; }
.word .c.next::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px; border-radius: 1px; background: currentColor; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.word .c.blot { color: transparent; }
.word .c.blot::before { content: ""; position: absolute; inset: 18% 6%; border-radius: 40% 55% 45% 60%; background: var(--ink); opacity: 0.85; }
.strike .word { font-size: 22px; color: #ffd9dc; }
.strike--curse .word { color: #ead9ff; }
.word.is-err { animation: err 0.22s linear; }
@keyframes err { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); color: var(--danger); } 75% { transform: translateX(5px); color: var(--danger); } }

/* player */
.player { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.attack {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 26px 14px; border-radius: 12px; min-width: min(380px, 100%);
  background: linear-gradient(180deg, rgba(159, 227, 255, 0.08), rgba(159, 227, 255, 0.02));
  border: 1px solid rgba(159, 227, 255, 0.3);
}
.attack.is-locked { box-shadow: 0 0 0 2px var(--steel), 0 0 30px rgba(159, 227, 255, 0.25); }
.attack.is-cursed { border-color: rgba(177, 140, 255, 0.6); }
.attack__label { font: 700 10px var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--steel); display: flex; gap: 8px; align-items: center; }
.attack__curse { color: #12052b; background: var(--ink); border-radius: 4px; padding: 0 5px; }
.word--attack { font-size: clamp(30px, 5.4vw, 46px); color: var(--steel); line-height: 1.2; }
.attack__dmg { font-size: 11.5px; color: var(--muted); }
.attack.is-pop { animation: pop 0.2s ease-out; }
@keyframes pop { 40% { transform: scale(1.04); } }

.player__row { display: flex; align-items: center; gap: 14px; width: min(520px, 100%); }
.hpbar--you { flex: 1 1 auto; height: 16px; border-radius: 8px; }
.combo { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.combo__n { font-size: 24px; font-weight: 800; line-height: 1; color: var(--gold); transition: transform 0.1s; }
.combo.is-pop .combo__n { animation: cpop 0.25s ease-out; }
@keyframes cpop { 40% { transform: scale(1.45); } }
.combo.is-broken .combo__n { color: var(--danger); animation: err 0.25s linear; }
.combo.is-zero .combo__n { color: var(--muted); }

.boonlist { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; min-height: 20px; }
.chip { font: 600 10.5px var(--mono); padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); }
.chip b { color: var(--gold); }

/* fx */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.pop {
  position: absolute; transform: translate(-50%, -50%); font: 800 26px var(--mono); white-space: nowrap;
  animation: floatup 1.1s ease-out forwards; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}
.pop small { display: block; font: 600 11px var(--mono); color: var(--muted); text-align: center; }
.pop--hit { color: var(--steel); }
.pop--parry { color: #fff; }
.pop--riposte { color: var(--gold); font-size: 30px; }
.pop--hurt { color: var(--danger); }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0;
  box-shadow: inset 0 0 120px 30px rgba(255, 40, 60, 0.55);
}
.vignette.is-on { animation: vig 0.6s ease-out; }
.vignette.is-low { opacity: 0.35; animation: pulse 1.2s ease-in-out infinite; }
@keyframes vig { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.6; } }
.flash { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: #fff; opacity: 0; }
.flash.is-on { animation: flash 0.22s ease-out; }
@keyframes flash { 0% { opacity: 0.35; } 100% { opacity: 0; } }
.stamp {
  position: absolute; left: 50%; top: 44%; z-index: 3; pointer-events: none; opacity: 0;
  font: 900 44px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: #fff;
  transform: translate(-50%, -50%); text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}
.stamp.is-gold { color: var(--gold); text-shadow: 0 0 30px rgba(255, 209, 102, 0.6); }
.stamp.is-red { color: var(--danger); text-shadow: 0 0 30px rgba(255, 95, 109, 0.6); }
.stamp.is-on { animation: stamp 0.75s cubic-bezier(.2, .9, .3, 1); }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-6deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1) rotate(-3deg); }
}

/* overlays */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(5, 6, 10, 0.82); backdrop-filter: blur(4px); overflow-y: auto; z-index: 5;
}
.overlay--clear { background: rgba(5, 6, 10, 0.45); backdrop-filter: none; pointer-events: none; }
.card {
  width: min(520px, 100%); margin: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.card--wide { width: min(640px, 100%); }
.kicker { margin: 0; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--steel); }
.card h2 { margin: 4px 0 8px; font-size: 26px; letter-spacing: -0.02em; }
.lede { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.rules { margin: 0 0 14px; padding-left: 18px; color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.rules b { color: var(--text); }

.roster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.foecard { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); min-width: 0; }
.foecard:last-child { grid-column: 1 / -1; }
.foecard svg { width: 34px; height: 34px; flex: none; }
.foecard b { display: block; font-size: 13px; }
.foecard span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; }

.banner { text-align: center; padding: 20px 34px; border-radius: var(--radius); background: rgba(13, 16, 24, 0.92); border: 1px solid var(--line-2); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); animation: banner 0.35s ease-out; max-width: 92%; }
@keyframes banner { from { transform: scale(0.92); opacity: 0; } }
.banner h2 { margin: 4px 0 4px; font-size: 32px; letter-spacing: -0.02em; }
.banner__blurb { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.banner__bar { height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.banner__bar span { display: block; height: 100%; background: var(--steel); transform-origin: left center; }

.boons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.boonbtn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; min-width: 0;
  background: var(--panel); color: var(--text); font: inherit; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line-2); cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.boonbtn:hover, .boonbtn:focus-visible { border-color: var(--gold); transform: translateY(-2px); outline: none; }
.boonbtn kbd { margin: 0; }
.boonbtn b { font-size: 15px; }
.boonbtn span { font-size: 12.5px; color: var(--muted); }
.boonbtn em { font: 600 10.5px var(--mono); font-style: normal; color: var(--gold); }

.grade { font: 900 64px var(--sans); line-height: 1; color: var(--gold); text-shadow: 0 0 30px rgba(255, 209, 102, 0.4); margin: 0 0 8px; }
.tally {
  display: grid; grid-template-columns: repeat(2, auto 1fr); gap: 6px 14px; margin: 0; padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 10px;
}
.tally dt { color: var(--muted); font-size: 13px; }
.tally dd { margin: 0; text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fights { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.fights li { font-size: 12px; padding: 5px 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.fights li.died { border-color: rgba(255, 95, 109, 0.5); }
.fights li span { color: var(--muted); font-family: var(--mono); }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.card .row { margin-top: 16px; }
.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font: 600 14px var(--sans); padding: 9px 16px; border-radius: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--steel); }
.btn.primary { background: var(--steel); color: #04202b; border-color: var(--steel); }
.btn.primary:hover { background: #c4eeff; }
.btn.small { font-size: 12.5px; padding: 6px 10px; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
kbd { font: 600 10.5px var(--mono); color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.btn.primary kbd { color: #0d4a5e; border-color: rgba(0, 0, 0, 0.2); }

.tap {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 4;
  font: 600 13px var(--sans); color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 8px 16px;
}
.kbd-sink { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; pointer-events: none; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { margin: 0; color: var(--muted); font-size: 13.5px; flex: 1 1 260px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .app { padding: 14px 12px 22px; }
  .hud { width: 100%; }
  .stat { flex: 1 1 0; min-width: 0; padding: 5px 8px; }
  .arena { min-height: 560px; padding: 12px 12px 16px; }
  .foe__stage { width: 120px; height: 120px; }
  .attack { padding: 10px 14px 12px; min-width: 0; width: 100%; }
  .strike { min-width: 96px; padding: 8px 12px 12px; }
  .strike .word { font-size: 19px; }
  .card { padding: 16px; }
  .card h2 { font-size: 22px; }
  .roster { grid-template-columns: minmax(0, 1fr); }
  .boons { grid-template-columns: minmax(0, 1fr); }
  .tally { grid-template-columns: auto 1fr; }
  .stamp { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
