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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  background: #0a0e27;
  color: #fff;
}

/* ========================================================
   MODERN SLEEK SCROLLBAR STYLING (MODALS & HUD CONTAINERS)
   ======================================================== */

/* Firefox standard scrollbar properties */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 215, 0, 0.35) rgba(15, 23, 42, 0.6);
}

/* Modal Dialog and Scrollable Containers */
.game-dialog-card,
.edit-land-dialog-card,
.inspector-content-scroll,
.user-lands-list-scroll,
.merge-options-list,
.hud-bottom-panel {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 215, 0, 0.45) rgba(15, 23, 42, 0.7);
}

/* WebKit Scrollbar Styling (Chrome, Edge, Safari, Opera) */
.game-dialog-card::-webkit-scrollbar,
.edit-land-dialog-card::-webkit-scrollbar,
.inspector-content-scroll::-webkit-scrollbar,
.user-lands-list-scroll::-webkit-scrollbar,
.merge-options-list::-webkit-scrollbar,
.hud-bottom-panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.game-dialog-card::-webkit-scrollbar-track,
.edit-land-dialog-card::-webkit-scrollbar-track,
.inspector-content-scroll::-webkit-scrollbar-track,
.user-lands-list-scroll::-webkit-scrollbar-track,
.merge-options-list::-webkit-scrollbar-track,
.hud-bottom-panel::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 9999px;
  margin: 4px;
}

.game-dialog-card::-webkit-scrollbar-thumb,
.edit-land-dialog-card::-webkit-scrollbar-thumb,
.inspector-content-scroll::-webkit-scrollbar-thumb,
.user-lands-list-scroll::-webkit-scrollbar-thumb,
.merge-options-list::-webkit-scrollbar-thumb,
.hud-bottom-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.55), rgba(245, 158, 11, 0.75));
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  transition: all 0.2s ease;
}

.game-dialog-card::-webkit-scrollbar-thumb:hover,
.edit-land-dialog-card::-webkit-scrollbar-thumb:hover,
.inspector-content-scroll::-webkit-scrollbar-thumb:hover,
.user-lands-list-scroll::-webkit-scrollbar-thumb:hover,
.merge-options-list::-webkit-scrollbar-thumb:hover,
.hud-bottom-panel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffd700, #f59e0b);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.game-dialog-card::-webkit-scrollbar-corner,
.edit-land-dialog-card::-webkit-scrollbar-corner,
.inspector-content-scroll::-webkit-scrollbar-corner {
  background: transparent;
}

/* Fullscreen Leaflet Map Dark Background */
#map {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  background-color: #0b0e14 !important;
}

/* Empty Map Tile Layer (Transparent canvas over ruler network lines) */
.leaflet-tile-pane {
  background: transparent !important;
}

.network-grid-tile {
  pointer-events: none;
}

/* Middle-Bottom Map Zoom Controls Dock (- +) */
.zoom-controls-dock {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.zoom-controls-dock:hover {
  transform: translateX(-50%) translateY(-2px);
}

.zoom-display-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Outfit', sans-serif;
  user-select: none;
}

.zoom-display-badge .zoom-icon {
  font-size: 1rem;
}

.zoom-display-badge .zoom-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #9ca3af;
}

.zoom-display-badge .zoom-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffd700;
  min-width: 22px;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.zoom-display-badge .zoom-max {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
}

/* ========================================================
   MODERN SEPARATED RIGHT MENU: TOP & BOTTOM FLOATING PANELS
   ======================================================== */

/* TOP-LEFT PANEL: Brand Title, Commander Profile & Profile Badge */
.hud-top-left-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 420px);
}

/* Hide Leaflet's default top-left zoom controls (now unified in middle-bottom dock) */
.leaflet-control-zoom {
  display: none !important;
}

/* TOP-RIGHT PANEL: Kingdom Stats & Claim Progress */
.hud-top-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 40px);
  pointer-events: auto;
}

/* BOTTOM PANEL: Selected Territory Inspector & Realm Actions */
.hud-bottom-panel {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 380px);
  pointer-events: auto;
}

.user-lands-card:hover {
  border-color: rgba(255, 215, 0, 0.55);
}

.user-lands-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.18);
}

.user-lands-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #ffd700;
}

.lands-count-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 2px 8px;
  border-radius: 12px;
}

.user-lands-list-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.user-lands-list-scroll::-webkit-scrollbar {
  width: 4px;
}
.user-lands-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 0, 0.35);
  border-radius: 4px;
}

/* User Land List Item */
.user-land-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 215, 0, 0.16);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-land-item:hover {
  background: rgba(255, 215, 0, 0.08);
  border-color: rgba(255, 215, 0, 0.45);
  transform: translateY(-1px);
}

.user-land-item.active {
  background: rgba(255, 215, 0, 0.14);
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.25);
}

.user-land-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-land-name {
  font-size: 0.83rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-land-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
}

.user-land-metric-area {
  color: #ffd700;
  font-weight: 700;
}

.user-land-metric-clicks {
  color: #94a3b8;
}

.btn-land-edit {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.35);
  color: #ffd700;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-land-edit:hover {
  background: rgba(255, 215, 0, 0.25);
  border-color: #ffd700;
  color: #ffffff;
  transform: scale(1.04);
}

/* Land image thumbnail on the right (if exists) */
.user-land-thumb {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 215, 0, 0.45);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.user-land-item:hover .user-land-thumb {
  border-color: #ffd700;
  transform: scale(1.05);
}

.user-lands-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 10px;
  color: #94a3b8;
  gap: 4px;
}

.user-lands-empty .empty-icon {
  font-size: 26px;
  margin-bottom: 2px;
}

.user-lands-empty p {
  font-size: 0.83rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 0;
}

.user-lands-empty small {
  font-size: 0.72rem;
  color: #64748b;
}

/* Edit Land Section Modal Dialog */
.edit-land-dialog-card {
  width: 460px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left;
  padding: 22px 20px;
  background: linear-gradient(145deg, #131940, #0a0e27);
  border: 1.5px solid rgba(255, 215, 0, 0.45);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.75), 0 0 30px rgba(255, 215, 0, 0.25);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.dialog-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-dialog-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-dialog-close:hover {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.12);
}

.edit-modal-name-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
}

.name-edit-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.name-edit-inline .selected-title-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffd700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-section-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.modal-footer-actions {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
}

.hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.hud-icon {
  font-size: 26px;
  animation: floatIcon 3s ease-in-out infinite;
}

/* The game's badge (logo-128.png) in the top-left card */
.hud-logo { width: 44px; height: 44px; padding: 0; }
.hud-logo img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(255, 193, 7, 0.35)); }

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

.hud-title h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #ffd700;
  line-height: 1.2;
}

.commander-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.sub-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.5px;
  display: inline-block;
}

.btn-micro {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.3);
  color: #ffd700;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s ease;
  padding: 0;
}

/* Google Authentication HUD Widget */
.hud-auth-box {
  margin-top: 2px;
  width: 100%;
}

.google-btn-wrapper {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
}

.google-btn-wrapper.hidden {
  display: none !important;
}

.btn-fallback-google:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.auth-profile-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.28);
  border-radius: 10px;
  padding: 6px 10px;
  transition: all 0.2s ease;
}

.auth-profile-wrap.hidden {
  display: none !important;
}

.auth-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  object-fit: cover;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.auth-user-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.auth-user-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-user-email {
  font-size: 0.64rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-signout {
  width: 26px;
  height: 26px;
  font-size: 13px;
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

.btn-signout:hover {
  background: #ef4444;
  color: #fff;
}

/* Modern Empire Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-box:hover {
  border-color: rgba(255, 215, 0, 0.4);
  transform: translateY(-1px);
}

.stat-box.highlight {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(16, 185, 129, 0.05));
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.stat-box-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.stat-icon {
  font-size: 0.85rem;
}

.stat-box .label {
  font-size: 0.63rem;
  color: #9ca3af;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.stat-box .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.stat-box .value.gold {
  color: #ffd700;
  font-size: 1.55rem;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* Conquest Progress Bar Section */
.conquest-progress-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
}

.progress-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.progress-title-tag {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #9ca3af;
}

.progress-counter-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #10b981);
  border-radius: 999px;
  transition: width 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}

.progress-subtext {
  font-size: 0.72rem;
  color: #9ca3af;
  line-height: 1.35;
  margin-bottom: 0;
}

/* Selected Land Detail Inspector Card (Bottom Panel) */
.selected-land-panel {
  background: rgba(11, 16, 28, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1.5px solid rgba(255, 215, 0, 0.38);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65), 0 0 20px rgba(255, 215, 0, 0.12);
  transition: all 0.25s ease;
}

.selected-land-panel:hover {
  border-color: rgba(255, 215, 0, 0.6);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.72), 0 0 25px rgba(255, 215, 0, 0.2);
}

.selected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.selected-badge-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.land-status-indicator {
  color: #10b981;
  font-size: 11px;
  line-height: 1;
  animation: pulseIndicator 2s infinite ease-in-out;
}

@keyframes pulseIndicator {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.selected-type-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #ffd700;
  text-transform: uppercase;
}

.selected-owner-badge {
  font-size: 0.62rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 2px 7px;
  border-radius: 6px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-owner-badge.foreign-owner {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
}

/* Edit Polygon Section Container (Replaces Edit button with Auth Gate) */
.edit-polygon-section {
  margin-bottom: 12px;
}

.edit-poly-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-edit-title {
  flex: 1;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.45);
  color: #ffd700;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-edit-title:hover {
  background: #ffd700;
  color: #0b0f2a;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* Auth Lock Card shown in place of Edit Polygon for unauthenticated visitors */
.auth-lock-card {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 255, 255, 0.03));
  border: 1.5px dashed rgba(255, 215, 0, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.auth-lock-card .lock-icon {
  font-size: 20px;
}

.auth-lock-card .lock-info strong {
  display: block;
  font-size: 0.75rem;
  color: #ffd700;
  margin-bottom: 2px;
}

.auth-lock-card .lock-info span {
  display: block;
  font-size: 0.65rem;
  color: #9ca3af;
  line-height: 1.3;
}

.btn-google-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  color: #1f2937;
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  width: 100%;
}

.btn-google-trigger:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.foreign-lock-notice {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.68rem;
  color: #f59e0b;
  text-align: center;
  line-height: 1.35;
}

.selected-name-row {
  margin-bottom: 8px;
}

.selected-title-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  line-height: 1.25;
  word-break: break-word;
}

.selected-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.sel-stat-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sel-stat-label {
  font-size: 0.58rem;
  color: #9ca3af;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sel-stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sel-stat-val.gold {
  color: #ffd700;
}

.sel-hint-text {
  font-size: 0.68rem;
  color: #9ca3af;
  line-height: 1.35;
  margin-top: 6px;
}

/* Land Image Banner & Emblem Upload Section */
.selected-image-section {
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(255, 215, 0, 0.35);
  border-radius: 10px;
  padding: 10px;
  margin: 10px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.selected-image-preview-wrap {
  position: relative;
  width: 100%;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.selected-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-image-placeholder {
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.selected-image-controls {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-upload-image {
  flex: 1;
  background: rgba(255, 215, 0, 0.18);
  border: 1px solid rgba(255, 215, 0, 0.5);
  color: #ffd700;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-upload-image:hover {
  background: #ffd700;
  color: #0b0f2a;
}

.btn-remove-image {
  flex: none;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #ef4444;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-remove-image:hover {
  background: #ef4444;
  color: #fff;
}

.upload-limit-hint {
  font-size: 0.62rem;
  color: #9ca3af;
  letter-spacing: 0.3px;
}

/* Image Upload Loading Spinner Overlay */
.image-upload-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 39, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 10;
  transition: opacity 0.2s ease;
}

.image-upload-overlay.hidden {
  display: none !important;
}

.upload-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 215, 0, 0.2);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: uploadSpin 0.7s linear infinite;
}

@keyframes uploadSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.upload-status-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffd700;
  letter-spacing: 0.4px;
}

/* Image Upload Progress Bar Container */
.image-upload-progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  box-sizing: border-box;
}

.image-upload-progress-container.hidden {
  display: none !important;
}

.image-upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upload-progress-title {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #9ca3af;
}

.upload-progress-pct {
  font-size: 0.75rem;
  font-weight: 800;
  color: #ffd700;
}

.image-upload-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.image-upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ff9a00);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  border-radius: 999px;
  transition: width 0.15s ease-out;
}

/* Map Polygon Emblem Center Badge */
.poly-emblem-badge {
  background: transparent !important;
  border: none !important;
  pointer-events: none !important;
}

.poly-emblem-badge.clickable-emblem {
  pointer-events: auto !important;
  cursor: pointer !important;
}

.poly-emblem-badge .emblem-inner {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 2.5px solid #ffd700;
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.75), 0 4px 10px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: emblemFloat 3s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poly-emblem-badge.clickable-emblem .emblem-inner {
  pointer-events: auto !important;
  cursor: pointer !important;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
}

.poly-emblem-badge.clickable-emblem .emblem-inner:hover {
  transform: translateY(-4px) scale(1.15) !important;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.95), 0 6px 16px rgba(0, 0, 0, 0.85) !important;
}

/* Social sub-badge displayed in the logo when land has both image and social link */
.poly-emblem-badge .emblem-social-sub-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.85), 0 2px 6px rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2.5px;
  box-sizing: border-box;
}

.poly-emblem-badge .emblem-social-sub-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Standalone social logo emblem when land has link but no image */
.poly-emblem-badge .emblem-inner.social-logo-emblem {
  background: radial-gradient(circle, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.98));
  border: 2.5px solid #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.85), 0 4px 12px rgba(0, 0, 0, 0.8);
}

.poly-emblem-badge .emblem-inner.social-logo-emblem .emblem-social-main-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.poly-emblem-badge .emblem-inner.social-logo-emblem:hover {
  border-color: #ffd700 !important;
  box-shadow: 0 0 22px rgba(255, 215, 0, 0.95), 0 6px 14px rgba(0, 0, 0, 0.85) !important;
}

@keyframes emblemFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
}

.btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: #ffd700;
  color: #ffd700;
  transform: translateY(-1px);
}

/* Custom Polygon Glow & Smooth Geometry Transitions */
.polygon-glow {
  transition: stroke-width 0.25s ease, stroke 0.25s ease, fill-opacity 0.25s ease, filter 0.25s ease;
}

/* Expansion Pulse Animation on Polygons */
.polygon-expand-anim {
  animation: expandFlash 0.75s ease-out forwards;
}

@keyframes expandFlash {
  0% {
    stroke: #ffffff;
    stroke-width: 7;
    fill-opacity: 0.85;
    filter: drop-shadow(0 0 20px #ffd700) drop-shadow(0 0 35px #ffffff);
  }
  50% {
    stroke: #ffd700;
    stroke-width: 5;
    fill-opacity: 0.65;
  }
  100% {
    stroke: #ffd700;
    stroke-width: 3.5;
    fill-opacity: 0.5;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  }
}

/* Merge Union Flash Animation */
.polygon-merge-anim {
  animation: mergeShockwave 1s ease-out forwards;
}

@keyframes mergeShockwave {
  0% {
    stroke: #00ffff;
    stroke-width: 8;
    fill-opacity: 0.9;
    filter: drop-shadow(0 0 25px #00ffff) drop-shadow(0 0 40px #ffd700);
  }
  40% {
    stroke: #ffffff;
    stroke-width: 6;
    fill-opacity: 0.7;
  }
  100% {
    stroke: #ffd700;
    stroke-width: 3.5;
    fill-opacity: 0.5;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  }
}

/* Spawn / Create Animation for New Land Claim */
.polygon-create-anim {
  animation: createLandPulse 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes createLandPulse {
  0% {
    stroke: #ffffff;
    stroke-width: 9;
    fill-opacity: 0.95;
    filter: drop-shadow(0 0 25px #ffd700) drop-shadow(0 0 45px #ffffff);
  }
  30% {
    stroke: #ffe066;
    stroke-width: 6.5;
    fill-opacity: 0.8;
    filter: drop-shadow(0 0 20px #ffd700) drop-shadow(0 0 30px #ffe066);
  }
  70% {
    stroke: #ffd700;
    stroke-width: 4.5;
    fill-opacity: 0.6;
  }
  100% {
    stroke: #ffd700;
    stroke-width: 3.5;
    fill-opacity: 0.5;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  }
}

/* Ensure center landmark does not intercept clicks to polygon underneath */
.poly-center-marker {
  pointer-events: none !important;
}

.custom-polygon-tooltip {
  background: rgba(10, 14, 39, 0.95) !important;
  border: 1px solid #ffd700 !important;
  color: #ffd700 !important;
  font-family: 'Outfit', sans-serif !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  padding: 6px 12px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6) !important;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; /* not "all": Leaflet moves tooltips with transform */
  pointer-events: none !important;
  user-select: none !important;
}

.custom-polygon-tooltip::before {
  border-top-color: #ffd700 !important;
}

.tooltip-action-hint {
  display: block;
  font-size: 0.65rem;
  color: #9ca3af;
  font-weight: 500;
  margin-top: 2px;
}

/* Dynamic Click Ripple Effect with Rings */
.click-ripple {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid #ffd700;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.45) 0%, rgba(255, 215, 0, 0.05) 70%, transparent 100%);
  transform: translate(-50%, -50%) scale(0.2);
  animation: rippleAnim 0.55s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  pointer-events: none;
  z-index: 10000;
}

@keyframes rippleAnim {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 1;
    border-width: 3px;
  }
  60% {
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(3.8);
    opacity: 0;
    border-width: 1px;
  }
}

/* Floating Spark Particle on Click */
.click-spark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffd700;
  box-shadow: 0 0 8px #ffd700;
  pointer-events: none;
  z-index: 10001;
  animation: sparkFly 0.5s ease-out forwards;
}

@keyframes sparkFly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

/* Floating Milestone Popups */
.floating-popup {
  position: absolute;
  transform: translate(-50%, -100%);
  color: #ffd700;
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9), 0 0 20px #ffd700;
  pointer-events: none;
  z-index: 10002;
  animation: floatUpFade 1.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.floating-popup.merge-popup {
  color: #00ffff;
  font-size: 1.35rem;
  font-weight: 900;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9), 0 0 25px #00ffff;
  animation: floatUpFadeComic 1.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.floating-popup.comic-popup {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 1px;
  animation: floatUpFadeComic 1.2s cubic-bezier(0.18, 0.89, 0.32, 1.35) forwards;
}

@keyframes floatUpFade {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -80%) scale(1.15);
  }
  40% {
    transform: translate(-50%, -100%) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1.05);
  }
}

@keyframes floatUpFadeComic {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.3) rotate(-8deg);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -80%) scale(1.3) rotate(6deg);
  }
  50% {
    transform: translate(-50%, -105%) scale(1.05) rotate(-3deg);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -180%) scale(1.2) rotate(4deg);
  }
}

/* Funny Floating Emoji Particles */
.floating-emoji {
  position: absolute;
  font-size: 26px;
  pointer-events: none;
  z-index: 10003;
  animation: emojiFloatPop 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes emojiFloatPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(var(--rot-start, -15deg));
  }
  30% {
    opacity: 1;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -30px))) scale(1.4) rotate(var(--rot-mid, 12deg));
  }
  70% {
    opacity: 0.9;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -60px))) scale(1.1) rotate(var(--rot-end, -6deg));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -90px))) scale(0.6) rotate(var(--rot-end, -6deg));
  }
}

/* Screen Shake Effect for Dramatic Events */
.game-screen-shake {
  animation: screenShakeAnim 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screenShakeAnim {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(3px, -2px, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 3px, 0); }
  40%, 60% { transform: translate3d(4px, -3px, 0); }
}

.game-screen-shake-subtle {
  animation: screenShakeSubtle 0.22s ease-out both;
}

@keyframes screenShakeSubtle {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.5px, 1.5px); }
  50% { transform: translate(1.5px, -1.5px); }
  75% { transform: translate(-1px, 0.5px); }
}

/* ========================================= */
/* ⚔️ WAR ZONE COMBAT & SIEGE STYLES */
/* ========================================= */

.click-ripple.war-ripple {
  border-color: #ff3366 !important;
  background: radial-gradient(circle, rgba(255, 51, 102, 0.6) 0%, rgba(255, 51, 102, 0.1) 70%, transparent 100%) !important;
}

.click-spark.war-spark {
  background: #ff3366 !important;
  box-shadow: 0 0 6px #ff0055 !important;
}

.polygon-war-active {
  stroke: #ff3366 !important;
  stroke-width: 3.5px !important;
  stroke-dasharray: 8, 6;
  animation: warZoneMarch 2.5s linear infinite !important;
}

@keyframes warZoneMarch {
  to {
    stroke-dashoffset: 28;
  }
}

.tooltip-war-zone {
  background: rgba(35, 8, 18, 0.96) !important;
  border: 1.5px solid #ff3366 !important;
  color: #ff3366 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6) !important;
}

.tooltip-war-zone::before {
  border-top-color: #ff3366 !important;
}

.selected-owner-badge.war-owner-badge {
  background: rgba(255, 51, 102, 0.18) !important;
  border-color: #ff3366 !important;
  color: #ff3366 !important;
  box-shadow: 0 0 12px rgba(255, 51, 102, 0.35) !important;
}

.floating-popup.war-popup {
  color: #ff3366;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.95), 0 0 25px #ff3366;
}

.floating-popup.strong-popup,
.floating-popup.strong {
  color: #c084fc;
  font-size: 1.25rem;
  text-shadow: 0 0 14px rgba(0, 0, 0, 0.95), 0 0 26px #a855f7;
  letter-spacing: 1px;
}

.click-ripple.strong-ripple {
  border-color: #a855f7 !important;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.6) 0%, rgba(168, 85, 247, 0.1) 70%, transparent 100%) !important;
}

.click-spark.strong-spark {
  background: #c084fc !important;
  box-shadow: 0 0 8px #a855f7 !important;
}

.tooltip-def-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(168, 85, 247, 0.22);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #d8b4fe;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 3px;
  vertical-align: middle;
  transition: all 0.3s ease;
}

/* ========================================= */
/* 🛡️ DEFENSE TIER BORDER & AURA STYLES (40 -> 250+) */
/* ========================================= */

/* Tier Tooltip Badge Variants */
.tooltip-def-badge.tier-iron {
  background: rgba(148, 163, 184, 0.22);
  border-color: rgba(148, 163, 184, 0.5);
  color: #cbd5e1;
}
.tooltip-def-badge.tier-bronze {
  background: rgba(217, 119, 6, 0.22);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fcd34d;
}
.tooltip-def-badge.tier-steel {
  background: rgba(14, 165, 233, 0.22);
  border-color: rgba(56, 189, 248, 0.6);
  color: #7dd3fc;
  box-shadow: 0 0 6px rgba(14, 165, 233, 0.4);
}
.tooltip-def-badge.tier-mithril {
  background: rgba(5, 150, 105, 0.25);
  border-color: rgba(52, 211, 153, 0.65);
  color: #6ee7b7;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}
.tooltip-def-badge.tier-obsidian {
  background: rgba(147, 51, 234, 0.28);
  border-color: rgba(192, 132, 252, 0.75);
  color: #e9d5ff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}
.tooltip-def-badge.tier-dragon {
  background: rgba(225, 29, 72, 0.3);
  border-color: rgba(251, 113, 133, 0.85);
  color: #ffe4e6;
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.7);
}
.tooltip-def-badge.tier-celestial {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.4), rgba(236, 72, 153, 0.35));
  border-color: #ffd700;
  color: #ffffff;
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.9), 0 0 8px rgba(255, 255, 255, 0.8);
  animation: celestialBadgeShine 2s ease-in-out infinite;
}

@keyframes celestialBadgeShine {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 6px #ffd700); }
  50% { filter: brightness(1.25) drop-shadow(0 0 12px #ff007f); }
}

/* Tier 1: Iron Palisade (DEF 40 - 49) */
.polygon-tier-40 {
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
}

/* Tier 2: Bronze Bastion (DEF 50 - 69) - Dashed fortified border */
.polygon-tier-50 {
  stroke-dasharray: 12, 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
  animation: bronzeDashFlow 12s linear infinite;
}
@keyframes bronzeDashFlow {
  to { stroke-dashoffset: 68; }
}

/* Tier 3: Steel Citadel (DEF 70 - 89) - Cyan electrical pulsed dash */
.polygon-tier-70 {
  stroke-dasharray: 16, 6, 4, 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
  animation: steelGlowPulse 4s ease-in-out infinite, steelMarch 9s linear infinite;
}
@keyframes steelMarch {
  to { stroke-dashoffset: 64; }
}
@keyframes steelGlowPulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.65)); }
  50% { filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.95)) drop-shadow(0 0 6px #ffffff); }
}

/* Tier 4: Mithril Fortress (DEF 90 - 129) - Emerald dual-step pattern & radiant aura */
.polygon-tier-90 {
  stroke-dasharray: 20, 8, 8, 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
  animation: mithrilAuraPulse 3s ease-in-out infinite, mithrilFlow 7s linear infinite;
}
@keyframes mithrilFlow {
  to { stroke-dashoffset: 88; }
}
@keyframes mithrilAuraPulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.7)); }
  50% { filter: drop-shadow(0 0 24px rgba(52, 211, 153, 0.95)) drop-shadow(0 0 8px #a7f3d0); }
}

/* Tier 5: Obsidian Bulwark (DEF 130 - 179) - Intense purple runic boundary */
.polygon-tier-130 {
  stroke-dasharray: 24, 8, 6, 8, 6, 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
  animation: obsidianRunePulse 2.6s ease-in-out infinite, obsidianFlow 6s linear infinite;
}
@keyframes obsidianFlow {
  to { stroke-dashoffset: 120; }
}
@keyframes obsidianRunePulse {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(168, 85, 247, 0.75)) drop-shadow(0 0 5px rgba(216, 180, 254, 0.5)); }
  50% { filter: drop-shadow(0 0 28px rgba(192, 132, 252, 1)) drop-shadow(0 0 12px #ffffff); }
}

/* Tier 6: Dragon Aegis (DEF 180 - 249) - Fiery crimson dragon breath border */
.polygon-tier-180 {
  stroke-dasharray: 28, 7, 10, 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
  animation: dragonBreath 2s ease-in-out infinite, dragonShift 5s linear infinite;
}
@keyframes dragonShift {
  to { stroke-dashoffset: 104; }
}
@keyframes dragonBreath {
  0%, 100% { filter: drop-shadow(0 0 16px rgba(244, 63, 94, 0.85)) drop-shadow(0 0 8px rgba(251, 146, 60, 0.7)); }
  50% { filter: drop-shadow(0 0 32px rgba(239, 68, 68, 1)) drop-shadow(0 0 14px #ffd700); }
}

/* Tier 7: Celestial Aegis / God-King Fortress (DEF 250+) - Mythic shimmering rainbow-gold border */
.polygon-tier-250 {
  stroke-dasharray: 32, 6, 12, 6, 12, 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, fill-opacity 0.3s ease, filter 0.3s ease; /* never "all": a land's outline (d) would slide on every zoom */
  animation: celestialAura 1.8s ease-in-out infinite, celestialShift 4s linear infinite;
}
@keyframes celestialShift {
  to { stroke-dashoffset: 148; }
}
@keyframes celestialAura {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.9)) drop-shadow(0 0 10px rgba(244, 63, 94, 0.8)) drop-shadow(0 0 5px #ffffff); }
  50% { filter: drop-shadow(0 0 38px rgba(255, 255, 255, 1)) drop-shadow(0 0 22px rgba(255, 215, 0, 1)) drop-shadow(0 0 12px #a855f7); }
}

/* ========================================= */
/* 🎁 CONGRATULATIONS GIFT NOTIFICATION MODAL */
/* ========================================= */

.gift-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 39, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gift-overlay.hidden,
.game-dialog-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gift-card {
  position: relative;
  background: linear-gradient(145deg, #10163a, #0b0f2a);
  border: 2px solid #ffd700;
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.45), 0 20px 60px rgba(0, 0, 0, 0.9);
  border-radius: 20px;
  width: 440px;
  max-width: 90vw;
  padding: 36px 30px;
  text-align: center;
  transform: scale(0.9);
  animation: giftCardPop 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
  overflow: hidden;
}

@keyframes giftCardPop {
  0% { transform: scale(0.6) translateY(40px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.gift-icon-bounce {
  font-size: 58px;
  margin-bottom: 8px;
  display: inline-block;
  animation: bounceGift 1.8s ease-in-out infinite;
}

@keyframes bounceGift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-12px) rotate(-6deg); }
  75% { transform: translateY(-6px) rotate(6deg); }
}

.gift-stars {
  font-size: 1.1rem;
  letter-spacing: 4px;
  margin-bottom: 10px;
  color: #ffd700;
  text-shadow: 0 0 8px #ffd700;
}

.gift-title {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

.gift-subtitle {
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: #10b981;
  font-weight: 800;
  margin-bottom: 22px;
}

.gift-reward-box {
  background: rgba(255, 215, 0, 0.08);
  border: 1px dashed rgba(255, 215, 0, 0.6);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.reward-tag {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ffd700;
}

.reward-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.5rem;
  font-weight: 800;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
  line-height: 1.1;
}

.reward-desc {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #9ca3af;
}

.gift-msg {
  font-size: 0.85rem;
  color: #d1d5db;
  line-height: 1.5;
  margin-bottom: 26px;
}

.btn-claim {
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  color: #0b0f2a;
  border: none;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 14px 28px;
  border-radius: 10px;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
  transition: all 0.2s ease;
}

.btn-claim:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 28px rgba(255, 215, 0, 0.6);
  background: linear-gradient(135deg, #ffe033, #fbbf24);
}

/* Confetti Burst Particle Elements */
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall 2.2s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0.3);
    opacity: 0;
  }
}

/* ========================================= */
/* ✏️ DIALOGS: RENAME LAND & MERGE TITLE */
/* ========================================= */

.game-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(2, 6, 23, 0.5) !important;
  backdrop-filter: blur(4px) saturate(130%) !important;
  -webkit-backdrop-filter: blur(4px) saturate(130%) !important;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.game-dialog-card {
  background: rgba(15, 23, 42, 0.72) !important;
  backdrop-filter: blur(6px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(6px) saturate(140%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.12) !important;
  border-radius: 24px;
  width: 440px;
  max-width: 90vw;
  padding: 26px 24px;
  text-align: center;
  animation: dialogCardIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.edit-land-dialog-card {
  width: 520px !important;
  max-width: 94vw !important;
  text-align: left !important;
}

.merge-dialog-card {
  width: 480px;
  border-color: rgba(255, 215, 0, 0.5) !important;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 35px rgba(255, 215, 0, 0.25) !important;
}

@keyframes dialogCardIn {
  0% { transform: scale(0.92) translateY(12px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Inspector Modal Tab Styles */
.inspector-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.inspector-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.inspector-tab-btn.active {
  color: #020617 !important;
  background: linear-gradient(135deg, #ffd700, #f59e0b) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35) !important;
  transform: translateY(-1px);
}

.inspector-content-scroll {
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.dialog-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.dialog-icon-crown {
  font-size: 44px;
  margin-bottom: 6px;
  animation: floatIcon 2s ease-in-out infinite;
}

.dialog-title {
  color: #ffd700;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.dialog-desc {
  font-size: 0.8rem;
  color: #9ca3af;
  line-height: 1.45;
  margin-bottom: 20px;
}

.dialog-input-group {
  margin-bottom: 20px;
}

.dialog-input-group input,
.custom-title-section input {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1.5px solid rgba(255, 215, 0, 0.4);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 10px;
  outline: none;
  transition: all 0.2s ease;
  text-align: center;
}

.dialog-input-group input:focus,
.custom-title-section input:focus {
  border-color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
  background: rgba(0, 0, 0, 0.6);
}

.dialog-actions {
  display: flex;
  gap: 12px;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #d1d5db;
}

.btn-confirm {
  background: #ffd700;
  color: #0b0f2a;
  border: none;
  font-weight: 800;
}

.btn-confirm:hover {
  background: #ffe347;
  color: #000;
}

/* Merge Options List */
.merge-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 18px;
  padding: 2px;
}

.merge-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.merge-option-item:hover {
  background: rgba(255, 215, 0, 0.1);
  border-color: rgba(255, 215, 0, 0.5);
  transform: translateX(3px);
}

.merge-option-item.selected {
  background: rgba(255, 215, 0, 0.18);
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

.option-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.option-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.15);
  padding: 3px 8px;
  border-radius: 6px;
}

.custom-title-section {
  text-align: left;
  margin-bottom: 22px;
}

.custom-title-label {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

/* Force Google Login Modal */
.auth-force-card {
  max-width: 400px;
  text-align: center;
}

.auth-force-btn-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 18px 0;
  width: 100%;
}

/* 24-Hour Expiry Warning Banner (For Guests) */
.unauthenticated-warning-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(245, 158, 11, 0.15));
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: pulseWarning 3s ease-in-out infinite;
}

@keyframes pulseWarning {
  0%, 100% {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
  }
  50% {
    border-color: rgba(239, 68, 68, 0.85);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
  }
}

.warning-banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fca5a5;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.warning-icon {
  font-size: 1.1rem;
}

.warning-banner-text {
  font-size: 0.78rem;
  line-height: 1.35;
  color: #e5e7eb;
  margin: 0;
}

.warning-banner-text strong {
  color: #f87171;
}

.warning-banner-action {
  margin-top: 4px;
}

.btn-warning-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: #ffffff;
  color: #1f2937;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.btn-warning-signin:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.btn-warning-signin svg {
  flex-shrink: 0;
}

/* Welcome Modal & Error Text */
.welcome-card {
  max-width: 420px;
  text-align: center;
}

.dialog-error-text {
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: -6px;
  margin-bottom: 10px;
  text-align: left;
}

.dialog-error-text.hidden {
  display: none !important;
}

.clickable-badge {
  cursor: pointer;
  transition: all 0.2s ease;
}

.clickable-badge:hover {
  background: rgba(255, 215, 0, 0.25);
  color: #ffd700;
  transform: scale(1.03);
}

/* ===================================================
   Territory Link & Social Media Styling
   =================================================== */
.selected-link-section {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sel-link-display-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}

.land-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(147, 51, 234, 0.25));
  border: 1px solid rgba(96, 165, 250, 0.5);
  padding: 8px 14px;
  border-radius: 10px;
  color: #60a5fa;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  word-break: break-all;
  max-width: 100%;
}

.land-link-chip:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.45), rgba(147, 51, 234, 0.45));
  border-color: #93c5fd;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.land-link-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.land-link-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.land-link-arrow {
  font-size: 0.95rem;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.land-link-chip:hover .land-link-arrow {
  transform: translate(2px, -2px);
  opacity: 1;
}

.sel-link-empty-hint {
  font-size: 0.78rem;
  color: #64748b;
  font-style: italic;
  padding: 4px 0;
}

.sel-link-edit-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.link-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.link-field-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sel-land-link-select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 0.82rem;
  padding: 8px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.sel-land-link-select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.sel-land-link-select option {
  background: #0f172a;
  color: #f8fafc;
}

.sel-land-link-input {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 0.82rem;
  padding: 8px 12px;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.sel-land-link-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.sel-land-link-input.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25) !important;
}

.sel-land-link-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 6px;
  color: #fca5a5;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  text-align: left;
  line-height: 1.35;
}

.link-button-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-save-link {
  flex: 1;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-save-link:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.btn-remove-link {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-remove-link:hover {
  background: #ef4444;
  color: #fff;
}

/* Tooltip Link Badge */
.tooltip-link-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 6px;
  font-size: 0.72rem;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(96, 165, 250, 0.6);
  color: #93c5fd;
  font-weight: 700;
  vertical-align: middle;
}

.tooltip-link-logo {
  width: 14px;
  height: 14px;
  object-fit: contain;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
}

.land-link-logo-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.link-select-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.link-select-icon-preview {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}

.link-select-icon-preview:hover {
  transform: scale(1.08);
}
.sel-land-link-select {
  flex: 1;
}

/* INVITE BEACON PING & MARKER ANIMATION */
.invite-beacon-leaflet-icon {
  background: transparent !important;
  border: none !important;
}

/* ========================================================
   📱 COMPREHENSIVE MOBILE RESPONSIVE ENGINE (PHONE & TABLET)
   ======================================================== */

/* Touch optimization & Fast Response */
html, body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Standalone / PWA / Safe-Area insets for iPhone Notch & Android Nav */
@supports (padding: env(safe-area-inset-top)) {
  .hud-top-left-panel {
    top: calc(12px + env(safe-area-inset-top)) !important;
    left: calc(12px + env(safe-area-inset-left)) !important;
  }
  .hud-top-panel {
    top: calc(12px + env(safe-area-inset-top)) !important;
    right: calc(12px + env(safe-area-inset-right)) !important;
  }
  .hud-bottom-panel {
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    right: calc(12px + env(safe-area-inset-right)) !important;
  }
  .zoom-controls-dock {
    bottom: calc(14px + env(safe-area-inset-bottom)) !important;
  }
}

/* Responsive transitions for HUD panels */
.hud-top-left-panel,
.hud-top-panel,
.hud-bottom-panel {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

/* Mobile Toggle Hamburger styling */
.mobile-toggle-btn {
  touch-action: manipulation;
}

.mobile-toggle-btn:active {
  transform: scale(0.92);
}

/* TABLETS & INTERMEDIATE BREAKPOINTS (max-width: 1024px) */
@media (max-width: 1024px) {
  .hud-top-left-panel {
    max-width: 290px;
    top: 14px;
    left: 14px;
  }
  .hud-top-panel {
    width: 290px;
    top: 14px;
    right: 14px;
  }
  .hud-bottom-panel {
    width: 290px;
    right: 14px;
    bottom: 14px;
    max-height: calc(100vh - 420px);
  }
  /* Move - + zoom controls to bottom left on tablet */
  .zoom-controls-dock {
    position: fixed !important;
    bottom: 18px !important;
    left: 18px !important;
    right: auto !important;
    transform: none !important;
    z-index: 1005 !important;
  }
}

/* MOBILE PHONES & SMALL SCREENS (max-width: 768px) - NATIVE MOBILE APP EXPERIENCE */
@media (max-width: 768px) {
  /* 1. TOP NATIVE-LIKE APP BAR */
  .hud-top-left-panel {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    max-width: none;
    width: auto;
    z-index: 1050;
  }

  .hud-top-left-panel .hud-title {
    padding: 7px 10px;
    border-radius: 16px;
    background: rgba(10, 14, 39, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }

  .hud-top-left-panel .hud-icon {
    width: 30px;
    height: 30px;
    font-size: 1.15rem;
    padding: 4px;
    border-radius: 10px;
  }

  .hud-top-left-panel .hud-logo {
    width: 36px;
    height: 36px;
    padding: 0;
  }

  .hud-top-left-panel .clickable-badge {
    font-size: 10px;
    padding: 2px 7px;
    max-width: 120px;
  }

  /* Collapsible top-left drawer items (Google Sign-In, Leaderboard, Invite) */
  .hud-top-left-collapsible {
    background: rgba(10, 14, 39, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    transition: all 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    transform-origin: top center;
  }

  .hud-top-left-collapsible.mobile-hidden {
    display: none !important;
  }

  /* 2. FLOATING MINI STATUS PILL */
  .mobile-mini-status-pill {
    top: calc(52px + max(8px, env(safe-area-inset-top)));
    transition: all 0.25s ease;
  }

  .mobile-mini-status-pill.hidden-pill {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate(-50%, -10px) !important;
  }

  /* 3. CONQUEST HUD (Slide-Down Card / Sheet on Mobile) */
  .hud-top-panel {
    top: calc(52px + max(8px, env(safe-area-inset-top)));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    z-index: 1045;
    gap: 8px;
    max-height: calc(85vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(-130%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
  }

  .hud-top-panel.mobile-sheet-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7);
  }

  .hud-top-panel .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .hud-top-panel .stat-box {
    padding: 8px 10px;
    border-radius: 14px;
  }

  .hud-top-panel .stat-box.highlight {
    grid-column: span 2;
  }

  .hud-top-panel .stat-box #val-area {
    font-size: 1.15rem;
  }

  .hud-top-panel .stat-box #val-count,
  .hud-top-panel .stat-box #val-clicks {
    font-size: 0.9rem;
  }

  .conquest-progress-section {
    padding: 10px 12px;
    border-radius: 14px;
    gap: 8px;
  }

  .conquest-progress-section .strategy-switcher-container {
    padding: 4px;
  }

  .conquest-progress-section .strategy-toggle-btn {
    padding: 6px 8px;
    font-size: 9.5px;
  }

  .progress-subtext {
    font-size: 10px;
    line-height: 1.3;
  }

  /* 4. MY LANDS PANEL (Slide-Up Native Bottom Sheet) */
  .hud-bottom-panel {
    bottom: calc(64px + max(4px, env(safe-area-inset-bottom)));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    z-index: 1045;
    max-height: 68vh;
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
  }

  .hud-bottom-panel.mobile-sheet-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.65);
  }

  .user-lands-card {
    padding: 12px 14px;
    border-radius: 22px;
    max-height: 64vh;
    background: rgba(10, 14, 39, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .user-lands-list-scroll {
    max-height: 48vh;
    -webkit-overflow-scrolling: touch;
  }

  /* 5. VERTICAL MICRO ZOOM DOCK (Native mobile map controls on bottom left) */
  .zoom-controls-dock {
    position: fixed !important;
    bottom: calc(72px + max(6px, env(safe-area-inset-bottom))) !important;
    left: 12px !important;
    right: auto !important;
    transform: none !important;
    flex-direction: column !important;
    padding: 5px !important;
    border-radius: 18px !important;
    gap: 5px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6) !important;
    z-index: 1005 !important;
  }

  .zoom-controls-dock #zoom-display-badge {
    display: none !important;
  }

  .zoom-controls-dock button {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: 0.9rem;
  }

  .zoom-controls-dock .h-5.w-px {
    width: 20px !important;
    height: 1px !important;
    margin: 2px auto !important;
  }

  /* 6. MOBILE APP BOTTOM NAVIGATION BAR */
  .mobile-app-bottom-nav {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    height: calc(56px + max(6px, env(safe-area-inset-bottom)));
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-app-bottom-nav .mobile-nav-item {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }

  .mobile-app-bottom-nav .mobile-nav-item.active {
    color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.12);
  }

  /* 7. BACKDROP OVERLAY */
  #mobile-hud-backdrop.active {
    display: block !important;
    opacity: 1;
  }

  /* MODALS & FULLSCREEN DIALOGS ON MOBILE */
  .game-dialog-overlay {
    padding: 8px !important;
    align-items: flex-end; /* Mobile Bottom Sheet Feel */
  }

  .game-dialog-card,
  .edit-land-dialog-card {
    max-height: 88vh !important;
    width: 100% !important;
    border-bottom-left-radius: 18px !important;
    border-bottom-right-radius: 18px !important;
    border-top-left-radius: 26px !important;
    border-top-right-radius: 26px !important;
    padding: 16px !important;
    gap: 12px !important;
  }

  .inspector-content-scroll {
    max-height: 52vh !important;
  }

  .inspector-tabs {
    gap: 4px;
    padding: 3px;
  }

  .inspector-tab-btn {
    padding: 7px 6px !important;
    font-size: 11px !important;
    gap: 4px !important;
  }

  /* Territory Inspector Stats Grid 2x2 on mobile */
  .selected-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Leaderboard modal on mobile */
  #leaderboard-modal .game-dialog-card {
    max-height: 90vh !important;
    padding: 14px !important;
  }

  #leaderboard-sort-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 3px;
  }

  #leaderboard-sort-bar .leaderboard-tab-btn {
    flex-shrink: 0;
    padding: 6px 10px !important;
    font-size: 10.5px !important;
  }

  #leaderboard-entries-container {
    max-height: 52vh !important;
  }

  /* Welcome and Gift Modals */
  .gift-card,
  .welcome-card {
    padding: 20px 16px !important;
    border-radius: 24px !important;
  }

  .gift-card .reward-amount {
    font-size: 1.8rem !important;
  }

  /* Comic Popups size adjust on mobile */
  .comic-popup {
    font-size: 0.95rem !important;
    padding: 6px 12px !important;
  }
}

/* VERY SMALL SCREENS (iPhone SE, Galaxy Fold Folded: max-width: 380px) */
@media (max-width: 380px) {
  .hud-top-left-panel h1 {
    display: none; /* Keep crown icon & commander name for ultra compact layout */
  }
  .hud-top-panel .stat-box #val-area {
    font-size: 1.05rem;
  }
  .conquest-progress-section .strategy-toggle-btn span {
    font-size: 9px;
  }
  .zoom-controls-dock #zoom-display-badge .zoom-label {
    display: none;
  }
}

/* First-Time Empty Spot Tutorial Target Animation */
.first-time-tutorial-marker {
  position: relative;
  width: 140px;
  height: 140px;
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px dashed #ffd700;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.25) 0%, rgba(255, 215, 0, 0.05) 50%, transparent 70%);
  animation: tutorialSpin 10s linear infinite, tutorialPulse 2s ease-in-out infinite;
  box-shadow: 0 0 35px rgba(255, 215, 0, 0.5), inset 0 0 25px rgba(255, 215, 0, 0.3);
}

.tutorial-pulse-core {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd700 0%, #f59e0b 60%, transparent 100%);
  box-shadow: 0 0 25px #ffd700, 0 0 45px rgba(255, 215, 0, 0.8);
  animation: tutorialCorePulse 1.2s ease-in-out infinite;
}

.tutorial-badge-card {
  position: absolute;
  top: -46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.98));
  border: 2px solid #ffd700;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.6);
  white-space: nowrap;
  animation: tutorialBounce 1.5s ease-in-out infinite;
  z-index: 10;
}

.tutorial-prompt-title {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffd700;
  display: flex;
  align-items: center;
  gap: 4px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.tutorial-count-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 900;
  color: #ffffff;
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.4);
  padding: 1px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.tutorial-count-pill .current-taps {
  color: #ffd700;
  font-size: 15px;
}

.tutorial-count-pill .max-taps {
  color: #94a3b8;
  font-size: 11px;
}

.tutorial-finger-pointer {
  position: absolute;
  bottom: -40px;
  font-size: 32px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.8));
  animation: tutorialFingerTap 0.9s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}

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

@keyframes tutorialPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.15); opacity: 1; }
}

@keyframes tutorialCorePulse {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
}

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

@keyframes tutorialFingerTap {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.18); }
}
