/* POP TROOP — jungle-carpentry UI. Painted wood, rope and banana-yellow;
   circus red only where the enemy is involved (lives, selling, danger). */

:root {
  --bark: #4a2c17;
  --plank: #7b4a26;
  --plank-hi: #9a6234;
  --sawdust: #f3d9a4;
  --paper: #fff4d6;
  --canopy: #4fae3a;
  --canopy-dk: #2f7d22;
  --banana: #ffd23a;
  --circus: #e2412f;
  --sky: #59b7ff;
  --ink: #2a160b;
  --font: "Arial Rounded MT Bold", "Nunito", "Varela Round", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(80, 160, 60, 0.35) 0 120px, transparent 260px),
    radial-gradient(circle at 88% 82%, rgba(60, 140, 50, 0.3) 0 140px, transparent 300px),
    radial-gradient(circle at 50% 50%, #1f4a1f, #0e2610 75%);
  font-family: var(--font);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1600px;
  height: 900px;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  overflow: hidden;
}
#stage.booting { visibility: hidden; }

/* ------------------------------------------------------------ playfield */
#field {
  position: absolute;
  left: 0;
  top: 0;
  width: 1200px;
  height: 900px;
  overflow: hidden;
  background: #2a160b;
}
#game { display: block; width: 1200px; height: 900px; touch-action: none; }
#game.placing { cursor: none; }
#game.hovering { cursor: pointer; }

.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: none; }

/* painted wooden signs */
#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}
.sign {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 48px;
  padding: 0 16px 0 10px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, var(--plank-hi), var(--plank) 55%, #643b1d);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22), 0 4px 0 var(--ink), 0 6px 14px rgba(0, 0, 0, 0.35);
  font-size: 25px;
  color: var(--paper);
  text-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}
.sign b { font-weight: normal; min-width: 1.6em; display: inline-block; font-variant-numeric: tabular-nums; }
.sign i { font-style: normal; font-size: 16px; opacity: 0.75; }
#hudRound { font-size: 21px; }
.sign-ico { width: 30px; height: 30px; display: grid; place-items: center; }
.sign-ico svg { width: 30px; height: 30px; filter: drop-shadow(0 2px 0 var(--ink)); }
.sign-ico.heart svg { color: #ff5b4d; }
.sign-ico.coin svg { color: var(--banana); }
.sign-ico.flag svg { color: #7ddb53; }
.sign.bump { animation: bump 0.35s ease-out; }
.sign.hurt { animation: hurt 0.45s ease-out; }
@keyframes bump { 30% { transform: scale(1.08); } }
@keyframes hurt {
  20% { transform: translateX(-5px); background: linear-gradient(180deg, #c0392b, #8e2418); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
}

#hudRight {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}
.chip {
  height: 48px;
  min-width: 56px;
  padding: 0 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--plank-hi), var(--plank));
  color: var(--paper);
  font-size: 20px;
  text-shadow: 0 2px 0 var(--ink);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22), 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.1s;
}
.chip.icon { min-width: 48px; padding: 0; font-size: 26px; display: grid; place-items: center; }
.chip:hover { filter: brightness(1.12); }
.chip:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22), 0 1px 0 var(--ink); }
.chip[aria-pressed="true"] { background: linear-gradient(180deg, #7fd45c, var(--canopy-dk)); }
.chip.fast { background: linear-gradient(180deg, #ffe27a, #e0a800); color: var(--ink); text-shadow: none; }

:focus-visible { outline: 3px solid var(--banana); outline-offset: 2px; }

/* abilities */
#abilityBar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
}
.ability {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--banana) 55%, #c58f00);
  box-shadow: 0 4px 0 var(--ink), 0 6px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}
.ability img { width: 62px; height: 62px; margin-top: 2px; pointer-events: none; }
.ability .cd {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(30, 15, 5, 0.72) calc(var(--cd, 0) * 1turn), transparent 0);
  pointer-events: none;
}
.ability .key {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 6px;
  padding: 0 5px;
  border: 2px solid var(--ink);
}
.ability .nm {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  font-size: 10.5px;
  text-align: center;
  color: var(--paper);
  text-shadow: 0 1px 0 var(--ink), 0 -1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink);
}
.ability.ready { animation: glow 1.2s ease-in-out infinite; }
.ability:disabled { cursor: default; filter: saturate(0.6); }
@keyframes glow { 50% { box-shadow: 0 4px 0 var(--ink), 0 0 26px 6px rgba(255, 214, 60, 0.85); } }

/* round banner */
#banner {
  position: absolute;
  left: 50%;
  top: 150px;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
  opacity: 0;
}
#banner.show { animation: bannerIn 2.6s cubic-bezier(.2, .9, .3, 1.2) forwards; }
#banner.show.long { animation-duration: 5.2s; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -30px) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  18% { transform: translate(-50%, 0) scale(1); }
  85% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(0.96); }
}
.banner-title {
  font-size: 64px;
  color: var(--banana);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 10px 22px rgba(0, 0, 0, 0.5);
  line-height: 1;
  white-space: nowrap;
}
.banner-card {
  margin: 14px auto 0;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 600px;
  padding: 12px 18px;
  background: rgba(42, 22, 11, 0.9);
  border: 3px solid var(--banana);
  border-radius: 16px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.banner-card img { width: 56px; height: 56px; flex: none; }
.banner-card h3 { margin: 0 0 4px; font-size: 22px; color: var(--banana); font-weight: normal; }
.banner-card p { margin: 0; font-size: 15px; line-height: 1.35; color: var(--paper); }
#banner.boss .banner-title { color: #ff5b4d; font-size: 76px; }
#banner.boss .banner-card { border-color: #ff5b4d; }

#toasts {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 8px 16px;
  background: rgba(42, 22, 11, 0.9);
  border: 2px solid rgba(255, 210, 58, 0.8);
  border-radius: 12px;
  font-size: 17px;
  animation: toast 2.2s ease forwards;
  white-space: nowrap;
}
.toast.bad { border-color: #ff5b4d; }
@keyframes toast {
  0% { opacity: 0; transform: translateY(10px); }
  10% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* --------------------------------------------------------------- sidebar */
#sidebar {
  position: absolute;
  left: 1200px;
  top: 0;
  width: 400px;
  height: 900px;
  padding: 10px 16px 14px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 26px),
    repeating-linear-gradient(180deg, transparent 0 98px, rgba(30, 14, 5, 0.55) 98px 101px, transparent 101px 104px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 3px, transparent 3px 11px),
    linear-gradient(180deg, #8a5630, #6f4122);
  border-left: 3px solid var(--ink);
}
#sidebar::before {
  /* rope binding along the left edge */
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 12px;
  background: repeating-linear-gradient(160deg, #d8b679 0 7px, #a47e45 7px 11px, #6e5128 11px 12px);
  border-right: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
}

#brand { display: flex; flex-direction: column; align-items: center; gap: 0; }
#brandLogo { width: 360px; height: 70px; }
#mapLabel {
  margin-top: -4px;
  font-size: 15px;
  color: var(--sawdust);
  text-shadow: 0 2px 0 var(--ink);
}

#shop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.crate {
  position: relative;
  height: 128px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background:
    linear-gradient(90deg, transparent 0 5px, rgba(60, 30, 10, 0.35) 5px 7px, transparent 7px calc(100% - 7px), rgba(60, 30, 10, 0.35) calc(100% - 7px) calc(100% - 5px), transparent calc(100% - 5px)),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.08) 0 1px, transparent 1px 30px),
    linear-gradient(180deg, #e1ae74, #c48a52);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 4px 0 var(--ink);
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.12s;
}
.crate:hover { transform: translateY(-2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 6px 0 var(--ink); }
.crate:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 2px 0 var(--ink); }
.crate img { width: 76px; height: 76px; display: block; margin: 4px auto 0; pointer-events: none; filter: drop-shadow(0 3px 0 rgba(42, 22, 11, 0.35)); }
.crate .nm { display: block; font-size: 12.5px; line-height: 1; margin-top: 1px; white-space: nowrap; }
.crate .price {
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  padding: 2px 9px;
  background: var(--banana);
  border: 2px solid var(--ink);
  border-radius: 9px;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}
.crate .key {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 13px;
  color: #5b3417;
  opacity: 0.85;
}
.crate.poor { filter: saturate(0.25) brightness(0.8); }
.crate.poor .price { background: #d9cbb0; color: #8e2418; }
.crate.active { outline: 4px solid var(--banana); outline-offset: 1px; }
#shop { padding-bottom: 8px; }

/* selected-tower panel */
#panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
#panel[hidden] { display: none; }
.pnl-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(42, 22, 11, 0.45);
  border: 2px solid rgba(42, 22, 11, 0.9);
  border-radius: 14px;
}
.pnl-head img { width: 64px; height: 64px; flex: none; }
.pnl-head h2 { margin: 0; font-size: 22px; font-weight: normal; color: var(--banana); text-shadow: 0 2px 0 var(--ink); }
.pnl-head .meta { font-size: 13.5px; color: var(--sawdust); }
.pnl-close {
  margin-left: auto;
  align-self: flex-start;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: var(--plank-hi);
  color: var(--paper);
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.targeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 15px;
}
.targeting .tgt {
  display: flex;
  align-items: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}
.targeting .tgt button {
  border: 0;
  background: var(--sawdust);
  color: var(--ink);
  font-size: 18px;
  width: 34px;
  height: 32px;
  cursor: pointer;
}
.targeting .tgt span { min-width: 74px; text-align: center; font-size: 16px; }
.paths { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.path {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 244, 214, 0.1);
  border: 2px solid rgba(42, 22, 11, 0.85);
  border-radius: 12px;
}
.path h4 { margin: 0; font-size: 14px; font-weight: normal; color: var(--sawdust); }
.tiers { display: flex; gap: 4px; }
.tier {
  flex: 1;
  height: 30px;
  border-radius: 7px;
  border: 2px solid var(--ink);
  background: rgba(42, 22, 11, 0.5);
  display: grid;
  place-items: center;
  color: rgba(255, 244, 214, 0.35);
  font-size: 17px;
}
.tier.owned { background: linear-gradient(180deg, #8de06a, var(--canopy-dk)); color: var(--paper); }
.tier.owned.t3 { background: linear-gradient(180deg, #ffe27a, #d39b00); color: var(--ink); }
.tier.locked { background: repeating-linear-gradient(135deg, rgba(42, 22, 11, 0.7) 0 5px, rgba(80, 40, 20, 0.7) 5px 10px); }
.up {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 150px;
}
.up .up-name { display: flex; align-items: center; gap: 6px; font-size: 15.5px; color: var(--paper); }
.up .up-name .ico { width: 22px; height: 22px; color: var(--banana); }
.up p { margin: 0; font-size: 12.5px; line-height: 1.32; color: var(--sawdust); flex: 1; }
.buy {
  height: 40px;
  border: 3px solid var(--ink);
  border-radius: 11px;
  background: linear-gradient(180deg, #8de06a, var(--canopy-dk));
  color: var(--paper);
  font-size: 18px;
  text-shadow: 0 2px 0 var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.buy:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.buy.poor { background: linear-gradient(180deg, #a08a6a, #6e5a40); color: #ffc0b0; }
.buy:disabled { cursor: default; background: rgba(42, 22, 11, 0.6); color: rgba(255, 244, 214, 0.6); box-shadow: none; text-shadow: none; }
.buy .k {
  font-size: 11px;
  line-height: 1;
  padding: 2px 5px 3px;
  border: 1.5px solid rgba(42, 22, 11, 0.7);
  border-radius: 5px;
  background: rgba(255, 244, 214, 0.25);
  text-shadow: none;
  color: var(--paper);
}
.pnl-actions { display: flex; gap: 8px; margin-top: auto; }
.sell {
  flex: 1;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: linear-gradient(180deg, #f26b5a, #b8291b);
  color: var(--paper);
  font-size: 18px;
  text-shadow: 0 2px 0 var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.sell:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.withdraw {
  flex: 1;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe27a, #d39b00);
  color: var(--ink);
  font-size: 16px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.stats { font-size: 13px; color: var(--sawdust); display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 6px; }
.stats .good { color: #9cff7a; }
.stats .bad { color: #ffb0a0; }

/* next round preview */
#nextRound {
  margin-top: auto;
  padding: 9px 12px;
  background: rgba(42, 22, 11, 0.55);
  border: 2px solid var(--ink);
  border-radius: 14px;
  min-height: 92px;
}
#nextRound h3 { margin: 0 0 6px; font-size: 15px; font-weight: normal; color: var(--sawdust); display: flex; justify-content: space-between; }
.nr-list { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.nr-item { display: flex; align-items: center; gap: 2px; font-size: 15px; }
.nr-item img { width: 30px; height: 30px; }
.nr-warn {
  margin-top: 7px;
  padding: 5px 9px;
  border-radius: 9px;
  background: rgba(226, 65, 47, 0.25);
  border: 2px solid #ff7a64;
  font-size: 13px;
  line-height: 1.3;
  color: var(--paper);
}

/* the big round go button */
#goWrap { display: flex; align-items: center; gap: 14px; padding: 4px 4px 0; }
#btnGo {
  width: 104px;
  height: 104px;
  flex: none;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: radial-gradient(circle at 35% 28%, #b8f59a, #5cc243 45%, var(--canopy-dk));
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), 0 6px 0 var(--ink), 0 10px 20px rgba(0, 0, 0, 0.45);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.07s, box-shadow 0.07s;
}
#btnGo .ico { width: 54px; height: 54px; filter: drop-shadow(0 3px 0 var(--ink)); }
#btnGo:active { transform: translateY(4px); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), 0 2px 0 var(--ink); }
#btnGo.ready { animation: goPulse 1.4s ease-in-out infinite; }
#btnGo.running { background: radial-gradient(circle at 35% 28%, #fff1b8, var(--banana) 50%, #c58f00); color: var(--ink); }
#btnGo.running .ico { filter: none; }
@keyframes goPulse { 50% { box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), 0 6px 0 var(--ink), 0 0 30px 8px rgba(141, 224, 106, 0.6); } }
#goLabel { font-size: 18px; line-height: 1.25; color: var(--paper); text-shadow: 0 2px 0 var(--ink); }
#goLabel small { display: block; font-size: 13px; color: var(--sawdust); }

/* ---------------------------------------------------------------- tooltip */
#tooltip {
  position: absolute;
  z-index: 50;
  max-width: 300px;
  padding: 10px 13px;
  background: rgba(42, 22, 11, 0.95);
  border: 2px solid var(--banana);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--paper);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
#tooltip.show { opacity: 1; }
#tooltip h4 { margin: 0 0 3px; font-size: 18px; font-weight: normal; color: var(--banana); }
#tooltip .caps { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
#tooltip .cap { font-size: 12px; padding: 2px 7px; border-radius: 8px; background: rgba(255, 244, 214, 0.12); }
#tooltip .cap.yes { background: rgba(110, 210, 80, 0.3); }
#tooltip .cap.no { background: rgba(226, 65, 47, 0.3); }

/* ---------------------------------------------------------------- screens */
#screens { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(14, 26, 12, 0.62);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  animation: fadeIn 0.25s ease;
}
.screen.title { background: transparent; backdrop-filter: none; }
@keyframes fadeIn { from { opacity: 0; } }
.board {
  position: relative;
  min-width: 520px;
  max-width: 1100px;
  padding: 28px 36px 30px;
  background:
    repeating-linear-gradient(180deg, transparent 0 58px, rgba(30, 14, 5, 0.45) 58px 61px),
    linear-gradient(180deg, #91592f, #6f4122);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.18), 0 8px 0 var(--ink), 0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: boardIn 0.35s cubic-bezier(.2, .9, .3, 1.3);
}
@keyframes boardIn { from { transform: scale(0.85) translateY(20px); opacity: 0; } }
.board h1 {
  margin: 0 0 6px;
  font-size: 54px;
  font-weight: normal;
  color: var(--banana);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
}
.board h2 { margin: 0 0 14px; font-size: 22px; font-weight: normal; color: var(--sawdust); text-shadow: 0 2px 0 var(--ink); }
.board p { font-size: 17px; line-height: 1.45; color: var(--paper); margin: 8px auto; max-width: 62ch; }
.btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.btn {
  min-width: 170px;
  height: 58px;
  padding: 0 24px;
  border: 4px solid var(--ink);
  border-radius: 16px;
  background: linear-gradient(180deg, #8de06a, var(--canopy-dk));
  color: var(--paper);
  font-size: 22px;
  text-shadow: 0 2px 0 var(--ink);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), 0 5px 0 var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.07s, box-shadow 0.07s, filter 0.1s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), 0 1px 0 var(--ink); }
.btn.alt { background: linear-gradient(180deg, var(--plank-hi), #5e3519); }
.btn.gold { background: linear-gradient(180deg, #ffe27a, #d39b00); color: var(--ink); text-shadow: none; }
.btn.red { background: linear-gradient(180deg, #f26b5a, #b8291b); }
.btn.small { min-width: 0; height: 44px; font-size: 17px; padding: 0 16px; border-width: 3px; }
.btn .ico { width: 26px; height: 26px; }

/* title */
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#titleLogo { width: 900px; height: 260px; }
.tagline { font-size: 24px; color: var(--paper); text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(0, 0, 0, 0.6); margin: -6px 0 18px; }
.continue-note { font-size: 15px; color: var(--sawdust); margin-top: 12px; text-shadow: 0 2px 0 var(--ink); }

/* map select */
.maps { display: flex; gap: 22px; justify-content: center; margin-top: 8px; }
.mapcard {
  width: 300px;
  padding: 12px;
  background: rgba(42, 22, 11, 0.55);
  border: 3px solid var(--ink);
  border-radius: 18px;
  text-align: left;
}
.mapcard .thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  border: 3px solid var(--ink);
  display: block;
  background: #333;
}
.mapcard h3 { margin: 10px 0 2px; font-size: 24px; font-weight: normal; color: var(--banana); text-shadow: 0 2px 0 var(--ink); }
.mapcard .lvl { font-size: 14px; color: var(--sawdust); }
.mapcard p { font-size: 14px; margin: 6px 0 10px; line-height: 1.35; min-height: 3.9em; }
.diffs { display: flex; gap: 6px; }
.diffs .btn { flex: 1; min-width: 0; height: 48px; font-size: 16px; padding: 0 6px; flex-direction: column; gap: 0; line-height: 1.05; }
.diffs .btn small { font-size: 11px; opacity: 0.9; }
.medal { color: var(--banana); }
.medal.flawless { color: #fff; filter: drop-shadow(0 0 4px #ffd23a); }

/* stats on win/lose */
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 8px 28px;
  justify-content: center;
  margin: 16px auto 4px;
  font-size: 15px;
  color: var(--sawdust);
}
.result-stats b { display: block; font-size: 28px; font-weight: normal; color: var(--paper); text-shadow: 0 2px 0 var(--ink); }

/* settings */
.setting { display: flex; align-items: center; gap: 16px; justify-content: space-between; margin: 12px 0; font-size: 19px; }
.setting input[type="range"] { width: 260px; accent-color: var(--banana); }
.setting label { cursor: pointer; }
.toggle { width: 26px; height: 26px; accent-color: var(--canopy); }

/* field guide */
.guide { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-height: 600px; overflow-y: auto; padding: 4px 6px; text-align: left; }
.guide.wide { grid-template-columns: repeat(3, 1fr); }
.gcard {
  padding: 8px 10px;
  background: rgba(42, 22, 11, 0.5);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.28;
}
.gcard header { display: flex; align-items: center; gap: 6px; }
.gcard img { width: 38px; height: 38px; }
.gcard h4 { margin: 0; font-size: 16px; font-weight: normal; color: var(--banana); }
.gcard .imm { margin-top: 4px; color: #ffb0a0; }
.gcard .ctr { margin-top: 4px; color: #b9f59a; }
.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.tabs .btn[aria-pressed="true"] { background: linear-gradient(180deg, #ffe27a, #d39b00); color: var(--ink); text-shadow: none; }
.keys { columns: 2; text-align: left; font-size: 15px; line-height: 1.7; max-width: 720px; margin: 0 auto; }
.keys kbd {
  display: inline-block;
  min-width: 28px;
  padding: 0 6px;
  margin-right: 6px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  font-family: inherit;
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* attract mode behind the title: centered demo field, no sidebar */
#stage.menu {
  background:
    radial-gradient(circle at 8% 20%, rgba(90, 170, 70, 0.45) 0 90px, transparent 200px),
    radial-gradient(circle at 92% 75%, rgba(90, 170, 70, 0.4) 0 110px, transparent 230px),
    linear-gradient(180deg, #1d4a1d, #0f2a11);
}
#stage.menu #sidebar { display: none; }
#stage.menu #field { left: 200px; box-shadow: 0 0 0 4px var(--ink), 0 20px 60px rgba(0, 0, 0, 0.6); }
#stage.menu #hud, #stage.menu #hudRight, #stage.menu #abilityBar { display: none; }
.screen.title { background: radial-gradient(ellipse at 50% 45%, rgba(10, 20, 8, 0.15), rgba(10, 20, 8, 0.65)); }

/* the hidden attribute must win over the display rules above */
#shop[hidden], #panel[hidden] { display: none !important; }

/* rotating tips sign in the sidebar's free space */
#tips {
  margin-top: 6px;
  padding: 10px 12px;
  border: 2px dashed rgba(243, 217, 164, 0.45);
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--sawdust);
}
#tips b { color: var(--banana); font-weight: normal; }
#shop[hidden] + #tips { display: none; }
