@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&family=Noto+Serif+Tibetan:wght@400;700&family=Outfit:wght@300;400;600;700&display=swap');

:root {
  --bg-dark: #12100e;
  --bg-panel: rgba(26, 22, 19, 0.88);
  --bg-panel-light: rgba(40, 34, 30, 0.92);
  --border-gold: #c59b27;
  --border-gold-glow: rgba(197, 155, 39, 0.4);
  --text-main: #f5eedc;
  --text-dim: #b8a994;
  --monk-red: #881337;
  --saffron: #d97706;
  --player-blue: #0284c7;
  --player-blue-light: #38bdf8;
  --player-blue-bg: #0369a1;
  --crimson-red: #be123c;
  --crimson-bg: #9f1239;
  --gold-faction: #d97706;
  --gold-bg: #b45309;
  --neutral-gray: #64748b;
  --neutral-bg: #334155;
  --font-tibetan: 'Noto Serif Tibetan', serif;
  --font-himalaya: 'Cinzel Decorative', serif;
  --font-sans: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 50% 30%, rgba(197, 155, 39, 0.08) 0%, transparent 65%),
    linear-gradient(rgba(18, 16, 14, 0.95), rgba(18, 16, 14, 0.95));
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Prayer Flags Garland */
.prayer-flags-garland {
  position: relative;
  width: 100%;
  height: 44px;
  background: linear-gradient(180deg, #1c1815 0%, rgba(28, 24, 21, 0) 100%);
  border-bottom: 1px solid rgba(197, 155, 39, 0.25);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  z-index: 100;
}

/* ── Tibetan Prayer Flags (Lungta / རླུང་རྟ) ────────────────────────── */
.prayer-flag {
  clip-path: polygon(0 0, 100% 0, 100% 85%, 50% 100%, 0 85%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-tibetan);
  font-weight: bold;
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 6px rgba(0,0,0,0.5);
  transform-origin: top center;
  animation: flutter 3.5s ease-in-out infinite alternate;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  flex-shrink: 0;
}

/* Three distinct random sizes, slightly smaller and delicate */
.flag-sz-1 {
  width: 20px;
  height: 19px;
  font-size: 8px;
}

.flag-sz-2 {
  width: 28px;
  height: 26px;
  font-size: 9px;
}

.flag-sz-3 {
  width: 36px;
  height: 34px;
  font-size: 11px;
}

.prayer-flag:nth-child(even) {
  animation-duration: 4.2s;
  animation-delay: -1.5s;
}

.prayer-flag:nth-child(3n) {
  animation-duration: 3.1s;
  animation-delay: -0.7s;
}

/* Five Sacred Buddhist Elements / Colors */
.flag-blue   { background: #0284c7; } /* Sky / Space */
.flag-white  { background: #e2e8f0; color: #1e293b !important; text-shadow: none; } /* Air / Wind */
.flag-red    { background: #b91c1c; } /* Fire */
.flag-green  { background: #15803d; } /* Water */
.flag-yellow { background: #eab308; color: #451a03 !important; text-shadow: none; } /* Earth */

@keyframes flutter {
  0% { transform: rotate(0deg) skewX(0deg); }
  50% { transform: rotate(3deg) skewX(4deg) translateY(1px); }
  100% { transform: rotate(-3deg) skewX(-4deg); }
}

/* App Header & Power Bar */
.game-header {
  padding: 6px 18px 8px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border-gold);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: relative;
}

/* Center Brand with flanking prayer flags and rotating wheels */
.header-center-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  position: relative;
}

.flags-arm {
  display: flex;
  position: relative;
  align-items: flex-start;
  flex: 1;
  max-width: 500px;
  min-width: 80px;
  height: 38px;
  overflow: hidden;
}

.flags-arm-left {
  justify-content: flex-end;
}

.flags-arm-right {
  justify-content: flex-start;
}

.arm-rope {
  position: absolute;
  top: 0px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #78350f 15%, #b45309 50%, #78350f 85%, transparent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
  z-index: 1;
}

.arm-flags-list {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  position: relative;
  z-index: 2;
  flex-wrap: nowrap;
}

.brand-center-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  margin: 0 8px;
}

.brand-text-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-title-main {
  font-family: var(--font-himalaya), 'Cinzel', Georgia, serif;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #fbbf24;
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.7), 0 2px 5px #000;
  margin: 0;
  line-height: 1;
}

.brand-mantra-sub {
  font-family: var(--font-tibetan), sans-serif;
  font-size: 15px;
  color: var(--border-gold);
  letter-spacing: 2.5px;
  margin-top: 4px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.brand-wheel {
  font-size: 32px;
  color: #fde047;
  filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.8));
  user-select: none;
  line-height: 1;
}

.wheel-left {
  animation: slow-spin 25s linear infinite;
}

.wheel-right {
  animation: slow-spin-rev 25s linear infinite;
}

@keyframes slow-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes slow-spin-rev {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-tibetan {
  background: linear-gradient(180deg, #451a03 0%, #291204 100%);
  border: 1px solid var(--border-gold);
  color: #fbbf24;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.header-controls .btn-tibetan {
  padding: 6px 10px;
  font-size: 15px;
  min-width: 36px;
  justify-content: center;
}

.btn-tibetan:hover {
  background: linear-gradient(180deg, #78350f 0%, #451a03 100%);
  border-color: #fde047;
  color: #fff;
  transform: translateY(-1px);
}

.btn-tibetan:active {
  transform: translateY(1px);
}

@keyframes btn-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.btn-shake {
  animation: btn-shake 0.35s ease-in-out !important;
  border-color: #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.7) !important;
}

/* Faction Conflict Crests / Flags Header */
.conflict-crests-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.crest-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(197, 155, 39, 0.4);
  padding: 4px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.crest-flag {
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.crest-player .crest-flag {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid #38bdf8;
  color: #fff;
}

.crest-crimson .crest-flag {
  background: linear-gradient(135deg, #be123c 0%, #9f1239 100%);
  border: 1px solid #fda4af;
  color: #fff;
}

.crest-gold .crest-flag {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  border: 1px solid #fde047;
  color: #fff;
}

.crest-neutral .crest-flag {
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
  border: 1px solid #94a3b8;
  color: #fff;
}

.crest-info {
  display: flex;
  flex-direction: column;
}

.crest-name {
  font-size: 11px;
  font-weight: 700;
  color: #f5eedc;
}

.crest-stats {
  font-size: 10px;
  color: var(--text-dim);
}



/* Tower Specs Widget (Directly above Sidebar Karma Altar) */
.tower-specs-card {
  background: rgba(24, 18, 14, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6);
}

.tower-spec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.tower-spec-row .spec-label {
  color: #f5eedc;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tower-spec-row .spec-value {
  color: #fde047;
  font-weight: 800;
  text-shadow: 0 0 6px rgba(253, 224, 71, 0.4);
}

/* Large Sidebar Karma Card */
.sidebar-karma-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.75) 0%, rgba(41, 18, 4, 0.85) 100%);
  border: 2px solid #fbbf24;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.6), inset 0 0 12px rgba(251, 191, 36, 0.2);
}

.sidebar-karma-icon {
  font-size: 32px;
  color: #fde047;
  filter: drop-shadow(0 0 8px #fbbf24);
  animation: slow-spin 25s linear infinite;
}

.sidebar-karma-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #fbbf24;
}

.sidebar-karma-number {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 10px rgba(253, 224, 71, 0.7);
}

/* Floating Karma Particle */
.karma-pop-tag {
  position: absolute;
  font-size: 16px;
  font-weight: 800;
  color: #fde047;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.9), 0 2px 4px #000;
  pointer-events: none;
  z-index: 9999;
  animation: karma-float-up 1.1s ease-out forwards;
}

@keyframes karma-float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(1.3); }
}

/* Balance of Power Bar (State.io style) */
.power-bar-wrapper {
  width: 100%;
  margin-top: 2px;
}

.power-bar-track {
  height: 8px;
  width: 100%;
  background: #1e293b;
  border-radius: 4px;
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(197, 155, 39, 0.35);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.power-segment {
  height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.seg-player {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.seg-crimson {
  background: linear-gradient(180deg, #f43f5e 0%, #be123c 100%);
}

.seg-gold {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}

.seg-neutral {
  background: linear-gradient(180deg, #94a3b8 0%, #475569 100%);
}

/* AI Aggressiveness Buttons */
.btn-agg.active {
  background: linear-gradient(180deg, #78350f 0%, #451a03 100%) !important;
  border-color: #fde047 !important;
  color: #fde047 !important;
}

/* Layout Grid: Left Sidebar (280px) | Center Battlefield (1fr) */
.main-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  transition: grid-template-columns 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-stage.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.main-stage.sidebar-collapsed .sidebar-left {
  visibility: hidden;
  pointer-events: none;
  border-right: none;
}

/* Sidebars */
.sidebar {
  background: var(--bg-panel);
  border-top: 1px solid rgba(197, 155, 39, 0.2);
  border-bottom: 1px solid rgba(197, 155, 39, 0.2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  z-index: 15;
}

.sidebar-left {
  border-right: 2px solid var(--border-gold);
}

.sidebar-right {
  border-left: 2px solid var(--border-gold);
}

.mantra-ribbon {
  background: rgba(120, 53, 15, 0.35);
  border-bottom: 1px solid var(--border-gold);
  padding: 6px 12px;
  font-family: var(--font-tibetan);
  font-size: 13px;
  color: #fde047;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(253, 224, 71, 0.4);
}

.panel-section {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(197, 155, 39, 0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-title {
  font-family: var(--font-himalaya);
  font-size: 13px;
  color: #fbbf24;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(197, 155, 39, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.stat-label {
  color: var(--text-dim);
}

.stat-value {
  font-weight: 700;
  color: #fff;
}

.stat-value.player-val {
  color: var(--player-blue-light);
}

/* Level Selector Buttons */
.level-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.level-btn {
  background: rgba(41, 18, 4, 0.7);
  border: 1px solid rgba(197, 155, 39, 0.35);
  color: var(--text-main);
  padding: 7px 10px;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.level-btn:hover {
  background: rgba(120, 53, 15, 0.5);
  border-color: #fbbf24;
}

.level-btn.active {
  background: linear-gradient(90deg, #78350f 0%, #451a03 100%);
  border-color: #fde047;
  color: #fde047;
  box-shadow: inset 0 0 10px rgba(253, 224, 71, 0.2);
}

/* Prayer Wheel Section (Interactive 3D Wheel) */
.prayer-wheel-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 0;
}

.prayer-wheel {
  width: 54px;
  height: 80px;
  background: linear-gradient(90deg, #78350f 0%, #d97706 40%, #fde047 50%, #d97706 60%, #78350f 100%);
  border-radius: 6px;
  border: 2px solid #fbbf24;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 15px rgba(0,0,0,0.6);
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.prayer-wheel::before,
.prayer-wheel::after {
  content: '';
  position: absolute;
  width: 66px;
  height: 8px;
  background: #fde047;
  border: 1px solid #78350f;
  border-radius: 3px;
}

.prayer-wheel::before { top: -7px; }
.prayer-wheel::after { bottom: -7px; }

.prayer-wheel-mantra {
  writing-mode: vertical-rl;
  font-family: var(--font-tibetan);
  font-size: 11px;
  font-weight: bold;
  color: #451a03;
  letter-spacing: 2px;
}

.wheel-handle {
  width: 6px;
  height: 24px;
  background: #78350f;
  margin-top: 8px;
  border-radius: 0 0 4px 4px;
}

.spinning {
  animation: wheel-spin 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes wheel-spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(720deg) scale(1.08); }
  100% { transform: rotate(1440deg) scale(1); }
}

/* Custom SVG Dropzone */
.svg-dropzone {
  border: 2px dashed rgba(197, 155, 39, 0.5);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 11px;
  color: var(--text-dim);
}

.svg-dropzone:hover {
  border-color: #fbbf24;
  color: #fff;
  background: rgba(197, 155, 39, 0.1);
}

/* Center Battlefield / Canvas */
.battlefield-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, #2a241e 0%, #171310 80%);
  overflow: hidden;
  height: 100%;
}

.battlefield-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.42;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" preserveAspectRatio="none"><polygon points="0,600 0,240 160,90 340,210 540,55 760,200 980,75 1200,220 1200,600" fill="%23211c17"/><polygon points="0,600 0,340 210,170 430,300 660,150 890,290 1080,180 1200,290 1200,600" fill="%231b1713"/><polygon points="0,600 0,430 260,290 500,400 780,260 1020,390 1200,310 1200,600" fill="%2314110e"/></svg>');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.level-info-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 16, 14, 0.85);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 6px 20px;
  text-align: center;
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.level-title {
  font-family: var(--font-himalaya);
  font-size: 15px;
  color: #fbbf24;
}

.level-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.level-timer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 11px;
}

.timer-label {
  color: var(--text-dim);
}

.timer-val {
  color: #fde047;
  font-weight: 700;
  font-family: monospace, sans-serif;
  letter-spacing: 0.5px;
}

.timer-sep {
  color: rgba(251, 191, 36, 0.4);
}

.map-container {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  overflow: hidden;
  box-sizing: border-box;
}

#map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.15s ease, height 0.15s ease;
}

#map-svg-host {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

#map-svg-host svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Territory Styling inside SVG */
.territory {
  stroke-width: 2.5;
  stroke: #1e1b18;
  cursor: pointer;
  transition: fill 0.35s ease, stroke 0.2s ease, filter 0.2s ease;
  vector-effect: non-scaling-stroke;
}

.territory:hover {
  filter: brightness(1.2) drop-shadow(0 0 8px rgba(251, 191, 36, 0.6));
  stroke: #fde047 !important;
  stroke-width: 3.5 !important;
  stroke-linejoin: round !important;
}

/* Owner Colors for Territories */
.owner-player {
  fill: #0284c7;
  stroke: #38bdf8;
}

.owner-crimson {
  fill: #be123c;
  stroke: #fda4af;
}

.owner-gold {
  fill: #b45309;
  stroke: #fcd34d;
}

.owner-neutral {
  fill: #475569;
  stroke: #94a3b8;
}

.territory-selected {
  stroke: #fde047 !important;
  stroke-width: 4.5 !important;
  stroke-linejoin: round !important;
  stroke-linecap: round !important;
  filter: drop-shadow(0 0 10px #fde047) drop-shadow(0 0 18px rgba(253, 224, 71, 0.6)) !important;
}

/* Serpentine Mountain Caravan Roads (Winding solid roads between base centers) */
.mountain-roads-layer {
  pointer-events: none;
}

.mountain-road-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.36);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.mountain-road {
  fill: none;
  stroke: rgba(226, 232, 240, 0.28);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

/* Winding Mountain Rivers (Main horizontal collector + descending tributaries) */
.mountain-rivers-layer {
  pointer-events: none;
}

.river-main-glow {
  fill: none;
  stroke: rgba(2, 132, 199, 0.32);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}
.river-main-bed {
  fill: none;
  stroke: #0284c7;
  stroke-width: 7;
  opacity: 0.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.river-main-stream {
  fill: none;
  stroke: #bae6fd;
  stroke-width: 3.2;
  opacity: 0.95;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.river-tributary-glow {
  fill: none;
  stroke: rgba(2, 132, 199, 0.22);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.4));
}
.river-tributary-bed {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 4.2;
  opacity: 0.72;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.river-tributary-stream {
  fill: none;
  stroke: #e0f2fe;
  stroke-width: 1.8;
  opacity: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.river-brook-glow {
  fill: none;
  stroke: rgba(2, 132, 199, 0.18);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.river-brook-bed {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 2.6;
  opacity: 0.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.river-brook-stream {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.1;
  opacity: 0.88;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

/* Atmospheric Cartographic Scenery (White Peaks, Fir Trees, Deciduous Trees, Mountain Huts) */
.map-scenery-layer {
  pointer-events: none;
}

.scenery-peak, .scenery-tree, .scenery-deciduous, .scenery-hut {
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  transition: opacity 0.3s ease;
}

/* Interactive Overlays */
#nodes-overlay, #squads-overlay, #interaction-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* TOWER NODE in mathematical center (3 Sizes: 10, 20, 30 units) */
.tower-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  z-index: 20;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tower-node:hover {
  transform: translate(-50%, -50%) scale(1.12);
  filter: drop-shadow(0 0 12px #fde047);
}

.tower-node.selected {
  transform: translate(-50%, -50%) scale(1.18);
  filter: drop-shadow(0 0 16px #38bdf8);
}

/* Tower Shake / Jolt Animation when warrior hits it */
.tower-node.tower-shake {
  animation: tower-impact-jolt 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
}

@keyframes tower-impact-jolt {
  0% { transform: translate(-50%, -50%) scale(1); }
  20% { transform: translate(calc(-50% + 4px), calc(-50% - 3px)) scale(1.12); filter: drop-shadow(0 0 16px #f59e0b) brightness(1.35); }
  40% { transform: translate(calc(-50% - 4px), calc(-50% + 2px)) scale(0.95); }
  60% { transform: translate(calc(-50% + 3px), calc(-50% + 1px)) scale(1.06); }
  80% { transform: translate(calc(-50% - 1px), calc(-50% - 1px)) scale(0.99); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.tower-node.tower-conquest {
  animation: tower-conquest-burst 0.5s ease-out both !important;
}

@keyframes tower-conquest-burst {
  0% { transform: translate(-50%, -50%) scale(0.85); filter: drop-shadow(0 0 24px #38bdf8) brightness(1.6); }
  50% { transform: translate(-50%, -50%) scale(1.22); filter: drop-shadow(0 0 30px #fde047) brightness(1.4); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* Tower Visual Base Container */
.tower-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

/* Atmospheric Ground Shadow around the Palace (larger radius and stronger) */
.tower-visual::before {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 220%;
  height: 48px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.75) 40%, rgba(0, 0, 0, 0.35) 70%, transparent 85%);
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  filter: blur(4px);
}

/* 3 TIER SIZES (10, 20, 30 units) - Taller Himalayan Pagodas */
.tower-tier-1 {
  width: 40px;
  height: 54px;
}

.tower-tier-2 {
  width: 52px;
  height: 70px;
}

.tower-tier-3 {
  width: 64px;
  height: 88px;
}

/* Inner SVG Tower Art with deep multi-layer drop-shadow */
.tower-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 28px rgba(0, 0, 0, 0.85));
}

/* Unit Badge attached to the Tower - anchored at the foundation base */
.tower-shield {
  position: absolute;
  top: auto;
  bottom: 0px;
  left: 50%;
  transform: translate(-50%, 25%);
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 3px 8px rgba(0,0,0,0.75);
  z-index: 25;
  transition: background 0.3s ease;
}

.shield-player {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

.shield-crimson {
  background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.8);
}

.shield-gold {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
}

.shield-neutral {
  background: linear-gradient(135deg, #94a3b8 0%, #475569 100%);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}

/* Territory Name Label positioned below the tower */
.tower-label-group {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 8px;
  pointer-events: none;
  white-space: nowrap;
}

/* Tower Elimination Blast & Fine Particle Explosion */
.tower-node.tower-exploding {
  animation: tower-blast 0.65s cubic-bezier(0.25, 1, 0.5, 1) both !important;
}

@keyframes tower-blast {
  0% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
  15% { transform: translate(-50%, -50%) scale(1.3); filter: brightness(2.8) drop-shadow(0 0 30px #fde047); }
  35% { transform: translate(calc(-50% + 5px), calc(-50% - 4px)) scale(1.12); filter: brightness(1.7) drop-shadow(0 0 22px #f97316); }
  60% { transform: translate(calc(-50% - 4px), calc(-50% + 3px)) scale(0.96); filter: brightness(1.2); }
  80% { transform: translate(calc(-50% + 2px), calc(-50% - 1px)) scale(1.02); }
  100% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
}

.tower-explosion-container {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 50;
  width: 0;
  height: 0;
}

.explosion-shockwave {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.1);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid #fde047;
  box-shadow: 0 0 16px #fde047, inset 0 0 12px #f59e0b;
  pointer-events: none;
  animation: shockwave-expand 0.65s cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}

.explosion-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(253,224,71,0.85) 45%, rgba(245,158,11,0) 75%);
  pointer-events: none;
  animation: flash-fade 0.45s ease-out forwards;
}

.explosion-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
  animation: particle-fly 0.75s cubic-bezier(0.12, 0.8, 0.32, 1) forwards;
}

@keyframes shockwave-expand {
  0% { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

@keyframes flash-fade {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

@keyframes particle-fly {
  0% {
    transform: translate(0, 0) scale(1.3);
    opacity: 1;
  }
  60% {
    opacity: 0.95;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.15);
    opacity: 0;
  }
}

.tower-name {
  font-size: 11px;
  font-weight: 700;
  color: #f5eedc;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 0 6px #000;
  white-space: nowrap;
}

.tower-owner-sub {
  font-size: 9.5px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 5px #000;
  letter-spacing: 0.3px;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  margin-top: 1px;
}

/* Semi-transparent Drag Arrow (State.io style) */
.drag-arrow-path {
  pointer-events: none;
  transition: d 0.05s ease;
}

/* Squad Marching Formations (Rows of 3-4-5 warrior dots, like screenshot!) */
.squad-unit-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 30;
  transition: transform 0.05s linear;
}

.dot-player {
  background: radial-gradient(circle at 35% 35%, #7dd3fc 0%, #0284c7 80%);
  border: 1px solid #e0f2fe;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.7);
}

.dot-crimson {
  background: radial-gradient(circle at 35% 35%, #fda4af 0%, #be123c 80%);
  border: 1px solid #ffe4e6;
  box-shadow: 0 0 6px rgba(244, 63, 94, 0.7);
}

.dot-gold {
  background: radial-gradient(circle at 35% 35%, #fef08a 0%, #d97706 80%);
  border: 1px solid #fef9c3;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.7);
}

.squad-formation-tag {
  position: absolute;
  transform: translate(-50%, -150%);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 1px 6px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 35;
  white-space: nowrap;
}

/* Field Unit Clash & Mutual Annihilation Spark */
.clash-spark {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  background: radial-gradient(circle, #ffffff 15%, #fde047 45%, #ef4444 85%, transparent 100%);
  box-shadow: 0 0 12px #fde047, 0 0 22px #ef4444;
  pointer-events: none;
  z-index: 40;
  animation: clash-spark-burst 0.35s ease-out forwards;
}

@keyframes clash-spark-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.4);
    opacity: 0;
  }
}

#salute-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1050;
}

/* Game Modal (Win/Defeat) */
.game-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.game-modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-triumph-wrapper {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  position: relative;
  max-width: 96vw;
}

.modal-flank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 155px;
  position: relative;
  z-index: 10;
  pointer-events: none;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
}

.flank-left {
  transform: translateX(-35px) scale(0.9);
}

.flank-right {
  transform: translateX(35px) scale(0.9);
}

.game-modal-backdrop.show.is-victory .flank-left,
.game-modal-backdrop.show.is-victory .flank-right {
  transform: translateX(0) scale(1);
}

/* Hide flank regalia and crest when not victory (e.g. defeat) */
.game-modal-backdrop:not(.is-victory) .modal-flank,
.game-modal-backdrop:not(.is-victory) .victory-crest-top {
  display: none !important;
}

.flank-banner-container {
  width: 130px;
  height: 310px;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 16px rgba(14, 165, 233, 0.35));
  margin-bottom: -15px;
}

.flank-banner-container svg {
  width: 100%;
  height: 100%;
  transform-origin: top center;
}

.flank-left .flank-banner-container svg {
  animation: bannerSwayLeft 5.5s ease-in-out infinite alternate;
}

.flank-right .flank-banner-container svg {
  animation: bannerSwayRight 5.8s ease-in-out infinite alternate;
}

@keyframes bannerSwayLeft {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(-2deg) skewY(-0.8deg); }
  100% { transform: rotate(1deg); }
}

@keyframes bannerSwayRight {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(2deg) skewY(0.8deg); }
  100% { transform: rotate(-1deg); }
}

.flank-cannon-container {
  width: 155px;
  height: 125px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 18px rgba(245, 158, 11, 0.25));
  position: relative;
}

.flank-cannon-container svg {
  width: 100%;
  height: 100%;
}

.flank-cannon-container::after {
  content: '';
  position: absolute;
  top: 10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.6) 0%, transparent 70%);
  filter: blur(4px);
  animation: cannonEmber 3s infinite ease-in-out alternate;
  pointer-events: none;
}

.flank-left .flank-cannon-container::after {
  left: 12px;
}

.flank-right .flank-cannon-container::after {
  right: 12px;
}

@keyframes cannonEmber {
  0% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 0.75; transform: scale(1.3); }
  100% { opacity: 0.3; transform: scale(0.9); }
}

.victory-crest-top {
  width: 100%;
  max-width: 440px;
  height: 130px;
  margin-top: -70px;
  margin-bottom: -15px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 30px rgba(253, 224, 71, 0.45));
  position: relative;
  z-index: 20;
}

.crest-svg {
  width: 100%;
  height: 100%;
}

.modal-card {
  width: 440px;
  background: var(--bg-panel-light);
  border: 2px solid var(--border-gold);
  border-radius: 14px;
  padding: 24px 28px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 30px rgba(197, 155, 39, 0.3);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

/* Martial Triumph Victory Card Polish */
.game-modal-backdrop.is-victory .modal-card {
  background: radial-gradient(circle at 50% 12%, #2d1d13 0%, #17100c 55%, #0c0806 100%);
  border: 2px solid #eab308;
  box-shadow: 0 0 50px rgba(234, 179, 8, 0.35), 0 25px 70px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(254, 240, 138, 0.5);
}

.game-modal-backdrop.show .modal-card {
  transform: scale(1);
}

.modal-icon {
  font-size: 44px;
  color: #fbbf24;
}

.game-modal-backdrop.is-victory .modal-icon {
  display: none; /* Replaced by the glorious top crossed Khukuris & Dharma solar crest */
}

.modal-title {
  font-family: var(--font-himalaya);
  font-size: 24px;
  color: #fbbf24;
}

.game-modal-backdrop.is-victory .modal-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fef08a 0%, #eab308 50%, #ca8a04 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 18px rgba(234, 179, 8, 0.45);
  margin-top: 4px;
}

.modal-msg {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
}

.modal-score-breakdown {
  background: rgba(10, 8, 6, 0.6);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #f5eedc;
}

.score-row span:last-child {
  font-weight: 700;
  color: #fde047;
}

.score-row.score-total {
  border-top: 1px solid rgba(251, 191, 36, 0.3);
  padding-top: 8px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 800;
  color: #fbbf24;
}

.score-row.score-total span:last-child {
  font-size: 16px;
  color: #fde047;
  text-shadow: 0 0 10px rgba(253, 224, 71, 0.6);
}

.score-time {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

/* Footer / Instructions */
.bottom-instructions {
  background: rgba(18, 16, 14, 0.95);
  border-top: 1px solid rgba(197, 155, 39, 0.2);
  padding: 6px 20px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Nepal Overview Map Modal ─────────────────────────────────── */
.overview-modal-card {
  max-width: 820px !important;
  width: 90vw !important;
  padding: 20px 28px 24px !important;
}

.overview-map-container {
  width: 100%;
  background: rgba(10, 8, 6, 0.7);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 10px;
  margin: 14px 0 10px;
  overflow: hidden;
}

#overview-map-host {
  width: 100%;
}

#overview-map-host svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Province paths in overview */
.ov-province {
  transition: filter 0.4s, opacity 0.4s;
  cursor: default;
}

/* Conquered province — glowing golden border + slight desaturate base */
.ov-province.conquered {
  filter: brightness(1.2) saturate(1.1);
}

/* Next target province — pulsing border */
.ov-province.next-target {
  filter: brightness(1.35) saturate(1.3);
  animation: ov-pulse 1.8s ease-in-out infinite;
}

@keyframes ov-pulse {
  0%, 100% { filter: brightness(1.35) saturate(1.3) drop-shadow(0 0 6px #fde047); }
  50%       { filter: brightness(1.5) saturate(1.5) drop-shadow(0 0 14px #fde047); }
}

.overview-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.legend-conquered { color: #fde047; font-weight: 700; }
.legend-next      { color: #86efac; font-weight: 700; }
.legend-free      { color: var(--text-dim); }

/* Level list — smaller buttons for 7 items */
#level-list .level-btn {
  padding: 7px 10px;
  font-size: 11px;
}

@media (max-width: 820px) {
  .modal-flank {
    display: none !important;
  }
}

