/* ==================== GARDEN DEFENSE ==================== */

.garden { padding: clamp(18px, 2.8vh, 30px) 0 28px; }
.garden__layout { display: grid; gap: 14px; }
.garden__heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; }
.garden__heading h1 { margin-top: 8px; font-size: clamp(1.9rem, 3vw, 2.8rem); }
.garden__heading > p { max-width: 42ch; color: var(--color-text-muted); font-size: .86rem; text-align: right; }

.garden__topbar {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: clamp(14px, 2.3vw, 28px);
  padding: 0 2px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.garden-stat { display: grid; flex: 0 0 auto; gap: 1px; }
.garden-stat > span:not(.sun-icon), .garden-health > span, .wave-progress__label span {
  color: var(--color-text-muted);
  font-size: .61rem;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.garden-stat strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.garden-stat--sun { position: relative; min-width: 62px; padding-left: 30px; }
.sun-icon { position: absolute; top: 50%; left: 1px; width: 21px; height: 21px; border-radius: 50%; background: #f8c438; box-shadow: 0 -7px 0 -5px #c98909, 0 7px 0 -5px #c98909, 7px 0 0 -5px #c98909, -7px 0 0 -5px #c98909, 5px 5px 0 -5px #c98909, -5px -5px 0 -5px #c98909, 5px -5px 0 -5px #c98909, -5px 5px 0 -5px #c98909; transform: translateY(-50%); }
.wave-progress { display: grid; min-width: 170px; max-width: 390px; flex: 1 1 auto; gap: 5px; margin-left: auto; }
.wave-progress__label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wave-progress__label strong { font-size: .65rem; font-variant-numeric: tabular-nums; }
.wave-progress__track { overflow: hidden; height: 6px; background: var(--color-surface-raised); }
.wave-progress__track i { display: block; width: 0; height: 100%; background: var(--color-danger); transition: width 180ms linear; }
.garden-health { display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 9px; }
.garden-health > span { grid-column: 1 / -1; }
.garden-health__pips { display: flex; gap: 3px; }
.garden-health__pips i { width: 7px; height: 13px; background: var(--color-brand); }
.garden-health__pips i.is-empty { background: var(--color-surface-raised); }
.garden-health strong { color: var(--color-text-muted); font-size: .66rem; font-variant-numeric: tabular-nums; }
.garden__controls { display: flex; gap: 2px; }
.icon-button--garden { width: 42px; height: 42px; }
.garden-control__play { display: none; }
.icon-button--garden[data-state="play"] .garden-control__pause { display: none; }
.icon-button--garden[data-state="play"] .garden-control__play { display: block; }

.garden-board {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 50 / 27;
  min-height: 330px;
  border: 1px solid var(--color-border);
  background: #a7d980;
  isolation: isolate;
}
.garden-board canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.garden-board__notice {
  position: absolute;
  z-index: 4;
  top: 15px;
  left: 50%;
  max-width: calc(100% - 28px);
  padding: 7px 11px;
  border: 1px solid rgba(255,255,255,.24);
  background: rgba(8, 30, 24, .9);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.garden-board__notice[hidden] { display: none; }
.garden-board__overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 18px;
  background: rgba(241, 249, 245, .92);
  backdrop-filter: blur(5px);
}
[data-theme="dark"] .garden-board__overlay { background: rgba(10, 24, 19, .93); }
.garden-board__overlay[hidden] { display: none; }

.mode-select, .result { width: min(660px, 100%); text-align: center; }
.mode-select__mark { position: relative; display: inline-grid; width: 50px; height: 50px; place-items: center; }
.mode-select__mark::before, .mode-select__mark::after { position: absolute; width: 25px; height: 39px; border-radius: 100% 0 100% 0; background: var(--color-brand); content: ""; transform: rotate(-42deg) translate(-7px, -2px); }
.mode-select__mark::after { transform: scaleX(-1) rotate(-42deg) translate(-7px, -2px); }
.mode-select__mark i { position: relative; z-index: 1; width: 5px; height: 39px; background: var(--color-brand-dark); transform: translateY(9px); }
.mode-select .eyebrow { margin-top: 7px; }
.mode-select h2, .result h2 { margin-top: 6px; font-size: clamp(1.35rem, 3vw, 1.95rem); }
.mode-select > p:last-of-type, .result > p { max-width: 54ch; margin: 7px auto 0; color: var(--color-text-muted); font-size: .8rem; }
.level-picker { display: flex; justify-content: center; gap: 5px; margin-top: 15px; }
.level-picker__button { width: 30px; height: 30px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); font-size: .66rem; font-weight: 850; }
.level-picker__button:hover:not(:disabled), .level-picker__button.is-selected { border-color: var(--color-brand); background: var(--color-brand-soft); color: var(--color-brand-dark); }
.level-picker__button:disabled { cursor: not-allowed; opacity: .38; }
.mode-select__options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 15px; }
.mode-card {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, transform 120ms ease;
}
.mode-card:hover { border-color: var(--color-brand); background: var(--color-brand-soft); }
.mode-card:active { transform: translateY(1px); }
.mode-card--campaign { border-color: var(--color-brand); }
.mode-card__number, .mode-card__infinity { display: grid; width: 43px; height: 43px; flex: 0 0 auto; place-items: center; background: var(--color-brand-soft); color: var(--color-brand-dark); font-size: 1.15rem; font-weight: 900; }
.mode-card__infinity { font-size: 1.7rem; }
.mode-card > span:last-child { display: grid; gap: 3px; }
.mode-card strong { font-size: .9rem; }
.mode-card small { color: var(--color-text-muted); font-size: .68rem; }

.result__icon { display: inline-grid; width: 52px; height: 52px; place-items: center; background: var(--color-brand); color: #063d2d; font-size: 1.55rem; font-weight: 950; }
.result__icon.is-loss { background: var(--color-danger); color: #fff; }
.result .eyebrow { margin-top: 13px; }
.result__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 19px; }
.result__actions .button { min-height: 44px; }
.result > small { display: block; margin-top: 11px; color: var(--color-text-muted); font-size: .63rem; }

.plant-console { display: grid; gap: 9px; }
.plant-console__plants { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.plant-button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 78px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid #355b48;
  border-radius: var(--radius-small);
  background: #142c23;
  color: #f5fff9;
  text-align: left;
  transition: border-color 130ms ease, background-color 130ms ease, transform 100ms ease;
}
.plant-button:hover:not(:disabled), .plant-button.is-selected { border-color: #60dda9; background: #1c4435; }
.plant-button.is-selected { box-shadow: inset 0 -3px 0 #35d99b; }
.plant-button:active:not(:disabled) { transform: translateY(1px); }
.plant-button:disabled { cursor: not-allowed; opacity: .43; }
.plant-button__copy { display: grid; min-width: 0; gap: 2px; }
.plant-button__copy strong { overflow: hidden; color: #fff; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.plant-button__copy small { color: #f8d65a; font-size: .62rem; font-weight: 800; white-space: nowrap; }
.plant-button kbd { position: absolute; top: 4px; right: 4px; min-width: 17px; padding: 1px 3px; border: 0; background: transparent; color: #8eb6a5; font-size: .56rem; text-align: center; }
.plant-symbol { position: relative; display: block; width: 37px; height: 43px; flex: 0 0 auto; }
.plant-symbol i, .plant-symbol::before, .plant-symbol::after { position: absolute; content: ""; }
.plant-symbol i { bottom: 2px; left: 17px; width: 5px; height: 23px; background: #43a760; }
.plant-symbol i::after { position: absolute; top: 9px; left: -7px; width: 11px; height: 7px; border-radius: 100% 0; background: #68c779; content: ""; transform: rotate(24deg); }
.plant-symbol--sunflower::before { z-index: 2; top: 8px; left: 11px; width: 16px; height: 16px; border: 5px solid #f5bf2c; border-radius: 50%; background: #77451d; box-shadow: 0 -6px 0 -3px #f5bf2c, 0 6px 0 -3px #f5bf2c, 6px 0 0 -3px #f5bf2c, -6px 0 0 -3px #f5bf2c; }
.plant-symbol--pea::before { z-index: 2; top: 8px; left: 7px; width: 24px; height: 21px; border-radius: 50%; background: #53bb65; }
.plant-symbol--pea::after { z-index: 3; top: 12px; right: 0; width: 13px; height: 12px; border-radius: 3px 8px 8px 3px; background: #3a9650; }
.plant-symbol--chili i { left: 17px; height: 13px; transform: rotate(24deg); }
.plant-symbol--chili::before { z-index: 2; top: 11px; left: 7px; width: 23px; height: 28px; border-radius: 60% 38% 63% 43%; background: #ed5545; transform: rotate(19deg); }
.plant-symbol--chili::after { z-index: 3; top: 5px; left: 20px; width: 11px; height: 8px; border-top: 4px solid #5eb867; transform: rotate(31deg); }
.plant-symbol--pumpkin i { display: none; }
.plant-symbol--pumpkin::before { top: 10px; left: 3px; width: 32px; height: 28px; border-radius: 48%; background: #ef982f; box-shadow: inset 7px 0 #da7925, inset -7px 0 #f5ad3e; }
.plant-symbol--pumpkin::after { top: 5px; left: 17px; width: 5px; height: 9px; background: #558e45; }
.plant-symbol--whip i { left: 10px; height: 34px; border: 5px solid #52b268; border-top: 0; border-right: 0; background: transparent; transform: skewX(-13deg); }
.plant-symbol--whip::before { z-index: 2; top: 4px; left: 4px; width: 17px; height: 10px; border-radius: 100% 0; background: #7fd085; transform: rotate(-14deg); }
.plant-symbol--whip::after { bottom: 1px; left: 2px; width: 28px; height: 8px; border-radius: 50%; background: #3d8f52; }
.plant-symbol--shovel { transform: rotate(-12deg); }
.plant-symbol--shovel i { bottom: 2px; left: 17px; width: 5px; height: 27px; border-radius: 3px; background: #a86f3f; }
.plant-symbol--shovel i::after { top: -4px; left: -5px; width: 15px; height: 8px; border: 3px solid #d9b37a; border-bottom: 0; border-radius: 9px 9px 0 0; background: transparent; }
.plant-symbol--shovel::before { bottom: 0; left: 9px; width: 21px; height: 17px; border-radius: 2px 2px 10px 10px; background: linear-gradient(135deg, #eef3f0, #91a19b 75%); clip-path: polygon(18% 0, 82% 0, 100% 70%, 50% 100%, 0 70%); }
.plant-symbol--shovel::after { bottom: 13px; left: 13px; width: 13px; height: 3px; border-radius: 2px; background: #65736e; }
.plant-console__tip { display: flex; min-height: 25px; align-items: center; justify-content: space-between; gap: 20px; color: var(--color-text-muted); font-size: .65rem; }
.plant-console__tip > span:first-child { color: var(--color-text); font-weight: 750; }

.garden-help { max-height: min(650px, calc(100dvh - 28px)); }
.garden-help .dialog__content { overflow-y: auto; }
.garden-help__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 17px; background: var(--color-border); }
.garden-help__grid section { display: grid; gap: 2px; padding: 10px; background: var(--color-surface); }
.garden-help__grid strong { color: var(--color-text); font-size: .77rem; }
.garden-help__grid span { font-size: .7rem; }
.garden-help__note { margin-top: 16px; padding: 10px; background: var(--color-surface-raised); font-size: .72rem; }
.garden-help__note strong { color: var(--color-text); }

/* Garden Defense responsive */

@media (max-width: 860px) {
  .garden__heading > p { display: none; }
  .garden-stat:nth-child(2) { display: none; }
  .garden-board { min-height: 330px; aspect-ratio: 16 / 9; }
  .plant-button { flex-direction: column; gap: 1px; text-align: center; }
}

@media (max-width: 640px) {
  .garden { padding: 13px 0 21px; }
  .garden__layout { gap: 10px; }
  .garden__heading .eyebrow { display: none; }
  .garden__heading h1 { margin: 0; font-size: 1.55rem; }
  .garden__topbar { min-height: 48px; gap: 11px; }
  .garden-stat--sun { min-width: 50px; padding-left: 25px; }
  .sun-icon { width: 18px; height: 18px; }
  .wave-progress { min-width: 90px; }
  .garden-health strong, .garden-health > span { display: none; }
  .garden-health { display: block; }
  .garden-health__pips i { width: 5px; height: 11px; }
  .garden__controls { gap: 0; }
  .icon-button--garden { width: 40px; height: 40px; }
  .garden-board { min-height: 270px; aspect-ratio: 4 / 3; }
  .garden-board__overlay { padding: 12px; }
  .mode-select__mark { width: 36px; height: 36px; transform: scale(.75); }
  .mode-select .eyebrow { margin-top: 2px; }
  .mode-select h2, .result h2 { font-size: 1.22rem; }
  .mode-select > p:last-of-type, .result > p { font-size: .67rem; line-height: 1.4; }
  .level-picker { gap: 3px; margin-top: 10px; }
  .level-picker__button { width: 25px; height: 27px; }
  .mode-select__options { gap: 6px; margin-top: 10px; }
  .mode-card { min-height: 58px; gap: 8px; padding: 7px 9px; }
  .mode-card__number, .mode-card__infinity { width: 34px; height: 34px; }
  .mode-card strong { font-size: .75rem; }
  .mode-card small { font-size: .56rem; }
  .result__icon { width: 42px; height: 42px; }
  .result .eyebrow { margin-top: 8px; }
  .result__actions { gap: 6px; margin-top: 13px; }
  .result__actions .button { min-height: 42px; padding-inline: 13px; font-size: .68rem; }
  .result > small { margin-top: 7px; }
  .plant-console__plants { gap: 5px; }
  .plant-button { min-height: 62px; padding: 4px 2px; }
  .plant-button__copy small, .plant-button kbd { display: none; }
  .plant-button__copy strong { max-width: 62px; font-size: .58rem; }
  .plant-symbol { width: 33px; height: 37px; transform: scale(.86); }
  .plant-console__tip { justify-content: center; text-align: center; }
  .plant-console__tip > span:last-child { display: none; }
}

@media (max-width: 390px) {
  .wave-progress__label strong { display: none; }
  .garden-health { display: none; }
  .garden-board { min-height: 255px; }
  .mode-card__number, .mode-card__infinity { display: none; }
  .mode-card { justify-content: center; text-align: center; }
  .plant-button__copy strong { max-width: 55px; }
}

@media (max-height: 760px) and (min-width: 861px) {
  .garden { padding-block: 12px; }
  .garden__heading { display: none; }
  .garden-board { min-height: 300px; aspect-ratio: 2.1 / 1; }
  .plant-button { min-height: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  .wave-progress__track i, .plant-button, .mode-card { transition: none; }
}
