:root {
  --bg: #0b0a0f;
  --bg-2: #14121c;
  --panel: #1a1724;
  --panel-2: #221e30;
  --border: #3a3350;
  --text: #f3efe6;
  --muted: #a89bb8;
  --pink: #ff4d8d;
  --pink-2: #ff7aa8;
  --gold: #ffc857;
  --cyan: #4de1ff;
  --green: #5dff9a;
  --red: #ff5c5c;
  --wine: #c43b6e;
  --donut: #ffb347;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font-display: "Bangers", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1000px 500px at 15% -10%, #2a1540 0%, transparent 55%),
    radial-gradient(800px 400px at 100% 0%, #1a2a40 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body { min-height: 100dvh; }

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 12px 28px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 4px 2px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark { color: var(--pink); font-size: 16px; }
.brand-title em { color: var(--gold); font-style: normal; }
.season-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── TITLE ── */
.title-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 12px;
  align-items: center;
  min-height: 70dvh;
}

.title-cast {
  position: relative;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(255, 77, 141, 0.25), transparent 60%),
    url("assets/arena.jpg?v=3") center/cover;
  border-radius: 18px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.title-hero-art {
  height: min(52vh, 420px);
  width: auto;
  max-width: 70%;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6));
  animation: idleBob 2.4s ease-in-out infinite;
  z-index: 2;
}

.title-donut-art {
  position: absolute;
  right: 6%;
  bottom: 12%;
  height: min(22vh, 170px);
  width: auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
  animation: idleBob 2.1s ease-in-out infinite 0.3s;
  z-index: 3;
}

@keyframes idleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.title-copy { padding: 8px 4px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--cyan);
  margin: 0 0 8px;
}

.title-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 9vw, 5rem);
  line-height: 0.92;
  margin: 0 0 12px;
  text-shadow: 0 0 40px rgba(255, 77, 141, 0.35);
}

.shig-name {
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255, 200, 87, 0.45);
}

.tagline {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
  margin: 0 0 18px;
  max-width: 36ch;
}

.fine-print { margin-top: 12px; color: var(--muted); font-size: 0.88rem; }

.content-warn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--red);
  border: 1px solid rgba(255, 92, 92, 0.45);
  background: rgba(255, 40, 40, 0.08);
  padding: 8px 10px;
  border-radius: 10px;
  margin: 0 0 16px;
  max-width: 42ch;
  line-height: 1.4;
}

/* ── PANELS ── */
.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-wide { max-width: 720px; margin: 0 auto; }

.intro-art-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 140px;
}

.intro-shig { height: 150px; width: auto; filter: drop-shadow(0 6px 12px #000); }
.intro-donut { height: 100px; width: auto; filter: drop-shadow(0 6px 12px #000); }

.ai-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  background: rgba(77, 225, 255, 0.08);
  border: 1px solid rgba(77, 225, 255, 0.25);
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.narration { font-size: 1rem; line-height: 1.55; }
.narration.compact { font-size: 0.95rem; color: var(--muted); }
.narration.compact p { margin: 0 0 0.75em; }
.narration.compact strong { color: var(--text); }

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ── BUTTONS ── */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  text-align: left;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--pink);
  background: #2a2438;
}

.btn:active { transform: translateY(0) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #ff4d8d 0%, #ff7a4d 100%);
  border-color: transparent;
  color: #1a0a12;
  box-shadow: 0 8px 24px rgba(255, 77, 141, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff6aa0 0%, #ff9168 100%);
  border-color: transparent;
}

.btn-xl {
  font-size: 1.1rem;
  padding: 14px 24px;
  letter-spacing: 0.04em;
}

.btn-danger { border-color: rgba(255, 92, 92, 0.5); }
.btn-wine { border-color: rgba(196, 59, 110, 0.65); }
.btn-cat { border-color: rgba(255, 179, 71, 0.55); }

.action-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 56px;
}

.action-icon {
  font-size: 1.45rem;
  width: 2rem;
  text-align: center;
  line-height: 1;
}

.action-text { line-height: 1.25; }

/* ── HUD ── */
.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-face {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.hud-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  line-height: 1;
}

.hud-class {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

.hud-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.hud-stat {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 6px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
}

.hud-stat span { color: var(--muted); }
.hud-stat b { min-width: 2.2ch; text-align: right; font-weight: 600; }

.bar {
  height: 8px;
  background: #0e0c14;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 0.35s ease;
}

.bar-fill.hp { background: linear-gradient(90deg, #ff5c5c, #ff9a5c); }
.bar-fill.ratings { background: linear-gradient(90deg, #4de1ff, #7a6bff); }
.bar-fill.wine { background: linear-gradient(90deg, #7a1f4a, #c43b6e); }
.bar-fill.donut { background: linear-gradient(90deg, #ff9a3c, #ffd27a); }
.bar-fill.foe-hp { background: linear-gradient(90deg, #b44dff, #ff4d8d); }

.hud-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  line-height: 1.4;
}

/* ── ARENA ── */
.arena {
  position: relative;
  height: clamp(220px, 38vh, 340px);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: 12px 8px 16px;
}

.arena-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 8, 16, 0.15) 0%, rgba(10, 8, 16, 0.55) 100%),
    url("assets/arena.jpg?v=3") center/cover;
  z-index: 0;
}

.arena-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  z-index: 5;
  pointer-events: none;
}

.arena-flash.hit {
  animation: flashHit 0.28s ease;
}

.arena-flash.heal {
  animation: flashHeal 0.35s ease;
}

@keyframes flashHit {
  0% { opacity: 0.65; background: #8b0000; }
  40% { opacity: 0.35; background: #ff1a1a; }
  100% { opacity: 0; }
}

@keyframes flashHeal {
  0% { opacity: 0.4; background: #5dff9a; }
  100% { opacity: 0; }
}

.arena.bloodied::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(circle at 70% 40%, rgba(140, 0, 0, 0.45) 0 12%, transparent 13%),
    radial-gradient(circle at 75% 55%, rgba(180, 0, 0, 0.35) 0 8%, transparent 9%),
    radial-gradient(circle at 30% 70%, rgba(120, 0, 0, 0.25) 0 10%, transparent 11%);
  animation: bloodFade 1.2s ease forwards;
}

@keyframes bloodFade {
  0% { opacity: 1; }
  100% { opacity: 0.35; }
}

.blood-drop {
  position: absolute;
  width: 10px;
  height: 14px;
  background: #b30000;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  box-shadow: 0 0 6px #ff0000;
  animation: drip 0.7s ease forwards;
  z-index: 7;
}

@keyframes drip {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(50px) scale(0.6); }
}

.gore-burst {
  position: absolute;
  font-size: 2rem;
  z-index: 7;
  animation: gorePop 0.7s ease forwards;
  filter: drop-shadow(0 0 6px #ff0000);
}

@keyframes gorePop {
  0% { opacity: 1; transform: scale(0.4) rotate(-10deg); }
  40% { opacity: 1; transform: scale(1.3) rotate(8deg); }
  100% { opacity: 0; transform: scale(1.6) translateY(-30px); }
}

.fighter {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.fighter-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.55);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 200, 87, 0.35);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foe-side .fighter-label {
  color: var(--pink-2);
  border-color: rgba(255, 77, 141, 0.4);
}

.sprite-stack {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: clamp(140px, 28vh, 240px);
  width: 100%;
}

.sprite {
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.65));
  user-select: none;
  pointer-events: none;
}

.sprite-shig {
  height: 100%;
  width: auto;
  max-width: 100%;
  animation: idleBob 2.6s ease-in-out infinite;
}

.sprite-donut {
  position: absolute;
  left: 4%;
  bottom: 8%;
  height: 42%;
  width: auto;
  animation: idleBob 2.2s ease-in-out infinite 0.25s;
  z-index: 3;
}

.sprite-foe {
  height: 95%;
  width: auto;
  max-width: 100%;
  animation: foeIdle 2.8s ease-in-out infinite;
}

@keyframes foeIdle {
  0%, 100% { transform: translateY(0) scaleX(-1); }
  50% { transform: translateY(-6px) scaleX(-1); }
}

/* face foes toward hero when we want - scaleX(-1) already flips */
.sprite-foe.no-flip {
  animation-name: idleBob;
}

.fighter.hit .sprite-shig,
.fighter.hit .sprite-foe {
  animation: shake 0.35s ease !important;
}

.fighter.attack .sprite-shig {
  animation: lungeRight 0.35s ease !important;
}

.fighter.attack .sprite-foe {
  animation: lungeLeft 0.35s ease !important;
}

.fighter.die .sprite {
  animation: dieOut 0.6s ease forwards !important;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px) rotate(-3deg); }
  75% { transform: translateX(10px) rotate(3deg); }
}

@keyframes lungeRight {
  0% { transform: translateX(0); }
  40% { transform: translateX(28px) scale(1.05); }
  100% { transform: translateX(0); }
}

@keyframes lungeLeft {
  0% { transform: translateX(0) scaleX(-1); }
  40% { transform: translateX(-28px) scaleX(-1) scale(1.05); }
  100% { transform: translateX(0) scaleX(-1); }
}

@keyframes dieOut {
  to { opacity: 0; transform: translateY(30px) rotate(12deg) scale(0.8); filter: grayscale(1); }
}

.fighter-hp-mini {
  width: min(140px, 70%);
}

.vs-badge {
  position: relative;
  z-index: 3;
  align-self: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--pink);
  text-shadow: 0 0 20px rgba(255, 77, 141, 0.7);
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid var(--pink);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 40px;
}

.vs-badge.loot,
.vs-badge.social {
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  border-color: var(--gold);
  color: var(--gold);
}

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.dmg-float {
  position: absolute;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--red);
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(255, 80, 80, 0.8);
  animation: floatUp 0.9s ease forwards;
  white-space: nowrap;
}

.dmg-float.good {
  color: var(--green);
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(93, 255, 154, 0.7);
}

.dmg-float.star {
  color: var(--gold);
  font-size: 1.4rem;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  100% { opacity: 0; transform: translateY(-70px) scale(1.15); }
}

/* ── ENCOUNTER ── */
.encounter {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px 14px;
  box-shadow: var(--shadow);
}

.encounter-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.room-type {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--pink-2);
  background: rgba(255, 77, 141, 0.1);
  border: 1px solid rgba(255, 77, 141, 0.3);
  padding: 3px 8px;
  border-radius: 999px;
}

.encounter-head h2 {
  margin: 0;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  line-height: 1.2;
}

.room-blurb {
  margin: 0 0 8px;
  font-size: 1.02rem;
  line-height: 1.4;
  color: var(--text);
}

.flavor-details {
  margin: 0 0 10px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.15);
}

.flavor-details summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  list-style: none;
}

.flavor-details summary::-webkit-details-marker { display: none; }
.flavor-details[open] summary { margin-bottom: 8px; color: var(--cyan); }

.room-body {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.room-body p { margin: 0 0 0.7em; }

.speech {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: start;
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.speech p { margin: 0; font-size: 0.92rem; line-height: 1.4; }
.speech-who {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  margin-bottom: 2px;
}

.speech-face {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.speech-ai-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: rgba(77, 225, 255, 0.1);
  border-radius: 8px;
}

.donut-speech {
  background: rgba(255, 179, 71, 0.08);
  border-color: rgba(255, 179, 71, 0.35);
}
.donut-speech .speech-who { color: var(--donut); }

.ai-speech {
  background: rgba(77, 225, 255, 0.06);
  border-color: rgba(77, 225, 255, 0.28);
}
.ai-speech .speech-who { color: var(--cyan); }

.hidden { display: none !important; }

.action-grid {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.event-log {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
  min-height: 28px;
}

.event-log .log-line { margin: 0 0 3px; }
.event-log .good { color: var(--green); }
.event-log .bad { color: var(--red); }
.event-log .meh { color: var(--gold); }

.loot-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.loot-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.loot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.loot-chips span {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.loot-chips:empty::after {
  content: "empty pockets";
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── RESULT ── */
.result-art {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 140px;
}

.result-art img:first-child { height: 150px; width: auto; }
.result-art img:last-child { height: 100px; width: auto; }

.result-panel h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.03em;
  margin: 0 0 10px;
  color: var(--gold);
}

.achievements {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.ach {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 200, 87, 0.08);
  border: 1px solid rgba(255, 200, 87, 0.25);
}

.ach-icon { font-size: 1.2rem; }
.ach-title { font-weight: 700; color: var(--gold); }
.ach-desc { font-size: 0.88rem; color: var(--muted); }

.final-stats {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
}

/* ── MOBILE ── */
@media (max-width: 720px) {
  .title-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .title-cast { min-height: 240px; }
  .title-hero-art { height: 220px; }
  .title-donut-art { height: 100px; }

  .hud {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hud-meta {
    display: flex;
    gap: 12px;
    text-align: left;
  }

  .hud-bars { grid-template-columns: 1fr; }

  .arena { height: 210px; padding-bottom: 10px; }

  .sprite-stack { height: 140px; }

  .vs-badge {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    margin-bottom: 28px;
  }
}
