:root {
  --bg: #050505;
  --ink: #e8e8e8;
  --muted: #6e6e6e;
  --line: #1a1a1a;
  --panel: rgba(6, 6, 6, 0.82);
  --bone: #d7d7d7;
  --ash: #8a8a8a;
  --blood: #9b0b0b;
  --gore: #5a0000;
  --buy: #8fbc6a;
  --sell: #c4453a;
  --crit: #e6c84a;
  --font-gothic: "Cinzel", "Times New Roman", serif;
  --font-pixel: "Press Start 2P", ui-monospace, monospace;
  font-size: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-pixel);
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(900px 420px at 50% 18%, rgba(255, 255, 255, 0.04), transparent 55%),
    radial-gradient(1200px 700px at 50% 120%, rgba(0, 0, 0, 0.95), #050505 70%),
    #050505;
}

.crt-scanlines,
.crt-vignette,
.crt-flicker,
.film-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
}

.crt-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.22) 0px,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.55;
}

.crt-vignette {
  background: radial-gradient(circle at 50% 42%, transparent 28%, rgba(0, 0, 0, 0.78) 100%);
}

.crt-flicker {
  background: rgba(255, 255, 255, 0.015);
  animation: flicker 7s infinite;
}

.film-grain {
  opacity: 0.14;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes flicker {
  0%,
  100% { opacity: 0.02; }
  94% { opacity: 0.02; }
  95% { opacity: 0.08; }
  96% { opacity: 0.01; }
}

#app {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 20px 32px;
  transform-origin: 50% 40%;
}

#app.is-shaking {
  animation: shake 0.42s steps(5, end);
}

@keyframes shake {
  0%,
  100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(9px, -5px); }
  60% { transform: translate(-6px, -3px); }
  80% { transform: translate(7px, 3px); }
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--ash);
  font-size: 8px;
  letter-spacing: 3px;
  margin-bottom: 10px;
}

h1 {
  font-family: var(--font-gothic);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.25;
  color: var(--bone);
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.08);
}

.subtitle,
.flavor {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--font-gothic);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar__center {
  text-align: center;
  padding-top: 4px;
}

.phase {
  font-family: var(--font-gothic);
  color: var(--bone);
  font-size: clamp(13px, 2vw, 20px);
  letter-spacing: 0.22em;
}

.topbar__right {
  justify-self: end;
  text-align: right;
}

.pill {
  display: inline-block;
  padding: 8px 10px;
  border: 1px solid #3a3a3a;
  margin-bottom: 8px;
  font-size: 8px;
  color: var(--ash);
}

.pill--live {
  border-color: #ccc;
  color: #eee;
}

.pill--demo,
.pill--idle {
  border-color: #333;
  color: var(--muted);
}

.wallet-addr {
  margin-top: 8px;
  color: var(--muted);
  font-size: 8px;
}

.pixel-btn {
  font-family: inherit;
  font-size: 8px;
  color: var(--bone);
  background: #0a0a0a;
  border: 1px solid #4a4a4a;
  padding: 10px 12px;
  cursor: pointer;
}

.pixel-btn:hover:not(:disabled) {
  background: #161616;
  border-color: #888;
  color: #fff;
}

.pixel-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pixel-btn--gold {
  width: 100%;
  margin-top: 10px;
}

body.is-bleeding .pixel-btn--gold:not(:disabled) {
  border-color: var(--blood);
  color: #ffd0d0;
}

.hp-block {
  margin: 4px 0 16px;
}

.hp-block__meta,
.burn-meta {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: var(--muted);
  margin-bottom: 8px;
}

.hp-track {
  position: relative;
  height: 8px;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  overflow: visible;
}

.hp-track__fill,
.hp-track__delay {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transform-origin: left center;
}

.hp-track__delay {
  background: #3a3a3a;
  transition: transform 0.8s steps(10, end);
  z-index: 1;
}

.hp-track__fill {
  background: linear-gradient(180deg, #f0f0f0, #9a9a9a);
  transition: transform 0.28s steps(6, end), background 0.12s linear;
  z-index: 2;
}

body.is-bleeding .hp-track__fill,
.hp-track.is-low .hp-track__fill {
  background: linear-gradient(180deg, #d41616, #5a0000);
}

.hp-track.is-low .hp-track__fill {
  animation: hpPulse 0.9s steps(2, end) infinite;
}

@keyframes hpPulse {
  50% { filter: brightness(1.35); }
}

.hp-track__ticks {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.hp-tick {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: #666;
}

.hp-tick span {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  color: #666;
  white-space: nowrap;
}

.arena {
  display: grid;
  grid-template-columns: 230px 1fr 230px;
  gap: 18px;
  align-items: stretch;
  min-height: 460px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.panel h2 {
  font-family: var(--font-gothic);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--bone);
  margin-bottom: 8px;
}

.panel__tag {
  font-size: 7px;
  color: var(--muted);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.panel__blurb,
.panel__stat,
.claim-msg {
  font-size: 8px;
  line-height: 1.7;
  color: var(--muted);
}

.panel__stat {
  color: var(--bone);
  margin: 8px 0;
}

.meter {
  height: 6px;
  background: #0a0a0a;
  border: 1px solid #222;
  margin: 12px 0;
}

.meter__fill {
  height: 100%;
  width: 0%;
  transition: width 0.35s steps(8, end);
  background: #bdbdbd;
}

.meter__fill--cyan,
.meter__fill--gold {
  background: linear-gradient(180deg, #efefef, #6a6a6a);
}

.shield {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 8px;
}

.shield__ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(220, 220, 220, 0.18);
  border-radius: 50%;
  transform: scale(0.7);
  transition: transform 0.4s steps(6, end), border-color 0.3s;
}

.shield__core {
  position: absolute;
  inset: 28px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #080808;
  border: 1px solid #333;
  border-radius: 50%;
}

.shield__core span {
  font-size: 14px;
  color: var(--bone);
}

.shield__core small {
  font-size: 7px;
  color: var(--muted);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 460px;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.07), transparent 22%),
    radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0.03), transparent 42%),
    linear-gradient(180deg, #0a0a0a, #030303);
  border: 1px solid #161616;
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  width: 140px;
  height: 220px;
  transform: translateX(-50%);
  background:
    linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.03) 40%, transparent 100%);
  clip-path: polygon(50% 0, 92% 18%, 92% 100%, 8% 100%, 8% 18%);
  opacity: 0.5;
}

.stage-fog {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 0;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(8, 8, 8, 0.55) 40%, rgba(0, 0, 0, 0.92));
  pointer-events: none;
}

.stage.is-hurt {
  animation: hurtFlash 0.32s steps(2, end);
}

body.is-bleeding .stage {
  box-shadow: inset 0 0 80px rgba(90, 0, 0, 0.35);
}

@keyframes hurtFlash {
  0%,
  100% { background-color: transparent; }
  50% { background-color: rgba(90, 0, 0, 0.28); }
}

#boss-canvas {
  position: relative;
  z-index: 1;
  width: min(520px, 78vw);
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.float-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.dmg-float {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  font-size: 16px;
  color: var(--buy);
  text-shadow: 3px 3px 0 #000;
  animation: floatUp 0.95s steps(8, end) forwards;
}

.dmg-float.is-sell {
  font-size: 12px;
  color: var(--sell);
  text-shadow: 2px 2px 0 #000;
}

.dmg-float.is-crit {
  font-size: 20px;
  color: var(--crit);
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -76px); }
}

.stage__hint {
  position: absolute;
  bottom: 14px;
  z-index: 2;
  font-size: 8px;
  color: #4a4a4a;
}

.chest {
  position: relative;
  width: 88px;
  height: 74px;
  margin: 8px auto 10px;
  filter: grayscale(1);
}

.chest__box {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 40px;
  background: #1a1a1a;
  border: 2px solid #3a3a3a;
  box-shadow: inset 0 -8px 0 #101010;
}

.chest__box::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%);
  background: #9a9a9a;
}

.chest__lid {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 12px;
  height: 22px;
  background: #242424;
  border: 2px solid #3a3a3a;
  transform-origin: bottom center;
}

.chest.is-full {
  filter: none;
}

.chest.is-full .chest__lid {
  transform: rotate(-14deg) translateY(-5px);
}

.chest.is-full .chest__glow {
  opacity: 1;
}

.chest__glow {
  position: absolute;
  inset: 10px 18px auto;
  height: 18px;
  background: radial-gradient(circle, rgba(230, 230, 230, 0.45), transparent 70%);
  opacity: 0;
}

.bottom {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 16px;
  margin-top: 16px;
}

.log-wrap,
.mvp-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  min-height: 180px;
}

.log-wrap h2,
.mvp-wrap h2 {
  font-family: var(--font-gothic);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--ash);
  margin-bottom: 12px;
}

.log,
.board {
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.log li,
.board li {
  font-size: 8px;
  line-height: 1.6;
  color: #b5b5b5;
}

.log .is-buy {
  color: var(--buy);
}

.log .is-sell {
  color: var(--sell);
}

.log .is-crit {
  color: var(--crit);
}

.log .is-phase {
  color: #f0f0f0;
}

.log .is-claim {
  color: #d0d0d0;
}

.board li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: center;
}

.board .rank {
  color: #888;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: none;
}

.overlay[hidden] {
  display: none;
}

.overlay--hit {
  background: rgba(70, 0, 0, 0.22);
}

.overlay--crit {
  background: rgba(40, 32, 0, 0.28);
}

.overlay--crit p,
.overlay--phase p,
.overlay--dead p {
  font-family: var(--font-gothic);
  letter-spacing: 0.28em;
}

.overlay--crit p {
  font-size: clamp(26px, 6vw, 52px);
  color: var(--crit);
  text-shadow: 0 0 28px rgba(230, 200, 74, 0.55), 4px 4px 0 #000;
  animation: critPop 0.75s steps(6, end);
}

@keyframes critPop {
  0% { transform: scale(0.45); opacity: 0; }
  30% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.overlay--phase p {
  font-size: clamp(18px, 4vw, 30px);
  color: var(--bone);
}

.overlay--dead {
  background: rgba(0, 0, 0, 0.72);
}

.overlay--dead p {
  font-size: clamp(18px, 4vw, 30px);
  color: var(--bone);
}

.overlay--dead small {
  display: block;
  margin-top: 14px;
  color: var(--blood);
  font-family: var(--font-gothic);
  letter-spacing: 0.24em;
  font-size: 12px;
}

@media (max-width: 980px) {
  .topbar,
  .arena,
  .bottom {
    grid-template-columns: 1fr;
  }

  .topbar__right {
    justify-self: start;
    text-align: left;
  }

  .arena,
  .stage {
    min-height: 0;
  }
}
