/**
 * Seedfall — layout, HUD, glass UI, map, modals
 * Colors are botanical (sage, terracotta, parchment).
 * Tune the :root tokens to retheme the chrome.
 */
:root {
  --ink-deep: #1A2418;
  --ink-mid: #2C3D28;
  --gold: #E8B86D;
  --gold-dark: #C4893A;
  --sprout: #5B8C5A;
  --sprout-dark: #3E6A3D;
  --raspberry: #5B8C5A;
  --raspberry-dark: #3E6A3D;
  --parchment: #F6F1E4;
  --parchment-dim: #E6DCC4;
  --glass-bg: rgba(246, 241, 228, 0.14);
  --glass-border: rgba(246, 241, 228, 0.28);
  --glass-bg-strong: rgba(26, 36, 24, 0.55);
  --font-display: "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#app {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background-color: #2C3D28;
  background-image: url("../assets/images/bg-garden.jpg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  font-family: var(--font-body);
  color: var(--parchment);
  touch-action: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stageWrapper {
  position: relative;
  touch-action: none;
}

canvas#game {
  display: block;
  touch-action: none;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  cursor: crosshair;
}
canvas#game.snipCursor {
  cursor: none;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  border-radius: 20px;
}

button {
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.btn {
  box-sizing: border-box;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  color: var(--ink-deep);
  background: linear-gradient(180deg, #FFE9B8, var(--gold));
  box-shadow: 0 4px 0 var(--gold-dark), 0 6px 14px rgba(0, 0, 0, 0.35);
  padding: 10px 14px;
  min-height: 44px;
  min-width: 0;
  max-width: 100%;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.1;
  white-space: nowrap;
}

.btn .btnIcon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  pointer-events: none;
  object-fit: contain;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45));
}

.btn.small {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 12px;
  min-height: 40px;
}
.btn.small .btnIcon { width: 22px; height: 22px; flex-basis: 22px; }

.btn.lg {
  font-size: 18px;
  padding: 12px 22px;
  min-height: 48px;
}
.btn.lg .btnIcon { width: 20px; height: 20px; flex-basis: 20px; }

.btn.wide {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
}

.iconBtn {
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: rgba(246, 241, 228, 0.12);
  border: 1px solid rgba(246, 241, 228, 0.3);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  transition: transform .08s ease, filter .15s ease;
}
.iconBtn img { width: 28px; height: 28px; pointer-events: none; object-fit: contain; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.4)); }
.iconBtn.sm { width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 12px; }
.iconBtn.sm img { width: 26px; height: 26px; }

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--gold-dark), 0 2px 6px rgba(0, 0, 0, 0.3);
}
.iconBtn:active { transform: translateY(2px); }

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { filter: brightness(1.07); }
  .iconBtn:hover { filter: brightness(1.12); }
  .powerBtn:hover:not(:disabled) { filter: brightness(1.1); }
  .levelNode:hover:not(.locked) { transform: translate(-50%, -50%) translateY(-3px); }
}

.btn.raspberry {
  background: linear-gradient(180deg, #8fbf6a, var(--sprout));
  box-shadow: 0 4px 0 var(--sprout-dark), 0 6px 14px rgba(0, 0, 0, 0.35);
  color: #fff;
}
.btn.raspberry:active:not(:disabled) {
  box-shadow: 0 1px 0 var(--sprout-dark), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn.ghost {
  background: rgba(246, 241, 228, 0.1);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  color: var(--parchment);
  border: 1px solid rgba(246, 241, 228, 0.3);
}
.btn.ghost:active:not(:disabled) {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn.danger {
  background: linear-gradient(180deg, #f08a7a, #c44a3a);
  box-shadow: 0 4px 0 #8a2a20, 0 6px 14px rgba(0, 0, 0, 0.35);
  color: #fff;
}
.btn.danger:active:not(:disabled) {
  box-shadow: 0 1px 0 #8a2a20, 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

#hudLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hudLayer > * {
  pointer-events: auto;
}

#hudTop {
  position: absolute;
  top: 2.2%;
  left: 2.5%;
  right: 2.5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.hudPill, #levelPill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--parchment);
  background: rgba(18, 22, 14, 0.82);
  border: 2px solid rgba(246, 241, 228, 0.55);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 0 #000;
}

#pauseBtn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(18, 22, 14, 0.82);
  border: 2px solid rgba(246, 241, 228, 0.55);
}

#progressTrack {
  position: absolute;
  top: 9.6%;
  left: 6%;
  right: 6%;
  height: 8px;
  border-radius: 8px;
  background: rgba(18, 22, 14, 0.7);
  border: 1px solid rgba(246, 241, 228, 0.35);
  overflow: hidden;
  pointer-events: none;
}

#progressFill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  box-shadow: 0 0 8px rgba(232, 184, 109, 0.7);
  transition: width .12s linear;
}

#powerTray {
  position: absolute;
  top: 50%;
  right: 1.8%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 6px;
  box-sizing: border-box;
  justify-content: center;
  align-items: center;
  z-index: 15;
  background: rgba(18, 22, 14, 0.78);
  border: 2px solid rgba(246, 241, 228, 0.4);
  border-radius: 20px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.powerBtn {
  box-sizing: border-box;
  width: 48px;
  height: 50px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 1 48px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(246, 241, 228, 0.1);
  border: 1px solid rgba(246, 241, 228, 0.28);
  cursor: pointer;
  position: relative;
  color: var(--parchment);
  transition: transform .1s ease;
  padding: 4px;
  touch-action: manipulation;
}

.powerBtn:active { transform: scale(0.9); }
.powerBtn .powerIc { width: 30px; height: 30px; pointer-events: none; object-fit: contain; }
.powerBtn .ct { font-size: 9px; font-weight: 800; margin-top: 1px; }

.powerBtn.active {
  background: rgba(232, 184, 109, 0.35);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(232, 184, 109, 0.6);
  animation: powerPulse 1s ease-in-out infinite;
}

@keyframes powerPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(232, 184, 109, 0.5); }
  50% { box-shadow: 0 0 18px rgba(232, 184, 109, 0.9); }
}

.powerBtn:disabled { opacity: 0.35; }

#comboLabel {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translate(-50%, 0);
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: #1A2418;
  background: #F6F1E4;
  border: 2px solid #1A2418;
  box-shadow: 0 3px 0 #1A2418;
  padding: 6px 14px;
  border-radius: 999px;
  text-shadow: none;
  opacity: 0;
  letter-spacing: 0.04em;
}

#levelIntroLabel {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--parchment);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
  opacity: 0;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 10px 22px;
  border-radius: 16px;
  background: rgba(26, 36, 24, 0.4);
  transition: opacity .35s ease, transform .35s ease;
  z-index: 12;
  white-space: nowrap;
}

#levelIntroLabel.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#toastWrap {
  position: absolute;
  top: 11%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 9px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  background: rgba(26, 36, 24, 0.85);
  border: 1px solid rgba(246, 241, 228, 0.3);
  color: var(--parchment);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .25s ease, transform .25s ease;
  white-space: normal;
  max-width: min(280px, 86vw);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modalScreen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 8, 0.55);
  z-index: 40;
  opacity: 0;
  transition: opacity .22s ease;
}

.modalScreen.visible { opacity: 1; }

.modalCard {
  width: min(86%, 340px);
  max-width: calc(100% - 16px);
  max-height: min(92%, 100%);
  box-sizing: border-box;
  padding: 22px 16px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  overflow-x: visible;
  overflow-y: auto;
  transform: scale(0.88) translateY(10px);
  transition: transform .28s cubic-bezier(.34, 1.56, .64, 1);
}

.modalScreen.visible .modalCard {
  transform: scale(1) translateY(0);
}

.modalCard h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 24px;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  text-align: center;
}

.modalStars {
  display: flex;
  gap: 10px;
  margin: 6px 0;
  justify-content: center;
  align-self: center;
}

.modalStars img {
  width: 38px;
  height: 38px;
}

.modalHero {
  width: 88px;
  height: 88px;
  margin: -4px auto 0;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

.modalCopy {
  margin: 0;
  opacity: 0.8;
  font-size: 13px;
}

.rewardLine {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-display);
  color: var(--gold);
  font-weight: 800;
}

.rewardLine img { width: 22px; height: 22px; }

.currencyPill img { width: 18px; height: 18px; }

.modalBtnRow {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  align-self: stretch;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 4px;
  box-sizing: border-box;
}

.modalBtnRow .btn {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 6px;
  font-size: 13px;
  letter-spacing: 0;
  gap: 4px;
  white-space: nowrap;
}

.modalBtnRow .btn .btnIcon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

#titleScreen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  z-index: 50;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(180deg, #2C3D28, #141a12 70%);
  border-radius: 18px;
  overflow: hidden;
}

#titleBgDeco {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#titleBgDeco img {
  position: absolute;
  object-fit: contain;
  background: none;
  border-radius: 0;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0% { transform: translateY(20px) scale(0.6); opacity: 0; }
  10% { opacity: 0.8; }
  90% { opacity: 0.5; }
  100% { transform: translateY(-620px) scale(1.1); opacity: 0; }
}

#logoWordmark {
  width: min(280px, 78%);
  height: auto;
  margin: 0;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 3px 0 var(--sprout-dark)) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.5));
  object-fit: contain;
}

#logoWordmark span { color: var(--gold); }

#titleScreen .tagline,
#titleScreen p {
  opacity: 0.75;
  margin: 0;
  font-size: 13px;
  text-align: center;
  max-width: 260px;
  position: relative;
  z-index: 2;
}

#titleCreature {
  width: 132px;
  height: 132px;
  animation: titleBob 2.6s ease-in-out infinite;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
  object-fit: contain;
}

.titleTools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

.titleTools .btn {
  min-width: 0;
  max-width: 100%;
}

@keyframes titleBob {
  0%, 100% { transform: translateY(0) scaleY(1); }
  45% { transform: translateY(-10px) scaleY(1.04); }
  55% { transform: translateY(-10px) scaleY(1.04); }
  75% { transform: translateY(2px) scaleY(0.96); }
}

#titleBtnRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

#titleBtnRow .btn {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

#titleProgress {
  font-size: 11px;
  opacity: 0.6;
  position: relative;
  z-index: 2;
  letter-spacing: 0.03em;
}

#loadingScreen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.1), transparent 45%),
    linear-gradient(180deg, #2C3D28, #12160f 80%);
  border-radius: 18px;
}

#loadingCreature {
  width: 100px;
  height: 100px;
  animation: loadBob 0.9s ease-in-out infinite;
  object-fit: contain;
}

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

#loadingScreen h3 {
  font-family: var(--font-display);
  color: var(--gold);
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.03em;
}

#loadingBarTrack {
  width: min(70%, 260px);
  height: 16px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(246, 241, 228, 0.15);
  border: 1px solid rgba(246, 241, 228, 0.3);
}

#loadingBarFill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  transition: width 0.1s linear;
}

#loadingTip {
  font-size: 12px;
  opacity: 0.7;
  max-width: 240px;
  text-align: center;
}

#howToPlayModal { z-index: 55; }

#howToPlayModal .modalCard {
  text-align: left;
  max-height: 80vh;
  overflow-y: auto;
}

#howToPlayModal h2 { align-self: center; }

.htpStep {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
}

.htpStep .htpIcon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.35));
}

.htpStep .htpText {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.9;
}

.htpStep b { color: var(--gold); }

#mapScreen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  opacity: 0;
  transition: opacity .22s ease;
  background:
    radial-gradient(ellipse at 50% -8%, #5a7a44 0%, transparent 46%),
    linear-gradient(180deg, #2a3c26, #12180f 88%);
}

#mapScreen.visible { opacity: 1; }

#mapHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px;
  flex: 0 0 auto;
  gap: 8px;
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
}

#mapHeader h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 16px;
  color: var(--parchment);
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#mapHeader .currencyPill {
  flex: 0 1 auto;
  min-width: 0;
}

#mapHeaderActions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

#mapScroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 0 30px;
}

.worldSection {
  padding: 6px 12px 22px;
  position: relative;
}

.worldHead {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 0 auto 12px;
  max-width: 440px;
  padding: 8px 12px;
  background: #F6F1E4;
  color: var(--ink-deep);
  border: 3px solid #1A2418;
  border-radius: 16px;
  box-shadow: 0 4px 0 #1A2418;
}

.worldHead .worldPlanter {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: contain;
}

.worldTitle {
  font-family: var(--font-display);
  text-align: left;
  font-size: 15px;
  padding: 0;
  width: auto;
  border-radius: 0;
  background: none;
  border: none;
  color: var(--ink-deep) !important;
}

.worldProgress {
  font-size: 11px;
  opacity: 0.75;
  font-family: var(--font-display);
  color: var(--ink-deep);
  display: flex;
  align-items: center;
  gap: 4px;
}

.trailWrap {
  position: relative;
  width: 92%;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 10px 18px;
  background: rgba(246, 241, 228, 0.08);
  border: 2px solid rgba(246, 241, 228, 0.22);
  border-radius: 22px;
  overflow: visible;
}

.trailWrap .vineTrail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.85;
}

.levelNode {
  box-sizing: border-box;
  width: 52px;
  height: 52px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  border: 3px solid #5a4630;
  background: radial-gradient(circle at 35% 30%, #6a8a52, #2a3c26 72%);
  color: var(--parchment);
  position: relative;
  cursor: pointer;
  box-shadow: 0 4px 0 #1a140c, inset 0 1px 0 rgba(255,255,255,0.18);
  transition: transform .12s ease;
  z-index: 1;
}

.levelNode:active { transform: translate(-50%, -50%) scale(0.92); }

.levelNode.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.levelNode.done {
  border-color: var(--gold);
  background: linear-gradient(180deg, #FFE29A, #E8B24B);
  color: var(--ink-deep);
}

.levelNode.boss {
  width: 60px;
  height: 60px;
  font-size: 17px;
  border-width: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(246, 241, 228, 0.08);
}

.levelNode.boss .bossCrown {
  position: absolute;
  top: -18px;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.levelNode.next { animation: nextPulse 1.4s ease-in-out infinite; }

@keyframes nextPulse {
  0%, 100% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(232, 184, 109, 0.6); }
  50% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), 0 0 0 8px rgba(232, 184, 109, 0); }
}

.levelNode .miniStars {
  position: absolute;
  bottom: -13px;
  display: flex;
  gap: 1px;
}

.levelNode .miniStars img { width: 10px; height: 10px; }
.levelNode .lockIc {
  width: 20px;
  height: 20px;
  opacity: 0.9;
}

#shopRow {
  display: flex;
  gap: 10px;
  padding: 10px 12px 20px;
  flex-wrap: wrap;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.shopItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  width: 92px;
  max-width: calc(50% - 12px);
  box-sizing: border-box;
  min-width: 0;
}

.shopItem .ic {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.shopItem .label { font-size: 11px; opacity: 0.8; text-align: center; }
.shopItem .btn {
  width: 100%;
  margin-top: 2px;
  font-size: 11px;
  padding: 6px 4px;
  min-height: 36px;
  box-sizing: border-box;
}

#failFlash {
  position: absolute;
  inset: 0;
  background: rgba(180, 20, 60, 0);
  pointer-events: none;
  z-index: 20;
  border-radius: 18px;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 18px;
  z-index: 5;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.45);
}

#settingsModal { z-index: 56; }

#settingsModal .modalCard { text-align: left; }

#settingsModal .hint {
  font-size: 12px;
  opacity: 0.7;
  margin: 0;
  line-height: 1.4;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb {
  background: rgba(246, 241, 228, 0.3);
  border-radius: 6px;
}

@media (max-width: 480px) {
  .modalCard h2 { font-size: 22px; }
  #logoWordmark { font-size: 34px; }
  .powerBtn { width: 46px; height: 48px; }
  #titleCreature { width: 110px; height: 110px; }
  .modalCard { padding: 22px 14px 18px; }
  .modalBtnRow { gap: 6px; }
  .modalBtnRow .btn { padding: 10px 4px; font-size: 12px; }
}

@media (max-width: 360px) {
  #completeModal .modalBtnRow,
  #failModal .modalBtnRow {
    flex-wrap: wrap;
  }
  #completeModal .modalBtnRow .btn,
  #failModal .modalBtnRow .btn {
    flex: 1 1 calc(50% - 4px);
  }
  #completeNextBtn {
    flex: 1 1 100%;
  }
}

.btn:focus-visible,
.iconBtn:focus-visible,
.powerBtn:focus-visible,
.levelNode:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#closeHowToPlayBtn {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  margin-top: 6px;
  box-sizing: border-box;
}

#hudLayer.slowMo::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(90, 160, 220, 0.1);
  border-radius: 18px;
}

#confirmModal { z-index: 80; }

@media (orientation: landscape) and (max-height: 500px) {
  #logoWordmark { font-size: 28px; }
  #titleCreature { width: 72px; height: 72px; }
  #titleScreen { gap: 10px; }
  .modalCard { padding: 12px 14px; gap: 8px; }
  .modalHero { width: 56px; height: 56px; }
  #powerTray { padding: 4px; gap: 4px; }
  .powerBtn { width: 42px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  #titleCreature,
  #loadingCreature,
  .powerBtn.active,
  .levelNode.next,
  #titleBgDeco img {
    animation: none !important;
  }
}

.worldHeadCopy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.trailWrap {
  height: 560px;
}

.levelNode {
  position: absolute;
  transform: translate(-50%, -50%);
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.levelNode .nodeNum {
  line-height: 1;
}

.shopHead {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--ink-deep);
  background: #F6F1E4;
  border: 3px solid #1A2418;
  box-shadow: 0 4px 0 #1A2418;
  border-radius: 16px;
  padding: 8px 16px;
  margin: 8px auto 0;
  width: fit-content;
}

.shopItem .owned {
  font-size: 11px;
  opacity: 0.7;
}

.grove-0 .trailWrap { background: linear-gradient(180deg, rgba(143,212,106,0.18), rgba(246,241,228,0.06)); }
.grove-1 .trailWrap { background: linear-gradient(180deg, rgba(160,140,220,0.2), rgba(246,241,228,0.06)); }
.grove-2 .trailWrap { background: linear-gradient(180deg, rgba(140,200,230,0.2), rgba(246,241,228,0.06)); }
.grove-3 .trailWrap { background: linear-gradient(180deg, rgba(90,180,190,0.2), rgba(246,241,228,0.06)); }
.grove-4 .trailWrap { background: linear-gradient(180deg, rgba(220,120,70,0.2), rgba(246,241,228,0.06)); }

#mapHeader {
  position: relative;
  z-index: 2;
  background: rgba(18, 22, 14, 0.72);
  border-bottom: 2px solid rgba(246, 241, 228, 0.22);
}

#mapScroll { position: relative; z-index: 1; }

.currencyPill {
  color: var(--parchment);
}

.modalStars img {
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.35));
}

/* ---- final polish overrides ---- */
.modalCard.glass {
  background: rgba(20, 26, 16, 0.94);
  border: 2px solid rgba(246, 241, 228, 0.42);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 6px 0 rgba(0, 0, 0, 0.25);
}

#levelIntroLabel {
  background: rgba(18, 22, 14, 0.86);
  border: 2px solid rgba(246, 241, 228, 0.5);
  color: var(--parchment);
  text-shadow: 0 1px 0 #000;
}

.powerBtn .ct {
  font-size: 11px;
  line-height: 1;
  color: var(--parchment);
  text-shadow: 0 1px 0 #000;
}

#mapHeader .iconBtn {
  background: rgba(18, 22, 14, 0.82);
  border: 2px solid rgba(246, 241, 228, 0.55);
}

.levelNode {
  padding: 0;
}

.levelNode.locked {
  opacity: 1;
  filter: none;
  background: radial-gradient(circle at 35% 30%, #3a4634, #1a2016 72%);
  border-color: #2a2418;
  color: #8a907e;
}

.levelNode.done {
  border-color: #C4893A;
  background: radial-gradient(circle at 35% 28%, #FFE9B8, #E8B24B 70%);
  color: var(--ink-deep);
  box-shadow: 0 4px 0 #8a5a18, inset 0 1px 0 rgba(255,255,255,0.45);
}

.levelNode.boss {
  background: radial-gradient(circle at 35% 28%, #f0a070, #8a3a28 72%);
  border-color: #E8B86D;
  color: #fff8e8;
}

.levelNode.boss.done {
  background: radial-gradient(circle at 35% 28%, #FFE9B8, #C4893A 72%);
  color: var(--ink-deep);
}

.levelNode.next {
  box-shadow: 0 4px 0 #1a140c, 0 0 0 3px rgba(232, 184, 109, 0.85);
}

.levelNode .miniStars {
  bottom: -15px;
  padding: 1px 4px;
  background: rgba(18, 22, 14, 0.78);
  border-radius: 999px;
  border: 1px solid rgba(246, 241, 228, 0.25);
}

.levelNode .miniStars img { width: 11px; height: 11px; }

.shopItem {
  background: #F6F1E4;
  color: var(--ink-deep);
  border: 3px solid #1A2418;
  box-shadow: 0 4px 0 #1A2418;
  border-radius: 16px;
}
.shopItem .label,
.shopItem .owned { color: var(--ink-deep); opacity: 0.85; }

.trailWrap {
  box-shadow: inset 0 0 0 1px rgba(246, 241, 228, 0.08), 0 10px 0 rgba(0, 0, 0, 0.18);
}

@media (max-width: 420px) {
  .trailWrap { height: 500px; }
  .levelNode { width: 46px; height: 46px; font-size: 13px; }
  .levelNode.boss { width: 54px; height: 54px; }
  .levelNode .nodeNum { font-size: 11px; }
  .levelNode.boss .nodeNum { font-size: 12px; }
  #mapHeader h2 { font-size: 14px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .trailWrap { height: 360px; }
  #progressTrack { top: 12%; }
  #comboLabel { top: 20%; }
}

@media (hover: hover) and (pointer: fine) {
  .levelNode:hover:not(.locked) { transform: translate(-50%, -50%) translateY(-3px); }
}

#levelPill img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

#mapHeader h2 img,
.modalCard h2 img {
  width: 28px;
  height: 28px;
  vertical-align: middle;
  margin-right: 8px;
  object-fit: contain;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.4));
}

.shopHead img {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 4px;
}

.vineTrail {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.trailLeaf,
.groveProp {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
}

.trailLeaf {
  width: 22px;
  height: 22px;
  opacity: 0.92;
  filter: drop-shadow(0 1px 0 #1A2418);
}

.groveProp {
  width: 28px;
  height: 28px;
  opacity: 0.55;
}

.levelNode .nodeFace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 62%;
  pointer-events: none;
  opacity: 1;
  z-index: 0;
  border-radius: 50%;
}

.levelNode .nodeNum {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #1A2418;
  pointer-events: none;
  text-shadow:
    0 0 2px #F6F1E4,
    1px 0 0 #F6F1E4,
    -1px 0 0 #F6F1E4,
    0 1px 0 #F6F1E4,
    0 -1px 0 #F6F1E4;
}

.levelNode.boss .nodeNum { font-size: 13px; }

.levelNode.locked .nodeFace {
  inset: auto;
  width: 50%;
  height: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  opacity: 0.95;
}

@media (max-width: 480px) {
  #logoWordmark { width: min(220px, 82%); }
  #powerTray { right: 1.2%; padding: 6px 4px; gap: 6px; }
  .powerBtn { width: 44px; height: 46px; min-width: 44px; min-height: 44px; }
  canvas#game, #stageWrapper { border-radius: 12px; }
}

@media (max-height: 700px) {
  #powerTray { gap: 5px; padding: 6px 4px; }
  .powerBtn { width: 44px; height: 46px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #logoWordmark { width: min(180px, 50%); }
}
