/* Just a Clicker Game... — deliberately plain. The weirdness is in the stickmen. */
:root {
  --bg: #fafaf7;
  --ink: #111;
  --muted: #777;
  --line: #d8d8d2;
  --panel: #fff;
  --accent: #111;
  --good: #2f8a3a;
  --bad: #d22b2b;
  --gold: #c9971a;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --hand: "Comic Sans MS", "Comic Neue", "Chalkboard SE", "Segoe Print", cursive;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* ================================================================ TITLE */
#title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
}
.title {
  margin: 0;
  font-size: clamp(40px, 9vw, 132px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 0.95;
}
.byline { font-size: clamp(16px, 2vw, 22px); color: var(--muted); margin-bottom: 40px; }
.big-btn {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 14px 54px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.05s;
}
.big-btn:hover { background: #f1f1ec; }
.big-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
#title-extra { color: var(--muted); font-size: 14px; min-height: 40px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.link-btn { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 2px 6px; }
.link-btn:hover { color: var(--ink); }

/* ================================================================ GAME LAYOUT */
#world {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.8s cubic-bezier(.5, -0.3, .5, 1.3), filter 0.3s;
}
#world.upside { transform: rotate(180deg); }
#world.tilt { transform: rotate(-3deg); }
#world.quake { animation: quake 0.08s linear infinite; }
@keyframes quake { 0% { translate: -3px 1px; } 50% { translate: 3px -2px; } 100% { translate: -1px 2px; } }

#hud { text-align: center; padding-top: clamp(12px, 4vh, 40px); min-height: 150px; position: relative; }
#clicks-label { font-size: 14px; letter-spacing: 0.3em; color: var(--muted); font-weight: 700; }
#clicks-value { font-size: clamp(40px, 7vw, 64px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
#rate { font-size: 14px; color: var(--muted); min-height: 18px; }
#nonsense { font-size: 15px; font-weight: 700; font-family: monospace; }
#nonsense div { animation: pop 0.2s; }
#threat {
  margin-top: 8px;
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
  border: 2px solid var(--bad);
  color: var(--bad);
  background: #fff;
}
#threat.soon { background: var(--bad); color: #fff; animation: pulse 0.6s infinite alternate; }

#arena { flex: 1; min-height: 190px; width: 100%; display: flex; align-items: center; justify-content: center; }
#button-wrap { position: relative; transition: opacity 0.4s; }
#button-wrap.vanished { opacity: 0; pointer-events: none; }
#clicker {
  width: clamp(170px, 26vw, 250px);
  height: clamp(92px, 13vw, 124px);
  font-size: clamp(30px, 4.4vw, 44px);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 9px 0 var(--ink);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.04s, box-shadow 0.04s, background 0.2s;
  touch-action: manipulation;
}
#clicker:hover { background: #f6f6f1; }
#clicker.pressed, #clicker:active { transform: translateY(7px); box-shadow: 0 2px 0 var(--ink); }
#clicker.locked { cursor: not-allowed; }
#clicker.polished::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%);
  animation: shine 3.5s infinite;
  pointer-events: none;
}
#clicker.polished { background: linear-gradient(#fff, #eef3ff); }
#clicker.premium #clicker-label { color: var(--gold); text-shadow: 0 1px 0 #7a5a00; }
@keyframes shine { 0% { translate: -70% 0; } 60%, 100% { translate: 70% 0; } }
#button-hat { position: absolute; left: 50%; top: 0; translate: -30% -86%; pointer-events: none; z-index: 2; }
#button-hat svg { display: block; }

.button-eyes { position: absolute; inset: 0; display: flex; justify-content: center; gap: 22%; align-items: center; pointer-events: none; }
.button-eye {
  width: 30%; aspect-ratio: 1; max-width: 60px;
  background: #fff; border: 3px solid var(--ink); border-radius: 50%;
  position: relative; animation: pop 0.25s;
}
.button-eye .pupil { position: absolute; width: 38%; height: 38%; background: var(--ink); border-radius: 50%; left: 31%; top: 31%; }
.button-eye.blink { animation: blink 0.25s; }
@keyframes blink { 50% { transform: scaleY(0.05); } }
.button-mustache { position: absolute; left: 50%; bottom: 10%; translate: -50% 0; font-size: 40px; pointer-events: none; }

#core-stats { display: flex; gap: clamp(20px, 8vw, 110px); justify-content: center; padding: 6px 16px 12px; }
.stat { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label { font-size: 12px; letter-spacing: 0.2em; color: var(--muted); font-weight: 700; }
.stat-value { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.buy-btn {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 9px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.04s, box-shadow 0.04s, opacity 0.2s;
}
.buy-btn small { font-weight: 600; font-size: 12px; color: var(--muted); margin-top: 1px; }
.buy-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.buy-btn:disabled { opacity: 0.38; cursor: default; }
.buy-btn.pulse { animation: pulse 0.5s infinite alternate; }

/* ================================================================ SHOP */
#shop { width: min(980px, 100%); padding: 0 12px 12px; }
#shop-tabs { display: flex; gap: 6px; justify-content: center; border-bottom: 2px solid var(--line); }
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  margin-bottom: -2px;
  position: relative;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab.new::after { content: "NEW"; position: absolute; top: -4px; right: -8px; font-size: 9px; background: var(--bad); color: #fff; padding: 1px 4px; border-radius: 4px; animation: pulse 0.5s infinite alternate; }
#shop-body {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 4px 6px;
  min-height: 120px;
  scrollbar-width: thin;
}
.shop-info { font-size: 13px; color: var(--muted); padding: 4px 8px; align-self: center; min-width: 180px; line-height: 1.5; }
.shop-info b { color: var(--ink); }
.card {
  flex: 0 0 200px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--panel);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}
.card-name { font-weight: 800; font-size: 14px; }
.card-desc { color: #555; flex: 1; line-height: 1.35; }
.card-buy {
  font-weight: 800;
  border: 2px solid var(--ink);
  background: #fff;
  border-radius: 7px;
  padding: 5px 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 12.5px;
}
.card-buy:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.card-buy:disabled { opacity: 0.4; cursor: default; }
.card.owned { border-style: dashed; opacity: 0.55; }
.card.danger { border-color: var(--bad); }
.hpbar { height: 6px; background: #eee; border: 1px solid #999; border-radius: 3px; overflow: hidden; }
.hpbar > div { height: 100%; background: var(--good); }
.empty-note { color: var(--muted); font-size: 13px; padding: 10px; align-self: center; }

/* ================================================================ LAYERS */
#darkness { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 15; }
#darkness.on { opacity: 1; pointer-events: auto; }
#stage { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
#overlay { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
#corner { position: fixed; right: 10px; bottom: 10px; z-index: 40; display: flex; gap: 6px; }
#corner button {
  background: #fff; border: 2px solid var(--line); border-radius: 8px; padding: 4px 9px;
  font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer;
}
#corner button:hover { color: var(--ink); border-color: var(--ink); }
#corner button.off { text-decoration: line-through; }

/* ================================================================ TUTORIAL */
#tutorial {
  position: fixed;
  left: 50%;
  bottom: 22px;
  translate: -50% 0;
  z-index: 25;
  max-width: min(460px, calc(100vw - 32px));
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 5px 0 var(--ink);
  animation: pop 0.25s;
}
#tutorial::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -14px;
  translate: -50% 0;
  border: 12px solid transparent;
  border-top: 0;
  border-bottom: 14px solid var(--ink);
}

/* ================================================================ ACTORS */
.actor { position: absolute; left: 0; top: 0; width: 0; height: 0; --ink: #111; --fill: #fff; --step: 0.35s; }
#stage.in-dark .actor { --ink: #e9e9e9; --fill: #000; }
.actor-body { position: absolute; left: -21px; bottom: 0; width: 42px; height: 59px; transform-origin: 50% 100%; }
.actor svg { display: block; overflow: visible; }
.actor svg line, .actor svg path { stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.actor .head { fill: var(--fill); stroke: var(--ink); stroke-width: 3.2; }
.actor .eye { fill: var(--ink); }
.actor .mouth, .actor .brow, .actor .zz { display: none; }
.actor .face path, .actor .face .m-o { stroke-width: 1.7; fill: none; stroke: var(--ink); }
.mood-happy .m-smile, .mood-cheeky .m-smile { display: inline; }
.mood-sad .m-frown, .mood-sad .b-sad { display: inline; }
.mood-angry .m-frown, .mood-angry .b-angry { display: inline; }
.mood-annoyed .m-flat, .mood-annoyed .b-angry { display: inline; }
.mood-surprised .m-o, .mood-surprised .b-up { display: inline; }
.mood-scared .m-o, .mood-scared .b-sad { display: inline; }
.mood-flat .m-flat { display: inline; }
.mood-sleep .eye { display: none; }
.mood-sleep .zz { display: inline; }
.mood-cheeky .b-up { display: inline; }

.arm { transform-origin: 30px 28px; transition: transform 0.18s ease-out; }
.leg { transform-origin: 30px 50px; }
.leg-f { transform: rotate(-9deg); }
.leg-b { transform: rotate(9deg); }
.walking .leg-f { animation: legswing var(--step) ease-in-out infinite alternate; }
.walking .leg-b { animation: legswing var(--step) ease-in-out infinite alternate-reverse; }
.walking:not(.arms-busy) .arm-f { animation: armswing var(--step) ease-in-out infinite alternate-reverse; }
.walking:not(.arms-busy) .arm-b { animation: armswing var(--step) ease-in-out infinite alternate; }
@keyframes legswing { from { transform: rotate(-30deg); } to { transform: rotate(30deg); } }
@keyframes armswing { from { transform: rotate(-32deg); } to { transform: rotate(32deg); } }

.anim-fist .arm-f { animation: fist 0.22s ease-in-out infinite alternate; }
@keyframes fist { from { transform: rotate(-138deg); } to { transform: rotate(-172deg); } }
.anim-wave .arm-f { animation: wave 0.28s ease-in-out infinite alternate; }
@keyframes wave { from { transform: rotate(-170deg); } to { transform: rotate(-118deg); } }
.anim-screw .arm-f { animation: screw 0.14s linear infinite alternate; }
@keyframes screw { from { transform: rotate(-182deg); } to { transform: rotate(-170deg); } }
.anim-flail .arm-f { animation: flailf 0.13s linear infinite alternate; }
.anim-flail .arm-b { animation: flailb 0.13s linear infinite alternate; }
@keyframes flailf { from { transform: rotate(-165deg); } to { transform: rotate(-40deg); } }
@keyframes flailb { from { transform: rotate(40deg); } to { transform: rotate(165deg); } }
.anim-dance .arm-f { animation: flailf 0.35s ease-in-out infinite alternate; }
.anim-dance .arm-b { animation: flailb 0.35s ease-in-out infinite alternate-reverse; }
.anim-dance svg, .anim-cheer svg { animation: bob 0.35s ease-in-out infinite alternate; }
.anim-cheer .arm-f { animation: cheerf 0.3s ease-in-out infinite alternate; }
.anim-cheer .arm-b { animation: cheerb 0.3s ease-in-out infinite alternate; }
@keyframes cheerf { from { transform: rotate(-175deg); } to { transform: rotate(-140deg); } }
@keyframes cheerb { from { transform: rotate(175deg); } to { transform: rotate(140deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-5px); } }
.shaking svg { animation: jitter 0.07s linear infinite alternate; }
@keyframes jitter { from { transform: translateX(-2px); } to { transform: translateX(2px); } }
.lying .actor-body svg { transform: rotate(-90deg) translate(18px, 0); transform-origin: 50% 100%; }

.facing-front .face { transform: translateX(-5px); }
#world.glitchy { animation: glitch 0.16s steps(2) infinite; }
@keyframes glitch {
  0% { transform: translate(3px, 0) skewX(3deg); filter: hue-rotate(90deg) contrast(1.4); }
  50% { transform: translate(-4px, 2px) skewX(-4deg); filter: invert(0.1); }
  100% { transform: none; }
}
.helmet, .headband, .tophat { display: none; }
.actor .helmet { stroke: var(--ink); stroke-width: 2.2; }
.k-troop .helmet, .k-traitor .helmet { display: inline; fill: #4c9a4c; }
.k-organized .helmet { display: inline; fill: #c93b3b; }
.k-enemy .headband, .k-organized .headband, .k-traitor .headband { display: inline; }
.actor .headband path { stroke: var(--bad); stroke-width: 3; }
.k-fancy .tophat { display: inline; }
.actor .tophat rect { fill: var(--ink); stroke: none; }
.k-ghost { opacity: 0.55; }
.k-ghost .leg { display: none; }
.k-tiny .actor-body { filter: none; }
.k-gold { --ink: var(--gold); }

.it-bulb circle { fill: #fff8cc; stroke: var(--ink); stroke-width: 2; }
.it-bulb rect { fill: #9a9a9a; stroke: var(--ink); stroke-width: 1.5; }
.actor .it-stick, .actor .it-stick path { stroke: #8a5a2b; stroke-width: 3; }
.actor .it-stick ellipse { fill: #bbb; stroke: #666; stroke-width: 1.5; }
.it-emoji { text-anchor: middle; dominant-baseline: central; stroke: none; }
.it-plate { fill: #fff !important; stroke-width: 1.5 !important; }
.actor .it-flag { fill: var(--bad); stroke: none; }
.actor .it-whiteflag { fill: #fff; stroke-width: 1.2; }

.bubble {
  position: absolute;
  left: 0;
  translate: -50% 0;
  background: #fff;
  color: #111;
  border: 2.5px solid #111;
  border-radius: 14px;
  padding: 3px 11px 4px;
  font: 700 15px/1.25 var(--hand);
  width: max-content;
  max-width: 230px;
  text-align: center;
  pointer-events: none;
  z-index: 3;
  animation: pop 0.15s;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -11px;
  translate: -50% 0;
  border: 7px solid transparent;
  border-top: 9px solid #111;
  border-bottom: 0;
}
.bubble.think { border-style: dashed; font-style: italic; color: #555; }
.bubble.shout { font-size: 18px; color: var(--bad); border-color: var(--bad); }
.bubble.shout::after { border-top-color: var(--bad); }

.sign { position: absolute; left: 0; translate: -50% 0; display: flex; flex-direction: column; align-items: center; pointer-events: none; z-index: 2; }
.sign-board {
  background: #fff;
  border: 2.5px solid #111;
  border-radius: 3px;
  padding: 2px 6px;
  font: 800 11px/1.15 var(--hand);
  color: #111;
  text-align: center;
  min-width: 32px;
  max-width: 110px;
  width: max-content;
}
.sign-pole { width: 3px; height: 26px; background: #8a5a2b; }
.no-symbol { width: 30px; height: 30px; display: block; }
.no-symbol circle, .no-symbol path { fill: none; stroke: var(--bad); stroke-width: 5; }

/* ================================================================ PROPS */
.prop { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.prop-inner { position: absolute; left: 0; }
.anchor-bottom > .prop-inner { bottom: 0; translate: -50% 0; transform-origin: 50% 100%; }
.anchor-center > .prop-inner { top: 0; translate: -50% -50%; transform-origin: 50% 50%; }
.anchor-top > .prop-inner { top: 0; translate: -50% 0; transform-origin: 50% 0; }
.prop svg { display: block; overflow: visible; }
.clickable, .clickable * { pointer-events: auto; cursor: pointer; }

.art-tank .tank-body, .art-tank .tank-dome { fill: #7d8a4e; stroke: #111; stroke-width: 3; }
.art-tank .tank-gun { stroke: #111; stroke-width: 5; stroke-linecap: round; }
.art-tank .tank-wheel { fill: #333; stroke: #111; stroke-width: 2; }
.art-tank .tank-label { font: 800 10px var(--font); fill: #fff; }
.art-bus .bus-body { fill: #f3c623; stroke: #111; stroke-width: 3; }
.art-bus .bus-win { fill: #cfe8ff; stroke: #111; stroke-width: 2; }
.art-bus .bus-door { fill: #9bc9f0; stroke: #111; stroke-width: 2; }
.art-bus .bus-wheel { fill: #333; stroke: #111; stroke-width: 2; }
.art-bus .bus-label { font: 800 9px var(--font); fill: #111; }
.art-shield rect { fill: #b9c3cc; stroke: #111; stroke-width: 3; }
.art-shield path { stroke: #111; stroke-width: 3; fill: none; }
.art-chute .chute { fill: #fff; stroke: #111; stroke-width: 2.5; }
.art-chute .chute-lines { stroke: #111; stroke-width: 1.2; fill: none; }
.art-cloud path { fill: #fff; stroke: #111; stroke-width: 3; }
.art-rain .rc { fill: #cfd6de; stroke: #111; stroke-width: 2.5; }
.art-rain .rd { stroke: #3b82c4; stroke-width: 2.5; stroke-linecap: round; animation: rain 0.3s linear infinite; }
@keyframes rain { from { stroke-dashoffset: 0; transform: translateY(-3px); } to { transform: translateY(3px); } }
.art-tumble circle, .art-tumble path { fill: none; stroke: #a07b45; stroke-width: 2.5; }
.art-ladder path { stroke: #8a5a2b; stroke-width: 3.5; fill: none; stroke-linecap: round; }
.fight-cloud .prop-inner { animation: fightwobble 0.12s infinite alternate; }
.art-fight path { fill: #f4f1ea; stroke: #111; stroke-width: 3.5; }
@keyframes fightwobble { from { transform: scale(calc(var(--s, 1) * 0.94)) rotate(-3deg); } to { transform: scale(calc(var(--s, 1) * 1.06)) rotate(3deg); } }

.emoji-prop { font-size: 26px; line-height: 1; }
.label-prop {
  font: 800 13px var(--font);
  background: #fff;
  border: 2px solid #111;
  border-radius: 99px;
  padding: 1px 8px;
  white-space: nowrap;
}
.label-prop.enemy { color: var(--bad); border-color: var(--bad); }
.label-prop.friend { color: var(--good); border-color: var(--good); }

/* the light bulb + switch left behind by Event 1 */
.bulb-fixture { display: flex; flex-direction: column; align-items: center; }
.bulb-cord { width: 2px; background: #111; height: 34px; }
.bulb-glass { width: 22px; height: 26px; border-radius: 50% 50% 45% 45%; border: 2.5px solid #111; background: #fffbe6; position: relative; }
.bulb-base { width: 12px; height: 8px; background: #999; border: 2px solid #111; border-bottom: 0; }
.bulb-fixture.lit .bulb-glass { background: #fff27a; box-shadow: 0 0 22px 8px rgba(255, 230, 80, 0.55); }
.bulb-fixture .bulb-cord { order: -1; }
.light-switch {
  width: 20px; height: 30px; border: 2.5px solid #111; border-radius: 4px; background: #fff;
  position: relative;
}
.light-switch::after {
  content: ""; position: absolute; left: 50%; width: 6px; height: 11px; translate: -50% 0;
  background: #111; border-radius: 2px; top: 3px; transition: top 0.08s;
}
.light-switch.off::after { top: 12px; }
#stage.in-dark .light-switch { border-color: #ddd; background: #000; }
#stage.in-dark .light-switch::after { background: #ddd; }
.light-switch.taped::before {
  content: ""; position: absolute; left: -6px; right: -6px; top: 9px; height: 9px;
  background: rgba(210, 190, 140, 0.9); rotate: -12deg; z-index: 2;
}

/* walls */
.wall-art { border: 2.5px solid #111; position: relative; }
.wall-wood { width: 26px; height: 58px; border-radius: 3px; background: repeating-linear-gradient(90deg, #b98649 0 7px, #8c5f2f 7px 9px); }
.wall-metal { width: 30px; height: 70px; border-radius: 3px; background: radial-gradient(circle at 6px 6px, #555 2px, transparent 3px) 0 0 / 12px 14px, linear-gradient(#c9cfd4, #8e979e); }
.wall-giant { width: 44px; height: 130px; border-radius: 4px; background: repeating-linear-gradient(0deg, #999 0 2px, #bdbdb5 2px 22px), #bdbdb5; }
.wall-unnecessary {
  width: 80px; height: 200vh; border-radius: 6px 6px 0 0;
  background: repeating-linear-gradient(0deg, #6c6c66 0 3px, #9d9d95 3px 30px);
  display: flex; align-items: flex-end; justify-content: center;
}
.wall-unnecessary span { writing-mode: vertical-rl; transform: rotate(180deg); color: #fff; font: 900 12px var(--font); letter-spacing: 0.2em; margin-bottom: 30px; }
.wall-hp { position: absolute; left: 0; right: 0; bottom: -9px; height: 5px; background: #eee; border: 1px solid #999; }
.wall-hp div { height: 100%; background: var(--good); }
.wall-fall .prop-inner { transition: transform 0.6s ease-in; }

/* ================================================================ OVERLAYS */
.banner {
  position: absolute;
  top: 21%;
  left: 50%;
  translate: -50% 0;
  background: #111;
  color: #fff;
  font-weight: 900;
  font-size: clamp(18px, 3.2vw, 34px);
  letter-spacing: 0.04em;
  padding: 12px 26px;
  border-radius: 10px;
  text-align: center;
  max-width: calc(100vw - 32px);
  animation: bannerin 0.3s cubic-bezier(.3, 1.6, .5, 1);
  transition: opacity 0.5s, translate 0.5s;
}
.banner small { display: block; font-size: 0.5em; font-weight: 700; letter-spacing: 0.02em; opacity: 0.85; margin-top: 4px; }
.banner.warn { background: var(--bad); animation: bannerin 0.3s cubic-bezier(.3, 1.6, .5, 1), pulse 0.5s 0.3s infinite alternate; }
.banner.good { background: var(--good); }
.banner.plain { background: #fff; color: #111; border: 3px solid #111; }
.banner.low { top: auto; bottom: 22%; }
.banner.out { opacity: 0; translate: -50% -20px; }
@keyframes bannerin { from { scale: 0.4; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.72; } }
@keyframes pop { from { scale: 0.6; opacity: 0; } to { scale: 1; opacity: 1; } }

.toast {
  position: absolute;
  bottom: 70px;
  left: 50%;
  translate: -50% 0;
  background: #fff;
  border: 2.5px solid #111;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  max-width: min(460px, calc(100vw - 32px));
  text-align: center;
  animation: pop 0.2s;
  transition: opacity 0.5s;
  box-shadow: 0 4px 0 #111;
}
.toast.out { opacity: 0; }

.floater {
  position: absolute;
  font-weight: 800;
  font-size: 18px;
  pointer-events: none;
  translate: -50% -50%;
  animation: floatup 1.1s ease-out forwards;
  white-space: nowrap;
}
.floater.pow { font: 900 22px var(--hand); color: var(--bad); -webkit-text-stroke: 1px #111; animation: powup 0.9s ease-out forwards; }
.floater.good { color: var(--good); }
.floater.gold { color: var(--gold); }
.floater.grey { color: var(--muted); font-style: italic; }
@keyframes floatup { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-60px); } }
@keyframes powup { 0% { opacity: 0; transform: scale(0.3) rotate(-10deg); } 20% { opacity: 1; transform: scale(1.2) rotate(6deg); } 100% { opacity: 0; transform: scale(1) translateY(-30px) rotate(-4deg); } }

.popup {
  position: absolute;
  left: 50%;
  top: 40%;
  translate: -50% -50%;
  background: #fff;
  border: 3px solid #111;
  border-radius: 12px;
  box-shadow: 0 6px 0 #111;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: auto;
  animation: pop 0.2s;
  overflow: hidden;
}
.popup.placed { translate: 0 0; }
.popup-title { background: #111; color: #fff; font-weight: 800; padding: 6px 12px; font-size: 14px; letter-spacing: 0.04em; }
.popup-body { padding: 14px 16px 6px; font-size: 15px; line-height: 1.4; }
.popup-buttons { display: flex; gap: 8px; padding: 10px 14px 14px; justify-content: flex-end; flex-wrap: wrap; }
.popup-btn { border: 2px solid #111; background: #fff; border-radius: 7px; padding: 6px 14px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 #111; }
.popup-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #111; }
.popup-btn.primary { background: #111; color: #fff; }
.popup.system .popup-title { background: #2b5fb5; }
.popup .progress { height: 14px; border: 2px solid #111; border-radius: 4px; margin: 10px 0 4px; overflow: hidden; }
.popup .progress div { height: 100%; background: #2b5fb5; width: 0; }

.flash { position: fixed; inset: 0; background: #fff; z-index: 50; pointer-events: none; animation: flash 0.45s forwards; }
@keyframes flash { from { opacity: 0.95; } to { opacity: 0; } }

.fake-cursor { font-size: 26px; line-height: 1; }
body.no-cursor, body.no-cursor * { cursor: none !important; }
body.comic-sans #world, body.comic-sans #world * { font-family: var(--hand) !important; }
body.wingdings #clicks-value, body.wingdings .stat-value { font-family: Wingdings, Webdings, var(--font) !important; }

/* ================================================================ STATS / END */
.stats-grid { display: grid; grid-template-columns: auto auto; gap: 4px 22px; font-size: 15px; text-align: left; }
.stats-grid span:nth-child(even) { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.stats-grid .sep { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 4px 0; }

#end-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 16px;
  background: var(--bg);
  z-index: 60;
}
.end-title { font-size: clamp(30px, 6vw, 72px); font-weight: 900; }
.end-sub { font-size: clamp(22px, 3.5vw, 36px); font-weight: 800; letter-spacing: 0.2em; color: var(--bad); margin-bottom: 10px; }
#end-stats { display: grid; grid-template-columns: repeat(2, auto); gap: 4px 30px; font-size: 16px; text-align: left; margin-bottom: 8px; }
#end-stats .k { color: var(--muted); }
#end-stats .v { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
#end-quip { font-style: italic; color: var(--muted); max-width: 520px; min-height: 24px; margin-bottom: 8px; }
#end-screen > * { opacity: 0; animation: fadein 0.6s forwards; }
#end-screen > :nth-child(2) { animation-delay: 0.8s; }
#end-screen > :nth-child(3) { animation-delay: 1.6s; }
#end-screen > :nth-child(4) { animation-delay: 2.6s; }
#end-screen > :nth-child(5) { animation-delay: 3.2s; }
@keyframes fadein { to { opacity: 1; } }

/* ================================================================ SMALL SCREENS */
@media (max-width: 640px) {
  #hud { min-height: 120px; }
  #core-stats { gap: 14px; }
  .buy-btn { min-width: 140px; font-size: 11.5px; padding: 7px 8px; }
  .stat-value { font-size: 24px; }
  .card { flex-basis: 170px; }
  .tab { padding: 8px 8px; letter-spacing: 0.06em; }
  #corner { top: 8px; bottom: auto; }
}
@media (max-height: 700px) {
  #hud { min-height: 118px; padding-top: 8px; }
  #arena { min-height: 150px; }
  #shop-body { min-height: 100px; }
}
