/* Grove of Thorns — 16-Bit Enchanted Forest Day/Night Druid TD */
:root {
  --bg-deep: #0b1310;
  --bg-panel: #13211b;
  --bg-panel-alt: #192c24;
  --border-gold: #c9a24b;
  --border-moss: #2e5442;
  --text-main: #eef5e9;
  --text-muted: #9eb8a8;
  --day-gold: #fbbf24;
  --day-emerald: #34d399;
  --night-indigo: #818cf8;
  --night-cyan: #38bdf8;
  --night-violet: #c084fc;
  --danger: #f87171;
  --font-ui: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-pixel: 'Courier New', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: radial-gradient(circle at top, #172a22 0%, #0a120f 70%);
  color: var(--text-main);
  font-family: var(--font-ui);
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 10px 44px;
  gap: 8px;
}

/* Top HUD */
#top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: linear-gradient(180deg, #1a2e25 0%, #111f19 100%);
  border: 2px solid var(--border-moss);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px 10px;
}

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

.hud-icon-btn {
  background: #1f3b2e;
  border: 1px solid #3c7058;
  color: var(--text-main);
  border-radius: 7px;
  width: 34px;
  height: 34px;
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.hud-icon-btn:hover { background: #29503d; border-color: var(--day-emerald); }

.hud-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-map-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.3px;
  color: #f4f7e8;
}

.cycle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: all 0.4s ease;
}
.cycle-pill.day {
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(251, 191, 36, 0.55);
  color: #fde68a;
}
.cycle-pill.night {
  background: rgba(129, 140, 248, 0.22);
  border-color: rgba(167, 139, 250, 0.65);
  color: #ddd6fe;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}
.cycle-pill.eclipse {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.3), rgba(168, 85, 247, 0.35));
  border-color: #fde047;
  color: #fff7c2;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.45);
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #0d1813;
  border: 1px solid #294638;
  border-radius: 7px;
  padding: 4px 9px;
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 13px;
}
.stat-chip.gold { border-color: rgba(56, 189, 248, 0.45); color: #7dd3fc; }
.stat-chip.hp { border-color: rgba(52, 211, 153, 0.45); color: #6ee7b7; }
.stat-chip.wave { border-color: rgba(251, 191, 36, 0.45); color: #fde68a; }
.stat-chip.score { border-color: rgba(192, 132, 252, 0.45); color: #e9d5ff; }

.hud-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-btn {
  background: #1b3127;
  border: 1px solid #355e4b;
  color: var(--text-main);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  min-height: 32px;
}
.hud-btn:hover { background: #264537; border-color: var(--day-emerald); }
.hud-btn.active { background: #2d5a42; border-color: var(--day-gold); color: #fef08a; }
.hud-btn.accent {
  background: linear-gradient(180deg, #433417, #2c210d);
  border-color: var(--border-gold);
  color: #fde68a;
}

/* Stage & Canvas */
#stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

#canvas-shell {
  position: relative;
  width: 100%;
  background: #0a1410;
  border: 2px solid #2c523f;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 580;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
  cursor: pointer;
}

/* Overlays on Canvas */
.cycle-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(12, 20, 32, 0.9);
  border: 2px solid #a78bfa;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 15;
  max-width: calc(100% - 24px);
}
.cycle-banner.day {
  background: rgba(24, 34, 18, 0.92);
  border-color: #fbbf24;
}
.cycle-banner.eclipse {
  background: linear-gradient(90deg, rgba(45, 27, 12, 0.94), rgba(35, 18, 56, 0.94));
  border-color: #fde047;
}
.cb-icon { font-size: 24px; }
.cb-title { font-weight: 900; font-size: 13px; letter-spacing: 0.7px; color: #fff; }
.cb-sub { font-size: 11px; color: #d6e4da; }

.boss-banner {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(76, 12, 34, 0.94), rgba(114, 18, 54, 0.94));
  border: 2px solid #f43f5e;
  color: #ffe4e6;
  padding: 6px 16px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 16;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.45);
}

.spell-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 32, 22, 0.94);
  border: 2px solid #34d399;
  color: #ecfdf5;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 18;
  max-width: calc(100% - 16px);
}
.mini-btn {
  background: #234634;
  border: 1px solid #4ade80;
  color: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}

.challenge-ribbon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(34, 18, 56, 0.9);
  border: 1px solid #c084fc;
  color: #f3e8ff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 12;
  pointer-events: none;
}

/* Pad / Tower Inspector (Desktop floating panel) */
.pad-inspector {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(470px, calc(100% - 20px));
  background: rgba(13, 24, 19, 0.96);
  border: 2px solid var(--border-gold);
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 25;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
}
.insp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.insp-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.insp-title {
  font-weight: 800;
  font-size: 14px;
  color: #fef3c7;
}
.insp-synergy {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
}
.insp-close {
  background: #22382e;
  border: 1px solid #3f6a56;
  color: #e5efe9;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-weight: 700;
}
.insp-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.insp-build-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.insp-build-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: #182e24;
  border: 1px solid #365f4b;
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text-main);
  cursor: pointer;
}
.insp-build-btn:hover:not(:disabled) {
  background: #214032;
  border-color: var(--day-gold);
}
.insp-build-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
.insp-thumb {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.insp-thumb canvas {
  max-width: 34px;
  max-height: 34px;
  image-rendering: pixelated;
}
.insp-b-name { font-weight: 800; font-size: 12px; }
.insp-b-sub { font-size: 10px; color: var(--text-muted); }
.insp-b-cost { font-family: var(--font-pixel); font-size: 11px; color: #7dd3fc; font-weight: 700; margin-top: 2px; }

.insp-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #d6e9de;
  background: #0d1914;
  border: 1px solid #264436;
  border-radius: 8px;
  padding: 6px 9px;
}
.insp-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.insp-actions-row button {
  flex: 1;
  min-width: 115px;
}

/* Bottom Action Bar */
#action-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, #172a22 0%, #101d18 100%);
  border: 2px solid var(--border-moss);
  border-radius: 10px;
  padding: 7px 8px;
}

.action-group {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.towers-group {
  flex: 1.45;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.spells-group {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tower-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  background: #162921;
  border: 2px solid #2c5240;
  border-radius: 9px;
  padding: 6px 7px;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  min-width: 0;
}
.tower-card:hover { background: #1e372c; border-color: #4f8f6f; }
.tower-card.selected {
  background: #234434;
  border-color: var(--day-gold);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
}
.tower-card.unaffordable { opacity: 0.56; }
.tower-card.boosted-day { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.35); }
.tower-card.boosted-night { box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.45); }

.tc-sprite {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}
.tc-sprite canvas {
  max-width: 34px;
  max-height: 34px;
  image-rendering: pixelated;
}
.tc-meta { min-width: 0; flex: 1; }
.tc-name {
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-tag {
  font-size: 10px;
  font-weight: 700;
  margin-top: 1px;
}
.day-tag { color: #fcd34d; }
.night-tag { color: #c4b5fd; }
.tc-cost {
  font-family: var(--font-pixel);
  font-size: 11px;
  font-weight: 700;
  color: #7dd3fc;
  margin-top: 2px;
}
.tc-key {
  position: absolute;
  top: 4px;
  right: 5px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: #82a896;
}

.spell-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #1b3a2d, #13281f);
  border: 2px solid #2f6b50;
  border-radius: 9px;
  padding: 6px 8px;
  color: #ecfdf5;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.spell-btn.eclipse {
  background: linear-gradient(180deg, #2d2649, #1b1630);
  border-color: #7c5fd1;
}
.spell-btn:hover:not(:disabled) { filter: brightness(1.14); border-color: #fde047; }
.spell-btn.active-cast {
  border-color: #4ade80;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.5);
}
.spell-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sp-key {
  position: absolute;
  top: 4px;
  right: 5px;
  font-family: var(--font-pixel);
  font-size: 10px;
  opacity: 0.7;
}
.sp-icon { font-size: 18px; flex-shrink: 0; }
.sp-info { display: flex; flex-direction: column; min-width: 0; }
.sp-name { font-weight: 800; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-cd { font-family: var(--font-pixel); font-size: 11px; color: #86efac; font-weight: 700; }
.spell-btn.eclipse .sp-cd { color: #fde68a; }

.wave-call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #b4781c, #7c4d0d);
  border: 2px solid #fbbf24;
  border-radius: 9px;
  padding: 6px 8px;
  color: #fffbeb;
  cursor: pointer;
  font-weight: 800;
}
.wave-call-btn:hover:not(:disabled) { filter: brightness(1.12); }
.wave-call-btn:disabled {
  background: #1d2b24;
  border-color: #314b3e;
  color: #7f9c8c;
  cursor: default;
}
.wc-top { font-size: 11px; letter-spacing: 0.4px; }
.wc-sub { font-size: 10px; font-family: var(--font-pixel); opacity: 0.92; margin-top: 2px; }

/* Modals (Fixed Full-Viewport Scrollable) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 11, 9, 0.84);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
}
#modal-tree, #modal-lb {
  z-index: 120;
}
.hidden { display: none !important; }

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  background: linear-gradient(180deg, #162921 0%, #0f1c16 100%);
  border: 2px solid var(--border-gold);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.72);
}

.title-hero {
  text-align: center;
  margin-bottom: 14px;
}
.hero-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  padding: 3px 11px;
  margin-bottom: 6px;
}
.game-logo {
  margin: 0;
  font-size: clamp(24px, 4.5vw, 34px);
  letter-spacing: 1.2px;
  color: #f6fae9;
  text-shadow: 0 3px 0 #0a1811, 0 0 22px rgba(52, 211, 153, 0.32);
}
.hero-tagline {
  margin: 6px auto 0;
  font-size: 13px;
  color: #c2dacb;
  max-width: 560px;
  line-height: 1.45;
}
.hl-day { color: #fde68a; font-weight: 800; }
.hl-night { color: #c4b5fd; font-weight: 800; }

/* Daily Strip */
.daily-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: linear-gradient(90deg, rgba(35, 25, 62, 0.85), rgba(20, 44, 34, 0.85));
  border: 1px solid #7c68b8;
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 14px;
}
.daily-tag {
  font-size: 12px;
  font-weight: 900;
  color: #e9d5ff;
  letter-spacing: 0.5px;
}
.daily-mod {
  font-size: 12px;
  color: #fde68a;
  margin-top: 2px;
}
.daily-meta {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: #bdd4c7;
  margin-top: 4px;
}
.daily-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: #d9eadf;
  margin-bottom: 8px;
}
.section-hint { font-size: 11px; font-weight: 600; color: var(--text-muted); }

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}
.map-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  background: #14261e;
  border: 2px solid #2b4e3d;
  border-radius: 10px;
  padding: 10px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.map-card:hover:not(:disabled) {
  border-color: var(--day-gold);
  background: #1b3428;
  transform: translateY(-1px);
}
.map-card.selected {
  border-color: #34d399;
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.25);
}
.map-card.locked {
  opacity: 0.52;
  cursor: not-allowed;
  background: #0f1a15;
}
.mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #93b8a3;
}
.mc-stars { color: #fbbf24; letter-spacing: 1px; font-size: 13px; }
.mc-name { font-weight: 800; font-size: 13px; color: #f6fae9; }
.mc-desc { font-size: 11px; color: #a7c2b3; line-height: 1.3; }
.mc-boss { font-size: 10px; color: #fca5a5; margin-top: auto; padding-top: 4px; }

.title-footer-row {
  display: flex;
  justify-content: center;
}
.big-play {
  width: 100%;
  max-width: 340px;
  font-size: 15px;
  padding: 11px 18px;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(180deg, #2d8a5b, #1d6340);
  border: 2px solid #6ee7b7;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  border-radius: 9px;
  padding: 8px 15px;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary {
  background: #1b3127;
  border: 1px solid #3c6a54;
  color: #e6f2eb;
  font-weight: 700;
  font-size: 12px;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn-secondary:hover { background: #264537; border-color: #6ee7b7; }
.btn-secondary.small { padding: 5px 10px; font-size: 11px; }

.btn-accent {
  background: linear-gradient(180deg, #5b3da8, #3d257a);
  border: 2px solid #c4b5fd;
  color: #faf5ff;
  font-weight: 800;
  font-size: 13px;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn-accent:hover { filter: brightness(1.12); }

.btn-danger {
  background: #471c24;
  border: 1px solid #f87171;
  color: #fee2e2;
  font-weight: 700;
  font-size: 12px;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}

.daily-btn {
  background: linear-gradient(180deg, #7c3aed, #5b21b6);
  border-color: #ddd6fe;
}

/* Modal Headers & Tree */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-header h2 { margin: 0; font-size: 19px; color: #fef3c7; }
.modal-sub { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }
.close-x {
  background: #1e352b;
  border: 1px solid #3f6a56;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  flex-shrink: 0;
}

.star-bank-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: #0d1813;
  border: 1px solid #355a48;
  border-radius: 9px;
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.star-gold { color: #fbbf24; font-size: 15px; }

.perk-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}
.perk-card {
  background: #14261e;
  border: 1px solid #2e5442;
  border-radius: 10px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.perk-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 13px;
}
.perk-rank {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: #fde68a;
}
.perk-desc { font-size: 11px; color: #b5cec0; line-height: 1.35; }
.perk-btn {
  margin-top: auto;
  width: 100%;
}

/* Leaderboard */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 130px;
}
.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: #12221b;
  border: 1px solid #274738;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
}
.lb-rank { font-family: var(--font-pixel); font-weight: 800; color: #fbbf24; }
.lb-name { font-weight: 700; color: #f0f8f2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-wave { font-size: 11px; color: #9eb8a8; }
.lb-score { font-family: var(--font-pixel); font-weight: 800; color: #6ee7b7; }
.lb-loading { text-align: center; color: var(--text-muted); padding: 26px 8px; font-size: 13px; }

/* End Modal */
.end-card { max-width: 560px; text-align: center; }
.end-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.end-badge.victory { background: rgba(52, 211, 153, 0.2); border: 1px solid #34d399; color: #6ee7b7; }
.end-badge.defeat { background: rgba(248, 113, 113, 0.2); border: 1px solid #f87171; color: #fecaca; }
.end-title { margin: 0 0 6px; font-size: 22px; color: #fef3c7; }
.end-stars { font-size: 28px; letter-spacing: 5px; color: #fbbf24; margin-bottom: 12px; }

.end-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 12px;
}
.end-stat {
  background: #0d1813;
  border: 1px solid #284738;
  border-radius: 8px;
  padding: 8px 6px;
}
.es-label { display: block; font-size: 10px; color: var(--text-muted); margin-bottom: 3px; }
.end-stat strong { font-family: var(--font-pixel); font-size: 15px; color: #f4f9f5; }

.cliffhanger-box {
  background: rgba(251, 191, 36, 0.11);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fef3c7;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  margin-bottom: 11px;
  text-align: left;
  line-height: 1.4;
}

.lb-submit-box {
  background: #101f19;
  border: 1px solid #2a4c3c;
  border-radius: 9px;
  padding: 10px;
  margin-bottom: 11px;
  text-align: left;
  font-size: 12px;
}
.lb-submit-row {
  display: flex;
  gap: 7px;
  margin-top: 6px;
}
.lb-submit-row input {
  flex: 1;
  min-width: 0;
  background: #0a1410;
  border: 1px solid #3c6953;
  color: #fff;
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 13px;
}
.submit-status { font-size: 11px; color: #86efac; margin-top: 5px; min-height: 14px; }

.share-box {
  background: #0d171f;
  border: 1px solid #4c4685;
  border-radius: 9px;
  padding: 10px;
  margin-bottom: 13px;
}
.share-preview {
  margin: 0 0 8px;
  font-family: var(--font-pixel);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e2e8f0;
  text-align: left;
}
.share-toast {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: #86efac;
  min-height: 14px;
}

.end-actions, .modal-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pause-card { max-width: 480px; text-align: center; }
.pause-cycle-guide {
  text-align: left;
  background: #0e1a15;
  border: 1px solid #2b4d3d;
  border-radius: 9px;
  padding: 10px 12px;
  margin: 12px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  line-height: 1.4;
}

/* Responsive Mobile (<= 760px, tested at 390x844, 0px horizontal overflow) */
@media (max-width: 760px) {
  #app {
    padding: 5px 6px 46px;
    gap: 6px;
  }

  #top-hud {
    padding: 6px 7px;
    gap: 6px;
  }
  .hud-map-name { font-size: 13px; }
  .cycle-pill { font-size: 10px; padding: 2px 7px; }
  .stat-chip { padding: 3px 6px; font-size: 12px; }
  .hud-btn { padding: 4px 7px; font-size: 11px; min-height: 29px; }

  #action-bar {
    flex-direction: column;
    padding: 6px;
    gap: 6px;
  }
  .towers-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .spells-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tower-card { padding: 5px 6px; gap: 6px; }
  .tc-sprite { width: 30px; height: 30px; }
  .tc-sprite canvas { max-width: 28px; max-height: 28px; }
  .tc-name { font-size: 11px; }
  .tc-key, .sp-key { display: none; }

  .spell-btn {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 5px 4px;
    gap: 2px;
  }
  .sp-icon { font-size: 15px; }
  .sp-name { font-size: 10px; }
  .sp-cd { font-size: 10px; }
  .wc-top { font-size: 10px; }
  .wc-sub { font-size: 9px; }

  /* Mobile Bottom-Sheet Tower Inspector */
  .pad-inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-width: 100vw;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 12px 12px 54px;
    z-index: 95;
  }

  .modal-overlay {
    padding: 8px;
    align-items: flex-start;
  }
  .modal-card {
    padding: 14px 12px;
    max-height: calc(100dvh - 16px);
  }
  .map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .end-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .daily-actions {
    width: 100%;
  }
  .daily-actions button {
    flex: 1;
  }
}
