@import url("https://fonts.googleapis.com/css2?family=Bungee&family=Press+Start+2P&display=swap");

:root {
  --sky-top: #98d8ff;
  --sky-bottom: #f7f1bd;
  --grass-top: #86cc5f;
  --grass-mid: #5ea947;
  --grass-dark: #2c6f2d;
  --yard-line: rgba(255, 255, 255, 0.22);
  --panel: rgba(13, 45, 24, 0.82);
  --panel-strong: rgba(10, 34, 18, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.1);
  --text-main: #f8ffe8;
  --text-muted: #d7f0bf;
  --text-dark: #153221;
  --gold: #ffd44d;
  --orange: #ff974f;
  --teal: #8cf4df;
  --rose: #ff7676;
  --shadow: 0 24px 60px rgba(5, 20, 10, 0.32);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --border-soft: 1px solid rgba(255, 255, 255, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text-main);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 24%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 44%, var(--grass-top) 44.5%, var(--grass-mid) 68%, var(--grass-dark) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 18%, rgba(255, 255, 255, 0.35), transparent 18%),
    radial-gradient(circle at 85% 14%, rgba(255, 215, 91, 0.18), transparent 24%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: auto, auto, 42px 42px, 42px 42px;
  pointer-events: none;
  z-index: 0;
}

.skyline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sun-glow {
  position: absolute;
  top: 40px;
  right: 110px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 243, 160, 0.95) 0%, rgba(255, 205, 77, 0.7) 42%, rgba(255, 205, 77, 0) 72%);
  animation: pulseSun 4s ease-in-out infinite;
}

.cloud {
  position: absolute;
  width: 180px;
  height: 64px;
  border-radius: 64px;
  background: rgba(255, 255, 255, 0.86);
  filter: blur(1px);
  opacity: 0.9;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 78px;
  height: 78px;
  top: -26px;
  left: 22px;
}

.cloud::after {
  width: 88px;
  height: 88px;
  top: -34px;
  right: 18px;
}

.cloud-one {
  top: 90px;
  left: 10%;
  animation: cloudFloat 26s linear infinite;
}

.cloud-two {
  top: 150px;
  left: 58%;
  transform: scale(0.78);
  animation: cloudFloat 34s linear infinite reverse;
}

.house-silhouette {
  position: absolute;
  bottom: 18vh;
  left: 7vw;
  width: 190px;
  filter: drop-shadow(0 24px 26px rgba(9, 25, 16, 0.18));
}

.house-asset {
  display: block;
  width: 100%;
  height: auto;
}

.house-asset-skyline {
  opacity: 0.96;
}

.ambient-swarm {
  position: absolute;
  inset: 0;
}

.ambient-mosquito {
  position: absolute;
  width: 72px;
  height: 62px;
  opacity: 0.72;
}

.drift-a {
  top: 23%;
  right: 16%;
  animation: driftMosquitoA 10s ease-in-out infinite;
}

.drift-b {
  top: 34%;
  left: 24%;
  animation: driftMosquitoB 12s ease-in-out infinite;
}

.drift-c {
  top: 54%;
  right: 31%;
  animation: driftMosquitoC 8s ease-in-out infinite;
}

.screen-shell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100vw - 40px));
  margin: 24px auto;
  padding: 22px;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(20, 74, 40, 0.48), rgba(4, 17, 9, 0.62));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform 220ms ease, filter 220ms ease, opacity 220ms ease;
}

body.phase-menu .board {
  filter: blur(7px) saturate(0.85) brightness(0.74);
  pointer-events: none;
}

/* While the start-game modal is open, hide the backdrop house, sun, and
   mosquitoes (clouds stay) and lock background scrolling. */
body.phase-menu {
  overflow: hidden;
}

body.phase-menu .sun-glow,
body.phase-menu .house-silhouette,
body.phase-menu .ambient-swarm,
body.phase-menu .cloud {
  opacity: 0;
  visibility: hidden;
}

.top-hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.hud-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  border: var(--border-soft);
}

.hud-card-wide {
  min-width: 0;
}

.hud-label,
.eyebrow,
.note-kicker {
  display: inline-block;
  margin: 0 0 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-value {
  display: block;
  font-size: 1.12rem;
  color: var(--text-main);
}

.meter-track {
  height: 12px;
  overflow: hidden;
  margin: 8px 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--gold), #fff8a8);
  transition: width 220ms ease;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
  gap: 18px;
}

.side-panel,
.battle-panel {
  min-width: 0;
  padding: 20px;
  border-radius: var(--radius-xl);
  border: var(--border-soft);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-strong) 100%);
}

.panel-header h1,
.menu-card h2 {
  margin: 0 0 10px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 0.94;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-copy,
.menu-subtitle,
.wave-copy,
.note-card p,
.phase-list,
.callout-bar p,
.tool-card-copy,
.empty-copy {
  margin: 0;
  line-height: 1.45;
  color: rgba(248, 255, 232, 0.86);
}

.toolbox-panel,
.phase-panel {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: var(--border-soft);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(140, 244, 223, 0.16);
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 700;
}

.toolbelt-list {
  display: grid;
  gap: 10px;
}

.tool-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 27, 14, 0.58);
  transition: transform 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.26);
}

.tool-card.is-locked {
  opacity: 0.68;
}

.tool-card.is-unaffordable:not(.is-locked) {
  border-color: rgba(255, 118, 118, 0.55);
}

.tool-card.is-owned {
  border-color: rgba(255, 212, 77, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255, 212, 77, 0.18);
}

.tool-card-icon {
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  font-size: 1.6rem;
}

.tool-card-title {
  margin: 0 0 4px;
  font-size: 1rem;
}

.tool-card-meta,
.tool-card-copy {
  font-size: 0.9rem;
}

.tool-card-meta {
  margin: 0 0 6px;
  color: var(--text-muted);
}

.tool-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tool-badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
}

.tool-badge.locked {
  background: rgba(255, 151, 79, 0.18);
  color: #ffd5b1;
}

.tool-badge.ready {
  background: rgba(140, 244, 223, 0.16);
  color: var(--teal);
}

.tool-badge.warning {
  background: rgba(255, 118, 118, 0.18);
  color: #ffd0d0;
}

.phase-list {
  padding-left: 20px;
}

.phase-list li + li {
  margin-top: 10px;
}

.battle-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.battle-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.round-banner {
  margin: 0;
  max-width: 620px;
  font-size: clamp(1.3rem, 2vw, 2rem);
  line-height: 1.08;
}

.wave-preview {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  min-width: 290px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: var(--border-soft);
}

.wave-icon {
  display: grid;
  place-items: center;
}

.wave-icon svg,
.brand-mark svg,
.ambient-mosquito svg {
  width: 100%;
  height: auto;
}

.brand-mark {
  width: 82px;
  height: 82px;
  flex: 0 0 auto;
}

.wave-count {
  display: block;
  font-size: 1.2rem;
}

.ghost-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease, background 180ms ease, color 180ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.primary-button {
  color: var(--text-dark);
  background: linear-gradient(180deg, #ffe57a, #ffc73e);
}

.secondary-button {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.ghost-button {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.danger-button {
  color: #fff2f2;
  background: rgba(255, 118, 118, 0.24);
  border: 1px solid rgba(255, 118, 118, 0.2);
}

/* ===================================================================
   Gameplay board — full-width PvZ-style lawn (phase-preview)
   =================================================================== */
.board {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100vw;
  min-height: 100vh;
}

/* --- Top seed bar --------------------------------------------------- */
.seed-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #b9824a 0%, #9a6433 100%);
  border-bottom: 4px solid #5e3b1e;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18);
}

.sun-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  min-width: 92px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff7d6, #f3e2a8);
  border: 3px solid #7a5a2a;
  color: #5a3f12;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.82rem;
}

/* Gem icon — used everywhere gems are shown (seed bar, tool modal, leaderboard) */
.gem-icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.2em;
  display: inline-block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.gem-icon-lg {
  width: 26px;
  height: 26px;
  vertical-align: middle;
}

.cost-dd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.seed-tray {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.seed-packet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.seed-packet-main {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 62px;
  padding: 0;
  border: 3px solid #6e4c2b;
  border-radius: 8px;
  background: linear-gradient(180deg, #f0d7a8, #d9b277);
  box-shadow: inset 0 0 0 2px rgba(255, 247, 221, 0.3);
  font-size: 1.7rem;
  cursor: pointer;
  transition: transform 120ms steps(2), box-shadow 120ms ease;
}

.seed-packet-main:hover {
  transform: translateY(1px);
}

.seed-packet.is-selected .seed-packet-main {
  box-shadow: 0 0 0 3px #ffe14d, inset 0 0 0 2px rgba(255, 247, 221, 0.3);
}

.seed-packet.is-locked .seed-packet-main {
  filter: grayscale(0.7) brightness(0.82);
  cursor: not-allowed;
}

.seed-packet.is-unaffordable .seed-packet-main {
  opacity: 0.72;
}

.seed-packet.is-maxed .seed-packet-main {
  opacity: 0.72;
  cursor: not-allowed;
}

.seed-packet-lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  background: rgba(20, 12, 4, 0.32);
  border-radius: 5px;
}

/* Clear "can't afford" overlay (more obvious than just dimming) */
.seed-packet-na {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: rgba(120, 18, 12, 0.4);
  border-radius: 5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Hover cost tooltip — sits just below the packet (the toolbelt hugs the
   top edge, so a popup above would be clipped off-screen). */
.seed-cost-tip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 2px solid #6e4c2b;
  background: #2b1c0e;
  color: #ffe9b8;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.5rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.seed-cost-tip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #6e4c2b;
}

.seed-packet:hover .seed-cost-tip,
.seed-packet:focus-within .seed-cost-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.seed-packet.is-unaffordable .seed-cost-tip {
  color: #ffd2cb;
  border-color: #c23a22;
}

.seed-packet.is-unaffordable .seed-cost-tip::before {
  border-bottom-color: #c23a22;
}

.seed-packet.is-maxed .seed-cost-tip {
  color: #ffe08a;
  border-color: #c98a2b;
}

.seed-packet.is-maxed .seed-cost-tip::before {
  border-bottom-color: #c98a2b;
}

.seed-info {
  margin-top: 3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid #6e4c2b;
  border-radius: 50%;
  background: #f3e2a8;
  color: #5a3f12;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.5rem;
  line-height: 1;
  cursor: pointer;
}

.seed-info:hover,
.seed-info:focus-visible {
  background: #fff3c8;
}

.seed-shovel {
  display: grid;
  place-items: center;
  width: 58px;
  height: 62px;
  border: 3px solid #6e4c2b;
  border-radius: 8px;
  background: linear-gradient(180deg, #cdd3d8, #a9b0b6);
  font-size: 1.5rem;
  cursor: pointer;
}

.seed-shovel[aria-pressed="true"] {
  box-shadow: 0 0 0 3px #ffe14d;
}

.seed-bar-spacer {
  flex: 1;
}

.board-menu-btn {
  padding: 11px 22px;
  border: 3px solid #69472b;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe598, #ffc55a);
  color: #3a2412;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.7rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #8f643c;
  transition: transform 120ms steps(2), box-shadow 120ms steps(2);
}

.board-menu-btn:hover,
.board-menu-btn:focus-visible {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #8f643c;
}

/* --- Lawn ----------------------------------------------------------- */
.lawn {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: linear-gradient(180deg, #7ec7f5 0%, #aee3ff 9%, #9ad36a 9%, #7cbe50 55%, #67ad45 100%);
}

.lawn-fence {
  position: absolute;
  top: 5.5%;
  left: 0;
  right: 0;
  height: 30px;
  background: repeating-linear-gradient(90deg, #eef1ee 0 22px, #d7ddd6 22px 27px);
  border-top: 3px solid #cfd5ce;
  border-bottom: 4px solid #b3bbb0;
  opacity: 0.85;
}

.lawn-house {
  position: absolute;
  bottom: 8%;
  width: 15%;
  min-width: 140px;
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.22));
}

.lawn-house img {
  width: 100%;
  height: auto;
}

.lawn-hedge {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 7%;
  min-width: 56px;
  background:
    repeating-linear-gradient(135deg, #43913c 0 10px, #387f31 10px 20px),
    #3c853a;
  border-left: 4px solid #2c6b2a;
}

.lawn-field {
  position: absolute;
  top: 15%;
  bottom: 8%;
  left: 15%;
  right: 9%;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
}

.mower-column {
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  align-items: center;
  justify-items: center;
}

.mower-img {
  display: block;
  width: clamp(34px, 4vw, 50px);
  height: auto;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.28));
}

.yard-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.16);
}

.yard-cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  font-size: clamp(1.3rem, 2.3vw, 2.4rem);
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.yard-cell.lane-a {
  background: rgba(150, 206, 108, 0.5);
}

.yard-cell.lane-b {
  background: rgba(120, 184, 86, 0.5);
}

/* ── Default (no active mode): placed tools can be grabbed to move ──── */
.board:not(.moving):not(.placing):not(.shovel-active) .yard-cell.has-tool {
  cursor: grab;
}

.board:not(.moving):not(.placing):not(.shovel-active) .yard-cell.has-tool:hover {
  box-shadow: inset 0 0 0 3px rgba(120, 220, 255, 0.9);
}

.board:not(.moving):not(.placing):not(.shovel-active) .yard-cell.has-tool:hover::after {
  content: "✥ Move";
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(18, 38, 22, 0.92);
  color: #d6f0ff;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.42rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* ── Place mode: empty plots glow green, occupied plots are blocked ── */
.board.placing .yard-cell:not(.has-tool) {
  cursor: copy;
}

.board.placing .yard-cell:not(.has-tool):hover {
  background: rgba(120, 235, 130, 0.3);
  box-shadow: inset 0 0 0 3px rgba(86, 214, 104, 0.95);
}

.board.placing .yard-cell.has-tool {
  cursor: not-allowed;
}

.board.placing .yard-cell.has-tool:hover {
  background: rgba(255, 110, 110, 0.18);
  box-shadow: inset 0 0 0 3px rgba(255, 110, 110, 0.7);
}

/* ── Move mode: held tool lifts + glows gold; empty plots glow green ── */
.board.moving {
  cursor: grabbing;
}

.board.moving .yard-cell:not(.has-tool) {
  cursor: copy;
}

.board.moving .yard-cell:not(.has-tool):hover {
  background: rgba(120, 235, 130, 0.3);
  box-shadow: inset 0 0 0 3px rgba(86, 214, 104, 0.95);
}

.board.moving .yard-cell.has-tool:not(.is-held) {
  cursor: not-allowed;
}

.yard-cell.is-held {
  box-shadow: inset 0 0 0 3px #ffe14d;
  z-index: 2;
}

.yard-cell.is-held .cell-tool {
  animation: heldLift 0.7s ease-in-out infinite;
}

@keyframes heldLift {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.07); }
}

/* ── Dig mode: occupied plots show a red "dig up" highlight ─────────── */
.board.shovel-active .yard-cell.has-tool {
  cursor: pointer;
}

.board.shovel-active .yard-cell.has-tool:hover {
  background: rgba(255, 90, 90, 0.2);
  box-shadow: inset 0 0 0 3px rgba(255, 96, 96, 0.92);
}

.board.shovel-active .yard-cell.has-tool:hover::after {
  content: "🪏 Dig up";
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(60, 16, 12, 0.92);
  color: #ffd8d2;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.42rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* Mode hint pill — tells the player what action mode they're in. */
.board-hint {
  position: absolute;
  bottom: 1.5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  max-width: 94%;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 40, 24, 0.92);
  border: 2px solid rgba(255, 226, 120, 0.55);
  color: #fff;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.56rem;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

.cell-tool {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.cell-tool-icon {
  position: relative;
  font-size: 1em;
  line-height: 1;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.25));
  animation: toolBob 2.4s ease-in-out infinite;
}

.tool-glyph {
  display: inline-block;
}

.cell-health {
  width: 62%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  pointer-events: none;
}

.cell-health-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #ffd24d, #7be06a);
}

.lawn-banner {
  position: absolute;
  top: 1.5%;
  left: 15%;
  right: 9%;
  margin: 0;
  text-align: center;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.68rem;
  line-height: 1.5;
  color: #ffffff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* --- Bottom status bar ---------------------------------------------- */
.board-status {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 9px 16px;
  background: linear-gradient(180deg, #3a6b2e, #274d20);
  border-top: 4px solid #1c3a16;
  color: #eaffd8;
}

.status-cluster {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-chip strong {
  color: #ffe14d;
}

.status-health {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  flex: 1;
}

.status-health-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #cdeeb0;
  white-space: nowrap;
}

.status-health .meter-track {
  flex: 1;
  margin: 0;
}

.status-wave {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.status-wave strong {
  color: #ffd24d;
}

.status-wave-icon {
  width: 42px;
  height: 36px;
}

.status-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-progress-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #cdeeb0;
}

.level-progress {
  width: 160px;
  height: 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.level-progress-fill {
  width: 8%;
  height: 100%;
  background: linear-gradient(90deg, #ff974f, #ffd44d);
}

/* --- Tool info modal (reuses .how-to-modal / .how-to-panel) --------- */
.tool-info-panel {
  width: min(420px, 100%);
  text-align: left;
}

.tool-info-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.tool-info-icon {
  font-size: 2.4rem;
}

.tool-info-head h3 {
  margin: 0;
}

.tool-info-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 14px;
}

.tool-info-stats div {
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(110, 76, 43, 0.12);
  text-align: center;
}

.tool-info-stats dt {
  margin-bottom: 5px;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.46rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a3920;
}

.tool-info-stats dd {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: #34302a;
}

.tool-info-desc {
  margin: 0;
  font-weight: 700;
  line-height: 1.5;
  color: #2e3f2d;
}

/* Stacked description paragraphs (e.g. the shovel guide) get breathing room. */
.tool-info-desc + .tool-info-desc {
  margin-top: 10px;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(17, 39, 70, 0.3), rgba(3, 15, 8, 0.15)),
    rgba(9, 18, 15, 0.1);
  backdrop-filter: blur(2px);
  transition: opacity 200ms ease, visibility 200ms ease;
}

body.phase-preview .menu-overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.menu-card {
  color: var(--text-main);
}

.title-screen {
  position: relative;
  overflow: hidden;
  width: min(1320px, calc(100vw - 28px));
  min-height: min(860px, calc(100vh - 28px));
  padding: 20px 44px 20px;
  border-radius: 34px;
  border: 4px solid #314031;
  background:
    linear-gradient(180deg, #60c7f7 0%, #a7e5ff 42%, #9ade79 42.5%, #9ade79 57%, #67bf56 57.5%, #67bf56 100%);
  box-shadow:
    0 10px 0 #6f5032,
    0 22px 0 #503626,
    0 40px 90px rgba(9, 15, 11, 0.35);
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 20px 20px 94px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.4), transparent 12%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 44%);
  pointer-events: none;
}

.title-panorama {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: 24px;
  align-items: start;
}

.title-copy {
  max-width: 700px;
}

.title-screen .menu-subtitle {
  max-width: 450px;
  margin-top: 10px;
  color: #16311f;
  font-size: 1.06rem;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.32);
}


.title-tagline-sign {
  padding-top: 0px;
  padding-bottom: 0px;
  padding-left: 0px;
  padding-right: 0px;
  padding: 16px 20px !important;
  border: 4px solid #6e4c2b;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #f2d1a0 0%, #c9935d 100%);
  box-shadow:
    inset 0 0 0 3px rgba(255, 247, 221, 0.26),
    0 6px 0 #8b5d37;
  color: #2f2115;
}

.title-mode {
  margin: 0;
  color: #173d55;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.72rem;
  line-height: 1.6;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.title-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0px 0 10px;
}

.title-word {
  display: block;
  font-family: "Bungee", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  text-transform: uppercase;
  line-height: 0.84;
  letter-spacing: 0.04em;
}

.title-word-plants {
  font-size: clamp(3.8rem, 10vw, 7.2rem);
  color: #fff7bc;
  text-shadow:
    0 3px 0 #214e22,
    3px 3px 0 #214e22,
    -3px 3px 0 #214e22,
    0 7px 0 rgba(16, 39, 17, 0.28);
}

.title-word-vs {
  margin-left: 18px;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  color: #ffe587;
  text-shadow:
    0 3px 0 #8d4e17,
    3px 3px 0 #8d4e17,
    -3px 3px 0 #8d4e17;
}

.title-word-mosquitos {
  font-size: clamp(3rem, 8vw, 6rem);
  color: #ff9f6f;
  text-shadow:
    0 3px 0 #6a3218,
    3px 3px 0 #6a3218,
    -3px 3px 0 #6a3218,
    0 8px 0 rgba(41, 20, 11, 0.28);
}

.menu-actions {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  margin: 30px auto 0;
}

.title-art {
  position: relative;
  min-height: 440px;
}

.sky-clouds {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 42%;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  border-radius: 30px 30px 0 0;
}

.title-cloud {
  position: absolute;
  width: 96px;
  height: 32px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.92);
  filter: blur(0.4px);
}

.title-cloud::before,
.title-cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.title-cloud::before {
  width: 44px;
  height: 44px;
  top: -16px;
  left: 14px;
}

.title-cloud::after {
  width: 52px;
  height: 52px;
  top: -22px;
  right: 12px;
}

/* Drift fully across the modal sky in each direction (left% is relative to
   the .sky-clouds width, so 100% parks the cloud just past the edge). */
@keyframes titleCloudRight {
  from { left: -130px; }
  to   { left: 100%; }
}

@keyframes titleCloudLeft {
  from { left: 100%; }
  to   { left: -130px; }
}

.t-cloud-1 {
  top: 8%;
  transform: scale(1);
  animation: titleCloudRight 26s linear infinite;
  animation-delay: -4s;
}

.t-cloud-2 {
  top: 24%;
  transform: scale(0.7);
  animation: titleCloudLeft 32s linear infinite;
  animation-delay: -16s;
}

.t-cloud-3 {
  top: 40%;
  transform: scale(1.1);
  animation: titleCloudRight 34s linear infinite;
  animation-delay: -22s;
}

.t-cloud-4 {
  top: 4%;
  transform: scale(0.6);
  animation: titleCloudLeft 40s linear infinite;
  animation-delay: -9s;
}

.t-cloud-5 {
  top: 54%;
  transform: scale(0.85);
  animation: titleCloudRight 30s linear infinite;
  animation-delay: -13s;
}

.t-cloud-6 {
  top: 32%;
  transform: scale(0.55);
  animation: titleCloudLeft 36s linear infinite;
  animation-delay: -27s;
}

.t-cloud-7 {
  top: 16%;
  transform: scale(0.75);
  animation: titleCloudRight 28s linear infinite;
  animation-delay: -19s;
}

.t-cloud-8 {
  top: 48%;
  transform: scale(0.65);
  animation: titleCloudLeft 44s linear infinite;
  animation-delay: -6s;
}

.title-sunburst {
  position: absolute;
  top: 12%;
  right: 6%;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 247, 155, 0.95) 0%, rgba(255, 200, 79, 0.9) 44%, rgba(255, 200, 79, 0) 72%);
}

.title-mosquito {
  position: absolute;
  top: 22px;
  right: 0;
  width: clamp(148px, 16vw, 208px);
  max-width: 34%;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.28));
}

.title-house {
  position: absolute;
  left: 28px;
  bottom: 54px;
  width: 384px;
  filter: drop-shadow(0 9px 0 rgba(122, 85, 53, 0.5)) drop-shadow(0 16px 18px rgba(0, 0, 0, 0.18));
}

.house-asset-title {
  width: 100%;
}

.title-grass {
  position: absolute;
  left: -44px;
  right: -44px;
  bottom: 52px;
  height: 54px;
  border-top: 4px solid #2f7b2f;
  background: repeating-linear-gradient(90deg, #85d463 0 14px, #6ebc53 14px 28px);
}

.title-dirt {
  position: absolute;
  left: -44px;
  right: -44px;
  bottom: -22px;
  height: 76px;
  border-top: 8px solid #3e7f31;
  background:
    repeating-linear-gradient(90deg, #774c3b 0 18px, #6b4336 18px 36px),
    linear-gradient(180deg, #704736, #4e3028);
}

.menu-option {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  min-height: 68px;
  padding: 10px 16px;
  border: 4px solid #69472b;
  border-radius: 8px;
  background: linear-gradient(180deg, #d7b28a 0%, #b78658 100%);
  box-shadow:
    inset 0 0 0 3px rgba(255, 245, 224, 0.26),
    0 6px 0 #8f643c;
  color: #2e1b11;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms steps(2), filter 120ms ease, box-shadow 120ms steps(2);
}

.menu-option:hover,
.menu-option:focus-visible {
  transform: translateY(2px);
  box-shadow:
    inset 0 0 0 3px rgba(255, 245, 224, 0.26),
    0 4px 0 #8f643c;
  filter: brightness(1.02);
}

.menu-option-primary {
  background: linear-gradient(180deg, #ffe598 0%, #ffc55a 100%);
  animation: slowPulseStart 3.6s ease-in-out infinite;
}

.menu-option-primary:hover,
.menu-option-primary:focus-visible {
  animation-play-state: paused;
  opacity: 1;
}

.menu-option-leaderboard {
  background: linear-gradient(180deg, #c7f0ff 0%, #79c7f6 100%);
}

.menu-option-leaderboard .menu-option-text {
  align-items: center;
  text-align: center;
}

.menu-option-leaderboard .menu-option-index {
  color: #174863;
}

.menu-option-leaderboard .menu-option-text strong {
  color: #16344a;
}

.menu-option-leaderboard .menu-option-text small {
  color: #295772;
}

.menu-option-index {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.72rem;
  text-align: center;
  color: #6d3c1c;
}

.menu-option-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.menu-option-text strong {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.35;
  text-transform: uppercase;
}

.menu-option-text small {
  font-size: 0.78rem;
  font-weight: 700;
  color: #5a3a24;
}

.how-to-panel {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  margin: 18px auto 0;
  padding: 18px 20px;
  border: 4px solid #274934;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8da 0%, #ffe7a7 100%);
  box-shadow: 0 8px 0 #4d6a41;
  color: #243125;
}

.how-to-panel h3 {
  margin: 0 0 12px;
  color: #5a3920;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.76rem;
  line-height: 1.5;
}

.how-to-panel ul {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
  font-weight: 700;
  color: #2e3f2d;
}

/* How to Play — closable popup modal (reuses the .how-to-panel styling) */
.how-to-modal {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 16px;
}

.how-to-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 20, 12, 0.55);
  backdrop-filter: blur(3px);
}

.how-to-modal .how-to-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  margin: 0;
  padding-top: 26px;
  box-shadow:
    0 8px 0 #4d6a41,
    0 30px 60px rgba(9, 15, 11, 0.4);
  animation: howToPop 180ms ease-out;
}

.how-to-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid #69472b;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffd98a 0%, #f3b65c 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 224, 0.3),
    0 3px 0 #8f643c;
  color: #5a3214;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms steps(2), filter 120ms ease;
}

.how-to-close:hover,
.how-to-close:focus-visible {
  transform: translateY(2px);
  filter: brightness(1.03);
}

@keyframes howToPop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.title-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 4px dashed rgba(28, 67, 51, 0.28);
  color: #18485e;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.62rem;
  line-height: 1.7;
}


.title-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  z-index: 2;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.title-credit-logo {
  width: 76px;
  height: auto;
  border-radius: 6px;
  opacity: 0.92;
}

.title-credit-copy {
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  color: #ffffff;
}

/* ── Player initials modal ───────────────────────────────────────── */
#playerInitialsForm {
  display: grid;
  gap: 14px;
  justify-items: center;
  margin-top: 10px;
}

.initials-input {
  width: min(260px, 78vw);
  padding: 16px 12px;
  text-align: center;
  text-transform: uppercase;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: clamp(1.4rem, 5vw, 2rem);
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* offsets the trailing letter-spacing so text reads centered */
  color: #1c4333;
  background: #fffef5;
  border: 4px solid #6e4c2b;
  border-radius: 14px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.18);
  outline: none;
}

.initials-input::placeholder {
  color: rgba(28, 67, 51, 0.3);
}

.initials-input:focus {
  border-color: #2c6b2a;
  box-shadow: 0 0 0 4px rgba(44, 107, 42, 0.28), inset 0 2px 8px rgba(0, 0, 0, 0.18);
}

.initials-input.is-invalid {
  border-color: #c0392b;
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.22), inset 0 2px 8px rgba(0, 0, 0, 0.18);
}

#playerInitialsError {
  min-height: 1.1em;
  text-align: center;
}

.end-card.is-initials .end-btn {
  width: min(280px, 82%);
  justify-content: center;
}

#playerInitialsTitle {
  color: #ffffff;
}

#endTitle {
  color: #ffffff;
}

.high-score-sign {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 3;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 18px;
  text-align: center;
  font-family: "Press Start 2P", "Courier New", monospace;
  line-height: 1.7;
  border: 4px solid #6e4c2b;
  border-radius: 12px;
  background: linear-gradient(180deg, #f2d1a0 0%, #c9935d 100%);
  box-shadow:
    inset 0 0 0 3px rgba(255, 247, 221, 0.26),
    0 5px 0 #8b5d37;
  color: #2f2115;
}

.high-score-sign-label {
  font-size: 0.5rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #5b3c1f;
}

.high-score-sign-value {
  font-size: 0.92rem;
  line-height: 1;
  color: #2f2115;
  text-shadow: 0 1px 0 rgba(255, 247, 221, 0.5);
}

/* ===== Leaderboard page — mirrors the title-screen modal ===== */
.leaderboard-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 14px;
}

.leaderboard-screen {
  display: flex;
  flex-direction: column;
  padding: 24px 44px 28px;
}

/* Render the brand credit in normal flow at the very bottom of the leaderboard
   so it's always visible. On the start menu it's absolutely positioned, which
   on the taller / scrollable leaderboard left it below the table or behind the
   Back to Menu action — making the logo look "missing". */
.leaderboard-screen .title-credit {
  position: static;
  margin-top: 18px;
}

/* decorative ground band echoing the start screen */
.lb-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 120px;
  z-index: 0;
  pointer-events: none;
}

.lb-grass {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 46px;
  border-top: 4px solid #2f7b2f;
  background: repeating-linear-gradient(90deg, #85d463 0 14px, #6ebc53 14px 28px);
}

.lb-dirt {
  position: absolute;
  left: 0;
  right: 0;
  top: 42px;
  bottom: 0;
  border-top: 8px solid #3e7f31;
  background:
    repeating-linear-gradient(90deg, #774c3b 0 18px, #6b4336 18px 36px),
    linear-gradient(180deg, #704736, #4e3028);
}

.lb-header {
  position: relative;
  z-index: 1;
  text-align: center;
}

.lb-title-stack {
  align-items: center;
  margin: 0px 0 12px;
}

.lb-word-top {
  font-size: clamp(2.4rem, 6vw, 4.4rem);
}

.lb-word-bottom {
  font-size: clamp(2.8rem, 7.4vw, 5.4rem);
}

.lb-header .menu-subtitle {
  display: inline-block;
  margin: 0 auto;
  max-width: 560px;
}

.lb-body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  margin-top: 22px;
}

.lb-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border: 4px solid #274934;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8da 0%, #ffe7a7 100%);
  box-shadow: 0 8px 0 #4d6a41;
  color: #243125;
}

.lb-section-heading {
  margin-bottom: 12px;
}

.lb-section-heading h2 {
  margin: 0;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #5a3920;
}

.lb-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 3px solid #6e4c2b;
  background: linear-gradient(180deg, #f2d1a0 0%, #c9935d 100%);
  color: #3a2614;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.52rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.lb-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 12px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-weight: 700;
}

.lb-table thead th {
  position: sticky;
  top: 0;
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
  background: linear-gradient(180deg, #e7c79a 0%, #d8b07f 100%);
  border-bottom: 3px solid rgba(110, 76, 43, 0.55);
  color: #5a3920;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lb-table tbody td {
  padding: 12px 10px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(110, 76, 43, 0.2);
  color: #34302a;
}

.lb-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.34);
}

.lb-table tbody tr:hover {
  background: rgba(255, 247, 218, 0.7);
}

.lb-table tbody td:first-child {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.72rem;
  color: #6d3c1c;
}

.lb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 16px;
  text-align: center;
  color: #3a2a17;
}

.lb-empty h3 {
  margin: 8px 0 0;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.8rem;
  color: #5a3920;
}

.lb-empty p {
  margin: 0;
  max-width: 360px;
  font-weight: 700;
}

.lb-actions {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(420px, 100%);
  margin: 22px auto 0;
}

.lb-back {
  animation: none;
}

/* Action-button icons in the modals (end / pause / leave-confirm) and the
   leaderboard "Back to Menu" button use symbol glyphs (≡ ↻ ★ → ▶ ← etc.).
   The pixel display font ("Press Start 2P") only covers basic ASCII, so those
   symbols would fall back to an unpredictable system font and look mismatched.
   Render them in a reliable symbol-font stack at a consistent size instead.
   The numbered title-menu options (01 / 02 / 03) keep the pixel font. */
.lb-back .menu-option-index,
.end-modal .menu-option-index {
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols2", system-ui, sans-serif;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mosquito-icon {
  width: 100%;
  height: auto;
  overflow: visible;
}

/* The horizontal flip is baked into the SVG markup (a transform attribute in
   user units) so it never offsets the sprite from its real position. */

/* The next-wave preview icon faces its natural direction — a CSS `transform`
   overrides the SVG `transform` attribute, so `none` cancels the baked flip. */
.status-wave-icon .mosquito-flipped {
  transform: none;
}

.mosquito-wings {
  transform-box: view-box;
  transform-origin: 148px 145px;
  animation: wingFlap 0.065s linear infinite alternate;
}

.mosquito-wing-blur {
  opacity: 0.35;
  filter: blur(1.25px);
  transform-box: view-box;
  transform-origin: 148px 145px;
  animation: wingBlurFlap 0.045s linear infinite alternate;
}

.mosquito-body {
  transform-box: view-box;
  transform-origin: 145px 145px;
  animation: mosquitoTinyTilt 0.22s ease-in-out infinite alternate;
}

.floating {
  animation: mosquitoHover 0.42s ease-in-out infinite alternate;
}

@keyframes pulseSun {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.94;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@keyframes cloudFloat {
  from {
    transform: translateX(-120px);
  }
  to {
    transform: translateX(120px);
  }
}

@keyframes driftMosquitoA {
  0%,
  100% {
    transform: translate(0, 0) rotate(-4deg);
  }
  50% {
    transform: translate(-24px, 12px) rotate(3deg);
  }
}

@keyframes driftMosquitoB {
  0%,
  100% {
    transform: translate(0, 0) rotate(2deg);
  }
  50% {
    transform: translate(22px, -16px) rotate(-4deg);
  }
}

@keyframes driftMosquitoC {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  50% {
    transform: translate(-14px, -12px) rotate(4deg);
  }
}

@keyframes mosquitoHover {
  from {
    transform: translateY(-4px);
  }
  to {
    transform: translateY(4px);
  }
}

@keyframes mosquitoTinyTilt {
  from {
    transform: rotate(-1.8deg);
  }
  to {
    transform: rotate(1.8deg);
  }
}

@keyframes wingFlap {
  from {
    transform: rotate(-5deg) scaleX(1) scaleY(1);
    opacity: 0.95;
  }
  to {
    transform: rotate(9deg) scaleX(0.18) scaleY(1.08);
    opacity: 0.58;
  }
}

@keyframes wingBlurFlap {
  from {
    transform: rotate(12deg) scaleX(0.85) scaleY(1);
  }
  to {
    transform: rotate(-12deg) scaleX(0.12) scaleY(1.15);
  }
}

@keyframes slowPulseStart {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@media (max-width: 1080px) {
  .top-hud,
  .game-layout,
  .leaderboard-grid {
    grid-template-columns: 1fr;
  }

  .battle-topline,
  .page-header,
  .callout-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .wave-preview {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .screen-shell,
  .leaderboard-shell {
    width: min(100vw - 18px, 100%);
    margin: 12px auto;
    padding: 14px;
    border-radius: 24px;
  }

  .side-panel,
  .battle-panel,
  .leaderboard-card,
  .sidebar-card,
  .empty-card,
  .menu-card {
    padding: 16px;
    border-radius: 20px;
  }

  .title-screen {
    width: min(100vw - 16px, 100%);
    min-height: calc(100vh - 16px);
    padding: 22px 18px 18px;
  }

  .leaderboard-screen {
    padding: 22px 16px 24px;
  }

  .lb-word-top {
    font-size: clamp(2rem, 9vw, 3rem);
  }

  .lb-word-bottom {
    font-size: clamp(2.4rem, 11vw, 3.6rem);
  }

  .title-panorama {
    grid-template-columns: 1fr;
  }

  .title-art {
    min-height: 240px;
  }

  .title-mosquito {
    top: 10px;
    right: 34px;
    width: min(34vw, 144px);
    max-width: 42%;
  }

  .menu-actions {
    width: 100%;
  }

  .title-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .lawn-field {
    left: 8%;
    right: 8%;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 6px;
  }

  .lawn-house {
    display: none;
  }

  .seed-bar {
    flex-wrap: wrap;
  }

  .board-status {
    gap: 10px;
  }

  .status-progress {
    display: none;
  }
}

/* ===================================================================
   Gameplay engine visuals — actors, effects, overlays, end screen
   =================================================================== */
.yard-stage {
  position: relative;
}

.yard-stage .yard-grid {
  width: 100%;
  height: 100%;
}

.lawn-actors {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.mower-slot {
  display: grid;
  place-items: center;
}

/* Mosquitoes */
.mosquito-actor {
  position: absolute;
  top: 0;
  left: 0;
  width: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  will-change: transform;
}

.mosquito-actor .mosq-body {
  width: 100%;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.28));
}

.mosquito-actor.biting .mosq-body {
  animation: mosqBite 0.28s ease-in-out infinite alternate;
}

.mosq-hp {
  width: 60%;
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.mosq-hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff5b5b, #ffd24d);
}

/* ── Death animations ─────────────────────────────────────────────── */
/* Full-page, unclipped layer so a dying sprite can fall off the screen. */
.death-layer {
  position: fixed;
  inset: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}

/* Closed eyes (paddle) and open mouth (soap) are baked into the SVG, hidden
   until the matching death. */
.mosq-dead-eyes,
.mosq-mouth {
  opacity: 0;
}

.mosq-mouth {
  transform-box: fill-box;
  transform-origin: center;
}

.dying {
  pointer-events: none;
}

.dying .mosq-hp {
  display: none;
}

/* Freeze idle flight (and wing flap) the instant it dies. */
.dying .mosquito-icon,
.dying .mosquito-body,
.dying .mosquito-wings,
.dying .mosquito-wing-blur {
  animation: none !important;
}

.dying-swatter .mosq-dead-eyes,
.dying-zapper .mosq-dead-eyes {
  opacity: 1;
}

/* Paddle (and Zapper) kill: wings knocked off + fade, then the body flips
   upside-down and falls down off the bottom of the page. */
.dying-swatter .mosquito-wings,
.dying-swatter .mosquito-wing-blur,
.dying-zapper .mosquito-wings,
.dying-zapper .mosquito-wing-blur {
  animation: wingsOff 0.5s ease-out forwards !important;
}

.dying-swatter,
.dying-zapper {
  animation: paddleFall 1.15s ease-in 0.45s forwards;
}

/* Zapper: the bug is consumed by electricity as it dies. */
.dying-zapper .mosq-body {
  animation: zapCrackle 0.45s steps(5) 2;
}

@keyframes zapCrackle {
  0%, 100% { filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.28)) brightness(1); }
  20% { filter: drop-shadow(0 0 7px #aee9ff) brightness(2.3) saturate(1.4); }
  45% { filter: drop-shadow(0 0 11px #6fd0ff) brightness(0.55); }
  70% { filter: drop-shadow(0 0 9px #eafbff) brightness(2.5); }
}

/* Lightning bolt arcing from the Zapper to the bug. */
.fx-bolt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 0 5px #7fd4ff) drop-shadow(0 0 11px #3aa8ff);
  animation: boltFlicker 0.3s steps(3);
}

@keyframes boltFlicker {
  0%, 100% { opacity: 1; }
  40% { opacity: 0.35; }
  60% { opacity: 0.9; }
}

/* The Zapper's jolt as it fires. */
.tool-zapper.is-zap .tool-glyph {
  animation: zapJolt 0.3s steps(3);
}

@keyframes zapJolt {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  30% { filter: brightness(2.6) drop-shadow(0 0 8px #aee9ff); transform: scale(1.2); }
  60% { filter: brightness(1.3); transform: scale(1.08); }
}

/* DEET Mine: bug just fades — the yard-wide blast is the spectacle. */
.dying-deet-mine {
  animation: mineVanish 0.4s ease forwards;
}

@keyframes mineVanish {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Atomic-style full-yard explosion (DEET Mine) ──────────────────── */
.fx-nuke {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 6;
}

.fx-nuke-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 56%, #ffffff 0%, rgba(255, 246, 210, 0.92) 30%, rgba(255, 200, 120, 0.55) 55%, rgba(255, 255, 255, 0) 80%);
  opacity: 0;
  animation: nukeFlash 1.5s ease-out forwards;
}

@keyframes nukeFlash {
  0% { opacity: 0; }
  6% { opacity: 1; }
  32% { opacity: 0.78; }
  100% { opacity: 0; }
}

.fx-nuke-fire {
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 56%, #fff7c4 0%, #ffd24d 22%, #ff8a3d 44%, #ff4e2a 66%, #b3261a 82%, rgba(120, 20, 10, 0) 100%);
  filter: blur(2px);
  opacity: 0;
  transform: scale(0.1);
  animation: nukeFire 1.6s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes nukeFire {
  0% { transform: scale(0.1); opacity: 0; }
  10% { opacity: 1; }
  55% { transform: scale(3.4); opacity: 1; }
  100% { transform: scale(3.9); opacity: 0; }
}

.fx-nuke-ring {
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 6px solid rgba(255, 222, 150, 0.9);
  box-shadow: 0 0 34px rgba(255, 180, 90, 0.85), inset 0 0 24px rgba(255, 200, 120, 0.6);
  opacity: 0;
  transform: scale(0.1);
  animation: nukeRing 1.15s ease-out forwards;
}

.fx-nuke-ring2 {
  border-color: rgba(255, 255, 255, 0.75);
  animation-delay: 0.18s;
}

@keyframes nukeRing {
  0% { transform: scale(0.1); opacity: 0.9; }
  100% { transform: scale(5.5); opacity: 0; }
}

.fx-nuke-smoke {
  position: absolute;
  width: 48%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 64, 58, 0.92) 0%, rgba(96, 86, 78, 0.55) 58%, rgba(96, 86, 78, 0) 80%);
  opacity: 0;
  transform: translateY(12%) scale(0.3);
  animation: nukeSmoke 1.9s ease-out forwards;
}

@keyframes nukeSmoke {
  0% { transform: translateY(12%) scale(0.3); opacity: 0; }
  30% { opacity: 0.85; }
  100% { transform: translateY(-34%) scale(2.5); opacity: 0; }
}

/* Board quake during the blast. */
.board.is-quaking {
  animation: quake 0.6s ease;
}

@keyframes quake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 4px); }
  30% { transform: translate(6px, -4px); }
  45% { transform: translate(-5px, 5px); }
  60% { transform: translate(5px, -3px); }
  80% { transform: translate(-3px, 2px); }
}

@keyframes wingsOff {
  0% { opacity: 1; }
  100% { transform: translate(140px, -320px) rotate(150deg) scale(0.28); opacity: 0; }
}

@keyframes paddleFall {
  0% { transform: translateY(0) rotate(0); }
  16% { transform: translateY(0) rotate(180deg); }
  100% { transform: translateY(116vh) rotate(180deg); }
}

/* The Paddle's firm, hard swat as it connects. */
.tool-swatter.is-swat .tool-glyph {
  animation: paddleSwat 0.32s ease-out;
}

@keyframes paddleSwat {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-46deg) scale(1.12); }
  45% { transform: rotate(30deg) scale(1.22); }
  70% { transform: rotate(-8deg) scale(1.05); }
  100% { transform: rotate(0) scale(1); }
}

/* Soap Bowl kill: the bug stays put, opens its mouth, and is consumed by a
   cellful of bubbles, then everything fades. (Position transform untouched —
   only opacity animates — so it stays in its cell.) */
.dying-soap-bowl {
  animation: soapFade 1.3s ease forwards;
}

.dying-soap-bowl .mosq-mouth,
.dying-citronella .mosq-mouth {
  opacity: 1;
  animation: mouthOpen 0.3s ease forwards;
}

@keyframes soapFade {
  0%, 45% { opacity: 1; }
  100% { opacity: 0; }
}

/* Citronella kill: the bug stays put, mouth opens, gets engulfed in flame and
   chars, then a quick smoke poof and it's gone. */
.dying-citronella {
  animation: candleBurn 0.7s ease forwards;
}

@keyframes candleBurn {
  0% { opacity: 1; filter: none; }
  35% { opacity: 1; filter: brightness(0.5) sepia(0.8) saturate(2.4); }
  70% { opacity: 0; }
  100% { opacity: 0; }
}

.fx-flame {
  position: absolute;
  top: 0;
  left: 0;
  width: 54px;
  height: 64px;
  margin: -40px 0 0 -27px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 50% 72%, #fff6b0 0%, #ffd24d 26%, #ff9a3d 50%, #ff5b2e 72%, rgba(255, 91, 46, 0) 86%);
  filter: blur(0.6px);
  pointer-events: none;
  animation: fxFlame 0.48s ease-out forwards;
}

@keyframes fxFlame {
  0% { transform: scale(0.3); opacity: 0; }
  30% { transform: scale(1.1); opacity: 1; }
  60% { transform: scale(1.18) translateY(-6px); opacity: 0.92; }
  100% { transform: scale(0.82) translateY(-16px); opacity: 0; }
}

@keyframes mouthOpen {
  0% { transform: scaleY(0.2); }
  100% { transform: scaleY(2.8); }
}

.fx-soap {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 4;
}

.fx-soap-bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.96), rgba(186, 228, 255, 0.78) 55%, rgba(120, 180, 230, 0.5));
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.6), 0 0 4px rgba(150, 200, 240, 0.5);
  opacity: 0;
  animation: soapBubble 1.3s ease forwards;
}

@keyframes soapBubble {
  0% { transform: scale(0); opacity: 0; }
  22% { transform: scale(1); opacity: 0.95; }
  62% { transform: scale(1.06); opacity: 0.95; }
  100% { transform: scale(0.9); opacity: 0; }
}

/* Projectiles */
.proj {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.proj-water {
  background: radial-gradient(circle at 35% 32%, #dff4ff, #5bb6f0 60%, #2b7fc4);
  box-shadow: 0 0 8px rgba(91, 182, 240, 0.7);
}

.proj-mist {
  width: 26px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(222, 232, 226, 0.92), rgba(200, 215, 205, 0) 70%);
  filter: blur(1px);
}

.proj-bomb {
  width: 18px;
  height: 18px;
  background: radial-gradient(circle at 38% 32%, #5a5a5a, #1b1b1b 70%);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.45), 0 0 4px rgba(0, 0, 0, 0.4);
  animation: bombSpin 0.5s linear infinite;
}

.proj-bomb::after {
  content: "";
  position: absolute;
  top: -3px;
  right: 1px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffae4d;
  box-shadow: 0 0 6px #ff8a3d;
}

/* Hit / death / area effects */
.fx-poof,
.fx-pulse,
.fx-blast,
.fx-gem {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.fx-poof {
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 70%);
  animation: fxPoof 0.42s ease-out forwards;
}

.fx-pulse {
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  border: 3px solid rgba(255, 226, 120, 0.85);
  animation: fxRing 0.48s ease-out forwards;
}

.fx-blast {
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 180, 90, 0.85), rgba(255, 90, 60, 0) 68%);
  animation: fxBlast 0.52s ease-out forwards;
}

.fx-gem {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.66rem;
  color: #eafff0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  animation: fxGem 0.76s ease-out forwards;
}

.mower-sweep {
  position: absolute;
  top: 0;
  left: 0;
}

@keyframes fxPoof {
  from { transform: scale(0.4); opacity: 0.9; }
  to { transform: scale(1.5); opacity: 0; }
}

@keyframes fxRing {
  from { transform: scale(0.3); opacity: 0.9; }
  to { transform: scale(1.2); opacity: 0; }
}

@keyframes fxBlast {
  from { transform: scale(0.3); opacity: 0.95; }
  to { transform: scale(1.3); opacity: 0; }
}

@keyframes fxGem {
  0% { transform: translate(-50%, -50%) translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(-34px); opacity: 0; }
}

@keyframes toolBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes mosqBite {
  from { transform: translateX(0); }
  to { transform: translateX(4px); }
}

/* Placing / moving / shovel cursors */
.board.shovel-active .yard-grid {
  cursor: not-allowed;
}

/* Home health pip */
.status-home strong {
  color: #ff8f8f;
  letter-spacing: 1px;
}

.status-home.hit {
  animation: homeHit 0.4s ease;
}

@keyframes homeHit {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-2px); filter: brightness(1.5); }
}

/* Pause control */
.ctrl-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  color: #eaffd8;
  font-size: 0.7rem;
  cursor: pointer;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Wave prep overlay (sits over the lawn) */
/* Non-blocking: only the card catches clicks so the player can still place
   tools on the yard during prep. */
.wave-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: 38px 12px 12px;
  pointer-events: none;
}

.wave-overlay-card {
  pointer-events: auto;
  width: min(440px, 100%);
  padding: 18px 24px;
  text-align: center;
  border: 4px solid #6e4c2b;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8da 0%, #ffe7a7 100%);
  box-shadow: 0 10px 0 #4d6a41, 0 26px 50px rgba(9, 15, 11, 0.4);
  color: #2f2115;
}

.wave-overlay-kicker {
  margin: 0 0 8px;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.62rem;
  color: #5a3920;
}

.wave-overlay-title {
  margin: 0 0 8px;
  font-family: "Bungee", Impact, sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  text-transform: uppercase;
  color: #2f7b2f;
}

.wave-overlay-copy {
  margin: 0 0 16px;
  font-weight: 700;
  line-height: 1.5;
  color: #3a2e1d;
}

.wave-start-btn {
  padding: 14px 26px;
  border: 4px solid #69472b;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe598, #ffc55a);
  color: #3a2412;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.78rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #8f643c;
  transition: transform 120ms steps(2), box-shadow 120ms steps(2);
}

.wave-start-btn:hover,
.wave-start-btn:focus-visible {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #8f643c;
}

/* Two-button row in the prep modal: Set Traps (secondary) + Start Wave. */
.wave-overlay-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.wave-secondary-btn {
  background: linear-gradient(180deg, #d7b28a 0%, #b78658 100%);
  color: #2e1b11;
}

/* Transient flash banner */
.flash-banner {
  position: absolute;
  top: 14%;
  left: 50%;
  z-index: 4;
  padding: 12px 22px;
  border-radius: 12px;
  background: rgba(20, 40, 24, 0.86);
  border: 2px solid rgba(255, 226, 120, 0.6);
  color: #fff;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.72rem;
  white-space: nowrap;
  transform: translate(-50%, -10px);
  opacity: 0;
  pointer-events: none;
}

.flash-banner.show {
  animation: flashPop 1.8s ease forwards;
}

@keyframes flashPop {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  82% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(0.98); }
}

/* End-of-run modal */
.end-modal {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 16px;
}

.end-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 16, 10, 0.62);
  backdrop-filter: blur(4px);
}

.end-card {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  padding: 22px 34px 22px;
  text-align: center;
  border: 4px solid #314031;
  border-radius: 26px;
  background: linear-gradient(180deg, #7a4f7e 0%, #5d3a62 100%);
  box-shadow: 0 12px 0 #3a2640, 0 30px 70px rgba(9, 15, 11, 0.5);
  color: #fff;
  animation: howToPop 220ms ease-out;
}

.end-card.is-victory {
  background: linear-gradient(180deg, #2f8f53 0%, #1f6c3c 100%);
  border-color: #1c3a16;
  box-shadow: 0 12px 0 #163a22, 0 30px 70px rgba(9, 15, 11, 0.5);
}

.end-card.is-paused {
  background: linear-gradient(180deg, #3a567e 0%, #283e60 100%);
  border-color: #1c2a3a;
  box-shadow: 0 12px 0 #16263a, 0 30px 70px rgba(9, 15, 11, 0.5);
}

.end-card.is-confirm {
  background: linear-gradient(180deg, #6e4c2b 0%, #4f3318 100%);
  border-color: #2f1d0d;
  box-shadow: 0 12px 0 #2c1b0c, 0 30px 70px rgba(9, 15, 11, 0.5);
}

/* The "save first?" prompt must sit above the Game Over modal (z-index 7). */
#leaveConfirmModal {
  z-index: 8;
}

.end-emblem {
  width: 76px;
  height: 64px;
  margin: 0 auto 6px;
}

.end-kicker {
  margin: 0;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #ffd24d;
}

.end-title {
  margin: 4px 0 6px;
  font-family: "Bungee", Impact, sans-serif;
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  line-height: 1.05;
  text-transform: uppercase;
  white-space: nowrap;
}

.end-subtitle {
  margin: 0 auto 12px;
  max-width: 540px;
  font-weight: 700;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 0 0 14px;
}

.end-stats div {
  padding: 14px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
}

.end-stats dt {
  margin: 0 0 8px;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.82);
}

.end-stats dd {
  margin: 0;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 1.2rem;
  white-space: nowrap;
  color: #ffe14d;
}

/* Larger Game Over card with merged signup */
.end-card-lg {
  width: min(960px, 100%);
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  /* Themed scrollbar (Firefox) — gold thumb on a dark translucent track. */
  scrollbar-width: thin;
  scrollbar-color: #ffc55a rgba(0, 0, 0, 0.28);
}

/* Themed scrollbar (WebKit/Chromium) */
.end-card-lg::-webkit-scrollbar {
  width: 12px;
}

.end-card-lg::-webkit-scrollbar-track {
  margin: 14px 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.26);
}

.end-card-lg::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #ffe598, #ffc55a);
}

.end-card-lg::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #fff0b4, #ffce6e);
}

.end-card-lg .js-mosquito-icon {
  position: absolute;
  right: 190px;
}

.end-stats-3 {
  grid-template-columns: repeat(3, 1fr);
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

/* Your Score vs High Score */
.score-compare {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  margin: 0 auto 12px;
  max-width: 480px;
}

.score-box {
  position: relative;
  flex: 1;
  padding: 14px 12px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.16);
}

.score-box-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.score-box-value {
  display: block;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 1.5rem;
  line-height: 1.1;
  white-space: nowrap;
}

.high-score .score-box-value {
  color: #ffd24d;
}

.your-score .score-box-value {
  color: #ffffff;
}

.your-score.is-record {
  border-color: #ffe14d;
  background: rgba(255, 225, 77, 0.18);
  box-shadow: 0 0 0 3px rgba(255, 225, 77, 0.3);
}

.your-score.is-record .score-box-value {
  color: #ffe14d;
}

.score-box-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffe14d;
  color: #4a3a0a;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.46rem;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.score-vs {
  align-self: center;
  font-family: "Bungee", Impact, sans-serif;
  font-size: 1rem;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

/* Merged signup block */
.end-signup {
  margin: 0 auto 12px;
  max-width: 520px;
  padding: 14px 18px 14px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.14);
  text-align: left;
}

.end-signup-title {
  margin: 0 0 12px;
  text-align: center;
  font-family: "Bungee", Impact, sans-serif;
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  text-transform: uppercase;
  color: #ffe14d;
}

.end-signup-perks {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.end-signup-perks li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.perk-ico {
  font-size: 1.1rem;
}

.form-submit-cta {
  margin-top: 2px;
  font-size: 0.84rem;
  background: linear-gradient(180deg, #8be06a, #4fae3f);
  border-color: #2f7b2f;
  box-shadow: 0 5px 0 #2f7b2f;
}

/* Form sits on a dark panel — lighten the label/help text for contrast. */
.end-signup .field > span {
  color: #e6f3d6;
}

.end-signup .form-note {
  color: rgba(255, 255, 255, 0.72);
}

.end-signup .field-error {
  color: #ffb3a8;
}

.score-saved {
  margin: 0 auto 18px;
  max-width: 460px;
}

.score-saved-emblem {
  font-size: 2.4rem;
  margin-bottom: 6px;
}

.end-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.end-btn {
  text-align: left;
}

.end-btn-danger {
  background: linear-gradient(180deg, #e9897e 0%, #cf5848 100%);
  border-color: #8a3327;
  box-shadow: inset 0 0 0 3px rgba(255, 235, 230, 0.22), 0 6px 0 #8a3327;
}

.end-btn-danger .menu-option-index,
.end-btn-danger .menu-option-text strong {
  color: #43130c;
}

.end-btn-danger .menu-option-text small {
  color: #6e241a;
}

/* The Leaderboard button reuses the menu-option-leaderboard style, which
   center-aligns its text on the start screen — keep it left here to match. */
.end-btn.menu-option-leaderboard .menu-option-text {
  align-items: flex-start;
  text-align: left;
}

@media (max-width: 620px) {
  .end-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .end-stats-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .end-title {
    white-space: normal;
  }
}

/* Score-save form (must sit above the end modal at z-index 7) */
#scoreFormModal {
  z-index: 8;
}

.score-form-panel {
  width: min(480px, 100%);
  text-align: left;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field > span {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a3920;
}

.field input {
  padding: 11px 12px;
  border: 3px solid #b69266;
  border-radius: 10px;
  background: #fffdf3;
  color: #2e2a22;
  font: inherit;
  font-weight: 700;
}

.field input:focus {
  outline: none;
  border-color: #6e4c2b;
  box-shadow: 0 0 0 3px rgba(255, 213, 110, 0.5);
}

.field input.is-invalid {
  border-color: #d8543f;
  background: #fff3f0;
}

.field-error {
  min-height: 0.9em;
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 700;
  color: #c23a22;
}

.form-note {
  margin: 4px 0 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #5a4a33;
}

.form-submit {
  display: inline-block;
  width: 100%;
  padding: 14px 20px;
  border: 4px solid #69472b;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe598, #ffc55a);
  color: #3a2412;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.72rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 5px 0 #8f643c;
  transition: transform 120ms steps(2), box-shadow 120ms steps(2);
}

.form-submit:hover,
.form-submit:focus-visible {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #8f643c;
}

.score-saved {
  text-align: center;
}

.score-saved-msg {
  margin: 6px 0 16px;
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
}

@media (max-width: 520px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* ===================================================================
   Per-tool action animations + smoke
   =================================================================== */
.fx-smoke {
  position: absolute;
  top: 0;
  left: 0;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 202, 196, 0.92), rgba(176, 182, 176, 0) 68%);
  pointer-events: none;
  animation: fxSmoke 0.72s ease-out forwards;
}

@keyframes fxSmoke {
  0% { transform: scale(0.4) translateY(0); opacity: 0.85; }
  100% { transform: scale(1.6) translateY(-24px); opacity: 0; }
}

@keyframes bombSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Fly Swatter — swats while a mosquito is on it */
.tool-swatter .tool-glyph {
  transform-origin: 72% 88%;
}
.tool-swatter.is-attacking .tool-glyph {
  animation: swat 0.3s ease-in-out infinite;
}
@keyframes swat {
  0%, 100% { transform: rotate(0deg); }
  35% { transform: rotate(-36deg); }
  60% { transform: rotate(16deg); }
}

/* Soap Bowl — gentle bubbles that surge on contact */
.tool-soap-bowl .cell-tool-icon::before,
.tool-soap-bowl .cell-tool-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  bottom: 44%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffffff, rgba(176, 226, 255, 0.7));
  opacity: 0;
  pointer-events: none;
}
.tool-soap-bowl .cell-tool-icon::before {
  left: 40%;
  animation: bubbleUp 2.4s ease-in infinite;
}
.tool-soap-bowl .cell-tool-icon::after {
  left: 56%;
  animation: bubbleUp 2.9s ease-in infinite 0.9s;
}
.tool-soap-bowl.is-attacking .cell-tool-icon::before {
  animation-duration: 0.7s;
}
.tool-soap-bowl.is-attacking .cell-tool-icon::after {
  animation-duration: 0.9s;
}
.tool-soap-bowl.is-attacking .tool-glyph {
  animation: wobble 0.42s ease-in-out infinite;
}
@keyframes bubbleUp {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  25% { opacity: 0.95; }
  100% { opacity: 0; transform: translateY(-22px) scale(1.15); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

/* Citronella Candle — flickers, glows when it poofs a bug */
.tool-citronella .tool-glyph {
  animation: flicker 0.6s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.07); filter: brightness(1.25); }
}

/* Bug Zapper — electric flash on contact */
.tool-zapper.is-attacking .tool-glyph {
  animation: zapFlash 0.18s steps(2) infinite;
}
@keyframes zapFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(2.4) drop-shadow(0 0 6px #fff59a); }
}

/* Spray Mist Can — recoil puff */
.tool-spray-mist.is-firing .tool-glyph {
  animation: sprayKick 0.24s ease;
}
@keyframes sprayKick {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(-14deg) translateX(-2px); }
  100% { transform: rotate(0deg); }
}

/* Super Soaker — flip the glyph everywhere it appears (faces the swarm) */
.seed-packet.tool-super-soaker .seed-packet-icon,
.tool-info-icon.flip-x {
  display: inline-block;
  transform: scaleX(-1);
}

/* Super Soaker — flipped to face the swarm; recoils on each shot */
.tool-super-soaker .tool-glyph {
  transform: scaleX(-1);
}
.tool-super-soaker.is-firing .tool-glyph {
  animation: soakerRecoil 0.24s ease;
}
@keyframes soakerRecoil {
  0% { transform: scaleX(-1) translateX(0); }
  40% { transform: scaleX(-1) translateX(-5px) rotate(6deg); }
  100% { transform: scaleX(-1) translateX(0); }
}

/* DEET Mister — area sway */
.tool-deet-mister .tool-glyph {
  animation: misterSway 1.6s ease-in-out infinite;
}
@keyframes misterSway {
  0%, 100% { transform: translateX(-2px); }
  50% { transform: translateX(2px); }
}

/* DEET Bomber — lobs a bomb */
.tool-deet-bomber.is-firing .tool-glyph {
  animation: lob 0.32s ease;
}
@keyframes lob {
  0% { transform: translateY(0) rotate(0deg); }
  45% { transform: translateY(-7px) rotate(-16deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* DEET Mine — armed blink */
.tool-deet-mine .tool-glyph,
.tool-deet-bomber .tool-glyph {
  animation: mineBlink 1.1s steps(2, end) infinite;
}
@keyframes mineBlink {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 5px #ff5b5b) brightness(1.3); }
}

/* DEET Bomber detonation — a line of fire sweeping the whole row. */
.fx-rowfire {
  position: absolute;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(255, 170, 60, 0),
    rgba(255, 140, 40, 0.92) 30%,
    rgba(255, 90, 30, 0.98) 50%,
    rgba(255, 140, 40, 0.92) 70%,
    rgba(255, 170, 60, 0)
  );
  box-shadow: 0 0 24px rgba(255, 120, 40, 0.85);
  pointer-events: none;
  animation: fxRowFire 0.6s ease-out forwards;
}
@keyframes fxRowFire {
  0% { opacity: 0; transform: translateY(-50%) scaleY(0.25); }
  18% { opacity: 1; transform: translateY(-50%) scaleY(1); }
  100% { opacity: 0; transform: translateY(-50%) scaleY(1); }
}

/* Area-pulse glow flash (citronella / DEET mister) */
.cell-tool.is-pulsing::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 205, 110, 0.55), transparent 70%);
  pointer-events: none;
  animation: pulseGlow 0.32s ease forwards;
}
.tool-deet-mister.is-pulsing::after {
  background: radial-gradient(circle, rgba(150, 230, 170, 0.55), transparent 70%);
}
@keyframes pulseGlow {
  0% { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ===================================================================
   Start-menu Tool Guide button + almanac modal
   =================================================================== */
.tool-guide-btn {
  position: absolute;
  bottom: 22px;
  left: 22px;
  z-index: 4;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 4px solid #6e4c2b;
  border-radius: 12px;
  background: linear-gradient(180deg, #f2d1a0 0%, #c9935d 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 247, 221, 0.26), 0 5px 0 #8b5d37;
  color: #3a2614;
  cursor: pointer;
  transition: transform 120ms steps(2), box-shadow 120ms steps(2);
}

.tool-guide-btn:hover,
.tool-guide-btn:focus-visible {
  transform: translateY(2px);
  box-shadow: inset 0 0 0 3px rgba(255, 247, 221, 0.26), 0 3px 0 #8b5d37;
}

.tool-guide-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.tool-guide-label {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.46rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tools-panel {
  width: min(1180px, calc(100vw - 24px)) !important;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  text-align: left;
  /* Hidden scrollbar (still scrollable via wheel/trackpad/keys) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* old Edge/IE */
}

.tools-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.tools-intro {
  margin: 0 0 14px;
  font-weight: 700;
  line-height: 1.45;
  color: #3a2e1d;
}

.almanac-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.almanac-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 3px solid #c9a36e;
  background: rgba(255, 255, 255, 0.5);
}

.almanac-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff3d2, #ffe2a3);
  border: 2px solid #c9a36e;
}

.almanac-body {
  min-width: 0;
}

.almanac-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 800;
  color: #41301c;
}

.almanac-behavior {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(110, 76, 43, 0.16);
  color: #6e4c2b;
  font-size: 0.66rem;
  font-weight: 700;
}

.almanac-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.almanac-stat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #3a2e1d;
}

.almanac-desc {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.4;
  color: #4a3a28;
}

@media (max-width: 600px) {
  .almanac-list {
    grid-template-columns: 1fr;
  }
}
