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

:root {
  --wall: #17171c;
  --ink: #111114;
  --paper: #f5f1e6;      /* sticker card */
  --pink: #ff2e88;
  --acid: #b7ff00;
  --cyan: #23e6ff;
  --yell: #ffe600;
  --muted: #8f8da6;
  --rare: #a8b0b9;   /* set per-card from rarity_color */
  --elem: #4fc3f7;   /* set per-card from element_color */
}

html, body { height: 100%; }
body {
  background-color: var(--wall);
  /* concrete noise */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  color: #fff;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.graf { font-family: "Bangers", "Impact", sans-serif; font-weight: 400; letter-spacing: 1.5px; }
.marker { font-family: "Permanent Marker", "Comic Sans MS", cursive; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px; /* room for nav */
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
}
.logo {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 30px;
  letter-spacing: 2px;
  transform: rotate(-2.5deg);
  text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 5px 5px 0 rgba(255,46,136,0.55);
}
.logo span { color: var(--acid); }
.counter {
  font-family: "Permanent Marker", cursive;
  font-size: 13px;
  color: var(--ink);
  background: var(--yell);
  border: 2px solid #000;
  border-radius: 4px;
  padding: 3px 10px;
  transform: rotate(2deg);
  box-shadow: 3px 3px 0 #000;
}

.screen { display: none; flex: 1; padding: 12px 16px; flex-direction: column; gap: 16px; }
.screen.active { display: flex; }
.screen h1 {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 32px;
  letter-spacing: 2px;
  transform: rotate(-1.5deg);
  text-shadow: 3px 3px 0 #000;
}
.screen h1::after {
  content: "";
  display: block;
  width: 62%;
  height: 8px;
  margin-top: 2px;
  background: var(--pink);
  transform: skewX(-24deg) rotate(-0.5deg);
  box-shadow: 2px 2px 0 #000;
}

/* ---------- scan screen ---------- */
.scan-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 24px 8px;
  position: relative;
}
.scan-hero h1 { text-align: center; }
.scan-hero h1::after { margin: 4px auto 0; }
.splat { position: absolute; pointer-events: none; opacity: 0.8; z-index: -1; }
.splat.s1 { top: 4%; left: -30px; width: 150px; transform: rotate(-15deg); }
.splat.s2 { bottom: 8%; right: -36px; width: 180px; transform: rotate(24deg); }

.scan-ring {
  width: 148px; height: 148px;
  border-radius: 46% 54% 52% 48% / 55% 45% 55% 45%;
  border: 5px solid var(--pink);
  background: rgba(255, 46, 136, 0.08);
  box-shadow: 4px 4px 0 #000, inset 0 0 26px rgba(255, 46, 136, 0.35);
  display: flex; align-items: center; justify-content: center;
  animation: wobble 5s ease-in-out infinite;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50% { transform: rotate(3deg) scale(1.04); }
}
.scan-emoji { font-size: 60px; filter: drop-shadow(3px 3px 0 #000); }
.hint {
  font-family: "Permanent Marker", cursive;
  color: #cfcbe0;
  font-size: 15px;
  line-height: 1.6;
  max-width: 300px;
}

.btn {
  display: inline-block;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 19px;
  letter-spacing: 2.5px;
  background: #fff;
  color: var(--ink);
  border: 3px solid #000;
  border-radius: 8px;
  padding: 12px 22px;
  cursor: pointer;
  text-align: center;
  user-select: none;
  transform: rotate(-1.2deg);
  box-shadow: 5px 5px 0 #000;
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:active { transform: rotate(-1.2deg) translate(4px, 4px); box-shadow: 1px 1px 0 #000; }
.btn-big {
  background: var(--acid);
  font-size: 23px;
  padding: 15px 30px;
  transform: rotate(-2deg);
  box-shadow: 6px 6px 0 #000, 0 0 34px rgba(183, 255, 0, 0.3);
}
.btn-big:active { transform: rotate(-2deg) translate(5px, 5px); box-shadow: 1px 1px 0 #000; }
.btn-ghost { background: var(--yell); transform: rotate(1deg); }
.btn-ghost:active { transform: rotate(1deg) translate(4px, 4px); }
.row { display: flex; gap: 14px; justify-content: center; padding: 0 4px; }
.row .btn { flex: 1; }

/* ---------- scanning overlay ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 10, 14, 0.93);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 30px; z-index: 50;
}
.overlay[hidden] { display: none; }
.pulse {
  width: 120px; height: 120px;
  border-radius: 44% 56% 60% 40% / 50% 44% 56% 50%;
  background: radial-gradient(circle at 40% 40%, var(--acid), var(--pink) 75%, transparent 78%);
  animation: pulse 0.9s ease-in-out infinite;
  filter: drop-shadow(0 0 24px rgba(255, 46, 136, 0.6));
}
@keyframes pulse {
  0%, 100% { transform: scale(0.72) rotate(-6deg); opacity: 0.6; }
  50% { transform: scale(1.12) rotate(6deg); opacity: 1; }
}
#scan-line {
  font-family: "Permanent Marker", cursive;
  color: var(--acid);
  font-size: 19px;
  transform: rotate(-1.5deg);
  text-shadow: 2px 2px 0 #000;
}

/* ---------- creature card (white slap sticker on the wall) ---------- */
.card {
  background: var(--paper);
  color: var(--ink);
  border: 3px solid #000;
  border-radius: 14px;
  padding: 16px 16px 20px;
  transform: rotate(-1deg);
  box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.55), 0 0 38px color-mix(in srgb, var(--rare) 55%, transparent);
  animation: card-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
  position: relative;
  overflow: hidden;
}
@keyframes card-in {
  from { transform: scale(0.5) rotate(-14deg); opacity: 0; }
  to   { transform: scale(1) rotate(-1deg); opacity: 1; }
}
/* tape strip on top */
.card::before {
  content: "";
  position: absolute;
  top: -8px; left: 50%;
  width: 110px; height: 26px;
  background: rgba(255, 230, 0, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.25);
  transform: translateX(-50%) rotate(-3deg);
  z-index: 3;
}

.rarity-banner {
  text-align: center;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 20px;
  letter-spacing: 7px;
  color: var(--rare);
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 10px;
}

/* photo scene: the beast's home turf */
.scene {
  position: relative;
  border: 3px solid #000;
  border-radius: 10px;
  overflow: hidden;
  padding: 18px 10px 6px;
  background: #24242c;
}
.scene-bg {
  position: absolute; inset: -12px;
  background: center / cover no-repeat;
  filter: blur(2.5px) brightness(0.72) saturate(1.3);
}
.scene-bg.no-bg {
  background: repeating-linear-gradient(45deg, #2b2b34 0 16px, #202027 16px 32px);
  filter: none;
}
.scene::after {
  content: "";
  position: absolute; inset: 0;
  box-shadow: inset 0 -34px 44px rgba(0, 0, 0, 0.6), inset 0 18px 26px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.stage {
  position: relative;
  width: fit-content;
  max-width: 86%;
  margin: 0 auto;
  z-index: 1;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.stage img { display: block; max-width: 100%; max-height: 38vh; }

.part { position: absolute; pointer-events: none; }
.part svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* limbs sit behind the body (negative z inside the stage's stacking context) */
.limb { z-index: -1; }
.arm-l { transform-origin: 90% 50%; animation: arm-wiggle 3.4s ease-in-out infinite; }
.arm-r { transform: scaleX(-1); transform-origin: 10% 50%; animation: arm-wiggle-r 3.4s ease-in-out infinite; }
@keyframes arm-wiggle {
  0%, 100% { rotate: 0deg; } 50% { rotate: -9deg; }
}
@keyframes arm-wiggle-r {
  0%, 100% { rotate: 0deg; } 50% { rotate: 9deg; }
}
.leg-b svg { transform: scaleX(-1); }

/* rarity shine, masked to the sprite alpha */
.tex {
  left: 0; top: 0; width: 100%; height: 100%;
  mask-size: 100% 100%; -webkit-mask-size: 100% 100%;
  mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat;
  mix-blend-mode: screen;
}
.tex-sheen {
  background: linear-gradient(115deg, transparent 32%, rgba(255,255,255,0.35) 50%, transparent 68%);
  background-size: 260% 100%;
  animation: sheen-slide 3.6s ease-in-out infinite;
}
.tex-sparkle {
  background:
    radial-gradient(circle at 24% 30%, rgba(255,255,255,0.9) 1.5%, transparent 4%),
    radial-gradient(circle at 70% 22%, rgba(255,255,255,0.8) 1.2%, transparent 3.5%),
    radial-gradient(circle at 48% 64%, rgba(255,255,255,0.85) 1.4%, transparent 4%),
    radial-gradient(circle at 82% 74%, rgba(255,255,255,0.75) 1.2%, transparent 3.5%);
  animation: sparkle-twinkle 1.8s ease-in-out infinite alternate;
}
.tex-gold {
  background: linear-gradient(115deg,
    rgba(255,215,0,0.4) 15%, rgba(255,255,255,0.25) 40%,
    rgba(255,179,0,0.45) 60%, rgba(255,255,255,0.2) 85%);
  background-size: 300% 100%;
  animation: sheen-slide 2.6s linear infinite;
}
@keyframes sheen-slide {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
@keyframes sparkle-twinkle {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

.eyes { animation: blink 4.2s infinite; transform-origin: center; }
@keyframes blink {
  0%, 94%, 100% { transform: scaleY(1); }
  96%, 98% { transform: scaleY(0.08); }
}

.card h2 {
  text-align: center;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 34px;
  letter-spacing: 2px;
  margin-top: 12px;
  line-height: 1;
  text-shadow: 3px 3px 0 color-mix(in srgb, var(--elem) 70%, white);
}
.card h2 .title {
  display: block;
  font-family: "Permanent Marker", cursive;
  font-size: 15px;
  letter-spacing: 0;
  color: #55524a;
  margin-top: 5px;
  text-shadow: none;
  transform: rotate(-1deg);
}
.card h2 .record {
  color: #fff;
  background: var(--ink);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: 6px;
}

.chips { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.chip {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 15px;
  letter-spacing: 1.5px;
  border: 2.5px solid #000;
  border-radius: 6px;
  padding: 4px 13px;
  box-shadow: 3px 3px 0 #000;
  background: #fff;
}
.chip.elem { background: color-mix(in srgb, var(--elem) 45%, white); transform: rotate(-2deg); }
.chip.rare { background: color-mix(in srgb, var(--rare) 45%, white); transform: rotate(1.5deg); }

.species {
  text-align: center;
  font-family: "Permanent Marker", cursive;
  font-size: 12.5px;
  color: #6b675c;
  margin: 2px 0 4px;
  transform: rotate(-0.8deg);
}

.btn-res { display: block; margin: 12px auto 0; }
.report { text-align: center; margin-top: 10px; }
.report span {
  font-family: "Permanent Marker", cursive;
  font-size: 11px;
  color: #9a958a;
  cursor: pointer;
  text-decoration: underline dotted;
}

.stats { display: grid; gap: 8px; margin: 14px 6px 4px; }
.stat {
  display: grid;
  grid-template-columns: 48px 1fr 40px;
  align-items: center;
  gap: 10px;
}
.stat b {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--ink);
}
.bar {
  height: 13px;
  background: #dcd6c6;
  border: 2px solid #000;
  border-radius: 8px;
  overflow: hidden;
}
.bar i {
  display: block; height: 100%;
  background: var(--elem);
  background-image: linear-gradient(90deg, transparent 0, rgba(255,255,255,0.35) 50%, transparent 100%);
  border-right: 2px solid #000;
  animation: grow 0.8s ease-out;
}
@keyframes grow { from { width: 0; } }
.stat span { text-align: right; font-family: "Bangers", Impact, sans-serif; font-size: 17px; }

.traits { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0 12px; }
.trait {
  font-family: "Permanent Marker", cursive;
  font-size: 12.5px;
  color: #fff;
  background: var(--ink);
  border-radius: 4px;
  padding: 4px 12px;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}
.trait:nth-child(odd) { transform: rotate(-2deg); }
.trait:nth-child(even) { transform: rotate(1.6deg); }

.flavor {
  text-align: center;
  font-family: "Permanent Marker", cursive;
  font-size: 14.5px;
  color: #3c3931;
  line-height: 1.55;
  transform: rotate(-0.6deg);
}

/* ---------- permadeath ---------- */
.card.dead .stage { filter: grayscale(1) brightness(0.65) drop-shadow(0 8px 10px rgba(0,0,0,0.6)); animation: none; }
.card.dead .eyes { animation: none; }
.rip {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(10, 10, 14, 0.35);
  pointer-events: none;
}
.rip-title {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 54px;
  letter-spacing: 5px;
  color: var(--pink);
  text-shadow: 4px 4px 0 #000;
  transform: rotate(-8deg);
}
.rip-line {
  font-family: "Permanent Marker", cursive;
  font-size: 13px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  text-align: center;
  padding: 0 18px;
  transform: rotate(-2deg);
}
.cell.dead img { filter: grayscale(1) brightness(0.6); }
.cell.dead { opacity: 0.85; }
.cell.dead .rr { color: #777; }

/* sparkles for epic/legendary */
.spark {
  position: absolute; font-size: 15px;
  animation: spark-fall linear forwards;
  pointer-events: none;
  z-index: 4;
}
@keyframes spark-fall {
  from { transform: translateY(-24px) rotate(0); opacity: 1; }
  to   { transform: translateY(460px) rotate(260deg); opacity: 0; }
}

#dupe-toast {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 17px;
  letter-spacing: 1.5px;
  background: var(--yell);
  border: 3px solid #000;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
  transform: rotate(-1deg);
  box-shadow: 4px 4px 0 #000;
}

/* ---------- collection ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 4px 2px; }
.cell {
  background: var(--paper);
  border: 3px solid #000;
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5), 0 0 16px color-mix(in srgb, var(--rare) 40%, transparent);
}
.cell:nth-child(3n+1) { transform: rotate(-2deg); }
.cell:nth-child(3n+2) { transform: rotate(1.4deg); }
.cell:nth-child(3n)   { transform: rotate(-0.8deg); }
.cell:active { transform: scale(0.93); }
.cell img { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(2px 3px 2px rgba(0,0,0,0.4)); }
.cell .nm {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--ink);
  margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell .rr {
  font-family: "Permanent Marker", cursive;
  font-size: 10px;
  color: color-mix(in srgb, var(--rare) 75%, black);
  letter-spacing: 1px;
  text-transform: uppercase;
}

#empty-msg { margin: 0 auto; text-align: center; }

/* ---------- battle ---------- */
#arena {
  position: relative;
  height: 46vh;
  border: 3px solid #000;
  border-radius: 12px;
  overflow: hidden;
  background: #1d1d24;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
}
#arena-bg {
  position: absolute; inset: -10px;
  background: center / cover no-repeat;
  filter: brightness(0.8) saturate(1.15);
}
#arena::after {
  content: "";
  position: absolute; inset: 0;
  box-shadow: inset 0 -50px 60px rgba(0, 0, 0, 0.65), inset 0 30px 40px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.fighter {
  position: absolute;
  bottom: 5%;
  width: 36%;
  z-index: 1;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.7));
  transition: filter 0.5s;
}
.fighter.left { left: 5%; }
.fighter.right { right: 5%; }
.fighter .stage { max-width: 100%; animation: none; }
.fighter .stage img { max-height: 24vh; }
.fighter.left .stage { transform: scaleX(-1); } /* face the enemy */

@keyframes lunge-l {
  0%, 100% { translate: 0 0; }
  35% { translate: 38% -7%; }
}
@keyframes lunge-r {
  0%, 100% { translate: 0 0; }
  35% { translate: -38% -7%; }
}
.fighter.left.attacking { animation: lunge-l 0.45s ease-in-out; }
.fighter.right.attacking { animation: lunge-r 0.45s ease-in-out; }

@keyframes shake {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  25% { translate: -6% 0; rotate: -6deg; }
  50% { translate: 5% 0; rotate: 5deg; }
  75% { translate: -3% 0; rotate: -2deg; }
}
.fighter.hit { animation: shake 0.4s ease-in-out; }

/* ----- battle FX ----- */
@keyframes arena-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 4px); }
  40% { transform: translate(6px, -5px); }
  60% { transform: translate(-5px, -3px); }
  80% { transform: translate(4px, 5px); }
}
#arena.shaking { animation: arena-shake 0.45s linear; }

.burst { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.burst i {
  position: absolute; left: 50%; top: 42%;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid #000;
  animation: fly 0.6s ease-out forwards;
}
@keyframes fly {
  to { transform: translate(var(--dx), var(--dy)) scale(0.15); opacity: 0; }
}

.dmg-float {
  position: absolute; left: 50%; top: 12%;
  transform: translateX(-50%);
  font-family: "Bangers", Impact, sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
  text-shadow: 2.5px 2.5px 0 #000;
  pointer-events: none;
  z-index: 5;
  animation: rise 0.95s ease-out forwards;
}
.dmg-float.crit { font-size: 46px; }
@keyframes rise {
  from { translate: 0 0; opacity: 1; }
  to { translate: 0 -70px; opacity: 0; }
}

.bubble {
  position: absolute;
  bottom: 103%; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  min-width: 90px; max-width: 200px;
  background: #fff;
  color: #111;
  border: 2.5px solid #000;
  border-radius: 12px;
  padding: 7px 11px;
  font-family: "Permanent Marker", cursive;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: center;
  z-index: 6;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4);
  animation: bubble-pop 0.22s cubic-bezier(0.2, 1.6, 0.5, 1);
}
.bubble::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  margin-left: -7px;
  border: 8px solid transparent;
  border-top-color: #000;
}
@keyframes bubble-pop {
  from { transform: translateX(-50%) scale(0.3) rotate(-10deg); opacity: 0; }
  to { transform: translateX(-50%) scale(1) rotate(-2deg); opacity: 1; }
}

#skill-banner {
  position: absolute;
  top: 34%; left: 50%;
  transform: translate(-50%, -50%) rotate(-3deg) scale(0);
  font-family: "Bangers", Impact, sans-serif;
  font-size: 30px;
  letter-spacing: 2px;
  color: var(--yell);
  text-shadow: 3px 3px 0 #000, 0 0 22px rgba(255, 230, 0, 0.5);
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
  transition: transform 0.15s cubic-bezier(0.2, 1.6, 0.5, 1);
}
#skill-banner.show { transform: translate(-50%, -50%) rotate(-3deg) scale(1); }
#skill-banner.show.big { font-size: 58px; color: var(--acid); transform: translate(-50%, -50%) rotate(-5deg) scale(1); }

.ko-flash {
  position: absolute; inset: 0;
  background: #fff;
  z-index: 6;
  pointer-events: none;
  animation: ko-fade 0.5s ease-out forwards;
}
@keyframes ko-fade { from { opacity: 0.9; } to { opacity: 0; } }

.ko-stamp {
  position: absolute;
  top: 40%; left: 50%;
  transform: translate(-50%, -50%) rotate(-14deg);
  font-family: "Bangers", Impact, sans-serif;
  font-size: 92px;
  color: var(--pink);
  text-shadow: 5px 5px 0 #000;
  z-index: 7;
  pointer-events: none;
  animation: card-in 0.3s cubic-bezier(0.2, 1.6, 0.5, 1);
}

.fighter.ko { filter: grayscale(1) brightness(0.7) drop-shadow(0 6px 8px rgba(0,0,0,0.7)); }
.fighter.ko .stage { transition: transform 0.7s cubic-bezier(0.4, 1.6, 0.6, 1); }
.fighter.ko.left .stage { transform: scaleX(-1) rotate(-96deg) translateY(14%); }
.fighter.ko.right .stage { transform: rotate(-96deg) translateY(14%); }

.hpbar { position: absolute; top: 10px; width: 42%; z-index: 2; }
.hpbar.left { left: 10px; }
.hpbar.right { right: 10px; text-align: right; }
.hpbar b {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 14px;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  display: block;
  margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hptrack {
  height: 12px;
  border: 2px solid #000;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.hptrack i {
  display: block; height: 100%; width: 100%;
  background: var(--acid);
  transition: width 0.5s ease-out, background-color 0.5s;
}
.hptrack i.low { background: var(--pink); }

#result-banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 44px;
  letter-spacing: 3px;
  text-align: center;
  color: var(--acid);
  text-shadow: 4px 4px 0 #000, 0 0 34px rgba(183, 255, 0, 0.6);
  background: rgba(10, 10, 14, 0.45);
  transform: rotate(-5deg);
  animation: card-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
  padding: 0 12px;
}
#result-banner[hidden] { display: none; }

#commentary {
  font-family: "Permanent Marker", cursive;
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--yell);
  text-shadow: 2px 2px 0 #000;
  min-height: 4.6em;
  text-align: center;
  padding: 2px 6px;
  transform: rotate(-0.5deg);
}

.picker-title, #picker .grid { width: 100%; max-width: 420px; padding: 0 20px; }
#picker .grid { max-height: 50vh; overflow-y: auto; }
#picker h1 {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 34px;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #000;
  transform: rotate(-1.5deg);
}

#share-img {
  width: min(86vw, 400px);
  border: 3px solid #000;
  border-radius: 10px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.6);
  transform: rotate(-1deg);
}

/* ---------- pseudo-AR living photo ---------- */
#ar-overlay {
  position: fixed; inset: 0;
  z-index: 80;
  background: #000;
  overflow: hidden;
  touch-action: none;
}
#ar-overlay[hidden] { display: none; }
#ar-bg {
  position: absolute; inset: -5%;
  background: center / cover no-repeat #17171c;
  filter: brightness(0.88) saturate(1.15);
  will-change: transform;
}
#ar-bg.no-bg {
  background-image: repeating-linear-gradient(45deg, #2b2b34 0 22px, #202027 22px 44px);
}
#ar-overlay.dead #ar-bg { filter: grayscale(0.7) brightness(0.6); }

#ar-particles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.pt { position: absolute; border-radius: 50%; will-change: transform, opacity; }
.pt-ember { background: #ff6d3f; box-shadow: 0 0 8px #ff6d3f; bottom: 8%; animation: pt-rise linear forwards; }
.pt-glow { background: #fff3b0; box-shadow: 0 0 10px #fff3b0; bottom: 10%; animation: pt-rise linear forwards; }
.pt-spark { background: #ffe600; box-shadow: 0 0 8px #ffe600; top: -3%; animation: pt-fall linear forwards; border-radius: 2px; }
.pt-drop { background: #4fc3f7; top: -3%; animation: pt-fall linear forwards; border-radius: 40% 60% 60% 60%; }
.pt-leaf { background: #5dbb63; top: -3%; animation: pt-fall ease-in-out forwards; border-radius: 70% 20% 70% 20%; }
.pt-dust { background: #b0917f; top: -3%; animation: pt-fall linear forwards; opacity: 0.7; }
.pt-wisp { background: #9575cd; filter: blur(3px); bottom: 8%; animation: pt-rise ease-in-out forwards; }
@keyframes pt-rise {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(var(--sway), -78vh); opacity: 0; }
}
@keyframes pt-fall {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(var(--sway), 80vh); opacity: 0; }
}

#ar-stage-wrap {
  position: absolute;
  left: 50%; bottom: 14%;
  width: 58%;
  transform: translateX(-50%);
  z-index: 3;
  cursor: pointer;
  will-change: transform;
}
#ar-stage-holder {
  transition: transform 3.8s ease-in-out;
  will-change: transform;
}
#ar-stage-holder .stage { max-width: 100%; margin: 0 auto; }
#ar-stage-holder .stage img { max-height: 40vh; }
#ar-overlay.dead #ar-stage-holder { filter: grayscale(1) brightness(0.7); }
#ar-overlay.dead #ar-stage-holder .eyes { animation: none; }

@keyframes boing {
  0% { scale: 1 1; }
  30% { scale: 1.12 0.82; }
  55% { scale: 0.9 1.14; translate: 0 -26px; }
  75% { scale: 1.05 0.95; }
  100% { scale: 1 1; }
}
#ar-stage-holder.boing .stage { animation: boing 0.55s ease-in-out; }

.ar-sticker {
  position: absolute;
  top: 18px; left: 14px;
  z-index: 4;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid #000;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 20px;
  letter-spacing: 1.5px;
  transform: rotate(-2.5deg);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
  max-width: 72%;
}
.ar-sticker.small {
  top: 74px;
  font-family: "Permanent Marker", cursive;
  font-size: 12.5px;
  letter-spacing: 0;
  transform: rotate(1.6deg);
}

#ar-hint {
  position: absolute;
  bottom: 26%;
  width: 100%;
  text-align: center;
  z-index: 4;
  font-family: "Permanent Marker", cursive;
  font-size: 15px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  opacity: 0.85;
  transition: opacity 1s;
  pointer-events: none;
}
#ar-hint.gone { opacity: 0; }

#ar-close {
  position: absolute;
  bottom: 22px; left: 50%;
  transform: translateX(-50%) rotate(-1deg);
  z-index: 5;
}

.live-badge {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #fff;
  background: var(--pink);
  border: 2px solid #000;
  border-radius: 6px;
  padding: 2px 8px;
  box-shadow: 2px 2px 0 #000;
  transform: rotate(2deg);
  animation: pulse-badge 2.2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- birth: parts grow onto a fresh card ---------- */
@keyframes part-pop {
  0% { scale: 0; opacity: 0; }
  70% { scale: 1.25; opacity: 1; }
  100% { scale: 1; opacity: 1; }
}
.card.born .limb.leg { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 0.15s backwards; }
.card.born .arm-l { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 0.35s backwards,
                    arm-wiggle 3.4s ease-in-out 0.8s infinite; }
.card.born .arm-r { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 0.35s backwards,
                    arm-wiggle-r 3.4s ease-in-out 0.8s infinite; }
.card.born .eyes { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 0.6s backwards,
                   blink 4.2s 1.2s infinite; }
.card.born .brows { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 0.75s backwards; }
.card.born .mouth { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 0.9s backwards; }
.card.born .acc { animation: part-pop 0.45s cubic-bezier(0.2,1.5,0.5,1) 1.1s backwards; }

/* ---------- attack styles + dodge/block ---------- */
@keyframes atk-jump-l {
  0%, 100% { translate: 0 0; }
  35% { translate: 30% -34%; }
  55% { translate: 40% -6%; }
}
@keyframes atk-jump-r {
  0%, 100% { translate: 0 0; }
  35% { translate: -30% -34%; }
  55% { translate: -40% -6%; }
}
.fighter.left.attacking.atk-element { animation: atk-jump-l 0.5s ease-in-out; }
.fighter.right.attacking.atk-element { animation: atk-jump-r 0.5s ease-in-out; }

@keyframes atk-spin-l {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: 38% -8%; rotate: 360deg; }
}
@keyframes atk-spin-r {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: -38% -8%; rotate: -360deg; }
}
.fighter.left.attacking.atk-quirk { animation: atk-spin-l 0.55s ease-in-out; }
.fighter.right.attacking.atk-quirk { animation: atk-spin-r 0.55s ease-in-out; }

@keyframes dodge-hop {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  40% { translate: 16% -12%; rotate: 10deg; }
}
.fighter.right.dodging { animation: dodge-hop 0.5s ease-out; }
.fighter.left.dodging { animation: dodge-hop-l 0.5s ease-out; }
@keyframes dodge-hop-l {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  40% { translate: -16% -12%; rotate: -10deg; }
}
@keyframes block-brace {
  0%, 100% { scale: 1 1; filter: none; }
  40% { scale: 1.06 0.9; filter: brightness(1.6); }
}
.fighter.blocking { animation: block-brace 0.45s ease-out; }

/* ---------- quest + leaderboard stickers ---------- */
.quest {
  background: var(--paper);
  color: var(--ink);
  border: 3px solid #000;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
  transform: rotate(-0.8deg);
  margin-bottom: 4px;
}
.q-title {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 19px;
  letter-spacing: 2.5px;
  margin-bottom: 8px;
}
.q-row {
  display: grid;
  grid-template-columns: 62px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
}
.q-row b { font-family: "Permanent Marker", cursive; font-size: 13px; font-weight: 400; }
.q-row span { text-align: right; font-family: "Bangers", Impact, sans-serif; font-size: 15px; }
.q-track {
  height: 11px;
  background: #dcd6c6;
  border: 2px solid #000;
  border-radius: 7px;
  overflow: hidden;
}
.q-track i { display: block; height: 100%; background: var(--acid); border-right: 2px solid #000; transition: width 0.4s; }
.q-claim { display: block; margin: 10px auto 2px; background: var(--acid); }
.q-done { font-family: "Permanent Marker", cursive; font-size: 12.5px; margin-top: 8px; color: #4a7a12; }
.lb-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 6px;
  align-items: baseline;
  margin: 4px 0;
}
.lb-row b { font-family: "Bangers", Impact, sans-serif; font-size: 16px; }
.lb-row span { font-family: "Permanent Marker", cursive; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row em { font-family: "Bangers", Impact, sans-serif; font-style: normal; font-size: 15px; color: #7a4a12; }

/* ---------- replay overlay ---------- */
#replay-video {
  width: min(88vw, 400px);
  max-height: 68vh;
  border: 3px solid #000;
  border-radius: 10px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.6);
  background: #000;
}
#replay-download { text-decoration: none; }

.gallery-link {
  font-family: "Permanent Marker", cursive;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline dotted;
  cursor: pointer;
}

/* ---------- nav ---------- */
nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex;
  background: #0d0d10;
  border-top: 3px solid #000;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.6);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  font-family: "Bangers", Impact, sans-serif;
  font-size: 18px;
  letter-spacing: 2.5px;
  padding: 15px 0;
  cursor: pointer;
}
nav button.active { color: var(--acid); text-shadow: 2px 2px 0 #000, 0 0 14px rgba(183, 255, 0, 0.5); }
