/* ===== Trivia Tower ===== */
:root {
  --bg-1: #0f1021;
  --bg-2: #1a1b34;
  --card: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #eef0ff;
  --text-dim: #9aa0c3;
  --accent-1: #7c5cff;
  --accent-2: #00d4ff;
  --good: #2ecc71;
  --bad: #ff5d6c;
  --lava-1: #ffd166;
  --lava-2: #ff7b2d;
  --lava-3: #e6392f;
  --radius: 16px;
  --step: 5.5556%; /* 100 / 18 stage grid slots */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, #2b2d5e 0%, transparent 60%),
              radial-gradient(1000px 700px at 0% 110%, #4d1a33 0%, transparent 55%),
              linear-gradient(160deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }

.screen { display: none; }
.screen.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ----- panels ----- */
.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(8px);
}

/* ----- home ----- */
.hero { text-align: center; margin-bottom: 22px; }
.logo { font-size: 44px; }
.hero h1 { font-size: 40px; letter-spacing: -1px; margin-top: 6px; }
.accent { background: linear-gradient(90deg, #ff7b2d, #ffd166); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--text-dim); margin-top: 6px; }
.how-to { color: var(--text-dim); font-size: 13px; margin-top: 10px; }

.home-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.diff-label { color: var(--text-dim); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.home-top .diff-label:first-of-type { margin-left: auto; }
select {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 8px 10px; font-size: 14px; outline: none; cursor: pointer;
}

.section-title { font-size: 15px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }

/* ----- mode cards ----- */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .mode-grid { grid-template-columns: 1fr; } }
.mode-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 18px 16px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border);
  color: var(--text); transition: all 0.15s ease;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--lava-2); background: linear-gradient(150deg, rgba(255, 123, 45, 0.16), rgba(124, 92, 255, 0.12)); }
.mode-emoji { font-size: 30px; }
.mode-name { font-size: 17px; font-weight: 800; }
.mode-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }

.home-bottom { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.home-stats { display: flex; gap: 20px; color: var(--text-dim); font-size: 14px; flex-wrap: wrap; margin-left: auto; }
.home-stats b { color: var(--text); }

/* ----- buttons ----- */
.btn {
  border: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.08);
  color: var(--text); padding: 10px 18px; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn.primary {
  background: linear-gradient(135deg, var(--lava-2), var(--lava-1));
  border: none; color: #1a0e05;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.big { font-size: 17px; padding: 14px 24px; }
.btn.icon { padding: 8px 12px; border-radius: 10px; font-size: 14px; }

/* ----- quiz chrome ----- */
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.quiz-meta { display: flex; align-items: center; gap: 10px; }
.cat-pill {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: rgba(255, 123, 45, 0.22); border: 1px solid rgba(255, 123, 45, 0.5);
  padding: 4px 10px; border-radius: 999px;
}
.counter { color: var(--text-dim); font-size: 14px; }
.quiz-live { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.streak { font-size: 14px; opacity: 0.6; transition: opacity 0.2s; }
.streak.hot { opacity: 1; text-shadow: 0 0 12px rgba(255, 150, 50, 0.8); }
.score { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

.progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-bottom: 8px; }
#progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--lava-2), var(--lava-1)); transition: width 0.3s ease; }

/* ============ THE STAGE ============ */
.stage {
  position: relative; height: 380px; overflow: hidden;
  border: 1px solid rgba(90, 77, 130, 0.6); border-radius: var(--radius); margin-bottom: 14px;
  background: linear-gradient(180deg, #241c42 0%, #191338 55%, #100b22 100%);
  box-shadow:
    inset 42px 0 60px -32px rgba(0, 0, 0, 0.85),
    inset -42px 0 60px -32px rgba(0, 0, 0, 0.85),
    inset 0 40px 60px -32px rgba(0, 0, 0, 0.7);
}
.stage.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 3px); }
  40% { transform: translate(6px, -3px); }
  60% { transform: translate(-5px, 2px); }
  80% { transform: translate(4px, -1px); }
}
.stage.caught-flash::after {
  content: ""; position: absolute; inset: 0; z-index: 7; pointer-events: none;
  background: rgba(230, 57, 47, 0.32); animation: fadeOut 1.3s forwards;
}
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- far wall (depth layer behind the shaft) --- */
.bg-far {
  position: absolute; inset: 0; z-index: 0;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 2px, transparent 2px 42px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 2px, transparent 2px 66px),
    linear-gradient(180deg, #1a1434 0%, #110c28 100%);
  opacity: 0.75;
}

/* --- side pillars --- */
.pillar {
  position: absolute; top: 0; bottom: 0; width: 36px; z-index: 0;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.32) 0 2px, transparent 2px 26px),
    linear-gradient(90deg, #413767 0%, #2a2248 50%, #191231 100%);
  box-shadow: inset 2px 0 0 rgba(255, 255, 255, 0.07), 8px 0 18px rgba(0, 0, 0, 0.55);
}
.p-l { left: 0; }
.p-r { right: 0; box-shadow: inset -2px 0 0 rgba(255, 255, 255, 0.07), -8px 0 18px rgba(0, 0, 0, 0.55); }

/* --- windows (night sky + moon + stars) --- */
.window {
  position: absolute; width: 46px; height: 62px; z-index: 0;
  border-radius: 23px 23px 5px 5px;
  border: 5px solid #463c6e;
  background:
    radial-gradient(circle at 26% 28%, rgba(255, 255, 255, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 62% 60%, rgba(255, 255, 255, 0.65) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 76%, rgba(255, 255, 255, 0.5) 0 1px, transparent 2px),
    linear-gradient(180deg, #24365f 0%, #141d38 70%);
  box-shadow: 0 0 24px rgba(90, 130, 220, 0.25), inset 0 0 10px rgba(0, 0, 0, 0.6);
}
.window::before {
  content: ""; position: absolute; top: 10px; right: 8px;
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fdf6d8, #d9cfa0 70%);
  box-shadow: 0 0 12px rgba(253, 246, 216, 0.7);
}
.window::after {
  content: ""; position: absolute; left: -7px; right: -7px; bottom: -8px; height: 7px;
  background: linear-gradient(180deg, #56498a, #38305e);
  border-radius: 2px;
}
.w-a { left: 9%; bottom: 66%; }
.w-b { right: 10%; bottom: 38%; }

/* --- moonlight beams --- */
.beam {
  position: absolute; width: 52px; height: 200px; z-index: 0;
  background: linear-gradient(180deg, rgba(150, 175, 255, 0.16), rgba(150, 175, 255, 0) 80%);
  transform: skewX(-14deg);
  filter: blur(5px);
  border-radius: 14px;
  pointer-events: none;
}
.beam-a { left: 12%; bottom: 38%; }
.beam-b { right: 14%; bottom: 12%; }

/* --- hanging chains --- */
.chain {
  position: absolute; top: -6px; width: 8px; height: 110px; z-index: 0;
  background: repeating-linear-gradient(180deg, #463e60 0 7px, #262042 7px 12px);
  border-radius: 4px;
  transform-origin: top center;
  animation: sway 5.5s ease-in-out infinite;
}
.c-a { left: 31%; }
.c-b { right: 27%; animation-delay: 1.4s; height: 150px; }
@keyframes sway {
  0%, 100% { transform: rotate(-2.4deg); }
  50% { transform: rotate(2.4deg); }
}

/* --- glowing crystals --- */
.crystal { position: absolute; width: 36px; height: 36px; z-index: 0; }
.crystal i {
  display: block; position: absolute; width: 15px; height: 24px;
  background: linear-gradient(160deg, #b8f1ff 0%, #57b8e8 45%, #2a6aa0 100%);
  clip-path: polygon(50% 0, 100% 35%, 78% 100%, 22% 100%, 0 35%);
  filter: drop-shadow(0 0 10px rgba(90, 200, 255, 0.6));
  animation: crystalPulse 3.2s ease-in-out infinite;
}
.crystal i:nth-child(2) { transform: rotate(26deg) scale(0.7); left: 15px; top: 11px; animation-delay: 1.3s; }
.k-a { left: 12%; bottom: 24%; }
.k-b { right: 12%; bottom: 55%; }
@keyframes crystalPulse { 50% { filter: brightness(1.6); } }

/* --- glowing runes --- */
.glyph {
  position: absolute; z-index: 0;
  font-size: 15px; letter-spacing: 6px; font-weight: 700;
  color: rgba(255, 170, 90, 0.34);
  text-shadow: 0 0 9px rgba(255, 150, 60, 0.45);
  animation: glyphGlow 4.5s ease-in-out infinite;
}
.g-a { left: 44%; bottom: 32%; }
.g-b { left: 21%; bottom: 73%; }
@keyframes glyphGlow { 50% { opacity: 0.45; } }

/* --- hanging vines --- */
.vines {
  position: absolute; width: 28px; height: 48px; z-index: 0;
  transform-origin: top center; animation: sway 6.5s ease-in-out infinite;
  background:
    linear-gradient(#3a6d3e, #3a6d3e) 22% 0 / 2px 100% no-repeat,
    linear-gradient(#4a8a44, #4a8a44) 50% 0 / 2px 85% no-repeat,
    linear-gradient(#35613a, #35613a) 78% 0 / 2px 70% no-repeat;
  opacity: 0.9;
}
.v-a { left: 24%; bottom: 46%; animation-delay: 0.8s; }
.v-b { right: 23%; bottom: 60%; }

/* --- torches --- */
.torch { position: absolute; width: 10px; height: 26px; z-index: 0; }
.torch::before {
  content: ""; position: absolute; bottom: 0; left: 2px; width: 6px; height: 20px;
  background: linear-gradient(180deg, #6d4526, #4a2f18); border-radius: 2px;
}
.torch .flame {
  position: absolute; top: -18px; left: -6px; width: 22px; height: 30px;
  background: radial-gradient(closest-side at 50% 72%, #fff7ae 0%, #ffc14d 40%, #ff7b2d 68%, rgba(255, 100, 30, 0) 100%);
  border-radius: 50% 50% 30% 30%;
  animation: flicker 0.16s infinite alternate;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 16px rgba(255, 150, 60, 0.7));
}
@keyframes flicker {
  from { transform: scale(1, 1) skewX(-3deg); }
  to { transform: scale(0.92, 1.1) skewX(4deg); }
}
.t-a { left: 15%; bottom: 52%; }
.t-b { right: 16%; bottom: 72%; }

/* --- dust motes --- */
.mote {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: rgba(220, 215, 255, 0.5); z-index: 0;
  animation: drift 16s linear infinite;
}
.m1 { left: 22%; bottom: 10%; }
.m2 { left: 48%; bottom: 4%; animation-delay: 3s; animation-duration: 20s; }
.m3 { left: 70%; bottom: 14%; animation-delay: 6s; animation-duration: 13s; }
.m4 { left: 35%; bottom: 2%; animation-delay: 9s; animation-duration: 22s; }
.m5 { left: 85%; bottom: 6%; animation-delay: 12s; animation-duration: 18s; }
@keyframes drift {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 0.7; }
  85% { opacity: 0.5; }
  100% { transform: translate(34px, -330px); opacity: 0; }
}

/* --- rocks (small jagged floating platforms) --- */
.ledge {
  position: absolute; height: 13px;
  background:
    radial-gradient(circle at 30% 45%, rgba(0, 0, 0, 0.28) 0 1.5px, transparent 3px),
    radial-gradient(circle at 66% 30%, rgba(0, 0, 0, 0.22) 0 1.2px, transparent 2.5px),
    radial-gradient(circle at 82% 70%, rgba(255, 255, 255, 0.14) 0 1.2px, transparent 2.5px),
    linear-gradient(180deg, #c3b6dd 0%, #8477ac 34%, #4a3f68 55%, #2c2450 100%);
  box-shadow: 0 4px 9px rgba(0, 0, 0, 0.6);
  animation: bob 3.8s ease-in-out infinite;
  animation-delay: var(--bobd, 0s);
}
@keyframes bob { 50% { transform: translateY(-2px); } }
.ledge.top {
  background:
    radial-gradient(circle at 30% 45%, rgba(0, 0, 0, 0.18) 0 1.5px, transparent 3px),
    linear-gradient(180deg, #ffe08a 0%, #ffb84d 34%, #b3541e 56%, #7a3a16 100%);
  box-shadow: 0 0 22px rgba(255, 209, 102, 0.5), 0 4px 9px rgba(0, 0, 0, 0.6);
}

/* rock tint variants (damage filter classes outrank these by specificity) */
.rk-b { filter: sepia(0.22) hue-rotate(-14deg) brightness(0.95); }
.rk-c { filter: hue-rotate(16deg) brightness(1.05); }

/* platform damage states */
.ledge.dmg1 { filter: brightness(0.82); }
.ledge.dmg2 { filter: brightness(0.62) saturate(0.7); }
.ledge.critical { animation: tremble 0.3s linear infinite; }
@keyframes tremble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-1.5px); }
  75% { transform: translateX(1.5px); }
}
.ledge.wobble { animation: slabWobble 0.5s ease; }
@keyframes slabWobble {
  25% { transform: rotate(3deg) translateY(1.5px); }
  50% { transform: rotate(-2.5deg) translateY(0.5px); }
  75% { transform: rotate(1.5deg); }
}
.ledge.crumble-out { animation: crumble 0.8s ease-in forwards; }
@keyframes crumble {
  20% { transform: translateY(6px) rotate(2deg); }
  100% { transform: translateY(170px) rotate(16deg); opacity: 0; }
}
.crack { position: absolute; left: 0; right: 0; display: none; pointer-events: none; }
.crack svg { display: block; width: 100%; height: 100%; }
.crack.c1 { top: -1px; height: 8px; }
.crack.c2 { bottom: -1px; height: 9px; transform: scaleX(-1); }
.ledge.dmg1 .c1 { display: block; }
.ledge.dmg2 .c1, .ledge.dmg2 .c2 { display: block; }

.rubble {
  position: absolute; width: 9px; height: 7px; border-radius: 2px; z-index: 3;
  background: linear-gradient(180deg, #8477ac, #332a52);
  animation: rubbleFall 0.9s ease-in forwards;
  pointer-events: none;
}
@keyframes rubbleFall {
  to { transform: translateY(170px) rotate(var(--rot, 180deg)); opacity: 0; }
}
.puff {
  position: absolute; width: 16px; height: 16px; border-radius: 50%; z-index: 3;
  background: radial-gradient(circle, rgba(205, 195, 230, 0.7), transparent 70%);
  animation: puffUp 0.7s ease-out forwards;
  pointer-events: none;
}
@keyframes puffUp {
  to { transform: translateY(-18px) scale(2.6); opacity: 0; }
}

/* --- exit door --- */
.exit-door {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(15 * var(--step)); height: calc(3 * var(--step)); width: 58px;
  border: 3px solid #5a4d82; border-bottom: none;
  border-radius: 36px 36px 0 0;
  background:
    repeating-linear-gradient(90deg, #7a4a2a 0 14px, #6d4526 14px 16px),
    linear-gradient(180deg, rgba(255, 209, 102, 0.25), rgba(255, 160, 60, 0.08));
  box-shadow: 0 0 26px rgba(255, 200, 100, 0.45), inset 0 0 18px rgba(255, 210, 120, 0.35);
  display: flex; align-items: center; justify-content: center;
}
.exit-door span {
  font-size: 10px; font-weight: 800; letter-spacing: 3px; color: var(--lava-1);
  text-shadow: 0 0 8px rgba(255, 200, 100, 0.8);
}

/* --- character --- */
.char-wrap {
  position: absolute;
  bottom: calc(5 * var(--step)); z-index: 3;
  transition: bottom 0.5s cubic-bezier(0.34, 1.35, 0.64, 1), left 0.5s cubic-bezier(0.34, 1.35, 0.64, 1);
  will-change: bottom, left, transform;
}
.char-wrap.jump { animation: hop 0.55s ease; }
@keyframes hop {
  35% { transform: translateY(-24px) scaleY(1.05); }
  70% { transform: translateY(0) scaleY(0.95); }
}
.char-wrap.panic { animation: wobble 0.6s ease; }
@keyframes wobble {
  20% { transform: translateX(-6px) rotate(-6deg); }
  40% { transform: translateX(6px) rotate(5deg); }
  60% { transform: translateX(-4px) rotate(-4deg); }
  80% { transform: translateX(3px) rotate(2deg); }
}
.char-wrap.dance { animation: dance 0.6s ease infinite; }
@keyframes dance {
  25% { transform: rotate(-8deg) translateY(-9px); }
  75% { transform: rotate(8deg) translateY(-9px); }
}
.char-wrap.caught { animation: sizzle 1.1s ease forwards; }
@keyframes sizzle {
  20% { transform: translate(-5px, 0) rotate(-9deg); opacity: 0.75; }
  40% { transform: translate(5px, -5px) rotate(9deg); opacity: 0.9; }
  60% { transform: translate(-4px, 0) rotate(-7deg); opacity: 0.6; }
  100% { transform: translateY(10px) rotate(90deg); opacity: 0.2; }
}
.char-wrap.fall { animation: fallTilt 0.85s ease-in forwards; }
@keyframes fallTilt {
  to { transform: rotate(9deg); }
}

/* idle breathing */
.c-inner { transform-origin: 32px 80px; animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scaleY(1.025); } }

/* eyes */
.eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.2s infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.12); } }
.pupil { transform-box: fill-box; transform-origin: center; transition: transform 0.3s ease; }
.worried .pupil { transform: translateY(2.2px); }
.sweat { opacity: 0; transform-box: fill-box; transform-origin: center; }
.worried .sweat { animation: drip 0.9s ease-in infinite; }
@keyframes drip {
  0% { opacity: 0; transform: translateY(0); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(9px); }
}

/* eye variants */
.eyeset { display: none; }
.ev-normal .eyeset-normal { display: block; }
.ev-big .eyeset-big { display: block; }
.ev-cyclo .eyeset-cyclo { display: block; }
.ev-angry .eyeset-normal { display: block; }
.brows { display: none; fill: #2b2118; }
.ev-angry .brows { display: block; }

/* mouths */
.mouth-smile, .mouth-flat, .mouth-o { display: none; }
.mt-smile .mouth-smile { display: block; }
.mt-flat .mouth-flat { display: block; }
.mt-open .mouth-o { display: block; }
.char-wrap.panic .mouth-smile, .char-wrap.panic .mouth-flat,
.char-wrap.caught .mouth-smile, .char-wrap.caught .mouth-flat,
.char-wrap.fall .mouth-smile, .char-wrap.fall .mouth-flat { display: none; }
.char-wrap.panic .mouth-o, .char-wrap.caught .mouth-o, .char-wrap.fall .mouth-o { display: block; }

/* hair variants */
.p-hair { display: none; }
.hs-buzz .h-buzz { display: block; }
.hs-short .h-short { display: block; }
.hs-spiky .h-spiky { display: block; }
.hs-mohawk .h-mohawk { display: block; }
.hs-long .h-long { display: block; }

/* cape & backpack */
.p-cape, .pack { display: none; }
.has-cape .p-cape { display: block; }
.has-pack .pack { display: block; }

/* arms & legs */
.arm { transform-box: fill-box; transform-origin: 50% 12%; }
.leg { transform-box: fill-box; transform-origin: 50% 8%; }
.arm-l { animation: swayL 2.6s ease-in-out infinite; }
.arm-r { animation: swayR 2.6s ease-in-out infinite; }
@keyframes swayL { 50% { transform: rotate(5deg); } }
@keyframes swayR { 50% { transform: rotate(-5deg); } }

.jump .arm-l { animation: raiseL 0.55s ease; }
.jump .arm-r { animation: raiseR 0.55s ease; }
.jump .leg-l { animation: tuckL 0.55s ease; }
.jump .leg-r { animation: tuckR 0.55s ease; }
@keyframes raiseL { 45% { transform: rotate(-135deg); } }
@keyframes raiseR { 45% { transform: rotate(135deg); } }
@keyframes tuckL { 45% { transform: rotate(-38deg); } }
@keyframes tuckR { 45% { transform: rotate(38deg); } }

.panic .arm-l, .fall .arm-l { animation: flailL 0.3s infinite alternate; }
.panic .arm-r, .fall .arm-r { animation: flailR 0.3s infinite alternate; }
@keyframes flailL { from { transform: rotate(-45deg); } to { transform: rotate(40deg); } }
@keyframes flailR { from { transform: rotate(45deg); } to { transform: rotate(-40deg); } }

.dance .arm-l { animation: waveL 0.5s infinite alternate; }
.dance .arm-r { animation: waveR 0.5s infinite alternate; }
@keyframes waveL { from { transform: rotate(-150deg); } to { transform: rotate(-100deg); } }
@keyframes waveR { from { transform: rotate(150deg); } to { transform: rotate(100deg); } }

/* --- lava --- */
.lava {
  position: absolute; left: 0; right: 0; bottom: 0; height: 8%; z-index: 2;
  background: linear-gradient(180deg, var(--lava-2) 0%, var(--lava-3) 35%, #8f120c 80%, #5e0a06 100%);
  transition: height 0.45s ease;
}
.lava-glow {
  position: absolute; bottom: 100%; left: 0; right: 0; height: 52px;
  background: radial-gradient(62% 100% at 50% 100%, rgba(255, 120, 40, 0.42), rgba(255, 120, 40, 0) 72%);
  animation: glowPulse 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glowPulse { 50% { opacity: 0.65; } }
.lava.urgent .lava-glow { animation-duration: 0.6s; }

.wave {
  position: absolute; top: -9px; left: 0; width: 200%; height: 11px;
}
.w1 { animation: waveMove 6.5s linear infinite; }
.w2 { animation: waveMove 10s linear infinite reverse; top: -6px; }
@keyframes waveMove { to { transform: translateX(-50%); } }

.lava-surface {
  position: absolute; top: -3px; left: 0; right: 0; height: 6px;
  background: linear-gradient(180deg, var(--lava-1), var(--lava-2));
  box-shadow: 0 0 18px rgba(255, 170, 70, 0.9);
}

.bubble {
  position: absolute; bottom: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #ff9a3d 70%);
  opacity: 0; animation: bubbleRise 2.4s ease-in infinite;
}
.b1 { left: 12%; } .b2 { left: 32%; animation-delay: 0.6s; animation-duration: 2s; }
.b3 { left: 52%; animation-delay: 1.2s; } .b4 { left: 71%; animation-delay: 0.3s; }
.b5 { left: 88%; animation-delay: 1.6s; animation-duration: 2.8s; }
@keyframes bubbleRise {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { opacity: 0.95; }
  75% { transform: translateY(-22px) scale(1.15); opacity: 0.9; }
  100% { transform: translateY(-26px) scale(1.3); opacity: 0; }
}

.splash {
  position: absolute; width: 7px; height: 10px; z-index: 3;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 40% 30%, #ffd166, #ff7b2d 75%);
  animation: splashUp 0.85s ease-out forwards;
  pointer-events: none;
}
@keyframes splashUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  55% { transform: translateY(-46px) rotate(140deg); opacity: 1; }
  100% { transform: translateY(8px) rotate(220deg); opacity: 0; }
}

.lava-label {
  position: absolute; top: 10px; right: 12px; z-index: 4;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  background: rgba(0, 0, 0, 0.4); padding: 4px 10px; border-radius: 999px;
}
.lava-label.danger { color: #fff; background: rgba(230, 57, 47, 0.85); animation: blinkFast 0.8s infinite; }
@keyframes blinkFast { 50% { opacity: 0.6; } }

.plat-label {
  position: absolute; top: 10px; left: 12px; z-index: 4;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  background: rgba(0, 0, 0, 0.4); padding: 4px 10px; border-radius: 999px;
}
.plat-label.warn { color: #fff; background: rgba(214, 158, 46, 0.85); }
.plat-label.crit { color: #fff; background: rgba(230, 57, 47, 0.85); animation: blinkFast 0.5s infinite; }

/* confetti */
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 8; }
.confetti-layer i {
  position: absolute; top: -14px; width: 8px; height: 13px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--dx, 0), 460px) rotate(540deg); opacity: 0.85; }
}

/* ----- question panel ----- */
.question { font-size: 22px; line-height: 1.35; margin-bottom: 18px; min-height: 60px; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .answers { grid-template-columns: 1fr; } }

.answer {
  text-align: left; padding: 14px 16px; border-radius: 12px; font-size: 16px; font-weight: 600;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--card-border);
  color: var(--text); cursor: pointer; transition: all 0.15s ease;
}
.answer:hover:not(:disabled) { background: rgba(255, 123, 45, 0.18); border-color: var(--lava-2); transform: translateY(-1px); }
.answer:disabled { cursor: default; opacity: 0.85; }
.answer.correct { background: rgba(46, 204, 113, 0.25); border-color: var(--good); box-shadow: 0 0 14px rgba(46, 204, 113, 0.35); opacity: 1; }
.answer.wrong { background: rgba(255, 93, 108, 0.2); border-color: var(--bad); opacity: 1; }

.feedback { min-height: 24px; margin-top: 14px; font-size: 15px; font-weight: 700; text-align: center; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* ----- customize screen ----- */
.custom-panel { max-width: 560px; margin: 0 auto; }
.custom-title { text-align: center; margin-bottom: 16px; }
.custom-layout { display: flex; gap: 18px; align-items: stretch; flex-wrap: wrap; }
.preview-stage {
  position: relative; flex: 0 0 170px; height: 240px; overflow: hidden;
  border-radius: 12px; border: 1px solid var(--card-border);
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 2px, transparent 2px 24px),
    linear-gradient(180deg, #2c2450 0%, #1d1738 60%, #120c26 100%);
}
.preview-char { left: 50%; margin-left: -18px; bottom: 20%; }
.custom-controls { flex: 1 1 220px; }
.custom-controls h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin: 12px 0 6px;
}
.custom-controls h3:first-child { margin-top: 0; }
.swatch-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15); cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: var(--lava-1); box-shadow: 0 0 8px rgba(255, 209, 102, 0.6); }
.color-input {
  width: 30px; height: 30px; padding: 2px; border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.style-row { display: flex; gap: 7px; flex-wrap: wrap; }
.style-opt {
  padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--card-border);
  color: var(--text); cursor: pointer;
}
.style-opt:hover { background: rgba(255, 255, 255, 0.13); }
.style-opt.selected { border-color: var(--lava-2); background: rgba(255, 123, 45, 0.22); }
.toggle-row { display: flex; gap: 7px; margin-top: 14px; }
.toggle-row .style-opt { flex: 1; }
.toggle-row .style-opt.selected { border-color: var(--accent-2); background: rgba(0, 212, 255, 0.15); }
.slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.slider-row .s-end { font-size: 11px; color: var(--text-dim); min-width: 40px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--lava-2); }
.custom-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* ----- results ----- */
.result-panel { text-align: center; padding: 30px 22px; }
.r-title { font-size: 26px; margin-bottom: 6px; }
.r-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }
.record {
  display: inline-block; margin-bottom: 14px; padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 200, 60, 0.25), rgba(255, 150, 50, 0.2));
  border: 1px solid rgba(255, 200, 60, 0.5); font-weight: 700; font-size: 14px;
}
.score-big {
  font-size: 56px; font-weight: 800;
  background: linear-gradient(90deg, var(--lava-2), var(--lava-1));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-grid { margin: 22px auto; max-width: 320px; display: grid; gap: 8px; }
.result-row {
  display: flex; justify-content: space-between; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04); border-radius: 10px; color: var(--text-dim);
}
.result-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ----- misc ----- */
.hidden { display: none !important; }
.ad-slot {
  margin-top: 16px; padding: 34px 12px; text-align: center;
  border: 2px dashed rgba(255, 255, 255, 0.15); border-radius: var(--radius);
  color: var(--text-dim); font-size: 13px; letter-spacing: 1px; text-transform: uppercase;
}

/* ============ BATTLE STAGE (Monster Slayer) ============ */
.battle-flash {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: radial-gradient(100% 100% at 50% 100%, rgba(255, 40, 40, 0.32), transparent 72%);
  opacity: 0; transition: opacity 0.15s;
}
.battle-flash.on { opacity: 1; }
.gold-badge {
  position: absolute; top: 10px; left: 12px; z-index: 4;
  font-size: 13px; font-weight: 800; color: #ffd166;
  background: rgba(0, 0, 0, 0.4); padding: 4px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.wave-banner {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); z-index: 1;
  font-size: 44px; font-weight: 800; letter-spacing: 6px; color: rgba(255, 209, 102, 0.14);
  text-shadow: 0 0 30px rgba(255, 160, 60, 0.15); pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.battle-arena {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 20px 30px 20px;
}
.fighter { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hero-side { align-items: center; width: 190px; }
.vs {
  align-self: center; font-size: 24px; opacity: 0.55; margin-bottom: 120px;
  text-shadow: 0 0 18px rgba(255, 160, 60, 0.6);
}
.fighter-name { font-size: 11px; font-weight: 800; letter-spacing: 2px; color: var(--text-dim); text-transform: uppercase; }
.fighter-svg { display: flex; align-items: flex-end; min-height: 72px; }
.fighter-svg svg { filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.5)); }

/* ============ TNT STAGE (TNT Chair — bomber POV) ============ */
.tnt-arena {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 24px 30px 24px;
}
.tnt-hero-side {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative;
}
.tnt-svg svg { filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.55)); }
.tnt-attempts {
  position: absolute; top: 10px; left: 12px; z-index: 4;
  font-size: 13px; font-weight: 800; color: #ff9e80;
  background: rgba(0, 0, 0, 0.4); padding: 4px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* the Bomber's hand: a big arm reaching in from the right edge (POV) */
.tnt-hand {
  position: absolute; right: -4%; top: 19%; width: 30%; z-index: 6;
  pointer-events: none;
}
.tnt-hand svg { width: 100%; height: auto; filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.55)); }
/* reach in toward the wick, flick the lighter wheel at full extension */
.tnt-hand.reach { animation: handReach 1.05s cubic-bezier(0.3, 0.7, 0.3, 1) forwards; }
@keyframes handReach {
  0% { transform: translateX(0) rotate(0deg); }
  42% { transform: translateX(-81%) rotate(-2deg); }
  52% { transform: translateX(-89%) rotate(-8deg); }  /* the flick */
  60% { transform: translateX(-89%) rotate(2deg); }
  68%, 100% { transform: translateX(-89%) rotate(0deg); }
}
.tnt-hand.jitter { animation: handJitter 0.7s ease forwards; }
@keyframes handJitter {
  0%, 100% { transform: translateX(-89%) rotate(0deg); }
  25% { transform: translateX(-86%) rotate(4deg); }
  55% { transform: translateX(-92%) rotate(-4deg); }
  80% { transform: translateX(-88%) rotate(2deg); }
}
.tnt-hand.retract { animation: handRetract 0.7s ease forwards; }
@keyframes handRetract {
  from { transform: translateX(-89%) rotate(0deg); }
  to { transform: translateX(0) rotate(0deg); }
}
.tnt-hand.yank { animation: handYank 0.45s ease-in forwards; }
@keyframes handYank {
  from { transform: translateX(-89%) rotate(0deg); }
  to { transform: translateX(20%) rotate(9deg); }
}
/* lighter flame flicker while visible */
#hand-flame { transform-origin: 33.5px 31px; animation: flameFlicker 0.16s infinite alternate; }
@keyframes flameFlicker {
  from { transform: scale(1) skewX(-4deg); }
  to { transform: scale(1.25, 1.45) skewX(6deg); }
}
/* white wick glows faintly so it reads against the dark room */
#tnt-wick-tip { filter: drop-shadow(0 0 2.5px rgba(255, 255, 255, 0.95)); }

/* hero tied to the chair */
#tnt-chair-svg.tense { animation: heroTense 0.55s ease-in-out 3; transform-origin: 50% 100%; }
@keyframes heroTense {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-3px) rotate(-1.4deg); }
  70% { transform: translateX(3px) rotate(1.4deg); }
}
#tnt-chair-svg.relief { animation: heroRelief 0.9s ease; }
@keyframes heroRelief {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
  60% { transform: translateY(-2px); }
}

/* sparks from the wick tip */
.tnt-spark {
  position: absolute; z-index: 7; width: 3px; height: 3px; border-radius: 50%;
  background: #ffd166; box-shadow: 0 0 6px 2px rgba(255, 183, 3, 0.85);
  pointer-events: none;
  left: var(--sx); top: var(--sy);
  animation: tntSparkFly 0.6s ease-out forwards;
}
.tnt-spark.big { width: 5px; height: 5px; box-shadow: 0 0 10px 4px rgba(255, 123, 45, 0.9); }
@keyframes tntSparkFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

/* explosion */
#tnt-stage.boom { animation: tntShake 0.6s ease; }
@keyframes tntShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-9px, 5px); }
  30% { transform: translate(8px, -6px); }
  45% { transform: translate(-7px, -4px); }
  60% { transform: translate(6px, 4px); }
  80% { transform: translate(-3px, 2px); }
}
.tnt-smoke {
  position: absolute; z-index: 8; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 110, 100, 0.75), rgba(70, 64, 60, 0.35) 62%, transparent 75%);
  pointer-events: none;
  left: var(--sx); top: var(--syy);
  animation: tntSmokeRise 2.1s ease-out forwards;
}
@keyframes tntSmokeRise {
  0% { transform: translate(0, 0) scale(0.5); opacity: 0.9; }
  100% { transform: translate(var(--ddx), -110px) scale(2.4); opacity: 0; }
}
.tnt-scorch {
  position: absolute; left: 44%; bottom: 16%; z-index: 6;
  font-size: 64px; opacity: 0.9; pointer-events: none;
  text-shadow: 0 0 24px rgba(255, 60, 20, 0.55);
}

/* ============ STREAK STAGE ============ */
.streak-center {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
}
.streak-flame {
  position: relative; width: 64px; height: 92px; margin-bottom: 10px;
  transform-origin: 50% 100%; transition: transform 0.5s ease, filter 0.5s ease;
}
.streak-flame i { position: absolute; inset: 0; pointer-events: none; }
.streak-flame .f-body {
  background: linear-gradient(to top, #ff6a00, #ff9e40 45%, #ffd166 78%, #fff3b0);
  border-radius: 50% 50% 42% 42% / 66% 66% 34% 34%;
  filter: blur(1px) drop-shadow(0 0 14px rgba(255, 150, 50, 0.65));
  animation: flameWiggle 0.55s ease-in-out infinite alternate;
}
.streak-flame .f-core {
  left: 26%; right: 26%; top: 34%; bottom: 8%;
  background: linear-gradient(to top, #fff8d9, #ffe066);
  border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
  filter: blur(0.5px);
  animation: flameWiggle 0.4s ease-in-out infinite alternate-reverse;
}
@keyframes flameWiggle {
  from { transform: scaleY(0.94) skewX(-3deg); }
  to { transform: scaleY(1.08) skewX(3deg); }
}
/* tier growth: candle → campfire → blaze → inferno → legendary */
.streak-flame.t0 { transform: scale(0.52); filter: saturate(0.55) brightness(0.85); }
.streak-flame.t1 { transform: scale(0.72); }
.streak-flame.t2 { transform: scale(1); }
.streak-flame.t3 { transform: scale(1.28); }
.streak-flame.t3 .f-body { background: linear-gradient(to top, #e0301e, #ff6a00 50%, #ffd166); }
.streak-flame.t4 { transform: scale(1.55); }
.streak-flame.t4 .f-body { background: linear-gradient(to top, #7a5cff, #3fa7ff 55%, #d0f4ff); filter: blur(1px) drop-shadow(0 0 18px rgba(90, 160, 255, 0.7)); }
.streak-flame.t5 { transform: scale(1.9); }
.streak-flame.t5 .f-body { background: linear-gradient(to top, #ff9d00, #ffe066 55%, #fffbe6); filter: blur(1px) drop-shadow(0 0 26px rgba(255, 214, 90, 0.9)); }
.streak-count {
  font-size: 54px; font-weight: 900; line-height: 1;
  color: #ffd166; text-shadow: 0 0 22px rgba(255, 160, 60, 0.6);
  font-variant-numeric: tabular-nums;
}
.streak-label {
  font-size: 11px; font-weight: 800; letter-spacing: 3px; color: var(--text-dim);
  text-transform: uppercase;
}
.streak-timer {
  margin-top: 6px; font-size: 15px; font-weight: 800; color: #ff9e80;
  background: rgba(0, 0, 0, 0.4); padding: 5px 14px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ============ STUDY PANEL (home screen) ============ */
.study-panel {
  margin-top: 18px; padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  display: flex; flex-direction: column; gap: 10px;
}
.study-panel h3 { margin: 0; font-size: 15px; color: var(--text-main); }
.study-hint { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
.study-hint code {
  background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px;
  font-size: 11.5px; color: #9fd0ff;
}
.study-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.study-file-btn {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px; color: var(--text-main);
  transition: background 0.15s;
}
.study-file-btn:hover { background: rgba(255, 255, 255, 0.12); }
.study-panel textarea {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: rgba(0, 0, 0, 0.35); color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px;
  padding: 9px 11px; font-family: Consolas, Monaco, monospace; font-size: 12.5px;
  line-height: 1.45;
}
.study-panel textarea:focus { outline: none; border-color: rgba(255, 209, 102, 0.5); }
.study-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.study-toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--text-main);
}
.study-toggle input { width: 16px; height: 16px; accent-color: #ffd166; cursor: pointer; }
.study-toggle input:disabled { cursor: not-allowed; }
.study-status { font-size: 12.5px; color: var(--text-dim); min-height: 1.2em; }
.study-manual {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px dashed rgba(255, 255, 255, 0.14);
}
.study-manual-title { font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); }
.study-input {
  width: 100%; box-sizing: border-box;
  background: rgba(0, 0, 0, 0.35); color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 9px;
  padding: 8px 10px; font-size: 13px;
}
.study-input:focus { outline: none; border-color: rgba(255, 209, 102, 0.5); }
.study-wrong-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }

/* idle animations per species */
.idle-squish { animation: squish 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
.idle-hover  { animation: hover 2.2s ease-in-out infinite; }
.idle-rock   { animation: rock 3s ease-in-out infinite; transform-origin: 50% 100%; }
.idle-sway   { animation: swayx 3.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes squish { 50% { transform: scaleY(0.92) scaleX(1.06); } }
@keyframes hover  { 50% { transform: translateY(-7px); } }
@keyframes rock   { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes swayx  { 50% { transform: translateX(3px) rotate(1.5deg); } }

/* hp bars */
.hpbar {
  position: relative; width: 150px; height: 15px; border-radius: 8px; overflow: hidden;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--card-border);
}
.hpbar > div { height: 100%; width: 100%; transition: width 0.3s ease; }
#hero-hp { background: linear-gradient(90deg, #2ecc71, #7ddf9a); }
.monster-slot .hpbar > div { background: linear-gradient(90deg, var(--bad), #ff9a9a); }
.monster-slot.boss .hpbar > div { background: linear-gradient(90deg, #d63384, #ffb0d0); }
.hp-text { font-size: 10.5px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* monsters column (1–2 slots) */
.monsters-col { display: flex; flex-direction: row; align-items: flex-end; gap: 10px; }
.monster-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.monster-slot .monster-svg { display: flex; align-items: flex-end; min-height: 72px; }
.monster-slot.boss .monster-svg svg { transform: scale(1.3); transform-origin: 50% 100%; }
.monster-slot .elite-star {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 15px; animation: starSpin 3s linear infinite;
}
@keyframes starSpin { 50% { transform: translateX(-50%) rotate(24deg) scale(1.25); } }

/* hero power row */
.power-row { display: flex; gap: 6px; align-items: center; }
.power-slot {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1.5px dashed rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.05);
  font-size: 17px; cursor: pointer; transition: all 0.15s ease; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.power-slot.filled { border-style: solid; border-color: var(--lava-2); background: rgba(255, 123, 45, 0.18); box-shadow: 0 0 10px rgba(255, 123, 45, 0.4); }
.power-slot.filled:hover { transform: translateY(-2px); }
.power-slot.armed { border-color: var(--accent-2); background: rgba(0, 212, 255, 0.2); box-shadow: 0 0 12px rgba(0, 212, 255, 0.5); }
.charge-dots { display: flex; gap: 3px; margin-left: 2px; }
.charge-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.2);
}
.charge-dots i.on { background: var(--lava-1); box-shadow: 0 0 6px rgba(255, 209, 102, 0.8); border-color: var(--lava-1); }
.buff-row { display: flex; gap: 4px; min-height: 22px; }
.buff-badge {
  font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 212, 255, 0.2); border: 1px solid rgba(0, 212, 255, 0.55); color: var(--accent-2);
}

/* legendary weapon auras (Lv6+) — subtle pulsing glow, overrides paused during swing */
.fighter-svg.wep-glow #hero-swing-group { animation: weaponGlow 1.7s ease-in-out infinite alternate; }
@keyframes weaponGlow {
  from { filter: drop-shadow(0 0 2px var(--wep-glow, #ffd700)); }
  to { filter: drop-shadow(0 0 6px var(--wep-glow, #ffd700)); }
}

/* hero weapon swing */
.fighter-svg.atk #hero-swing-group { animation: weaponSwing 0.45s ease; transform-box: fill-box; transform-origin: 30% 80%; }
@keyframes weaponSwing {
  0% { transform: rotate(-12deg); }
  45% { transform: rotate(80deg) translateX(4px); }
  100% { transform: rotate(0deg); }
}
.fighter-svg.hero-svg.atk { animation: lungeR 0.45s ease; }
@keyframes lungeR { 40% { transform: translateX(80px); } }
.monster-slot .monster-svg.hurt { animation: hurtFlash 0.4s ease; }
@keyframes hurtFlash {
  25% { filter: brightness(2.2) saturate(0.2); transform: translateX(5px); }
  60% { filter: brightness(1.3); transform: translateX(-4px); }
}
.fighter-svg.hero-svg.hurt { animation: heroHurt 0.45s ease; }
@keyframes heroHurt {
  25% { filter: brightness(1.8) hue-rotate(-40deg); transform: translateX(-6px); }
  60% { transform: translateX(4px); }
}
.monster-slot .monster-svg.dead { animation: dieFall 0.8s ease forwards; }
@keyframes dieFall {
  to { transform: translateY(26px) rotate(24deg); opacity: 0; }
}

/* slash arc / impact spark / claw marks / fireball */
.slash {
  position: absolute; width: 90px; height: 90px; z-index: 5; pointer-events: none;
  animation: slashArc 0.35s ease-out forwards;
}
.slash svg { width: 100%; height: 100%; }
@keyframes slashArc {
  0% { transform: scale(0.4) rotate(-30deg); opacity: 0; }
  35% { transform: scale(1.1) rotate(12deg); opacity: 1; }
  100% { transform: scale(1.4) rotate(28deg); opacity: 0; }
}
.spark {
  position: absolute; width: 6px; height: 6px; z-index: 5; border-radius: 50%;
  background: #ffe9a8; pointer-events: none;
  animation: sparkFly 0.5s ease-out forwards;
}
@keyframes sparkFly {
  to { transform: translate(var(--sx, 20px), var(--sy, -20px)) scale(0.3); opacity: 0; }
}
.claw {
  position: absolute; z-index: 5; width: 60px; height: 40px; pointer-events: none;
  animation: clawFade 0.6s ease-out forwards;
}
@keyframes clawFade {
  0% { opacity: 0; transform: scale(0.7); }
  30% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.15); }
}
.fireball {
  position: absolute; z-index: 5; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #ff7b2d 55%, rgba(255, 90, 20, 0.2) 85%);
  box-shadow: 0 0 18px rgba(255, 140, 45, 0.9);
  animation: fireballFly 0.45s ease-in forwards;
  pointer-events: none;
}
@keyframes fireballFly {
  from { left: 26%; top: 55%; }
  to { left: 64%; top: 38%; }
}
.explosion-ring {
  position: absolute; z-index: 5; width: 20px; height: 20px; border-radius: 50%;
  border: 4px solid #ffd166; pointer-events: none;
  animation: boom 0.5s ease-out forwards;
}
@keyframes boom {
  to { transform: scale(4); opacity: 0; border-color: #ff7b2d; }
}

/* floating damage numbers */
.dmg-pop {
  position: absolute; z-index: 5; font-size: 22px; font-weight: 900;
  color: #ffd166; text-shadow: 0 0 10px rgba(255, 160, 60, 0.9), 0 2px 0 #1a0e05;
  animation: dmgFloat 0.85s ease-out forwards;
  pointer-events: none; font-variant-numeric: tabular-nums;
}
.dmg-pop.bad { color: var(--bad); text-shadow: 0 0 10px rgba(255, 93, 108, 0.8), 0 2px 0 #2a0a10; }
.dmg-pop.heal { color: var(--good); text-shadow: 0 0 10px rgba(46, 204, 113, 0.8); }
.dmg-pop.crit { font-size: 30px; color: #ff8c2d; }
@keyframes dmgFloat {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  20% { transform: translateY(-14px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-56px) scale(1); opacity: 0; }
}

/* shop */
.shop {
  position: absolute; inset: 0; z-index: 6;
  background: rgba(10, 8, 24, 0.93);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 16px;
}
.shop h3 { font-size: 17px; }
.shop-items { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.shop-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 120px; padding: 12px 14px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--card-border);
  color: var(--text); cursor: pointer; transition: all 0.15s ease; font-size: 14px; font-weight: 700;
}
.shop-item:hover:not(:disabled) { border-color: var(--lava-2); background: rgba(255, 123, 45, 0.18); transform: translateY(-2px); }
.shop-item:disabled { opacity: 0.4; cursor: not-allowed; }
.shop-emoji { font-size: 24px; }
.shop-level { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.cost { font-size: 13px; font-weight: 800; color: #ffd166; font-variant-numeric: tabular-nums; }

/* hero armor visuals (upgrades) */
.armor-piece, .armor-piece2 { display: none; }
.has-armor .armor-piece { display: block; }
.has-armor2 .armor-piece2 { display: block; }

/* hair highlight (hidden when bald) */
.h-highlight { display: none; }
.hs-buzz .h-highlight, .hs-short .h-highlight, .hs-spiky .h-highlight, .hs-mohawk .h-highlight, .hs-long .h-highlight { display: block; }
.brows-soft { opacity: 0.85; }

/* monster lunge */
.monster-slot .monster-svg.atk { animation: lungeL 0.4s ease; }
@keyframes lungeL { 40% { transform: translateX(-60px); } }

/* hero death */
.fighter-svg.hero-svg.dead { animation: heroDie 1s ease forwards; }
@keyframes heroDie { to { transform: translateY(20px) rotate(-80deg); opacity: 0.25; } }

/* hero victory dance after wave clear */
.fighter-svg.hero-svg.dance { animation: dance 0.6s ease infinite; }

/* bigger battle hero + monsters */
#battle .hero-svg svg { transform: scale(1.25); transform-origin: 50% 100%; }
.monster-slot .monster-svg svg { transform: scale(1.18); transform-origin: 50% 100%; }
.monster-slot.boss .monster-svg svg { transform: scale(1.45); }

/* let the hero's head/weapon extend above the svg box without being clipped
   (tall/chonky characters scale past the viewBox top) */
#battle .hero-svg svg,
#stage .char-wrap svg,
.preview-char svg,
.monster-slot .monster-svg svg { overflow: visible; }
.hero-side .fighter-svg, .monster-slot .monster-svg { position: relative; z-index: 2; }
.hero-side .hpbar, .hero-side .hp-text, .hero-side .buff-row,
.monster-slot .hpbar, .monster-slot .hp-text { position: relative; z-index: 1; }
.hero-side .fighter-svg { margin-top: 14px; }
.monster-slot .monster-svg { margin-top: 10px; }

/* monster charge-up orb */
.charge-orb {
  position: absolute; right: -4px; top: 26%; width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 42% 40%, #fff 0%, var(--oc, #ff5d5d) 55%, rgba(0, 0, 0, 0.3) 90%);
  box-shadow: 0 0 22px var(--oc, #ff5d5d), 0 0 44px rgba(255, 90, 60, 0.5);
  z-index: 3; pointer-events: none;
  animation: chargeGrow 0.62s ease-out forwards;
}
@keyframes chargeGrow {
  0% { transform: scale(0.15); opacity: 0; }
  55% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0.8; }
}

/* monster projectiles flying at the hero */
.mproj {
  position: absolute; z-index: 5; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 62% 38%, #fff 0%, var(--pc, #ff5d5d) 55%, rgba(0, 0, 0, 0.28) 90%);
  box-shadow: 0 0 18px var(--pc, #ff5d5d), 12px 0 16px -4px var(--pc, #ff5d5d);
  pointer-events: none;
  animation: mprojFly 0.5s ease-in forwards;
}
.mproj.big2 { width: 50px; height: 50px; }
@keyframes mprojFly {
  from { transform: translate(var(--sx), var(--sy)) scale(0.6); }
  to { transform: translate(var(--ex), var(--ey)) scale(1); }
}

/* ===== elemental combat FX ===== */
.proj {
  position: absolute; z-index: 5; width: 68px; height: 68px; pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(255, 140, 40, 0.9)) drop-shadow(0 0 30px rgba(255, 90, 20, 0.5));
}
.proj.big { width: 108px; height: 108px; filter: drop-shadow(0 0 18px rgba(255, 140, 40, 1)) drop-shadow(0 0 42px rgba(255, 90, 20, 0.65)); }
.proj svg { width: 100%; height: 100%; overflow: visible; }
.flicker { transform-origin: 85% 50%; animation: flick 0.13s infinite alternate; }
.flicker2 { animation: flick 0.11s infinite alternate-reverse; }
@keyframes flick {
  from { transform: scale(1, 1) skewY(3deg); }
  to { transform: scale(0.88, 1.14) skewY(-4deg); }
}
/* embers shed while the fireball flies */
.proj-ember {
  position: absolute; z-index: 4; width: 5px; height: 6px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 40% 30%, #fff3b0, #ff9a3d 60%, rgba(255, 60, 0, 0) 90%);
  pointer-events: none;
  animation: emberUp 0.5s ease-out forwards;
}
@keyframes emberUp {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to { transform: translateY(-11px) scale(0.3); opacity: 0; }
}
/* embers bursting out of the explosion (little arc: out then falling) */
.fire-ember {
  position: absolute; z-index: 5; width: 5px; height: 7px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 40% 30%, #fff3b0, #ff9a3d 60%, rgba(255, 60, 0, 0) 90%);
  pointer-events: none;
  animation: emberBurst 0.7s ease-out forwards;
}
@keyframes emberBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  60% { transform: translate(calc(var(--ex) * 0.7), calc(var(--ey) * 0.7 - 12px)) scale(0.8); opacity: 0.9; }
  100% { transform: translate(var(--ex), calc(var(--ey) + 16px)) scale(0.4); opacity: 0; }
}
/* monster briefly on fire after a fire hit */
.monster-slot .monster-svg { position: relative; }
.burn-overlay {
  position: absolute; inset: -6px; pointer-events: none; mix-blend-mode: screen;
  background:
    radial-gradient(circle at 35% 72%, rgba(255, 140, 40, 0.8) 0 12%, transparent 40%),
    radial-gradient(circle at 65% 45%, rgba(255, 210, 102, 0.7) 0 10%, transparent 35%),
    radial-gradient(circle at 50% 88%, rgba(255, 90, 20, 0.6) 0 10%, transparent 38%);
  animation: burnFlicker 0.16s infinite alternate;
}
@keyframes burnFlicker { from { opacity: 0.85; } to { opacity: 0.5; } }
.impact-flash {
  position: absolute; z-index: 5; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle, var(--fc, #fff3b0) 0%, rgba(255, 160, 60, 0.65) 45%, transparent 75%);
  animation: flashPop 0.3s ease-out forwards; pointer-events: none;
}
@keyframes flashPop {
  from { transform: scale(0.4); opacity: 1; }
  to { transform: scale(2); opacity: 0; }
}
.impact-ring {
  position: absolute; z-index: 5; width: 26px; height: 26px; border-radius: 50%;
  border: 4px solid #ffd166; pointer-events: none;
  animation: impactPop 0.45s ease-out forwards;
}
@keyframes impactPop {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(var(--iscale, 4)); }
}
.bolt {
  position: absolute; z-index: 5; width: 30px; height: 90px; pointer-events: none;
  animation: boltFlash 0.4s ease-out forwards;
}
.bolt svg { width: 100%; height: 100%; }
@keyframes boltFlash {
  0% { opacity: 0; transform: scaleY(0.5); }
  30% { opacity: 1; transform: scaleY(1.05); }
  100% { opacity: 0; transform: scaleY(1); }
}
.ice-overlay {
  position: absolute; inset: -6px; border-radius: 14px; pointer-events: none;
  background: rgba(140, 225, 255, 0.28);
  border: 2px solid rgba(190, 240, 255, 0.8);
  box-shadow: 0 0 16px rgba(140, 225, 255, 0.6) inset;
  opacity: 0; transition: opacity 0.3s;
}
.ice-overlay.on { opacity: 1; }
.poison-drops { position: absolute; inset: 0; pointer-events: none; }
.p-bubble {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b6ffb0, #2f7a2c 75%);
  animation: bubbleUp 1.1s ease-out forwards;
}
@keyframes bubbleUp {
  from { transform: translateY(0); opacity: 0.95; }
  to { transform: translateY(-28px); opacity: 0; }
}
.dmg-pop.pop { color: #7ee08a; text-shadow: 0 0 10px rgba(126, 224, 138, 0.8), 0 2px 0 #10240f; }
.monster-slot.frozen .monster-svg svg { filter: saturate(0.35) brightness(1.35) hue-rotate(150deg); }
