/* =====================================================================
   Phase 2: camp, armoury, battles, shop. Layout here; materials per theme below.
   ===================================================================== */
.sprite { display: inline-block; line-height: 0; }
.sprite svg { display: block; image-rendering: pixelated; }
.screen-title { color: #fff; font-size: 1.2rem; }
.list { padding: 8px 16px; }
.option.gone { visibility: hidden; }

/* Camp: the hero stage is the one loud element. */
.stage { position: relative; padding: 18px 16px 16px; margin-bottom: 14px; text-align: center; overflow: hidden; }
.stage-hero { display: flex; justify-content: center; padding: 8px 0 14px; position: relative; z-index: 1; }
.nameplate { display: flex; align-items: baseline; justify-content: center; gap: 12px; position: relative; z-index: 1; }
.hero-name { border: 0; background: none; padding: 0; font-size: 1.7rem; font-weight: 700; cursor: pointer; color: inherit; }
.lvl { font-size: 1.1rem; }
.xp { max-width: 320px; margin: 10px auto 6px; display: grid; gap: 4px; position: relative; z-index: 1; }
.xp small { font-size: 0.85rem; }
.statline { display: flex; justify-content: center; gap: 18px; font-size: 1.1rem; font-weight: 600; position: relative; z-index: 1; }

.goal { display: grid; gap: 6px; width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 14px; cursor: pointer; font-size: 1rem; }
.quest-btn { flex-direction: column; gap: 2px; margin-bottom: 14px; }
.quest-btn small { font-size: 0.9rem; font-weight: 500; opacity: 0.9; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 14px; text-align: left; font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.tile-icon { font-size: 1.6rem; }

/* Armoury and shop rows */
.armoury-hero { display: flex; align-items: center; gap: 14px; color: #fff; margin-bottom: 12px; }
.armoury-hero div { display: grid; }
.shop-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 2px solid rgba(0, 0, 0, 0.12); }
.shop-row:last-child { border-bottom: 0; }
.shop-row.locked .row-icon { filter: grayscale(1) opacity(0.55); }
.row-icon { flex: none; width: 56px; display: flex; justify-content: center; font-size: 2rem; }
.row-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.row-text small { color: var(--muted); }
.tag { flex: none; padding: 6px 10px; font-size: 0.9rem; font-weight: 600; background: rgba(0, 0, 0, 0.08); }
.tag.on { background: var(--good-soft); color: #14532d; }
.btn.price { min-height: 44px; padding: 8px 14px; font-size: 1rem; }
.btn:disabled { cursor: not-allowed; }

/* World path: the worlds really are a sequence, so they're numbered. */
.world-path { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: world; }
.world { display: flex; align-items: center; gap: 12px; padding: 12px 14px; counter-increment: world; }
.world-boss { flex: none; }
.world.locked .world-boss { filter: brightness(0) opacity(0.45); }
.world .row-text small:first-child::before { content: "World " counter(world) ": "; }

/* Battle */
.battle-hud { display: grid; gap: 6px; margin-bottom: 12px; color: #fff; }
.hud-top { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; }
.hud-row { display: flex; align-items: center; gap: 12px; }
.hud-row.hero-row { margin-top: -8px; }
.hud-bars { flex: 1; display: grid; gap: 4px; }
.hp { height: 16px; }
.boss-hp > i { background: #e5484d; }
.hero-hp > i { background: #46c35a; }
.fighter { position: relative; flex: none; }
.dmg { position: absolute; left: 50%; top: 10%; transform: translateX(-50%); font-size: 1.8rem; font-weight: 700; color: #fff; text-shadow: 0 3px 0 #000, 0 0 6px #000; animation: dmg-rise 0.9s ease-out forwards; pointer-events: none; }
.dmg.to-hero { color: #ffb4b4; }
@keyframes dmg-rise { from { opacity: 0; transform: translate(-50%, 10px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -36px); } }
.fighter.hero.lunge { animation: hero-lunge 0.45s ease-in-out; }
.fighter.boss.lunge { animation: boss-lunge 0.45s ease-in-out; }
.fighter.hit { animation: hit 0.45s steps(2) 0.15s; }
@keyframes hero-lunge { 50% { transform: translate(28px, -26px); } }
@keyframes boss-lunge { 50% { transform: translate(-30px, 22px) scale(1.06); } }
@keyframes hit { 0%, 100% { filter: none; transform: none; } 25% { filter: brightness(2.6); transform: translateX(-6px); } 75% { filter: brightness(2.6); transform: translateX(6px); } }
.potions { display: flex; gap: 10px; }
.potion { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 6px 12px; font-size: 1.2rem; cursor: pointer; }
.potion span { font-size: 0.9rem; font-weight: 700; }
.potion:disabled { opacity: 0.4; cursor: not-allowed; }
.potion.active { outline: 3px solid #ffd23f; outline-offset: 2px; }

.battle-end { text-align: center; }
.end-art { display: flex; justify-content: center; align-items: flex-end; gap: 16px; margin-bottom: 8px; }
.defeated .sprite { filter: grayscale(1); transform: rotate(90deg) translateY(10px); }

/* Rewards shop */
.rewards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.reward { display: grid; justify-items: center; gap: 6px; padding: 16px 12px; text-align: center; }
.reward-emoji { font-size: 2.6rem; }
.reward-cost { font-weight: 700; }
.reward .btn { min-height: 44px; font-size: 1rem; width: 100%; }
.reward.is-goal { outline: 4px solid #ffd23f; }

/* Badges and themes */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.badge-tile { display: grid; justify-items: center; gap: 6px; padding: 14px 8px; text-align: center; opacity: 0.55; }
.badge-tile.earned { opacity: 1; }
.badge-emoji { font-size: 2.2rem; }
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.theme-card { display: grid; justify-items: center; gap: 8px; padding: 18px 10px; cursor: pointer; font-size: 1.1rem; }
.theme-card.on { outline: 4px solid #ffd23f; outline-offset: 3px; }
.theme-card[data-preview="block"] { background: linear-gradient(#8fd3ff 0 52%, #5fb83f 52% 57%, #c6c6c6 57%); border: 4px solid #1e1e1e; color: #1e1e1e; }
.theme-card[data-preview="run"] { background: linear-gradient(#5cc8ff 0 52%, #d9662b 52% 57%, #fff 57%); border: 4px solid #1b1b2f; border-radius: 20px; color: #1b1b2f; }

.celebrate {
  position: fixed; left: 50%; top: 38%; z-index: 20; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 4px; padding: 18px 28px; text-align: center;
  background: #ffe27a; color: #2b2112; border: 4px solid #2b2112; box-shadow: 0 8px 0 #2b2112;
  animation: celebrate 2.2s ease-out forwards; pointer-events: none;
}
.celebrate b { font-size: 2rem; }
@keyframes celebrate { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 20% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
.pop.heal { color: #46c35a; }
@media (prefers-reduced-motion: reduce) { .lunge, .hit, .dmg, .celebrate { animation: none !important; } }

/* =====================================================================
   Theme: Block World. Stone slabs, wooden planks, grass over dirt.
   ===================================================================== */
:root[data-theme="block"] { --muted: #4b4b4b; font-family: "Lexend", system-ui, sans-serif; }
[data-theme="block"] body {
  background-color: #74513a;
  background-image: linear-gradient(#5fb83f 0 44px, #3e8a2a 44px 52px, transparent 52px), repeating-conic-gradient(#7a563a 0 25%, #6c4b31 0 50%);
  background-size: 100% 100%, 32px 32px;
  background-attachment: scroll;
}
[data-theme="block"] :is(.hero-title, .screen-title, .hero-name, .lvl, .pill, .btn, .tile, .chip, .potion, .hud-top b, .reward-cost, .celebrate b, .tag) { font-family: "Pixelify Sans", "Lexend", sans-serif; }
[data-theme="block"] :is(.hero-title, .screen-title) { color: #fff; text-shadow: 3px 3px 0 #2b1a0a; }
[data-theme="block"] .sub { color: #f7e7c9; text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45); }
[data-theme="block"] :is(.card, .stage, .tile, .goal, .world, .reward, .badge-tile, .potion) {
  background: #c6c6c6; color: #1f1f1f; border: 4px solid #1e1e1e; border-radius: 2px;
  box-shadow: inset 4px 4px 0 #ececec, inset -4px -4px 0 #8a8a8a, 0 6px 0 rgba(0, 0, 0, 0.35);
}
[data-theme="block"] .option { border: 3px solid #1e1e1e; border-radius: 2px; background: #d6d6d6; box-shadow: inset 3px 3px 0 #ececec, inset -3px -3px 0 #9a9a9a; }
[data-theme="block"] .option.correct { background: #8fe07f; }
[data-theme="block"] .option.wrong { background: #ff9a9a; }
[data-theme="block"] .btn {
  background: #b4823f; color: #fff; text-shadow: 2px 2px 0 #4a2f12; border: 3px solid #2b1a0a; border-radius: 2px;
  box-shadow: inset 3px 3px 0 #dba862, inset -3px -3px 0 #7c5426, 0 5px 0 #2b1a0a;
}
[data-theme="block"] .btn.good { background: #4caf3c; box-shadow: inset 3px 3px 0 #82d86d, inset -3px -3px 0 #2f7a24, 0 5px 0 #173d12; text-shadow: 2px 2px 0 #1e5216; }
[data-theme="block"] .btn.alt { background: #9b9b9b; color: #1f1f1f; text-shadow: none; box-shadow: inset 3px 3px 0 #cbcbcb, inset -3px -3px 0 #6a6a6a, 0 5px 0 #2b2b2b; }
[data-theme="block"] .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6); }
[data-theme="block"] .pill { background: #2b2b2b; border: 3px solid #111; border-radius: 2px; }
[data-theme="block"] .chip { border-radius: 2px; background: #2b2b2b; border: 3px solid #111; }
[data-theme="block"] .chip.on { background: #f5c542; color: #2b1a0a; }
[data-theme="block"] .bar { border-radius: 0; background: #2b2b2b; border: 3px solid #111; height: 16px; }
[data-theme="block"] .bar > i { border-radius: 0; }
[data-theme="block"] .xp-bar > i { background: #7ee84f; }
[data-theme="block"] .stage { background: linear-gradient(#8fd3ff, #cdeeff 70%); padding-bottom: 54px; }
[data-theme="block"] .stage::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: linear-gradient(#5fb83f 0 10px, #3e8a2a 10px 14px, transparent 14px), repeating-conic-gradient(#7a563a 0 25%, #6c4b31 0 50%) 0 0 / 16px 16px;
}
[data-theme="block"] :is(.meaning-block, .tag, .celebrate) { border-radius: 2px; }
[data-theme="block"] :is(.hud-top b, .hud-bars b) { text-shadow: 2px 2px 0 #000; }

/* =====================================================================
   Theme: Power-Up Run. Bright sky, thick cartoon outlines, brick ground.
   ===================================================================== */
:root[data-theme="run"] { --muted: #4a4a68; --ink-run: #1b1b2f; font-family: "Lexend", system-ui, sans-serif; }
[data-theme="run"] body {
  background-color: #5cc8ff;
  background-image:
    radial-gradient(circle at 60px 70px, #fff 0 26px, transparent 27px),
    radial-gradient(circle at 92px 60px, #fff 0 32px, transparent 33px),
    radial-gradient(circle at 126px 72px, #fff 0 24px, transparent 25px);
  background-size: 360px 240px;
  background-attachment: scroll;
}
[data-theme="run"] :is(.hero-title, .screen-title, .hero-name, .lvl, .pill, .btn, .tile, .chip, .potion, .hud-top b, .reward-cost, .celebrate b, .tag) { font-family: "Lilita One", "Lexend", sans-serif; font-weight: 400; letter-spacing: 0.01em; }
[data-theme="run"] :is(.hero-title, .screen-title, .hud-top b, .hud-bars b) {
  color: #fff;
  text-shadow: -2px -2px 0 var(--ink-run), 2px -2px 0 var(--ink-run), -2px 2px 0 var(--ink-run), 2px 2px 0 var(--ink-run), 0 4px 0 var(--ink-run);
}
[data-theme="run"] .sub, [data-theme="run"] .armoury-hero { color: var(--ink-run); font-weight: 500; }
[data-theme="run"] :is(.card, .stage, .tile, .goal, .world, .reward, .badge-tile, .potion) {
  background: #fff; color: var(--ink-run); border: 4px solid var(--ink-run); border-radius: 20px; box-shadow: 0 6px 0 var(--ink-run);
}
[data-theme="run"] .option { border: 3px solid var(--ink-run); border-radius: 16px; box-shadow: 0 4px 0 var(--ink-run); }
[data-theme="run"] .btn { background: #ffcc1a; color: var(--ink-run); border: 4px solid var(--ink-run); border-radius: 999px; box-shadow: 0 5px 0 var(--ink-run); }
[data-theme="run"] .btn.good { background: #3ccf4e; }
[data-theme="run"] .btn.alt { background: #fff; }
[data-theme="run"] .btn.ghost { background: #fff; border-width: 3px; box-shadow: 0 3px 0 var(--ink-run); min-height: 40px; }
[data-theme="run"] :is(.pill, .chip) { background: #fff; color: var(--ink-run); border: 3px solid var(--ink-run); }
[data-theme="run"] .chip.on { background: #ffcc1a; }
[data-theme="run"] .bar { background: #fff; border: 3px solid var(--ink-run); height: 18px; }
[data-theme="run"] .xp-bar > i { background: #3ccf4e; }
[data-theme="run"] .stage { background: #9ee3ff; padding-bottom: 58px; }
[data-theme="run"] .stage::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 46px; border-top: 4px solid var(--ink-run);
  background-color: #d9662b;
  background-image: linear-gradient(var(--ink-run) 2px, transparent 2px), linear-gradient(90deg, var(--ink-run) 2px, transparent 2px);
  background-size: 100% 21px, 42px 21px;
}
[data-theme="run"] .meaning-block {
  border-color: var(--ink-run); box-shadow: 0 6px 0 var(--ink-run); border-radius: 16px;
  background-image:
    radial-gradient(circle at 10px 10px, #b8860b 3px, transparent 4px),
    radial-gradient(circle at calc(100% - 10px) 10px, #b8860b 3px, transparent 4px),
    radial-gradient(circle at 10px calc(100% - 10px), #b8860b 3px, transparent 4px),
    radial-gradient(circle at calc(100% - 10px) calc(100% - 10px), #b8860b 3px, transparent 4px);
}
[data-theme="run"] .tag { border-radius: 999px; }
[data-theme="run"] .celebrate { border-radius: 20px; border-color: var(--ink-run); box-shadow: 0 8px 0 var(--ink-run); }

/* Keep the counters on one line. */
.topbar .pill { white-space: nowrap; }

/* Phones: fit the whole camp on one screen. */
@media (max-width: 480px) {
  .stage { padding-top: 10px; margin-bottom: 10px; }
  .stage-hero { padding: 0 0 6px; }
  .stage-hero svg { width: 134px; height: 112px; } /* hero canvas is 24×20 */
  .hero-name { font-size: 1.35rem; }
  .xp { margin: 6px auto 4px; }
  [data-theme="block"] .stage { padding-bottom: 46px; }
  [data-theme="run"] .stage { padding-bottom: 50px; }
  [data-theme="block"] .stage::after { height: 36px; }
  [data-theme="run"] .stage::after { height: 38px; }
  .goal { padding: 8px 12px; margin-bottom: 10px; }
  .quest-btn { min-height: 60px; margin-bottom: 10px; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tile { flex-direction: column; justify-content: center; gap: 2px; min-height: 72px; padding: 8px 4px; text-align: center; font-size: 0.85rem; line-height: 1.15; }
  .tile-icon { font-size: 1.5rem; }
}

/* Blaster shot */
.battle-hud { position: relative; }
.shot {
  position: absolute; left: 0; top: 0; z-index: 3; width: 18px; height: 8px; pointer-events: none;
  background: #fff27a; border: 2px solid #1d1d1d; box-shadow: 0 0 10px 3px rgba(255, 242, 122, 0.85);
}

/* Idle movement: each boss moves in its own way. Only where the boss is "alive". */
:is(.fighter.boss, .world:not(.locked) .world-boss) .sprite { transform-origin: 50% 100%; }
:is(.fighter.boss, .world:not(.locked) .world-boss) .boss-slime { animation: idle-squish 1.1s ease-in-out infinite; }
:is(.fighter.boss, .world:not(.locked) .world-boss) .boss-skeleton { animation: idle-rattle 1.5s ease-in-out infinite; }
:is(.fighter.boss, .world:not(.locked) .world-boss) .boss-bramble { animation: idle-sway 2.2s ease-in-out infinite; }
:is(.fighter.boss, .world:not(.locked) .world-boss) .boss-golem { animation: idle-stomp 1.4s cubic-bezier(0.5, 0, 0.9, 0.5) infinite; }
:is(.fighter.boss, .world:not(.locked) .world-boss) .boss-wyrm { animation: idle-float 2.6s ease-in-out infinite; }
:is(.fighter.boss, .world:not(.locked) .world-boss) .boss-dragon { animation: idle-hover 1.8s ease-in-out infinite; }
@keyframes idle-squish { 0%, 100% { transform: scale(1.06, 0.93); } 50% { transform: scale(0.95, 1.06) translateY(-4px); } }
@keyframes idle-rattle { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-4px) rotate(-3deg); } 75% { transform: translateY(-4px) rotate(3deg); } }
@keyframes idle-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes idle-stomp { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-7px); } 64% { transform: translateY(1px) scale(1.03, 0.97); } }
@keyframes idle-float { 0%, 100% { transform: translate(-4px, 0); } 50% { transform: translate(4px, -8px); } }
@keyframes idle-hover { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-9px) scale(1.04); } }

/* The hero breathes on the camp and in battle, in two pixel steps. */
:is(.stage-hero, .fighter.hero) .sprite { animation: idle-breathe 1.6s steps(2, jump-none) infinite; }
@keyframes idle-breathe { from { transform: translateY(0); } to { transform: translateY(-3px); } }

@media (prefers-reduced-motion: reduce) {
  :is(.fighter, .world-boss, .stage-hero) .sprite { animation: none !important; }
}

/* In-game pop-up (replaces browser confirm/alert/prompt) */
.modal { width: min(360px, calc(100vw - 32px)); padding: 22px 20px 20px; text-align: center; color: #1f1f1f; background: #fff; border: 4px solid #1e1e1e; }
.modal::backdrop { background: rgba(10, 10, 20, 0.6); }
.modal h2 { margin: 4px 0 8px; font-size: 1.4rem; }
.modal p { margin: 0 0 16px; font-size: 1.05rem; line-height: 1.4; }
.modal-icon { font-size: 2.6rem; line-height: 1; }
.modal-input { width: 100%; margin: 4px 0 16px; padding: 12px; font-size: 1.3rem; text-align: center; border: 3px solid #1e1e1e; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { flex: 1; min-height: 52px; }
.modal[open] { animation: modal-in 0.18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.92); } }
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

[data-theme="block"] .modal { background: #c6c6c6; border-radius: 2px; box-shadow: inset 4px 4px 0 #ececec, inset -4px -4px 0 #8a8a8a, 0 8px 0 rgba(0, 0, 0, 0.45); }
[data-theme="block"] .modal h2 { font-family: "Pixelify Sans", "Lexend", sans-serif; }
[data-theme="block"] .modal-input { border-radius: 2px; background: #ececec; }
[data-theme="run"] .modal { border-color: var(--ink-run); border-radius: 24px; box-shadow: 0 8px 0 var(--ink-run); color: var(--ink-run); }
[data-theme="run"] .modal h2 { font-family: "Lilita One", "Lexend", sans-serif; font-weight: 400; }
[data-theme="run"] .modal-input { border-color: var(--ink-run); border-radius: 14px; }
