/* Pop Goes the Bloon: jungle + wood theme. The whole app is a 1280x720 stage scaled by JS. */

:root {
  --wood-950: #1f1005;
  --wood-900: #2a1608;
  --wood-800: #3e2412;
  --wood-700: #5a3418;
  --wood-600: #7a4b25;
  --wood-500: #97602f;
  --wood-300: #c9955a;
  --parch-100: #fff6df;
  --parch-200: #f7e8c3;
  --parch-300: #ead29c;
  --ink: #2b1a10;
  --ink-soft: #6d4d2f;
  --gold: #ffd23f;
  --gold-deep: #e8a100;
  --green: #5fdc8a;
  --green-deep: #1f8f45;
  --red: #ff6464;
  --red-deep: #b3262b;
  --blue: #5ec8ff;
  --jungle-950: #061209;
  --jungle-900: #0d2415;
  --jungle-700: #1d4a2c;
  --jungle-500: #2e7d46;
  --display: "Arial Black", "Helvetica Neue", Impact, system-ui, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--jungle-950);
  font-family: var(--ui);
  color: var(--parch-100);
  -webkit-font-smoothing: antialiased;
}

button { font-family: var(--ui); }

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #15361f 0%, #061209 75%);
}

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  transform-origin: 0 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background: var(--jungle-900);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 20px 60px rgba(0, 0, 0, 0.6);
}

.layer { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ buttons */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  min-height: 44px;
  border: 3px solid #6b3f1c;
  border-radius: 15px;
  background: linear-gradient(#fff08a 0%, #ffd23f 45%, #f2a900 100%);
  color: #3b2208;
  font-family: var(--display);
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 5px 0 #6b3f1c, 0 9px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.07) saturate(1.05); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #6b3f1c, 0 3px 6px rgba(0, 0, 0, 0.3); }
.btn:disabled {
  filter: grayscale(0.85) brightness(0.9);
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 3px 0 #6b3f1c;
}
.btn.big { font-size: 24px; padding: 14px 40px; min-width: 290px; min-height: 58px; border-radius: 18px; }
.btn.go {
  min-width: 268px;
  height: 58px;
  font-size: 22px;
  padding: 0 22px;
  border-color: #17592b;
  background: linear-gradient(#b9ffc8 0%, #5fdc8a 40%, #22a852 100%);
  color: #06331a;
  box-shadow: 0 5px 0 #17592b, 0 9px 16px rgba(0, 0, 0, 0.35);
}
.btn.go.speed-2 { background: linear-gradient(#d9ffe6 0%, #7ff0a4 40%, #1fbf5a 100%); }
.btn.go.speed-3 { background: linear-gradient(#fff6b0 0%, #ffe066 40%, #ffa51f 100%); border-color: #7a4a00; box-shadow: 0 5px 0 #7a4a00, 0 9px 16px rgba(0, 0, 0, 0.35); color: #3b2208; }
.btn.go:active { box-shadow: 0 1px 0 #17592b, 0 3px 6px rgba(0, 0, 0, 0.3); }
.btn.danger {
  border-color: #6a1516;
  background: linear-gradient(#ff9a8a 0%, #ff5b5b 45%, #c5282d 100%);
  color: #fff;
  box-shadow: 0 5px 0 #6a1516, 0 9px 16px rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.btn.danger:active { box-shadow: 0 1px 0 #6a1516, 0 3px 6px rgba(0, 0, 0, 0.3); }
.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 246, 223, 0.35);
  color: var(--parch-100);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--ui);
  font-weight: 700;
  font-size: 15px;
}
.btn.ghost:active { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn.small { min-height: 30px; padding: 4px 12px; font-size: 13px; border-radius: 10px; border-width: 2px; box-shadow: 0 3px 0 #6b3f1c; }
.btn.small:active { box-shadow: 0 1px 0 #6b3f1c; }

.icon-btn {
  position: relative;
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 3px solid var(--wood-950);
  border-radius: 13px;
  background: linear-gradient(#a06a38, #6f4420);
  box-shadow: 0 4px 0 var(--wood-950), inset 0 1px 0 rgba(255, 230, 180, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease, box-shadow 0.08s ease;
}
.icon-btn svg { width: 26px; height: 26px; fill: var(--parch-100); stroke: var(--parch-100); }
.icon-btn svg .slash { stroke: #ff6464; opacity: 0; }
.icon-btn .slash { opacity: 0; }
.icon-btn.muted svg .slash { opacity: 1; }
.icon-btn.muted svg .wave { opacity: 0.25; }
.icon-btn:hover { filter: brightness(1.12); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-950); }
.icon-btn.active { background: linear-gradient(#ffe27a, #d69a1a); }
.icon-btn.active svg { fill: #3b2208; stroke: #3b2208; }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn:focus-visible, .chip:focus-visible, .toggle:focus-visible, .shop-tile:focus-visible, .ab-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.chip {
  height: 34px;
  padding: 0 14px;
  border: 3px solid var(--wood-950);
  border-radius: 999px;
  background: linear-gradient(#7d5030, #4e2f17);
  color: var(--parch-200);
  font-family: var(--display);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.6px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--wood-950);
}
.chip:hover { filter: brightness(1.1); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-950); }
.chip.on { background: linear-gradient(#b9ffc8, #3fc274); color: #06331a; }

.toggle {
  min-width: 74px;
  height: 36px;
  padding: 0 14px;
  border: 3px solid #6b3f1c;
  border-radius: 12px;
  background: #5b3a1e;
  color: var(--parch-200);
  font-family: var(--display);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 #3e2412;
}
.toggle[aria-pressed="true"] { background: linear-gradient(#b9ffc8, #3fc274); color: #06331a; border-color: #17592b; box-shadow: 0 3px 0 #17592b; }
.toggle:active { transform: translateY(2px); }

/* ------------------------------------------------------------------ top bar */

#topbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 2px, transparent 2px 9px),
    linear-gradient(#a8703d 0%, #7d4c24 55%, #5a3418 100%);
  border-bottom: 4px solid var(--wood-950);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 221, 160, 0.35);
  z-index: 3;
}
.tb-group { display: flex; align-items: center; gap: 12px; }
.tb-stats { gap: 10px; }
.tb-go { gap: 12px; }
.tb-right { gap: 8px; }

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 14px 0 10px;
  border-radius: 14px;
  background: rgba(31, 16, 5, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 220, 170, 0.25);
  min-width: 118px;
}
.stat .ico { width: 30px; height: 30px; flex: none; }
.ico-heart { fill: #ff5a6a; stroke: #7a0f1b; stroke-width: 1; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35)); }
.ico-coin circle { fill: #ffd23f; stroke: #a86b00; stroke-width: 1.4; }
.ico-coin path { stroke-linecap: round; }
.stat-val {
  font-family: var(--display);
  font-weight: 900;
  font-size: 26px;
  color: #fff8e1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
}
.stat-lives.low .stat-val { color: #ff9a8a; }
.stat-lives.low .ico-heart { animation: heartbeat 0.9s ease-in-out infinite; }
.stat-cash .stat-val { color: #ffe07a; }
.stat-cash.bump { animation: bump 0.32s ease-out; }
.stat-lives.bump { animation: bump 0.32s ease-out; }
.stat-round { gap: 12px; padding-right: 12px; min-width: 150px; }
.round-col { display: flex; flex-direction: column; line-height: 1; }
.round-label { font-family: var(--display); font-size: 10px; letter-spacing: 1.6px; color: #f3c98a; }
.round-line { display: flex; align-items: baseline; margin-top: 3px; }
.round-val { font-family: var(--display); font-weight: 900; font-size: 26px; color: #fff8e1; font-variant-numeric: tabular-nums; }
.round-max { font-family: var(--ui); font-weight: 700; font-size: 15px; color: #d6b48a; }
.tag.test {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 1px;
  padding: 3px 6px;
  border-radius: 6px;
  background: #ff7a45;
  color: #2a0d00;
  transform: rotate(-4deg);
  box-shadow: 0 2px 0 #7a2a00;
}

/* ------------------------------------------------------------------ playfield + sidebar */

#main {
  position: absolute;
  left: 0;
  top: 80px;
  width: 1280px;
  height: 640px;
  display: flex;
}

#field-wrap {
  position: relative;
  width: 960px;
  height: 640px;
  flex: none;
  overflow: hidden;
  background: #2d5e2a;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.45);
}
#field {
  position: absolute;
  left: 0;
  top: 0;
  width: 960px;
  height: 640px;
  display: block;
  cursor: default;
}
#field-wrap.placing #field { cursor: none; }
#field-wrap.pointer #field { cursor: pointer; }

.field-hint {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 11, 4, 0.72);
  border: 1px solid rgba(255, 220, 160, 0.25);
  color: #ffe9bf;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.field-hint.show { opacity: 1; }

/* Abilities bar: bottom-left of the playfield */
.abilities {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;
}
.abilities:empty { display: none; }
.ab-btn {
  position: relative;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 3px solid var(--wood-950);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a8703d, #5a3418 80%);
  box-shadow: 0 5px 0 var(--wood-950), 0 8px 14px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.08s ease, filter 0.15s ease;
  display: grid;
  place-items: center;
}
.ab-btn canvas { width: 46px; height: 46px; pointer-events: none; }
.ab-btn:hover:not(:disabled) { filter: brightness(1.12); }
.ab-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--wood-950); }
.ab-btn:disabled { cursor: default; }
.ab-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(12, 6, 2, 0.72) calc(var(--cd, 0) * 1deg), transparent 0);
  pointer-events: none;
}
.ab-key {
  position: absolute;
  left: -4px;
  top: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 8px;
  background: #fff3cf;
  color: var(--ink);
  font-family: var(--display);
  font-size: 11px;
  font-weight: 900;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 0 var(--wood-950);
  pointer-events: none;
}
.ab-name {
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 800;
  color: #fff3cf;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  pointer-events: none;
}
.ab-btn.ready { animation: readyGlow 1.2s ease-in-out infinite; border-color: #ffe27a; }
.ab-btn.active { border-color: var(--green); box-shadow: 0 5px 0 var(--wood-950), 0 0 0 3px rgba(95, 220, 138, 0.55), 0 0 18px rgba(95, 220, 138, 0.6); }
.ab-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 2px 3px #000;
  pointer-events: none;
}

/* Banners and toasts */
.banner {
  position: absolute;
  left: 0;
  top: 190px;
  width: 960px;
  text-align: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: 64px;
  color: #fff7d6;
  text-shadow: 0 4px 0 #6b3f1c, 0 0 0 #000, 0 8px 18px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
  pointer-events: none;
  opacity: 0;
}
.banner.show { animation: bannerIn 1.6s ease-out forwards; }
.banner.warn { color: #ffd1c9; text-shadow: 0 4px 0 #7a1010, 0 8px 18px rgba(0, 0, 0, 0.6); }
.banner.warn.show { animation: bannerWarn 2.2s ease-out forwards; }
.banner small {
  display: block;
  font-size: 18px;
  letter-spacing: 1px;
  color: #ffe9bf;
  text-shadow: 0 2px 4px #000;
  margin-top: 4px;
}

.toasts {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 520px;
  pointer-events: none;
}
.toast {
  padding: 8px 16px;
  border-radius: 12px;
  background: linear-gradient(#5a3418, #3e2412);
  border: 2px solid var(--wood-950);
  box-shadow: 0 4px 0 var(--wood-950), 0 8px 14px rgba(0, 0, 0, 0.4);
  color: #fff3cf;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  animation: toastIn 0.25s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 100%;
}
.toast.good { background: linear-gradient(#2f8f4f, #1d5c31); color: #eafff0; }
.toast.bad { background: linear-gradient(#b3262b, #7a1417); color: #ffe6e3; }
.toast.gold { background: linear-gradient(#f3b400, #b77d00); color: #2a1a00; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* New bloon intro card */
.intro-card {
  position: absolute;
  left: 50%;
  top: 92px;
  transform: translate(-50%, -12px) scale(0.96);
  width: 500px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px 12px 12px;
  border-radius: 18px;
  background: linear-gradient(#fff6df, #efd9a6);
  border: 4px solid var(--wood-800);
  box-shadow: 0 6px 0 var(--wood-950), 0 14px 26px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.intro-card.show { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.intro-card canvas { width: 150px; height: 130px; flex: none; background: radial-gradient(circle, #ffffff 0%, #f0dfb5 75%); border-radius: 12px; }
.intro-kicker { font-family: var(--display); font-size: 11px; letter-spacing: 2px; color: #b3262b; font-weight: 900; }
.intro-text h3 { margin: 2px 0 4px; font-family: var(--display); font-size: 17px; line-height: 1.15; color: var(--ink); }
.intro-text p { margin: 0; font-size: 13px; line-height: 1.38; color: #4a2f19; }
.intro-dismiss { margin-top: 6px; font-size: 11px; color: var(--ink-soft); font-weight: 700; }

/* Sidebar */
#sidebar {
  position: relative;
  width: 320px;
  height: 640px;
  flex: none;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0 2px, transparent 2px 12px),
    linear-gradient(#5b3a1f, #3a2412 70%, #2a1a0d);
  border-left: 4px solid var(--wood-950);
  box-shadow: inset 6px 0 14px rgba(0, 0, 0, 0.35);
}

.panel {
  border-radius: 16px;
  border: 3px solid var(--wood-900);
  background: linear-gradient(#fff6df, #efd9a6);
  box-shadow: 0 4px 0 var(--wood-950), inset 0 1px 0 #fff;
  color: var(--ink);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.panel h2 { margin: 0; font-family: var(--display); font-size: 17px; color: var(--ink); letter-spacing: 0.5px; }
.panel-sub { font-size: 11px; color: var(--ink-soft); font-weight: 700; }

.preview { padding: 7px 12px 8px; min-height: 92px; flex: none; }
.preview.compact { min-height: 0; padding: 7px 12px 8px; }
.preview.compact .preview-row { display: none; }
.preview.compact .preview-msg { margin-top: 3px; min-height: 0; }
.preview .mk-new { display: inline-block; margin-top: 6px; padding: 2px 8px; font-size: 10px; letter-spacing: 0.5px; border-radius: 6px; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; }
.preview-head h2 { font-size: 14px; }
.preview-total { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.preview-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.chip-b {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px 1px 1px;
  border-radius: 11px;
  background: rgba(107, 63, 28, 0.12);
  border: 1px solid rgba(107, 63, 28, 0.25);
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
}
.chip-b canvas { pointer-events: none; }
.chip-b .n { font-variant-numeric: tabular-nums; }
.chip-b .mk { font-size: 8px; font-weight: 900; padding: 0 3px; border-radius: 4px; color: #fff; letter-spacing: 0.2px; }
.mk-camo { background: #556b2f; }
.mk-regrow { background: #1e9e5a; }
.mk-fort { background: #5b6a78; }
.mk-new { background: #d32f2f; }
.preview-msg { font-size: 11px; color: var(--ink-soft); margin-top: 5px; font-style: italic; min-height: 1em; }

.shop { padding: 10px 10px 8px; flex: none; }
.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shop-tile {
  position: relative;
  height: 104px;
  padding: 3px 4px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  border: 2px solid #8a5a2c;
  border-radius: 13px;
  background: linear-gradient(#fffaf0, #f2dfb6);
  box-shadow: 0 3px 0 #8a5a2c, inset 0 -6px 10px rgba(120, 70, 20, 0.08);
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.1s ease;
}
.shop-tile:hover { transform: translateY(-2px); filter: brightness(1.04); }
.shop-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a5a2c; }
.shop-tile canvas { pointer-events: none; }
.shop-tile .key {
  position: absolute;
  left: 4px;
  top: 4px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--wood-800);
  color: #fff3cf;
  font-family: var(--display);
  font-size: 11px;
  line-height: 19px;
  text-align: center;
  font-weight: 900;
}
.shop-tile .nm { font-size: 11.5px; font-weight: 800; line-height: 1.1; text-align: center; color: var(--ink); }
.shop-tile .pr { font-family: var(--display); font-size: 12px; font-weight: 900; color: #7a4b00; }
.shop-tile.unaffordable { filter: grayscale(0.75) brightness(0.96); opacity: 0.62; }
.shop-tile.unaffordable .pr { color: #b3262b; }
.shop-tile.placing { border-color: #ffb300; box-shadow: 0 3px 0 #8a5a2c, 0 0 0 3px #ffd23f, 0 0 16px rgba(255, 210, 63, 0.8); }
.shop-tile:disabled { cursor: default; transform: none; }
.shop-foot { margin: 6px 0 0; font-size: 11px; color: var(--ink-soft); text-align: center; min-height: 1.2em; font-weight: 700; }

/* Upgrade panel */
.upgrade { flex: 1; min-height: 0; padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 9px; overflow: hidden; }
.up-head { display: flex; gap: 10px; align-items: center; }
.up-icon { width: 68px; height: 68px; flex: none; border-radius: 14px; background: radial-gradient(circle, #fffdf6 0%, #ecd5a0 80%); border: 2px solid #8a5a2c; }
.up-title { flex: 1; min-width: 0; }
.up-title h2 { font-size: 17px; line-height: 1.1; }
.up-sub { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-top: 3px; }
.up-role { font-size: 11px; color: #7a4b00; margin-top: 2px; font-weight: 700; }
.up-close { width: 30px; height: 30px; flex: none; padding: 0; font-size: 18px; border-radius: 10px; border: 2px solid #8a5a2c; background: #f8ebcb; color: var(--ink); font-weight: 900; cursor: pointer; box-shadow: 0 3px 0 #8a5a2c; line-height: 1; }
.up-close:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a5a2c; }
.up-target { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 11px; background: rgba(107, 63, 28, 0.1); font-size: 12px; font-weight: 800; color: var(--ink); }
.up-target .btn { min-width: 118px; min-height: 30px; padding: 3px 10px; font-size: 13px; }
.paths { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.path-card {
  position: relative;
  padding: 8px 10px 9px;
  border-radius: 13px;
  border: 2px solid #9b6a38;
  background: linear-gradient(#fffdf6, #f5e5c0);
  box-shadow: inset 0 1px 0 #fff;
  transition: filter 0.15s ease;
}
.path-card[data-path="a"] { border-color: #d19a1e; }
.path-card[data-path="b"] { border-color: #3c9ad6; }
.path-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.path-letter { font-family: var(--display); font-size: 12px; font-weight: 900; color: #fff; padding: 3px 8px; border-radius: 7px; }
.path-card[data-path="a"] .path-letter { background: #d19a1e; }
.path-card[data-path="b"] .path-letter { background: #3c9ad6; }
.pips { display: flex; gap: 4px; }
.pip { width: 16px; height: 16px; border-radius: 50%; background: rgba(43, 26, 16, 0.2); border: 2px solid rgba(43, 26, 16, 0.25); }
.path-card[data-path="a"] .pip.on { background: #ffc233; border-color: #8a5a00; box-shadow: 0 0 0 1px #fff3cc inset; }
.path-card[data-path="b"] .pip.on { background: #5ec8ff; border-color: #0b5c8f; box-shadow: 0 0 0 1px #e4f7ff inset; }
.next { margin-top: 7px; }
.next-name { font-family: var(--display); font-size: 13.5px; font-weight: 900; color: var(--ink); line-height: 1.15; }
.next-desc { font-size: 11.5px; line-height: 1.32; color: #4a2f19; margin-top: 3px; min-height: 2.6em; }
.next-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.cost { font-family: var(--display); font-weight: 900; font-size: 14px; color: #7a4b00; }
.cost.short { color: #b3262b; }
.buy { min-width: 96px; min-height: 30px; padding: 3px 12px; font-size: 13px; border-radius: 11px; border-width: 2px; box-shadow: 0 3px 0 #6b3f1c; }
.buy:active { box-shadow: 0 1px 0 #6b3f1c; }
.tag-ab { display: inline-block; font-size: 10px; font-weight: 900; color: #fff; background: #7b3fe4; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 2px; letter-spacing: 0.4px; }
.state-note { font-size: 12px; font-weight: 800; color: #6d4d2f; margin-top: 4px; }
.state-maxed { color: #1d7a3e; }
.state-locked { color: #7a4b00; }
.path-card.locked { filter: saturate(0.4) brightness(0.96); }
.path-card.locked .next-name { color: #7a6a58; }
.sell-row { margin-top: auto; }
.sell { width: 100%; min-height: 40px; font-size: 15px; background: linear-gradient(#ffb0a0, #ff7a6a 45%, #d8473a 100%); border-color: #7a1f16; box-shadow: 0 4px 0 #7a1f16; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.sell:active { box-shadow: 0 1px 0 #7a1f16; }
.sell kbd { font-family: var(--ui); font-size: 11px; background: rgba(0, 0, 0, 0.2); padding: 1px 6px; border-radius: 6px; margin-left: 6px; font-weight: 700; }
kbd.k { font-family: var(--display); font-size: 10px; background: var(--wood-800); color: #fff3cf; padding: 1px 5px; border-radius: 5px; }

/* ------------------------------------------------------------------ menus */

.screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.screen.active { opacity: 1; transform: none; pointer-events: auto; }
.menu-screen {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(120, 200, 110, 0.18), transparent 60%),
    radial-gradient(ellipse at 50% 120%, #1c4a28, #061209 75%),
    var(--jungle-900);
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
}
.menu-head { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.menu-head h2 { margin: 0; font-family: var(--display); font-size: 36px; color: #fff3cf; text-shadow: 0 4px 0 #2a1608, 0 8px 18px rgba(0, 0, 0, 0.5); letter-spacing: 1px; }
.menu-spacer { width: 120px; }
.back { min-width: 110px; }
.cards { flex: 1; display: flex; align-items: center; justify-content: center; gap: 30px; }

.card {
  position: relative;
  width: 360px;
  padding: 14px 14px 16px;
  border-radius: 22px;
  border: 5px solid var(--wood-800);
  background: linear-gradient(#fff6df, #ecd49c);
  box-shadow: 0 8px 0 var(--wood-950), 0 20px 30px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.card:hover { transform: translateY(-6px) rotate(-0.5deg); box-shadow: 0 13px 0 var(--wood-950), 0 26px 34px rgba(0, 0, 0, 0.5); filter: brightness(1.04); }
.card:active { transform: translateY(2px); box-shadow: 0 4px 0 var(--wood-950), 0 10px 16px rgba(0, 0, 0, 0.4); }
.card:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
.card .thumb { width: 100%; aspect-ratio: 3 / 2; border-radius: 14px; overflow: hidden; border: 3px solid var(--wood-700); display: block; background: #2d5e2a; }
.card .thumb canvas { width: 100%; height: 100%; display: block; }
.card .name { margin: 12px 4px 2px; font-family: var(--display); font-size: 22px; font-weight: 900; color: var(--ink); }
.card .tier { display: inline-block; margin: 0 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; color: #fff; letter-spacing: 0.4px; }
.tier-beginner { background: #3c9a4f; }
.tier-intermediate { background: #d68a1b; }
.tier-expert { background: #c0392b; }
.card .best { margin: 12px 2px 0; font-size: 13px; color: #5a3d21; font-weight: 700; }
.card .best-title { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.9px; color: var(--ink-soft); margin: 0 0 5px 2px; }
.card .best-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.card .best-grid > div { padding: 5px 0 4px; border-radius: 10px; background: rgba(107, 63, 28, 0.1); text-align: center; }
.card .best-grid span { display: block; font-size: 10.5px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.card .best-grid b { font-family: var(--display); font-size: 16px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.card .best b { color: var(--ink); font-variant-numeric: tabular-nums; }
.card .desc { margin: 8px 4px 0; font-size: 13px; line-height: 1.4; color: #4a2f19; }
.card.diff { width: 330px; }
.card.diff .name { font-size: 28px; margin-top: 8px; }
.card.diff .big-num { font-family: var(--display); font-size: 56px; font-weight: 900; text-align: center; margin: 6px 0 0; color: var(--wood-700); text-shadow: 0 3px 0 #ffe9b0; }
.card.diff .rules { margin: 8px 6px 4px; padding: 0; list-style: none; font-size: 13px; color: #4a2f19; font-weight: 700; }
.card.diff .rules li { padding: 4px 0; border-top: 1px dashed rgba(107, 63, 28, 0.35); display: flex; justify-content: space-between; }
.card.diff .rules li:first-child { border-top: 0; }
.card.diff .rules span:last-child { color: var(--ink); }
.card.diff .best { margin-top: 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card.diff .best span { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.card.diff .best b { font-size: 15px; }
.card.diff.easy .name { color: #1d7a3e; }
.card.diff.medium .name { color: #8a5a00; }
.card.diff.hard .name { color: #a52a2a; }

/* Title */
#title-canvas { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; display: block; }
.title-ui { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.title-ui > * { pointer-events: auto; }
.title-ui .title-spacer { height: 430px; flex: none; }
.title-buttons { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title-buttons .btn { min-width: 260px; }
.title-foot { margin: 22px 0 0; font-size: 14px; color: #f3e5bd; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7); font-weight: 700; letter-spacing: 0.3px; }

/* ------------------------------------------------------------------ overlays */

#overlays { pointer-events: none; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 14, 7, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 2;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.overlay.overlay-top { z-index: 4; }
.overlay .modal { transform: translateY(16px) scale(0.94); transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.overlay.open .modal { transform: none; }

.modal {
  position: relative;
  width: 520px;
  padding: 26px 30px 22px;
  border-radius: 24px;
  border: 6px solid var(--wood-800);
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.6), transparent 50%),
    linear-gradient(#fff6df, #ecd49c);
  box-shadow: 0 10px 0 var(--wood-950), 0 24px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
  color: var(--ink);
}
.modal-small { width: 420px; }
.modal h2 { margin: 4px 0 0; font-family: var(--display); font-size: 27px; line-height: 1.15; color: var(--ink); text-shadow: 0 2px 0 #fff; }
.modal-sub { margin: 6px 0 0; font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.modal-buttons { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; }
.modal-buttons .btn { min-width: 290px; min-height: 50px; }
.modal-buttons .btn.big { min-height: 52px; font-size: 21px; min-width: 300px; }
.modal-ribbon {
  position: absolute;
  left: 50%;
  top: -21px;
  transform: translateX(-50%);
  padding: 5px 22px;
  border-radius: 12px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: #fff;
  border: 3px solid var(--wood-950);
  box-shadow: 0 4px 0 var(--wood-950);
}
.modal-ribbon.victory { background: linear-gradient(#ffe27a, #e8a100); color: #3b2208; }
.modal-ribbon.defeat { background: linear-gradient(#ff8a80, #b3262b); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; margin-top: 14px; text-align: left; }
.stat-cell { padding: 6px 11px 5px; border-radius: 12px; background: rgba(107, 63, 28, 0.1); border: 1px solid rgba(107, 63, 28, 0.18); }
.stat-cell .k { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; color: var(--ink-soft); }
.stat-cell .v { font-family: var(--display); font-size: 19px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.3; }

.setting-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; text-align: left; }
.setting-label { width: 170px; font-size: 15px; font-weight: 800; color: var(--ink); }
.setting-spacer { flex: 1; }
.setting-row input[type="range"] { flex: 1; accent-color: #e8a100; height: 26px; }
.setting-note { margin: 16px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-soft); font-weight: 700; }

/* ------------------------------------------------------------------ tooltip */

.tooltip {
  position: absolute;
  z-index: 9;
  max-width: 290px;
  padding: 10px 13px;
  border-radius: 12px;
  background: rgba(33, 19, 8, 0.96);
  border: 2px solid #c58f4a;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  color: #fff3cf;
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.tooltip.show { opacity: 1; transform: none; }
.tooltip .tt-title { font-family: var(--display); font-size: 14px; font-weight: 900; color: #ffd23f; margin-bottom: 4px; }
.tooltip .tt-line { color: #f6e7c3; }
.tooltip .tt-dim { color: #cbb08a; font-size: 11.5px; margin-top: 4px; }

/* ------------------------------------------------------------------ animations */

@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }
@keyframes readyGlow { 0%, 100% { box-shadow: 0 5px 0 var(--wood-950), 0 0 0 0 rgba(255, 226, 122, 0.0), 0 0 10px rgba(255, 226, 122, 0.25); } 50% { box-shadow: 0 5px 0 var(--wood-950), 0 0 0 4px rgba(255, 226, 122, 0.45), 0 0 22px rgba(255, 226, 122, 0.85); } }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(1.6); }
  12% { opacity: 1; transform: scale(0.96); }
  20% { transform: scale(1.03); }
  28% { transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.96) translateY(-10px); }
}
@keyframes bannerWarn {
  0% { opacity: 0; transform: scale(1.8); }
  10% { opacity: 1; transform: scale(0.94); }
  16% { transform: scale(1.02) translateX(-4px); }
  22% { transform: scale(1) translateX(4px); }
  28% { transform: translateX(0); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes pulseSoft { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
.shake-hint { animation: pulseSoft 1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .screen, .overlay, .modal, .btn, .card { transition: none !important; }
}

/* ------------------------------------------------------------------ polish: go pulse, low lives, how to play, confetti */

.preview .mk-new { color: #fff; font-family: var(--display); font-weight: 900; }

.btn.go.ready { animation: goPulse 1.3s ease-in-out infinite; }
@keyframes goPulse {
  0%, 100% { box-shadow: 0 5px 0 #17592b, 0 9px 16px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(120, 255, 170, 0.0); }
  50% { box-shadow: 0 5px 0 #17592b, 0 9px 16px rgba(0, 0, 0, 0.35), 0 0 0 6px rgba(120, 255, 170, 0.35), 0 0 26px rgba(120, 255, 170, 0.8); }
}

.stat-lives.low { border-color: rgba(255, 60, 80, 0.7); animation: lowLivesGlow 1s ease-in-out infinite; }
.stat-lives.low .ico-heart { fill: #ff1f3d; animation: heartbeat 0.9s ease-in-out infinite; }
@keyframes lowLivesGlow {
  0%, 100% { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 0 rgba(255, 40, 60, 0); }
  50% { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 40, 60, 0.75); }
}

/* How to Play */
.howto-screen { }
.howto-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 330px 1fr; gap: 16px; margin-top: 8px; }
.howto-panel { min-height: 0; display: flex; flex-direction: column; padding: 12px 16px 12px; text-align: left; }
.howto-panel h2 { font-size: 19px; margin: 0 0 8px; }
.howto-controls .howto-dl { margin: 0; overflow: auto; min-height: 0; }
.howto-dl dt { font-family: var(--display); font-weight: 900; font-size: 12.5px; color: var(--ink); margin-top: 9px; }
.howto-dl dt:first-child { margin-top: 0; }
.howto-dl dd { margin: 2px 0 0; font-size: 12px; line-height: 1.36; color: #4a2f19; }
.howto-bloons { min-width: 0; }
.bl-scroll { flex: 1; min-height: 0; overflow: auto; border-radius: 10px; }
.bl-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.bl-table tbody tr td { height: 31px; }
.bl-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--ink-soft); padding: 4px 6px; background: #f8e7bd; border-bottom: 2px solid rgba(107, 63, 28, 0.35); }
.bl-table td { padding: 0 6px; border-bottom: 1px dashed rgba(107, 63, 28, 0.25); vertical-align: middle; color: var(--ink); }
.bl-table td.bl-icon { width: 38px; padding: 0 0 0 4px; }
.howto-icon { display: block; width: 30px; height: 30px; }
.bl-name { font-family: var(--display); font-weight: 900; font-size: 13px; white-space: nowrap; }
.bl-num { text-align: center; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bl-table th:nth-child(3), .bl-table th:nth-child(4) { text-align: center; }
.bl-imm { font-weight: 700; color: #8a1f1f; min-width: 120px; }
.bl-note { color: #4a2f19; line-height: 1.25; }
.bl-mods-title { font-family: var(--display); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin-top: 8px; }
.bl-mods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.bl-mod { display: flex; gap: 8px; align-items: flex-start; padding: 6px 7px; border-radius: 12px; background: rgba(107, 63, 28, 0.1); font-size: 11px; line-height: 1.3; color: #4a2f19; }
.bl-mod b { display: block; font-family: var(--display); font-size: 12.5px; color: var(--ink); margin-bottom: 1px; }
.bl-mod .howto-icon { width: 44px; height: 44px; flex: none; }

/* Victory confetti (canvas sits over the victory modal, never takes clicks) */
.confetti { position: absolute; left: 160px; top: 90px; width: 960px; height: 540px; pointer-events: none; opacity: 0; transition: opacity 0.4s ease; z-index: 0; }
#ov-victory .modal { z-index: 1; }
.modal-buttons .btn.big.wide { min-width: 340px; font-size: 20px; }
.confetti.on { opacity: 1; }

/* Centre banners sit below the intro card while it is open (no overlap). */
#field-wrap.intro-open .banner { top: 296px; }
