/* ============================================================
   Ember Arena — style
   Palette: deep charcoal-violet pit, ember gold, blood crimson.
   ============================================================ */

:root {
  --bg: #0d0a16;
  --bg-2: #140f22;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-edge: rgba(232, 179, 75, 0.16);
  --ink: #efe8da;
  --ink-dim: #a99f92;
  --gold: #e8b34b;
  --ember: #ff7a3c;
  --ember-2: #ffb35c;
  --blood: #e84d3d;
  --hp: #57c96b;
  --hp-low: #e8b34b;
  --hp-crit: #e84d3d;
  --mp: #6a7ff2;
  --foe: #ff6a5a;
  --radius: 14px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 50% -10%, #241a3a 0%, transparent 60%),
    radial-gradient(900px 500px at 50% 115%, #2a1408 0%, transparent 55%),
    var(--bg);
  min-height: 100%;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px clamp(10px, 2.5vw, 26px) 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------------- top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 4px 2px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 62%, #ffe9b8 0 14%, #ff9a3c 15% 34%, transparent 35%),
    radial-gradient(circle at 50% 60%, #c04f22 0 46%, transparent 47%),
    linear-gradient(160deg, #2a1f42, #170f26);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 0 18px rgba(255, 122, 60, 0.25), inset 0 0 12px rgba(0,0,0,0.6);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 28px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffe9b8, var(--gold) 55%, #b97a2a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.topbar-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.seed-chip {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--ember-2);
  cursor: copy;
  user-select: all;
}
.seed-chip::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember);
}

.status-chip { font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.status-chip.st-progress { color: #9fd8ff; border-color: rgba(159, 216, 255, 0.3); }
.status-chip.st-won { color: #7ee08a; border-color: rgba(126, 224, 138, 0.4); box-shadow: 0 0 14px rgba(126,224,138,0.15); }
.status-chip.st-lost { color: var(--foe); border-color: rgba(255, 106, 90, 0.4); }

.sfx-chip { cursor: pointer; }
.sfx-chip:hover { border-color: var(--gold); }
.sfx-chip.muted { color: var(--ink-dim); text-decoration: line-through; }

/* ---------------- layout ---------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.stage-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.log-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.panel-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ---------------- arena ---------------- */

.arena {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid rgba(232, 179, 75, 0.22);
  overflow: hidden;
  aspect-ratio: 16 / 8.6;
  min-height: 290px;
  background:
    radial-gradient(75% 90% at 50% 108%, #3a2415 0%, transparent 55%),
    linear-gradient(180deg, #191129 0%, #241433 46%, #2e1a20 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 0 80px rgba(0, 0, 0, 0.5);
}

.arena-sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(340px 160px at 18% 30%, rgba(255, 122, 60, 0.14), transparent 70%),
    radial-gradient(340px 160px at 82% 30%, rgba(255, 122, 60, 0.14), transparent 70%),
    radial-gradient(600px 240px at 50% 118%, rgba(255, 150, 60, 0.22), transparent 70%);
}

.arena-floor {
  position: absolute;
  left: -10%; right: -10%; bottom: -38%;
  height: 62%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 170, 90, 0.16), transparent 60%),
    repeating-conic-gradient(from 0deg at 50% 0%, rgba(255,255,255,0.028) 0deg 9deg, transparent 9deg 18deg),
    linear-gradient(180deg, #4a3227, #241812);
  border-top: 2px solid rgba(255, 190, 110, 0.25);
  box-shadow: 0 -6px 30px rgba(0,0,0,0.5) inset;
}

.torch {
  position: absolute;
  top: 12%;
  width: 16px; height: 60px;
  background: linear-gradient(180deg, #6e5335, #3a2818);
  border-radius: 4px;
}
.torch-left { left: 6%; }
.torch-right { right: 6%; }
.torch span {
  position: absolute;
  left: 50%; top: -18px;
  width: 22px; height: 30px;
  transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 70%, #fff3c8 0 18%, #ffb35c 40%, #ff7a3c 65%, rgba(255,80,30,0) 75%);
  filter: blur(0.4px);
  animation: flick 0.9s ease-in-out infinite alternate;
  transform-origin: 50% 90%;
}
.torch::after {
  content: "";
  position: absolute;
  left: 50%; top: -30px;
  width: 120px; height: 120px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,140,60,0.22), transparent 65%);
  animation: glowpulse 1.6s ease-in-out infinite alternate;
}

@keyframes flick {
  from { transform: translateX(-50%) scaleY(1) scaleX(1) rotate(-2deg); }
  to   { transform: translateX(-50%) scaleY(1.12) scaleX(0.94) rotate(2.5deg); }
}
@keyframes glowpulse {
  from { opacity: 0.7; transform: translateX(-50%) scale(1); }
  to   { opacity: 1; transform: translateX(-50%) scale(1.15); }
}

.ember-field { position: absolute; inset: 0; pointer-events: none; }
.ember-field i {
  position: absolute;
  bottom: -6px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ember-2);
  box-shadow: 0 0 6px var(--ember);
  opacity: 0;
  animation: rise linear infinite;
}
.ember-field i:nth-child(1) { left: 12%; animation-duration: 6.2s; animation-delay: 0.4s; }
.ember-field i:nth-child(2) { left: 22%; animation-duration: 7.8s; animation-delay: 2.1s; }
.ember-field i:nth-child(3) { left: 34%; animation-duration: 5.6s; animation-delay: 1.2s; }
.ember-field i:nth-child(4) { left: 47%; animation-duration: 8.4s; animation-delay: 3.4s; }
.ember-field i:nth-child(5) { left: 58%; animation-duration: 6.8s; animation-delay: 0.9s; }
.ember-field i:nth-child(6) { left: 69%; animation-duration: 7.2s; animation-delay: 2.8s; }
.ember-field i:nth-child(7) { left: 79%; animation-duration: 5.9s; animation-delay: 1.7s; }
.ember-field i:nth-child(8) { left: 88%; animation-duration: 8.8s; animation-delay: 4.1s; }
.ember-field i:nth-child(9) { left: 40%; animation-duration: 9.2s; animation-delay: 5s; }

@keyframes rise {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  8%   { opacity: 0.9; }
  60%  { opacity: 0.5; }
  100% { transform: translateY(-340px) translateX(24px) scale(0.4); opacity: 0; }
}

/* ---------------- fighters ---------------- */

.fighter {
  position: absolute;
  bottom: 7%;
  width: clamp(130px, 26%, 215px);
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.5));
  transition: filter 0.25s;
}
.fighter svg { display: block; width: 100%; height: auto; }
.hero-side { left: 9%; }
.enemy-side { right: 9%; }

.fighter .fig { animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.fighter .fig.hover { animation-name: hoverbob; }
.fighter .eye-glow { animation: eyewink 2.6s ease-in-out infinite; }
.fighter .core-pulse { animation: corepulse 1.5s ease-in-out infinite alternate; }
.fighter .orb-glow { animation: corepulse 1.9s ease-in-out infinite alternate; }
.fighter .hover-shadow { animation: shadowbob 3.2s ease-in-out infinite; transform-origin: center; }

@keyframes breathe {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-3px) scaleY(1.012); }
}
@keyframes hoverbob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
@keyframes shadowbob {
  0%, 100% { transform: scaleX(1); opacity: 0.35; }
  50% { transform: scaleX(0.86); opacity: 0.25; }
}
@keyframes eyewink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes corepulse { from { opacity: 0.55; } to { opacity: 1; } }

/* action animations */
.fighter.a-lunge { animation: lunge 0.42s cubic-bezier(0.2, 0.7, 0.3, 1); }
.fighter.a-heavy { animation: heavy 0.62s cubic-bezier(0.2, 0.8, 0.25, 1); }
.fighter.a-cast { animation: castbob 0.6s ease; }
.fighter.a-guard { animation: guardbrace 0.55s ease; }
.fighter.a-use { animation: castbob 0.5s ease; }
.fighter.a-charge { animation: chargeup 0.8s ease; }
.fighter.a-hit { animation: hitshake 0.4s linear; }
.fighter.a-die { animation: die 0.9s ease forwards; }

@keyframes lunge {
  0% { transform: translateX(0); }
  38% { transform: translateX(var(--lunge, 46px)); }
  100% { transform: translateX(0); }
}
@keyframes heavy {
  0% { transform: translateX(0) translateY(0); }
  30% { transform: translateX(calc(var(--lunge, 46px) * 0.6)) translateY(-16px) rotate(-4deg); }
  55% { transform: translateX(var(--lunge, 46px)) translateY(4px) rotate(3deg); }
  100% { transform: translateX(0); }
}
@keyframes castbob {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); filter: brightness(1.35); }
}
@keyframes guardbrace {
  0%, 100% { transform: translateX(0) scale(1); }
  45% { transform: translateX(-10px) scale(0.96); filter: brightness(1.25); }
}
@keyframes chargeup {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-14px) scale(1.05); filter: brightness(1.3) saturate(1.3); }
}
@keyframes hitshake {
  0%, 100% { transform: translateX(0); filter: none; }
  18% { transform: translateX(-9px); filter: brightness(2) sepia(1) hue-rotate(-40deg) saturate(3); }
  36% { transform: translateX(8px); }
  54% { transform: translateX(-6px); }
  72% { transform: translateX(4px); }
}
@keyframes die {
  0% { transform: rotate(0) translateY(0); opacity: 1; }
  60% { transform: rotate(var(--die-rot, -14deg)) translateY(26px); opacity: 0.85; }
  100% { transform: rotate(var(--die-rot, -14deg)) translateY(60px); opacity: 0; }
}

.hero-side { --lunge: 48px; --die-rot: -16deg; }
.enemy-side { --lunge: -48px; --die-rot: 16deg; }
.enemy-side .char { transform: scaleX(1); }

/* screen shake */
.arena.shake { animation: arenashake 0.34s linear; }
@keyframes arenashake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 2px); }
}

/* ---------------- fx layer ---------------- */

.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.fx-num {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 3.4vw, 34px);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.6), 0 0 14px rgba(255, 200, 120, 0.4);
  transform: translate(-50%, 0);
  animation: floatup 1s ease-out forwards;
  letter-spacing: 0.02em;
}
.fx-num.crit { color: var(--ember-2); font-size: clamp(30px, 4.6vw, 44px); text-shadow: 0 2px 0 rgba(0,0,0,0.7), 0 0 22px rgba(255,140,60,0.65); }
.fx-num.magic { color: #9fd8ff; }
.fx-num.burn { color: #ff9a3c; font-size: clamp(18px, 2.6vw, 26px); }
.fx-num.heal { color: #7ee08a; }
.fx-num.mana { color: #9fa8ff; font-size: clamp(18px, 2.6vw, 26px); }
.fx-num.status { color: #d0a2ff; font-size: clamp(15px, 2.1vw, 21px); }

@keyframes floatup {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.7); }
  14% { opacity: 1; transform: translate(-50%, -6px) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -74px) scale(1); }
}

.fx-slash, .fx-claw, .fx-slam, .fx-hex, .fx-fireball, .fx-ring {
  position: absolute;
  transform: translate(-50%, -50%);
}

.fx-slash { width: 34%; aspect-ratio: 1; }
.fx-slash svg { width: 100%; height: 100%; overflow: visible; }
.fx-slash.big { width: 46%; }
.slash-arc, .slash-arc2 {
  stroke-dasharray: 130;
  stroke-dashoffset: 130;
  animation: slashdraw 0.32s ease-out forwards;
}
.slash-arc2 { animation-delay: 0.05s; }
@keyframes slashdraw { to { stroke-dashoffset: 0; } }
.fx-slash::after, .fx-claw::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.75), transparent 55%);
  animation: flashout 0.3s ease-out forwards;
}
@keyframes flashout { from { opacity: 1; transform: scale(0.4); } to { opacity: 0; transform: scale(1.4); } }

.fx-claw { width: 26%; aspect-ratio: 1; transform: translate(-50%,-50%) scaleX(-1) rotate(18deg); }
.fx-claw svg { width: 100%; height: 100%; }

.fx-fireball {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3c8, #ff9a3c 45%, #e84d3d 75%, rgba(232,77,61,0));
  box-shadow: 0 0 18px 6px rgba(255, 122, 60, 0.55);
  animation: firefly 0.5s ease-in forwards;
}
.fx-fireball.big { width: 52px; height: 52px; box-shadow: 0 0 26px 10px rgba(255, 122, 60, 0.6); }
@keyframes firefly {
  from { transform: translate(var(--fx-from-x), -50%) scale(0.7); opacity: 0.9; }
  to { transform: translate(var(--fx-to-x), -50%) scale(1.1); opacity: 1; }
}
.fx-fireball::after {
  content: "";
  position: absolute; inset: -30px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,150,60,0.5), transparent 60%);
  animation: flashout 0.5s ease-out 0.32s forwards;
  opacity: 0;
}

.fx-slam { width: 60%; aspect-ratio: 2.4; }
.fx-slam::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 190, 110, 0.85);
  animation: shockwave 0.55s ease-out forwards;
}
@keyframes shockwave {
  from { transform: scale(0.15); opacity: 1; }
  to { transform: scale(1.3); opacity: 0; }
}

.fx-hex { width: 30%; aspect-ratio: 1; }
.fx-hex::before, .fx-hex::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px dashed rgba(200, 140, 255, 0.8);
  animation: hexspin 0.8s linear forwards;
}
.fx-hex::after { inset: 18%; animation-direction: reverse; }
@keyframes hexspin { from { transform: rotate(0) scale(0.6); opacity: 1; } to { transform: rotate(180deg) scale(1.15); opacity: 0; } }

.fx-ring { width: 36%; aspect-ratio: 1; }
.fx-ring::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(126, 224, 138, 0.7);
  box-shadow: 0 0 24px rgba(126, 224, 138, 0.35) inset;
  animation: ringfade 0.9s ease-out forwards;
}
@keyframes ringfade { from { transform: scale(0.6); opacity: 1; } to { transform: scale(1.1); opacity: 0; } }

/* ---------------- stat cards ---------------- */

.duel-stats {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  gap: 12px;
  align-items: stretch;
}

.vs-mark {
  align-self: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  opacity: 0.75;
  letter-spacing: 0.08em;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.hero-card { border-color: rgba(126, 168, 224, 0.25); }
.enemy-card { border-color: rgba(255, 106, 90, 0.25); }

.stat-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who .nm {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-card .nm { color: #b9d4f7; }
.enemy-card .nm { color: #ffab9a; }
.who .ttl { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.06em; font-style: italic; }

.status-row { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.st-chip {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid;
}
.st-chip.guard { color: #7ee08a; border-color: rgba(126,224,138,0.5); background: rgba(126,224,138,0.1); }
.st-chip.burn { color: #ff9a3c; border-color: rgba(255,154,60,0.5); background: rgba(255,154,60,0.1); }
.st-chip.weakened { color: #d0a2ff; border-color: rgba(208,162,255,0.5); background: rgba(208,162,255,0.1); }
.st-chip.charging { color: #ffd25a; border-color: rgba(255,210,90,0.6); background: rgba(255,210,90,0.12); animation: chargeblink 0.7s ease-in-out infinite alternate; }
@keyframes chargeblink { from { box-shadow: 0 0 0 rgba(255,210,90,0); } to { box-shadow: 0 0 12px rgba(255,210,90,0.55); } }

.intent-row {
  font-size: 11.5px;
  color: #ffd25a;
  letter-spacing: 0.04em;
}
.intent-row::before { content: "\26A0 "; }

.bar {
  position: relative;
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.bar-fill {
  position: absolute; inset: 0;
  width: 100%;
  border-radius: inherit;
  transition: width 0.45s cubic-bezier(0.3, 0.8, 0.3, 1), background 0.3s;
}
.hp-bar .bar-fill { background: linear-gradient(180deg, #79dd88, #3da44e); }
.hp-bar.mid .bar-fill { background: linear-gradient(180deg, #ffd25a, #cf8b1f); }
.hp-bar.low .bar-fill { background: linear-gradient(180deg, #ff7a5a, #c93d2e); }
.hp-bar.low { animation: lowpulse 1s ease-in-out infinite alternate; }
@keyframes lowpulse { from { box-shadow: 0 0 0 rgba(232,77,61,0); } to { box-shadow: 0 0 12px rgba(232,77,61,0.6); } }
.enemy-hp .bar-fill { background: linear-gradient(180deg, #ff8a72, #c93d2e); }
.enemy-hp.mid .bar-fill { background: linear-gradient(180deg, #ff8a72, #c93d2e); }
.enemy-hp.low .bar-fill { background: linear-gradient(180deg, #ff5a44, #8f1f14); }
.bar-ghost {
  position: absolute; inset: 0;
  width: 100%;
  border-radius: inherit;
  background: rgba(255, 235, 200, 0.5);
  transition: width 0.7s cubic-bezier(0.3, 0.8, 0.3, 1) 0.28s;
}
.mp-bar { height: 14px; }
.mp-bar .bar-fill { background: linear-gradient(180deg, #8d9bff, #4a5ad0); }
.bar-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  font-variant-numeric: tabular-nums;
}

.mini-stats { display: flex; gap: 7px; flex-wrap: wrap; }
.mini {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px 8px;
}
.mini b { color: var(--ink-dim); font-weight: 600; letter-spacing: 0.08em; }
.mini i { font-style: normal; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }

.blurb { margin: 0; font-size: 11.5px; color: var(--ink-dim); font-style: italic; line-height: 1.45; }

/* ---------------- controls ---------------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.action-row { display: flex; gap: 9px; flex-wrap: wrap; }

.btn {
  font: inherit;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s, filter 0.15s;
  min-height: 44px;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 6px 18px rgba(0,0,0,0.4), 0 0 12px rgba(232,179,75,0.12); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--ember-2); outline-offset: 2px; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; filter: saturate(0.4); }

.btn.action { flex: 1 1 120px; flex-direction: column; gap: 3px; padding: 10px 8px 8px; }
.btn.action .ic { font-size: 19px; line-height: 1; color: var(--ember-2); }
.btn.action.attack .ic { color: #cfd8e6; }
.btn.action .lb { font-weight: 700; font-size: 13px; letter-spacing: 0.03em; }
.btn.action .cost { font-size: 10px; color: var(--mp); font-weight: 700; letter-spacing: 0.05em; }
.btn.action kbd {
  position: absolute;
  top: 5px; right: 6px;
  font-size: 9px;
  font-family: inherit;
  color: var(--ink-dim);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 1px 4px;
}
.btn.attack { border-color: rgba(207, 216, 230, 0.3); }
.btn.attack:hover:not(:disabled) { border-color: #cfd8e6; }

.btn .badge {
  position: absolute;
  top: -7px; left: -7px;
  min-width: 20px; height: 20px;
  border-radius: 999px;
  background: var(--blood);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.inventory {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}
.inv-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.inv-items { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.item { min-height: 40px; padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.item .ic { color: var(--ember-2); }
.btn.item .qty {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,0.5);
  border-radius: 999px;
  padding: 1px 6px;
  border: 1px solid rgba(255,255,255,0.18);
}
.btn.item kbd {
  font-size: 9px;
  font-family: inherit;
  color: var(--ink-dim);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 0 4px;
}

/* ---------------- log ---------------- */

.log-panel { display: flex; flex-direction: column; min-height: 220px; }
.log {
  list-style: none;
  margin: 0;
  padding: 2px 4px 2px 2px;
  overflow-y: auto;
  max-height: 380px;
  font-size: 12.5px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(232,179,75,0.35) transparent;
}
.log li {
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid transparent;
  animation: login 0.28s ease;
}
@keyframes login {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.log li.you { border-left-color: #7ea8e0; color: #e8eefb; }
.log li.foe { border-left-color: var(--foe); color: #ffd9d2; }
.log li.sys { border-left-color: rgba(232, 179, 75, 0.5); color: var(--ink-dim); font-style: italic; }
.log li.turn {
  text-align: center;
  background: none;
  border: none;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 2px 0;
}
.log li.turn::before, .log li.turn::after { content: "— "; }

/* ---------------- run panel ---------------- */

.seed-row { display: flex; gap: 8px; }
.seed-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 9px 11px;
  font-family: ui-monospace, Consolas, monospace;
}
.seed-row input:focus { outline: none; border-color: var(--gold); }
.btn.small { min-height: 38px; padding: 8px 14px; }
.hint { margin: 10px 0 0; font-size: 11px; color: var(--ink-dim); line-height: 1.55; }
.hint kbd {
  font-size: 10px;
  font-family: inherit;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  padding: 0 4px;
}

/* ---------------- end overlay ---------------- */

.end-overlay {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 14, 0.68);
  backdrop-filter: blur(4px);
  z-index: 5;
  animation: overlayin 0.45s ease;
}
.end-overlay[hidden] { display: none; }
@keyframes overlayin { from { opacity: 0; } to { opacity: 1; } }

.end-card {
  text-align: center;
  padding: 26px 34px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(38,28,52,0.95), rgba(20,14,30,0.95));
  border: 1px solid var(--panel-edge);
  box-shadow: 0 24px 70px rgba(0,0,0,0.7);
  animation: cardpop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-width: 86%;
}
@keyframes cardpop { from { transform: scale(0.8) translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.end-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 44px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.end-overlay.won h2 {
  background: linear-gradient(180deg, #fff3c8, var(--gold) 60%, #b97a2a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 34px rgba(255, 190, 90, 0.35);
}
.end-overlay.lost h2 { color: var(--foe); text-shadow: 0 0 30px rgba(232, 77, 61, 0.4); }
.end-card p { margin: 0 0 14px; color: var(--ink-dim); font-style: italic; font-size: 13.5px; }

.end-stats {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin: 0 0 18px;
  padding: 0;
}
.end-stats > div { display: flex; flex-direction: column; }
.end-stats dt { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim); }
.end-stats dd { margin: 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn.primary {
  background: linear-gradient(180deg, #f0c060, #b97a2a);
  color: #241505;
  font-weight: 800;
  border-color: #ffd98a;
}
.btn.primary:hover:not(:disabled) { border-color: #fff3c8; box-shadow: 0 6px 22px rgba(232, 179, 75, 0.35); }
.dim { opacity: 0.65; font-weight: 400; font-size: 11px; }

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .log { max-height: 240px; }
  .arena { aspect-ratio: 16 / 10; }
}

@media (max-width: 640px) {
  #app { padding: 10px 10px 30px; gap: 12px; }
  .topbar { gap: 8px; }
  .brand-text p { display: none; }
  .arena { min-height: 230px; aspect-ratio: 16 / 11; }
  .fighter { width: clamp(110px, 30%, 150px); bottom: 6%; }
  .hero-side { left: 4%; }
  .enemy-side { right: 4%; }
  .duel-stats { grid-template-columns: 1fr; gap: 8px; }
  .vs-mark { display: none; }
  .torch { display: none; }
  .btn.action { flex-basis: calc(50% - 9px); }
  .btn.action kbd { display: none; }
  .controls {
    position: sticky;
    bottom: 8px;
    z-index: 4;
    background: linear-gradient(180deg, #271d3a, #171021);
    border-color: rgba(232, 179, 75, 0.35);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.55), 0 12px 28px rgba(0,0,0,0.55);
  }
}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
