/* Balloon Blitz: warm wooden chrome, parchment panels, chunky buttons. */

:root {
  --wood-dark: #3b2414;
  --wood: #6b4423;
  --wood-light: #8a5a2b;
  --parch: #f7ecd2;
  --parch-dark: #e9d7aa;
  --ink: #2b1a0e;
  --ink-soft: #5a4026;
  --gold: #ffd23f;
  --go: #4fae3f;
  --go-dark: #2f7a24;
  --danger: #e0584d;
  --danger-dark: #9e2f27;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #14231a;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--ink);
}

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

.topbar {
  flex: 0 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: linear-gradient(#5a3820, var(--wood-dark));
  border-bottom: 3px solid #1f120a;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  color: #fff3d6;
  z-index: 3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-balloon {
  width: 22px;
  height: 28px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 35% 30%, #ffb4a8, #e8413c 55%, #8c1f19);
  position: relative;
  flex: 0 0 auto;
}
.brand-balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border: 3px solid transparent;
  border-top: 4px solid #5a4a3a;
  border-bottom: 0;
}

.brand-text {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-shadow: 0 2px 0 #1f120a;
  white-space: nowrap;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 230, 180, 0.22);
  white-space: nowrap;
}
.chip-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}
.chip-value {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.chip-sub {
  font-size: 13px;
  opacity: 0.75;
}
.chip-cash .chip-value { color: #b9f58b; }
.chip-lives .chip-value { color: #ffb0a6; }
.chip.bump { animation: bump 0.35s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.16); }
  100% { transform: scale(1); }
}
.chip.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.hud-next {
  font-size: 13px;
  line-height: 1.2;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}
.hud-next .tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  vertical-align: 1px;
}
.tag-lead { background: #6e7f8d; color: #fff; }
.tag-black { background: #2f3640; color: #fff; }
.tag-white { background: #f1f4f8; color: #222; }
.tag-camo { background: #5f7d3f; color: #fff; }
.tag-boss { background: #b5431a; color: #fff; }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---- icons (CSS shapes, no font dependency) ------------------------------------------------ */

.icon { display: inline-block; vertical-align: middle; }
.icon-heart {
  width: 16px; height: 14px; position: relative;
  transform: rotate(-45deg);
  background: #ff6b6b;
  border-radius: 3px 3px 0 0;
  margin-right: 2px;
}
.icon-heart::before, .icon-heart::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  background: #ff6b6b; border-radius: 50%;
}
.icon-heart::before { left: -8px; top: -8px; }
.icon-heart::after { left: 0; top: -8px; }
.icon-coin {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc93c 60%, #b77a10);
  border: 1.5px solid #7a500a;
  margin-right: 2px;
}
.icon-play {
  width: 0; height: 0;
  border-style: solid;
  border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent currentColor;
  margin-right: 8px;
}
.icon-pause {
  width: 12px; height: 14px;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 4px 100% no-repeat,
    linear-gradient(currentColor, currentColor) 8px 0 / 4px 100% no-repeat;
}
.icon-check { width: 12px; height: 12px; display: inline-block; }

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

.btn {
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: #fff8e6;
  background: linear-gradient(#a66d36, var(--wood-light));
  border: 2px solid #3a2310;
  border-bottom-width: 4px;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.06s, filter 0.12s, background 0.12s;
  user-select: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); transform: none; }
.btn-icon { padding: 7px 10px; }
.btn-go {
  background: linear-gradient(#7fd066, var(--go));
  border-color: #1f4d17;
  color: #f7ffee;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  min-width: 132px;
}
.btn-go:hover { background: linear-gradient(#8fdc74, #5fbd4c); }
.btn-go:disabled { background: linear-gradient(#8a9b84, #6f7f69); }
.btn-primary {
  background: linear-gradient(#7fd066, var(--go));
  border-color: #1f4d17;
  color: #f7ffee;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
.btn-danger {
  background: linear-gradient(#ef7b70, var(--danger));
  border-color: #5c1a15;
  color: #fff;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  border-color: #a98255;
  box-shadow: none;
}
.btn-small { font-size: 12px; padding: 4px 8px; border-bottom-width: 3px; min-width: 0; }
.btn-on { background: linear-gradient(#ffe27a, #f2b92a); color: #3a2300; border-color: #6d4b07; }

/* ---- stage --------------------------------------------------------------------------------- */

.main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 10px;
  padding: 10px;
}

.stage {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #14231a;
  box-shadow: inset 0 0 0 3px #1f120a, 0 8px 22px rgba(0, 0, 0, 0.4);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -8px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(30, 18, 8, 0.9);
  color: #fff4d8;
  font-weight: 800;
  font-size: 15px;
  border: 2px solid #ffb347;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  z-index: 2;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { border-color: #ff6b6b; }

.placing-note {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(20, 14, 6, 0.82);
  color: #fff4d8;
  font-size: 13px;
  font-weight: 700;
  max-width: 70%;
  z-index: 2;
}
.placing-note b { color: #ffd23f; }

.tooltip {
  position: absolute;
  pointer-events: none;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(24, 16, 8, 0.94);
  color: #fff4d8;
  font-size: 12.5px;
  line-height: 1.35;
  border: 2px solid #8a5a2b;
  z-index: 4;
  box-shadow: var(--shadow);
}
.tooltip strong { color: #ffd23f; }

/* ---- side panels --------------------------------------------------------------------------- */

.side {
  flex: 0 0 262px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.panel {
  background: var(--parch);
  border: 3px solid var(--wood);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  padding: 10px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.panel-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: var(--wood-dark);
}
.panel-hint { font-size: 11px; color: var(--ink-soft); }

.shop-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.shop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px 6px;
  border-radius: 10px;
  border: 2px solid #b08a5b;
  background: linear-gradient(#fffaf0, #f0e0bb);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: transform 0.08s, box-shadow 0.12s, border-color 0.12s;
  user-select: none;
}
.shop-card:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2); }
.shop-card[aria-pressed="true"] {
  border-color: #2f7a24;
  box-shadow: 0 0 0 3px #7fd066, 0 3px 8px rgba(0, 0, 0, 0.2);
  background: linear-gradient(#f2ffe6, #d9f2c6);
}
.shop-card.broke { opacity: 0.55; }
.shop-card img { width: 56px; height: 56px; image-rendering: auto; pointer-events: none; }
.shop-card { min-width: 0; }
.shop-card .card-name { font-size: 12px; font-weight: 800; text-align: center; line-height: 1.1; }
.shop-card .card-cost { font-size: 12px; font-weight: 900; color: #2f7a24; }
.shop-card.broke .card-cost { color: #b03a2e; }
.shop-card .card-key {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 10px;
  font-weight: 900;
  color: #6b4423;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  padding: 0 4px;
}

.shop-foot {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.35;
  min-height: 34px;
}

/* With a monkey selected, the shop shrinks to icons so the inspector fits without scrolling. */
.app.has-selection .shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.app.has-selection .shop-card { padding: 4px 2px; }
.app.has-selection .shop-card img { width: 38px; height: 38px; }
.app.has-selection .shop-card .card-name,
.app.has-selection .shop-card .card-cost { display: none; }
.app.has-selection .shop-card .card-key { top: 1px; left: 2px; font-size: 9px; }
.app.has-selection .shop-foot { display: none; }
.app.has-selection .panel-hint { display: none; }

/* ---- inspector ------------------------------------------------------------------------------ */

.inspector { display: flex; flex-direction: column; gap: 8px; }
.insp-head { display: flex; gap: 8px; align-items: center; }
.insp-head img { width: 54px; height: 54px; flex: 0 0 auto; }
.insp-title { min-width: 0; }
.insp-title h3 { margin: 0; font-size: 17px; font-weight: 900; color: var(--wood-dark); line-height: 1.1; }
.insp-title .insp-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.insp-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.35; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  background: rgba(107, 68, 35, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}
.stat-grid div { display: flex; justify-content: space-between; gap: 6px; }
.stat-grid span:first-child { color: var(--ink-soft); }
.stat-grid b { font-variant-numeric: tabular-nums; }
.stat-flags { grid-column: 1 / -1; color: #6b3b12; font-weight: 700; }

.target-row { display: flex; flex-wrap: wrap; gap: 4px; }
.target-row .btn { flex: 1 1 0; font-size: 12px; padding: 4px 6px; }

.paths { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.path {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid #c9a774;
}
.path.path-a { border-color: #e6a040; }
.path.path-b { border-color: #5aaee8; }
.path-name { font-size: 12px; font-weight: 900; }
.tiers { display: flex; gap: 3px; }
.tier-pip {
  flex: 1 1 0;
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.12);
}
.tier-pip.on { background: #e6a040; }
.path.path-b .tier-pip.on { background: #5aaee8; }
.tier-pip.gold { background: #ffd23f; box-shadow: 0 0 0 1px #9a6d00; }
.next-tier { font-size: 11px; color: var(--ink-soft); line-height: 1.2; min-height: 40px; }
.path .btn { font-size: 12px; padding: 4px 6px; white-space: normal; line-height: 1.15; }
.path { min-width: 0; }

.ability {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ability .btn { width: 100%; }
.ability-desc { font-size: 11.5px; color: var(--ink-soft); line-height: 1.3; }

.insp-foot { display: flex; gap: 8px; align-items: center; }
.insp-foot .btn { flex: 1 1 auto; }

.cooldown-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
}
.cooldown-bar > i { display: block; height: 100%; background: #f2b92a; width: 0; }

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 18, 12, 0.5);
  backdrop-filter: blur(2px);
  z-index: 10;
  padding: 16px;
  overflow: auto;
}

.card {
  width: min(880px, 100%);
  max-height: 100%;
  overflow: auto;
  background: linear-gradient(#fbf3dc, var(--parch));
  border: 4px solid var(--wood);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 3px rgba(255, 255, 255, 0.5);
  padding: 22px 26px;
  color: var(--ink);
}
.card.narrow { width: min(520px, 100%); }
.card h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 900;
  color: var(--wood-dark);
  text-shadow: 0 3px 0 #fff;
  letter-spacing: 0.5px;
}
.card h2 { margin: 6px 0 10px; font-size: 20px; color: var(--wood-dark); }
.card p { margin: 6px 0; line-height: 1.45; }
.card .lead-text { font-size: 15px; color: var(--ink-soft); }
.card .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.card .actions .btn { font-size: 16px; padding: 10px 18px; }

.map-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.map-card {
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 8px;
  border-radius: 12px;
  border: 3px solid #b08a5b;
  background: #fffaf0;
  cursor: pointer;
}
.map-card img { width: 100%; border-radius: 8px; display: block; aspect-ratio: 16 / 10; object-fit: cover; }
.map-card b { display: block; font-size: 16px; margin-top: 6px; }
.map-card span { font-size: 12.5px; color: var(--ink-soft); }
.map-card[aria-pressed="true"] { border-color: #2f7a24; box-shadow: 0 0 0 3px #7fd066; }

.diff-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.diff-row .btn { flex: 1 1 0; min-width: 110px; }
.diff-blurb { font-size: 13px; color: var(--ink-soft); margin-top: 6px; min-height: 20px; }

.stats-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 15px; }
.stats-table td { padding: 5px 4px; border-bottom: 1px dashed #c9a774; }
.stats-table td:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.guide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.guide-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.35; }
.guide-list img { width: 40px; height: 40px; flex: 0 0 auto; }
.guide-list b { color: var(--wood-dark); }
.keys { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; line-height: 1.3; }
.key-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; }
.key-cap { white-space: nowrap; }
kbd {
  font: 800 12px "Menlo", "Consolas", monospace;
  padding: 2px 7px;
  border-radius: 6px;
  background: #fff;
  border: 2px solid #b08a5b;
  border-bottom-width: 3px;
  color: var(--ink);
}

.hero-row { display: flex; gap: 16px; align-items: center; }
.hero-row .copy { flex: 1 1 auto; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pill {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(107, 68, 35, 0.12);
  color: var(--wood-dark);
}

.muted { color: var(--ink-soft); font-size: 13px; }
.best-line { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; }

.loading {
  color: #fff4d8;
  font-size: 18px;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .side { flex-basis: 230px; }
  .brand-text { font-size: 18px; }
  .btn { padding: 6px 9px; }
  .btn-go { min-width: 0; }
  .hud-next { display: none; }
}

@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px; }
  .hud { order: 3; width: 100%; }
  .main { flex-direction: column; }
  .side { flex: 0 0 auto; flex-direction: row; overflow: visible; }
  .shop { flex: 1 1 50%; }
  .inspector { flex: 1 1 50%; }
  .stage { flex: 1 1 60vh; min-height: 52vh; }
}

/* The top bar and shop are inert on the title screen; the attract mode plays behind the card. */
.app[data-screen="title"] .hud,
.app[data-screen="title"] .controls,
.app[data-screen="title"] .shop-grid,
.app[data-screen="title"] .shop-foot,
.app[data-screen="title"] .inspector {
  opacity: 0.4;
  pointer-events: none;
}

.app[data-screen="title"] #game { cursor: default; }

.btn.is-running .icon-play { opacity: 0.35; }

@media (prefers-reduced-motion: reduce) {
  .chip.bump, .chip.shake { animation: none; }
}
