:root {
  color-scheme: dark;
  --ink: #f2fbff;
  --muted: #8da7b8;
  --cyan: #5df3ff;
  --cyan-deep: #087f9c;
  --amber: #ffc15c;
  --violet: #c69cff;
  --red: #ff716d;
  --panel: rgba(5, 16, 27, 0.94);
  --panel-2: rgba(8, 27, 41, 0.94);
  --line: rgba(124, 221, 245, 0.22);
  --line-hot: rgba(93, 243, 255, 0.58);
  --radius: 18px;
  font-family: "Arial Narrow", "DIN Condensed", Inter, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 76% -10%, rgba(32, 158, 193, 0.2), transparent 35%),
    radial-gradient(circle at 6% 90%, rgba(105, 59, 168, 0.12), transparent 32%),
    #02070d;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.16;
  background-image: linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, #000, transparent 85%);
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.game-shell {
  position: relative;
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  background: radial-gradient(circle at 65% 0%, rgba(22, 116, 148, 0.1), transparent 35%);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(119, 218, 241, 0.18);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(11, 30, 45, 0.88), rgba(3, 11, 19, 0.82));
  box-shadow: inset 0 1px rgba(255,255,255,0.045), 0 16px 40px rgba(0,0,0,0.3);
  backdrop-filter: blur(14px);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; color: #fff; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: 0.12em; text-shadow: 0 0 24px rgba(93,243,255,0.25); }
h2 { margin-bottom: 6px; }

.eyebrow, .panel-kicker {
  margin-bottom: 3px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.run-stats { display: flex; gap: 10px; }
.run-stats div {
  min-width: 88px;
  padding: 8px 12px;
  border: 1px solid rgba(119, 218, 241, 0.16);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(18, 45, 62, 0.72), rgba(4, 16, 26, 0.8));
  box-shadow: inset 0 1px rgba(255,255,255,0.05);
}
.run-stats span { display: block; color: var(--muted); font-size: 0.72rem; }
.run-stats strong { color: #fff; font-size: 1rem; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions > strong { color: var(--amber); white-space: nowrap; }

.battle-layout {
  display: grid;
  grid-template-columns: minmax(450px, 0.95fr) minmax(560px, 1.3fr);
  gap: 14px;
}

.forge-panel, .arena-panel {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: linear-gradient(var(--panel), var(--panel)) padding-box, linear-gradient(145deg, rgba(93,243,255,0.52), rgba(93,243,255,0.06) 42%, rgba(255,193,92,0.24)) border-box;
  box-shadow: inset 0 1px rgba(255,255,255,0.035), 0 28px 75px rgba(0, 0, 0, 0.48), 0 0 35px rgba(30, 151, 181, 0.06);
}

.forge-panel { position: relative; padding: 16px; overflow: hidden; }
.forge-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.55;
}
.arena-panel { overflow: hidden; }

.target-card, .phrase-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.target-card {
  position: relative;
  overflow: hidden;
  min-height: 92px;
  padding: 12px 14px;
  border: 1px solid rgba(93, 243, 255, 0.32);
  border-radius: 13px;
  background: linear-gradient(120deg, rgba(16, 82, 104, 0.5), rgba(8, 25, 38, 0.62));
  box-shadow: inset 0 1px rgba(255,255,255,0.055), 0 12px 26px rgba(0,0,0,0.2);
}
.target-card::after { content: ""; position: absolute; right: -35px; top: -60px; width: 150px; height: 150px; border: 1px solid rgba(93,243,255,0.12); border-radius: 50%; box-shadow: 0 0 45px rgba(93,243,255,0.08); }

#targetPrompt { margin-bottom: 0; color: var(--muted); }
.theme-challenge { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin-top: 9px; padding: 7px 9px; border: 1px solid rgba(255,180,76,0.42); border-radius: 8px; color: var(--amber); background: rgba(45,27,9,0.42); }
.theme-challenge[hidden] { display: none; }
.theme-challenge span, .theme-challenge strong { font-size: 0.75rem; font-weight: 1000; }
.theme-challenge small { grid-column: 1 / -1; color: #b99b73; font-size: 0.64rem; letter-spacing: 0.02em; }
.theme-challenge.complete { border-color: rgba(93,243,255,0.55); color: var(--cyan); background: rgba(17,76,90,0.32); }
.mobile-combat-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.lesson-set { margin-bottom: 4px; color: var(--cyan); font-size: 0.78rem; font-weight: 800; }
.item-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 9px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(5, 16, 27, 0.72);
}
.item-bar strong { color: var(--amber); font-size: 0.8rem; }
.item-bar span { color: var(--muted); font-size: 0.78rem; }
.selection-readout {
  min-height: 44px;
  margin: 12px 0;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--cyan);
  border: 1px solid rgba(93,243,255,0.16);
  background: linear-gradient(180deg, #071725, #030b13);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.45);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
}

.letter-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  touch-action: manipulation;
  user-select: none;
}

.letter-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(124, 216, 243, 0.28);
  border-radius: 11px;
  color: var(--ink);
  background: linear-gradient(145deg, #1b4259, #0a1b2a 62%, #06111c);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 -8px 18px rgba(0,0,0,0.22), 0 5px 13px rgba(0, 0, 0, 0.34);
  font-size: clamp(0.95rem, 2.2vw, 1.5rem);
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.letter-tile::before { content: ""; position: absolute; inset: 1px 16% auto; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.38), transparent); }

.letter-tile:hover { transform: translateY(-2px); border-color: var(--cyan); }
.letter-tile.selected { color: #021018; border-color: #fff; background: linear-gradient(145deg, #b8fbff, var(--cyan) 55%, #25b7d2); box-shadow: 0 0 0 2px rgba(93,243,255,0.18), 0 0 24px rgba(93,243,255,0.58); transform: translateY(-2px) scale(1.04); }
.letter-tile.selected::after {
  content: attr(data-order);
  position: absolute;
  top: 3px;
  right: 5px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  color: var(--ink);
  background: #07131f;
  font-size: 0.68rem;
  line-height: 17px;
}
.letter-tile.hint { animation: hintPulse 900ms infinite alternate; }
.letter-tile.hint::before {
  content: attr(data-hint-order);
  position: absolute;
  left: 4px;
  bottom: 3px;
  color: var(--amber);
  font-size: 0.72rem;
}
.letter-tile.consumed { filter: brightness(2.5); opacity: 0; transform: scale(1.35) rotate(8deg); }

.board-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 12px; }

.primary-button, .combo-button, .ghost-button, .small-button, .icon-button {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.primary-button, .combo-button { color: #031018; background: linear-gradient(135deg, #78f2ff, #28b8d6); }
.primary-button, .combo-button { box-shadow: inset 0 1px rgba(255,255,255,0.7), 0 7px 18px rgba(26, 179, 207, 0.18); }
.primary-button:hover, .combo-button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.primary-button:active, .combo-button:active { transform: translateY(1px) scale(0.99); }
.ghost-button, .small-button, .icon-button { color: var(--ink); border-color: var(--line); background: #0c2131; }
.small-button { min-height: 34px; padding: 6px 12px; }
.icon-button { padding: 8px 18px; }
.combo-button:disabled { opacity: 0.42; cursor: not-allowed; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 10px; }
.mode-choice {
  min-height: 112px;
  padding: 15px;
  border: 1px solid rgba(84, 232, 255, 0.34);
  border-radius: 13px;
  color: var(--ink);
  background: linear-gradient(145deg, #12344a, #071724);
  cursor: pointer;
  text-align: left;
}
.mode-choice:hover { border-color: var(--cyan); transform: translateY(-2px); }
.mode-choice strong, .mode-choice span { display: block; }
.mode-choice strong { margin-bottom: 7px; color: var(--cyan); font-size: 1.12rem; }
.mode-choice span { color: var(--muted); line-height: 1.5; }

.arena {
  position: relative;
  isolation: isolate;
  min-height: 480px;
  overflow: hidden;
  background: #081420 url("assets/rune-forge-bg.png") center / cover no-repeat;
  box-shadow: inset 0 -35px 75px rgba(0,0,0,0.62);
}

.arena::before { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; background: radial-gradient(circle at 55% 42%, transparent 18%, rgba(1,7,12,0.18) 72%, rgba(0,3,7,0.72)); }
.arena::after { content: ""; position: absolute; z-index: 9; inset: 0; pointer-events: none; opacity: 0.06; background: repeating-linear-gradient(0deg, transparent 0 3px, #9ef8ff 4px); mix-blend-mode: screen; }

.arena-shade { position: absolute; z-index: 2; inset: 0; background: linear-gradient(90deg, rgba(3, 11, 19, 0.1), transparent 40%, rgba(2, 7, 12, 0.2)); }
.hero {
  position: absolute;
  z-index: 3;
  left: 3%;
  bottom: 9%;
  width: clamp(100px, 17%, 150px);
  height: 58%;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.75));
}

.lane-line { position: absolute; z-index: 2; left: 17%; right: 4%; bottom: 17%; height: 2px; background: linear-gradient(90deg, var(--cyan), rgba(93,243,255,0.1) 72%, transparent); box-shadow: 0 0 10px rgba(93,243,255,0.35); opacity: 0.42; }
.enemy-layer, .effect-layer { position: absolute; inset: 0; }
.enemy {
  position: absolute;
  z-index: 4;
  bottom: 13%;
  width: 110px;
  height: 145px;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 12px 11px rgba(0, 0, 0, 0.85));
  transform: translateX(-50%);
}
.enemy.golem { width: 145px; height: 185px; }
.enemy.boss { width: 250px; height: 310px; bottom: 8%; }
.enemy.slowed { filter: drop-shadow(0 0 14px #8af5ff) saturate(0.75); }
.enemy.burning { filter: drop-shadow(0 0 18px #ff8c38) saturate(1.3); }
.enemy.slowed.burning { filter: drop-shadow(0 0 13px #8af5ff) drop-shadow(0 0 16px #ff8c38); }
.enemy.phase-three { filter: drop-shadow(0 0 22px #ffb44c) saturate(1.35); }
.enemy.hit { animation: hitFlash 180ms ease; }

.enemy-bar {
  position: absolute;
  z-index: 5;
  width: 82px;
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(224,247,255,0.28);
  border-radius: 999px;
  background: rgba(20,5,12,0.92);
  box-shadow: 0 2px 8px #000;
  transform: translateX(-50%);
}
.enemy-bar span { display: block; height: 100%; background: linear-gradient(90deg, #ff706a, #ffb44c); }
.enemy-affinity {
  position: absolute;
  z-index: 6;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #dff9ff;
  background: rgba(3, 12, 20, 0.88);
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 900;
  white-space: nowrap;
}
.affinity-pop {
  position: absolute;
  z-index: 10;
  transform: translateX(-50%);
  pointer-events: none;
  font-weight: 1000;
  text-shadow: 0 2px 4px #000;
  animation: affinityFloat 800ms ease-out forwards;
}
.affinity-pop.effective { color: #8cff9b; }
.affinity-pop.resisted { color: #ff9c8f; }
.damage-pop {
  position: absolute;
  z-index: 11;
  color: #fff;
  font-size: 1.22rem;
  font-weight: 1000;
  text-shadow: 0 2px 5px #000, 0 0 10px rgba(255,255,255,0.45);
  transform: translateX(-50%);
  pointer-events: none;
  animation: damageFloat 650ms ease-out forwards;
}
.damage-pop.area { color: #ffe4a8; font-size: 1rem; }
.damage-pop.none { color: #b8d4df; font-size: 0.72rem; opacity: 0.75; }
.damage-pop.critical { color: #9affaa; font-size: 1.25rem; }
.damage-pop.resisted { color: #ffb1a8; font-size: 0.9rem; }

.combat-banner {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 14px;
  max-width: 58%;
  padding: 9px 16px;
  border: 1px solid rgba(93, 243, 255, 0.36);
  border-radius: 8px;
  color: #dffcff;
  background: linear-gradient(90deg, rgba(4, 17, 28, 0.7), rgba(9, 37, 52, 0.92), rgba(4, 17, 28, 0.7));
  box-shadow: inset 0 1px rgba(255,255,255,0.06), 0 8px 20px rgba(0,0,0,0.32), 0 0 24px rgba(93,243,255,0.08);
  transform: translateX(-50%);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: center;
}

.chain-hud {
  position: absolute;
  z-index: 9;
  left: 14px;
  top: 14px;
  width: 155px;
  padding: 7px 9px;
  border: 1px solid rgba(93,243,255,0.24);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(3,13,22,0.82);
  box-shadow: inset 0 1px rgba(255,255,255,0.04), 0 8px 20px rgba(0,0,0,0.28);
  backdrop-filter: blur(7px);
  pointer-events: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.chain-hud > div:first-child { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chain-hud span { font-size: 0.58rem; font-weight: 1000; letter-spacing: 0.13em; }
.chain-hud strong { color: #d9faff; font-size: 0.9rem; }
.chain-hud small { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; color: #728d9d; font-size: 0.58rem; white-space: nowrap; }
.chain-track { height: 3px; margin-top: 4px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,0.1); }
.chain-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), #fff); box-shadow: 0 0 9px var(--cyan); }
.chain-hud.active { border-color: rgba(93,243,255,0.64); box-shadow: inset 0 0 18px rgba(93,243,255,0.08), 0 0 25px rgba(93,243,255,0.13); }
.chain-hud.active strong { color: var(--cyan); font-size: 1.15rem; text-shadow: 0 0 12px var(--cyan); }
.chain-hud.overdrive { border-color: rgba(255,193,92,0.82); animation: chainPulse 760ms ease-in-out infinite alternate; }
.chain-hud.overdrive strong { color: var(--amber); text-shadow: 0 0 14px var(--amber); }

.chain-reaction {
  position: absolute;
  z-index: 14;
  left: 50%;
  top: 35%;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 8px;
  align-items: center;
  padding: 10px 17px;
  border: 1px solid rgba(255,193,92,0.76);
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(90deg, rgba(29,16,3,0.32), rgba(50,29,5,0.94), rgba(29,16,3,0.32));
  box-shadow: 0 0 42px rgba(255,164,54,0.3);
  transform: translateX(-50%);
  pointer-events: none;
  animation: chainReaction 1000ms cubic-bezier(.16,.82,.24,1) forwards;
}
.chain-reaction .scope-badge { grid-row: 1 / 3; }
.chain-reaction strong { color: var(--amber); font-size: 1.25rem; letter-spacing: 0.12em; white-space: nowrap; }
.chain-reaction > span:last-child { color: #ffdca0; font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; }
.chain-reaction.self { border-color: rgba(198,156,255,0.8); box-shadow: 0 0 42px rgba(168,99,255,0.3); }

.shield-aura { position: absolute; z-index: 2; left: 2%; bottom: 12%; width: 145px; height: 250px; border: 3px solid transparent; border-radius: 50%; }
.shield-aura.active { border-color: rgba(84, 232, 255, 0.75); box-shadow: inset 0 0 24px rgba(84, 232, 255, 0.35), 0 0 24px rgba(84, 232, 255, 0.25); }

.skill-callout {
  position: absolute;
  z-index: 13;
  left: 50%;
  top: 22%;
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 9px 15px;
  border: 1px solid var(--line-hot);
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(90deg, rgba(3,12,20,0.35), rgba(8,31,45,0.94), rgba(3,12,20,0.35));
  box-shadow: 0 0 35px rgba(93,243,255,0.2);
  transform: translateX(-50%);
  pointer-events: none;
  animation: skillCallout 1320ms cubic-bezier(.2,.8,.2,1) forwards;
}
.skill-callout img { width: 62px; height: 62px; object-fit: contain; filter: drop-shadow(0 0 13px rgba(93,243,255,0.8)); }
.skill-callout strong { font-size: 1.15rem; letter-spacing: 0.1em; }
.skill-callout.all { border-color: rgba(255,193,92,0.72); box-shadow: 0 0 38px rgba(255,163,55,0.24); }
.skill-callout.self { border-color: rgba(198,156,255,0.72); box-shadow: 0 0 38px rgba(170,99,255,0.22); }

.target-lock {
  position: absolute;
  z-index: 12;
  width: 118px;
  height: 118px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--cyan), inset 0 0 14px rgba(93,243,255,0.22);
  transform: translate(-50%, 50%);
  pointer-events: none;
  animation: targetLock 580ms ease-out forwards;
}
.target-lock::before, .target-lock::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--cyan); transform: translate(-50%,-50%); box-shadow: 0 0 8px var(--cyan); }
.target-lock::before { width: 142px; height: 2px; }
.target-lock::after { width: 2px; height: 142px; }
.target-lock.slash { border-color: #ffbf67; box-shadow: 0 0 14px #ff9f43; }
.target-lock.pierce { border-color: #aef9ff; }
.target-lock.blunt { border-color: #ffe5a1; }

.area-impact {
  position: absolute;
  z-index: 10;
  left: 15%;
  right: 0;
  bottom: 9%;
  height: 58%;
  pointer-events: none;
  background: radial-gradient(ellipse at 58% 72%, rgba(255,196,93,0.42), rgba(93,243,255,0.12) 38%, transparent 68%);
  border-bottom: 3px solid rgba(255,205,110,0.72);
  box-shadow: inset 0 -18px 34px rgba(255,143,44,0.18), 0 10px 28px rgba(255,166,63,0.12);
  animation: areaImpact 600ms ease-out forwards;
}
.area-impact.arcane { background: radial-gradient(ellipse at 58% 72%, rgba(113,231,255,0.46), rgba(138,90,255,0.15) 42%, transparent 70%); border-color: var(--cyan); }
.area-impact.slash { background: radial-gradient(ellipse at 58% 72%, rgba(255,191,103,0.48), transparent 67%); }

.self-impact {
  position: absolute;
  z-index: 7;
  left: 1%;
  bottom: 8%;
  width: 175px;
  height: 285px;
  border: 2px solid var(--violet);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(198,156,255,0.23), transparent 68%);
  box-shadow: inset 0 0 36px rgba(198,156,255,0.25), 0 0 30px rgba(198,156,255,0.3);
  pointer-events: none;
  animation: selfImpact 620ms ease-out forwards;
}

.arena.single-hit { animation: singleKick 230ms ease-out; }
.arena.area-hit { animation: areaShake 410ms ease-out; }
.arena.self-hit .hero { animation: heroEmpower 480ms ease-out; }

.projectile, .burst-effect {
  position: absolute;
  z-index: 7;
  pointer-events: none;
}
.projectile { left: 15%; bottom: 40%; width: 46px; height: 6px; border-radius: 99px; background: var(--cyan); box-shadow: 0 0 15px var(--cyan); animation: shoot 420ms ease-out forwards; }
.projectile.fire { background: var(--amber); box-shadow: 0 0 20px var(--amber); }
.object-projectile {
  position: absolute;
  z-index: 7;
  left: 11%;
  bottom: var(--start-bottom, 34%);
  width: 58px;
  height: 58px;
  object-fit: contain;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(84, 232, 255, 0.65));
  animation: objectThrow 660ms cubic-bezier(.2,.65,.35,1) forwards;
}
.object-projectile.spear, .object-projectile.arrow, .object-projectile.bolt, .object-projectile.dart, .object-projectile.sword { width: 96px; animation-name: spearThrow; }
.object-projectile.axe, .object-projectile.book { width: 68px; height: 68px; }
.object-projectile.animated { width: 118px; height: 118px; animation-name: animatedObjectThrow; }
.object-impact { position: absolute; z-index: 11; width: clamp(145px, 18vw, 205px); aspect-ratio: 1; object-fit: contain; pointer-events: none; transform: translateX(-50%); filter: drop-shadow(0 0 18px rgba(84,232,255,0.82)); animation: objectImpactPop 620ms ease-out forwards; }
.burst-effect { width: clamp(145px, 18vw, 205px); aspect-ratio: 1; object-fit: contain; transform: translateX(-50%); transform-origin: 50% 60%; clip-path: circle(49%); mix-blend-mode: screen; filter: drop-shadow(0 0 18px rgba(84,232,255,0.9)); animation: explosionKick 800ms ease-out forwards; }
.burst-effect.fire { filter: drop-shadow(0 0 22px rgba(255,118,38,0.95)); }
.burst-effect.poison { filter: drop-shadow(0 0 22px rgba(122,255,76,0.9)); }

.phrase-forge { position: relative; padding: 15px 16px 17px; border-top: 1px solid rgba(93,243,255,0.28); background: linear-gradient(145deg, rgba(11,39,56,0.96), rgba(5,18,29,0.97)); box-shadow: inset 0 1px rgba(255,255,255,0.04); }
.phrase-forge::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); opacity: 0.55; }
.weapon-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.weapon-legend span { padding: 3px 7px; border-radius: 999px; color: var(--muted); background: rgba(4, 16, 27, 0.76); font-size: 0.68rem; font-weight: 800; }
.scope-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.scope-legend span, .scope-badge { display: inline-flex; gap: 3px; align-items: center; padding: 2px 6px; border: 1px solid currentColor; border-radius: 999px; font-size: 0.62rem; font-weight: 1000; letter-spacing: 0.04em; white-space: nowrap; }
.scope-legend .single, .scope-badge.single { color: var(--cyan); background: rgba(34,179,202,0.1); }
.scope-legend .all, .scope-badge.all { color: var(--amber); background: rgba(255,161,54,0.1); }
.scope-legend .self, .scope-badge.self { color: var(--violet); background: rgba(164,99,238,0.1); }
.buff-tray { display: flex; gap: 7px; align-items: center; min-height: 31px; margin-top: 7px; padding: 5px 8px; border: 1px solid rgba(255, 180, 76, 0.25); border-radius: 9px; color: var(--muted); background: rgba(4, 16, 27, 0.7); font-size: 0.72rem; }
.buff-tray img { width: 28px; height: 28px; object-fit: contain; }
.buff-tray strong { color: var(--amber); }
.rune-tray { display: flex; flex-wrap: wrap; gap: 7px; min-height: 41px; margin: 11px 0; }
.rune-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid rgba(84, 232, 255, 0.4);
  border-radius: 8px;
  color: var(--cyan);
  background: linear-gradient(180deg, #0c2637, #05131e);
  box-shadow: inset 0 1px rgba(255,255,255,0.055), 0 4px 10px rgba(0,0,0,0.22);
  cursor: pointer;
  font-weight: 900;
}
.rune-chip.barrage-chip { display: inline-flex; align-items: stretch; min-height: 38px; padding: 0; overflow: hidden; border-color: rgba(255, 180, 76, 0.62); color: var(--amber); }
.rune-chip.barrage-chip img { width: 28px; height: 28px; object-fit: contain; }
.rune-select, .rune-fire { border: 0; color: inherit; background: transparent; cursor: pointer; font-weight: 900; }
.rune-select { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 4px 8px; }
.rune-fire { padding: 4px 8px; border-left: 1px solid rgba(255, 180, 76, 0.35); background: rgba(255, 180, 76, 0.1); font-size: 0.72rem; }
.rune-select:hover, .rune-fire:hover { background: rgba(255, 180, 76, 0.2); }
.rune-chip.tagged-chip { border-color: rgba(188, 126, 255, 0.58); color: #d9b5ff; }
.grammar-role { padding: 1px 5px; border: 1px solid rgba(255,255,255,0.22); border-radius: 999px; color: #b8cad7; font-size: 0.56rem; letter-spacing: 0.03em; }
.phrase-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(135px, 0.8fr); gap: 7px; align-items: stretch; }
.phrase-slot { min-height: 46px; border: 1px dashed rgba(84, 232, 255, 0.55); border-radius: 8px; color: var(--ink); background: rgba(4, 15, 25, 0.7); cursor: pointer; font-weight: 900; }
.phrase-slot.filled { border-style: solid; border-color: var(--cyan); background: linear-gradient(180deg, rgba(21,95,117,0.56), rgba(7,35,49,0.82)); box-shadow: inset 0 0 16px rgba(93,243,255,0.08), 0 0 14px rgba(93,243,255,0.09); }
.phrase-slot strong, .phrase-slot small { display: block; }
.phrase-slot small { margin-top: 2px; color: var(--muted); font-size: 0.58rem; }
.phrase-feedback { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; min-height: 24px; margin: 9px 0 0; color: var(--muted); }
.grammar-tier { padding: 2px 6px; border-radius: 4px; color: #07131d; background: var(--cyan); font-size: 0.63rem; font-weight: 1000; }
.grammar-tier.command { background: var(--amber); }
.grammar-tier.sentence { color: #fff; background: linear-gradient(90deg, #9b5cf2, #ef5e9b); box-shadow: 0 0 14px rgba(190,91,239,0.34); }
.helper-word { color: #70899b; font-weight: 700; }

.modal {
  width: min(540px, calc(100% - 28px));
  border: 1px solid rgba(93, 243, 255, 0.42);
  border-radius: 18px;
  color: var(--ink);
  background: linear-gradient(160deg, rgba(16,48,68,0.98), rgba(4,15,24,0.99) 65%);
  box-shadow: inset 0 1px rgba(255,255,255,0.07), 0 35px 110px #000, 0 0 45px rgba(40,184,214,0.1);
  padding: 26px;
}
.modal::backdrop { background: rgba(0, 5, 10, 0.82); backdrop-filter: blur(5px); }
.modal .primary-button { width: 100%; margin-top: 12px; }
.wide-button { width: 100%; margin-top: 8px; }
.help-modal { width: min(820px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: auto; }
.history-modal { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: auto; }
.current-run-card, .run-log-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #081b29; }
.current-run-card > strong { color: var(--cyan); }
.run-history-list { display: grid; gap: 9px; }
.run-history-list.empty, .word-log.empty { padding: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }
.run-log-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.run-log-heading strong { color: var(--cyan); }
.run-log-heading time { color: var(--muted); font-size: 0.76rem; }
.word-log-summary { margin: 8px 0 6px; color: var(--muted); font-size: 0.76rem; }
.word-log-sequence { display: flex; flex-wrap: wrap; gap: 5px; }
.word-log-chip { padding: 4px 7px; border: 1px solid rgba(84, 232, 255, 0.36); border-radius: 7px; color: var(--cyan); background: #05131f; font-size: 0.76rem; font-weight: 900; }
.word-log-chip.neutral { border-color: rgba(255, 180, 76, 0.42); color: var(--amber); }
.codex-atlases { display: grid; grid-template-columns: 4fr 3fr; gap: 10px; margin: 12px 0; }
.codex-atlases figure { margin: 0; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #06131f; }
.codex-atlases img { display: block; width: 100%; border-radius: 7px; }
.codex-atlases figcaption { margin-top: 6px; color: var(--muted); font-size: 0.72rem; text-align: center; }
.word-modal h2 { margin: 5px 0; color: var(--cyan); font-size: 3.2rem; letter-spacing: 0.1em; }
.word-meaning { font-size: 1.25rem; font-weight: 800; }
.speak-button { float: right; border: 0; color: var(--cyan); background: transparent; cursor: pointer; }
.muted { color: var(--muted); }
.reward-choices { display: grid; gap: 10px; }
.reward-choice { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #0d2638; cursor: pointer; text-align: left; }
.reward-choice:hover { border-color: var(--cyan); background: #12344a; }
.reward-choice img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.5)); }
.reward-choice strong { display: block; color: var(--cyan); font-size: 1.05rem; }
.recipe-list { display: grid; gap: 7px; padding: 0; list-style: none; }
.recipe-list li { display: flex; gap: 8px; align-items: center; padding: 9px 11px; border: 1px solid rgba(93,243,255,0.1); border-radius: 8px; background: linear-gradient(90deg, rgba(21, 58, 79, 0.62), rgba(7,26,39,0.68)); }
.recipe-list strong { color: var(--cyan); }
.result-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.result-stats div { padding: 12px; border-radius: 12px; background: #0b2232; text-align: center; }
.result-stats strong { display: block; color: var(--cyan); font-size: 1.7rem; }
.meta-modal { width: min(900px, calc(100% - 28px)); max-height: min(820px, calc(100vh - 28px)); overflow: auto; }
.meta-heading, .loadout-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.meta-heading-actions { display: flex; gap: 9px; align-items: center; }
.meta-heading-actions > strong, .loadout-heading span { color: var(--amber); font-weight: 900; }
.upgrade-grid, .meta-phrase-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.upgrade-card, .meta-phrase-card {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #0b2232;
  text-align: left;
}
.upgrade-card strong, .meta-phrase-card strong { display: block; color: var(--cyan); }
.upgrade-card span, .meta-phrase-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 0.78rem; }
.upgrade-card button, .meta-phrase-card button { width: 100%; min-height: 32px; margin-top: 9px; border: 0; border-radius: 8px; color: #041018; background: var(--cyan); cursor: pointer; font-weight: 900; }
.upgrade-card button:disabled, .meta-phrase-card button:disabled { opacity: 0.42; cursor: not-allowed; }
.meta-phrase-card.equipped { border-color: var(--cyan); background: rgba(16, 78, 99, 0.5); }
.meta-phrase-card.locked { opacity: 0.78; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 28px; padding: 12px 18px; border-radius: 999px; color: #041018; background: var(--cyan); font-weight: 900; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.editorial-note { margin: 10px 2px 0; color: #718a9c; font-size: 0.76rem; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@keyframes shoot { to { left: 88%; opacity: 0.2; transform: scaleX(1.8); } }
@keyframes objectThrow {
  0% { left: 11%; bottom: var(--start-bottom, 34%); opacity: 0; transform: translate(-50%, 20px) scale(0.65) rotate(-20deg); }
  12% { opacity: 1; }
  58% { opacity: 1; transform: translate(-50%, -40px) scale(1.15) rotate(260deg); }
  100% { left: var(--target-x, 88%); bottom: var(--target-bottom, 25%); opacity: 1; transform: translate(-50%, 0) scale(0.82) rotate(500deg); }
}
@keyframes spearThrow {
  0% { left: 11%; bottom: var(--start-bottom, 34%); opacity: 0; transform: translate(-50%, 18px) scale(0.7); }
  12% { opacity: 1; }
  58% { opacity: 1; transform: translate(-50%, -30px) scale(1.08); }
  100% { left: var(--target-x, 88%); bottom: var(--target-bottom, 25%); opacity: 1; transform: translate(-50%, 0) scale(0.8); }
}
@keyframes animatedObjectThrow { 0% { left: 11%; bottom: var(--start-bottom, 34%); opacity: 0; transform: translate(-50%, 12px) scale(0.72); } 14% { opacity: 1; } 100% { left: var(--target-x, 88%); bottom: var(--target-bottom, 25%); opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes objectImpactPop { 0% { opacity: 0.75; transform: translateX(-50%) scale(0.88); } 24%, 78% { opacity: 1; transform: translateX(-50%) scale(1.08); } 100% { opacity: 0; transform: translateX(-50%) scale(1); } }
@keyframes affinityFloat { to { opacity: 0; transform: translate(-50%, -38px) scale(1.08); } }
@keyframes damageFloat { to { opacity: 0; transform: translate(-50%, -52px) scale(1.18); } }
@keyframes explosionKick { 0% { opacity: 0.7; transform: translateX(-50%) scale(0.82); } 22% { opacity: 1; transform: translateX(-50%) scale(1.12); } 100% { opacity: 0; transform: translateX(-50%) scale(1); } }
@keyframes hitFlash { 50% { filter: brightness(2.3) drop-shadow(0 0 16px #fff); transform: translateX(-50%) translateX(7px); } }
@keyframes hintPulse { to { border-color: #fff; box-shadow: 0 0 16px var(--cyan); } }
@keyframes skillCallout { 0% { opacity: 0; transform: translate(-50%, 12px) scale(0.86); } 14%, 76% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -12px) scale(1.05); } }
@keyframes targetLock { 0% { opacity: 0; transform: translate(-50%, 50%) scale(1.7) rotate(-35deg); } 28% { opacity: 1; } 70% { opacity: 0.95; transform: translate(-50%, 50%) scale(0.82) rotate(8deg); } 100% { opacity: 0; transform: translate(-50%, 50%) scale(0.68) rotate(18deg); } }
@keyframes areaImpact { 0% { opacity: 0; transform: scaleX(0.35) translateY(24px); filter: brightness(2.2); } 28% { opacity: 1; } 100% { opacity: 0; transform: scaleX(1.08) translateY(-8px); filter: brightness(1); } }
@keyframes selfImpact { 0% { opacity: 0; transform: scale(0.65); } 35% { opacity: 1; } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes singleKick { 35% { filter: brightness(1.2) contrast(1.06); transform: translateX(-2px); } 70% { transform: translateX(1px); } }
@keyframes areaShake { 15% { filter: brightness(1.28); transform: translate(-5px, 1px); } 35% { transform: translate(5px, -2px); } 55% { transform: translate(-3px, 1px); } 75% { transform: translate(2px, 0); } }
@keyframes heroEmpower { 45% { filter: brightness(1.8) drop-shadow(0 0 26px var(--violet)); transform: translateY(-3px) scale(1.03); } }
@keyframes chainDrain { from { width: 100%; } to { width: 0; } }
@keyframes chainPulse { to { box-shadow: inset 0 0 22px rgba(255,193,92,0.12), 0 0 30px rgba(255,160,47,0.24); } }
@keyframes chainReaction { 0% { opacity: 0; transform: translate(-50%, 18px) scale(0.75); filter: brightness(2); } 18%, 62% { opacity: 1; transform: translate(-50%, 0) scale(1); filter: brightness(1); } 100% { opacity: 0; transform: translate(-50%, -18px) scale(1.08); } }

@media (max-width: 1020px) {
  .topbar { grid-template-columns: 1fr auto; }
  .run-stats { grid-column: 1 / -1; order: 3; }
  .top-actions { justify-content: flex-end; }
  .battle-layout { grid-template-columns: 1fr; }
  .forge-panel { order: 1; }
  .arena-panel { order: 2; }
  .arena { min-height: 390px; }
}

@media (min-width: 1021px) and (max-height: 760px) {
  .game-shell { padding: 10px 18px; }
  .topbar { margin-bottom: 7px; }
  .topbar h1 { font-size: 2rem; }
  .forge-panel { padding: 10px; }
  .target-card { min-height: 68px; padding: 8px 12px; }
  .target-card h2 { font-size: 1.15rem; }
  .item-bar { margin-top: 5px; padding: 4px 7px; }
  .selection-readout { min-height: 32px; margin: 5px 0; padding: 4px 10px; }
  .letter-board { width: min(100%, 390px); margin: 0 auto; gap: 4px; }
  .letter-tile { border-radius: 8px; font-size: 1.25rem; }
  .board-actions { margin-top: 7px; }
  .arena { min-height: 360px; }
  .phrase-forge { padding: 10px 14px 12px; }
  .rune-tray { min-height: 34px; margin: 7px 0; }
  .phrase-feedback { margin-top: 5px; }
}

@media (max-width: 560px) {
  .game-shell { padding: 10px; }
  .topbar { grid-template-columns: 1fr; gap: 8px; padding: 10px; }
  .topbar > div:first-child { display: flex; gap: 9px; align-items: baseline; }
  .topbar > div:first-child .eyebrow { margin: 0; }
  .topbar h1 { white-space: nowrap; font-size: 1.7rem; }
  .top-actions { display: grid; grid-template-columns: auto repeat(3, 1fr); width: 100%; }
  .top-actions .icon-button { min-height: 36px; padding: 5px 7px; font-size: 0.74rem; }
  .top-actions > strong { align-self: center; font-size: 0.78rem; }
  .run-stats { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .run-stats div { min-width: 0; }
  .mobile-combat-status { position: sticky; z-index: 12; top: 0; width: auto; height: auto; margin: 8px 0; padding: 8px 10px; overflow: visible; clip: auto; border: 1px solid rgba(255, 180, 76, 0.4); border-radius: 9px; color: var(--amber); background: rgba(4, 14, 24, 0.96); white-space: normal; font-size: 0.78rem; font-weight: 800; }
  .arena { min-height: 320px; }
  .combat-banner { max-width: calc(100% - 24px); }
  .chain-hud { top: 58px; width: 138px; }
  .phrase-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .combo-button { grid-column: 1 / -1; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .upgrade-grid, .meta-phrase-grid { grid-template-columns: 1fr; }
  .mode-grid, .codex-atlases { grid-template-columns: 1fr; }
  .letter-board { gap: 5px; }
  .letter-tile { border-radius: 8px; }
  .board-actions { grid-template-columns: 1fr 1fr; }
  .item-bar { grid-template-columns: 1fr 1fr; }
  .item-bar strong, .item-bar span { align-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
