:root{--accent:#6f42c1;--accent-2:#9b6ef2;--bg:#ffffff}
:root{--accent:#6f42c1;--accent-2:#9b6ef2;--bg:#ffffff;--card:#ffffff;--muted:#f3eefd;--border:rgba(111,66,193,0.12)}
/* Pixelify Sans font (optional): place font files at frontend/assets/fonts/PixelifySans.woff2 */
@font-face{font-family:'Pixelify Sans';src:local('Pixelify Sans'),url('/assets/fonts/PixelifySans.woff2') format('woff2');font-weight:700;font-style:normal;font-display:swap}
/* Apply Pixelify Sans to brand/title elements site-wide; falls back to Inter */
.brand .title,.pixel-title{font-family:'Pixelify Sans',Inter,Segoe UI,Arial,sans-serif}
html,body,#map,#app{height:100%;margin:0}
#app { background: linear-gradient(180deg,#ffffff,#fbf8ff) }
body{font-family:Inter,Segoe UI,Arial,sans-serif;background:var(--bg);color:#222}
#map{position:fixed;inset:0}

/* Header */
.site-header{position:fixed;left:0;right:0;top:8px;z-index:800;display:flex;justify-content:center;pointer-events:none}
.site-header .header-inner{width:100%;max-width:1100px;display:flex;justify-content:space-between;align-items:center;pointer-events:auto;padding:8px 12px}
.brand{display:flex;align-items:center;gap:12px}
.brand .title{font-size:18px;font-weight:700;color:var(--accent)}
.brand .subtitle{font-size:12px;color:#6b5aa3}
#siteLogo{width:40px;height:40px;border-radius:8px;box-shadow:0 8px 24px rgba(111,66,193,0.08)}

/* Help modal header: logo + pixel title */
.modal-header{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.modal-logo{width:44px;height:44px;border-radius:8px;box-shadow:0 8px 24px rgba(111,66,193,0.08)}
.modal-title-wrap{display:flex;flex-direction:column}
/* Help modal: larger centered pixel title using Pixelify Sans */
#helpModal .modal-header{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px}
#helpModal .modal-logo{width:72px;height:72px}
#helpModal .modal-title-wrap{align-items:center}
#helpModal .pixel-title{font-family:'Pixelify Sans',Inter,Segoe UI,Arial,sans-serif;font-weight:700;font-size:36px;color:var(--accent);letter-spacing:1px}
#helpModal .modal-sub{font-size:16px;color:#5d4aa1;margin-top:6px;font-weight:700}

/* Help modal specific larger logo & body */
#helpModal .modal-logo{width:72px;height:72px}
#helpModal .pixel-title{font-size:28px}
#helpModal .modal-sub{font-size:16px}
#helpModal .modal-body{font-size:15px}

/* Modal body container (for consistent scrolling inside modal) */
.modal-body{overflow:auto}

/* Center modal action buttons and ensure consistent spacing */
.modal-actions{display:flex;justify-content:center;align-items:center;gap:12px;margin-top:12px;width:100%}
.modal .modal-actions .close, .modal .modal-actions button { min-width:120px }

/* Profile ID styling (subtle grey, prefixed with #) */
.profile-id{font-size:14px;color:#9aa0b4;margin-top:6px;font-weight:700}

/* Profile bio: muted color and comfortable width */
.profile-bio{margin-top:8px;color:#6b6f78;max-width:520px;white-space:pre-wrap}

/* User panel: stack Logout above Close and style Logout with red tones */
#userPanel .modal-actions{flex-direction:column;gap:14px}
#userPanel .modal-actions #logoutBtn{min-width:160px;background:linear-gradient(180deg,#ff7b7b,#ff4040);border:1px solid rgba(220,40,40,0.12);color:#fff;font-weight:700;box-shadow:0 10px 30px rgba(255,80,80,0.08)}
#userPanel .modal-actions #logoutBtn:active{transform:translateY(1px)}

/* Ensure button text is centered horizontally */
.modal-content button { justify-content:center }

/* Normalize close buttons inside modals */
.modal .close{display:inline-flex;justify-content:center;align-items:center;padding:10px 14px;border-radius:10px;background:linear-gradient(180deg,#fff,#f6f4ff);border:1px solid var(--border);cursor:pointer;font-weight:700;text-align:center;min-width:120px}
.modal .close:focus{outline:3px solid rgba(111,66,193,0.16);outline-offset:3px}
.modal .close .fa, .modal .close i { margin-right:6px }
.header-stats{display:flex;gap:8px;align-items:center}
/* Hide compact header stats (Daily/Weekly/Monthly/Total) when not desired */
#headerStats { display: none !important; }

/* Avatar and user mini block in header */
.user-block{display:flex;align-items:center;gap:10px;padding:8px;border-radius:12px;background:#fff;box-shadow:0 8px 20px rgba(30,20,60,0.06);overflow:visible;position:relative;padding-left:8px}

/* Avatar progress ring */
.avatar-progress-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  z-index: 10;
  overflow: visible;
  pointer-events: none;
  margin: 0;
  padding: 0;
  display: block;
}

.avatar-progress-ring circle {
  transform-origin: 22px 22px;
  transform: rotate(-90deg);
}

.avatar-level-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

/* Avatar frame container */
.avatar-frame {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  z-index: 2;
}

.avatar-frame .avatar-level-badge {
  position: absolute;
  top: -14px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd700, #ffed4e);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #333;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
  z-index: 12;
}

.avatar{width:44px;height:44px;border-radius:10px;background:linear-gradient(180deg,var(--accent),var(--accent-2));color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:16px;box-shadow:0 8px 30px rgba(111,66,193,0.14)}
.user-meta{display:flex;flex-direction:column}
.user-name{font-size:13px;font-weight:700}
.user-mini{font-size:12px;color:#6b5aa3;display:inline-flex;align-items:center;gap:6px}
/* Cores icon styling: no background, no padding, fit image inside box */
.user-mini .cores-icon{width:18px;height:18px;border-radius:4px;padding:0;box-shadow:none;border:0;background:transparent;object-fit:contain;display:inline-block;vertical-align:middle}
.badge .cores-icon{width:14px;height:14px;border-radius:3px;padding:0;box-shadow:none;border:0;background:transparent;object-fit:contain;display:inline-block;vertical-align:middle}

/* Stats summary box */
.stats-summary{display:flex;gap:12px;align-items:center;padding:8px 12px;border-radius:14px;justify-content:center}
.stats-summary div{font-size:12px;color:#5d4aa1}
.stats-summary strong{color:var(--accent);margin-left:6px}

/* News banner */
.news{position:fixed;top:72px;left:50%;transform:translateX(-50%);background:linear-gradient(90deg,#f9f6ff,#fff);padding:8px 14px;border-radius:12px;border:1px solid var(--border);box-shadow:0 12px 40px rgba(111,66,193,0.06);z-index:790;font-size:13px;color:#4b3a88}

/* Notifications styling (purple-white theme) */
.notif-row { display:flex; gap:12px; align-items:center; padding:12px; border-radius:10px; background: linear-gradient(180deg,#ffffff,#fbf8ff); border:1px solid rgba(0,0,0,0.04); box-sizing:border-box; }
.notif-row .left-accent { width:6px; border-radius:4px; background:linear-gradient(180deg,#6f42c1,#8b5cf6); flex:0 0 6px; }
.notif-row .notif-body { flex:1; text-align:left; }
.notif-row .notif-title { font-weight:800; font-size:17px; color:#4b1fa0; }
.notif-row .notif-text { margin-top:6px; font-size:13px; color:#544b66; }
.notif-row.unread { box-shadow: 0 6px 18px rgba(111,66,193,0.06); }

/* News floating banner (bottom-right) */
.news-banner { position: fixed; right: 20px; bottom: 20px; z-index: 9999; background: linear-gradient(180deg,#fff,#fffafc); border-radius:12px; box-shadow: 0 12px 40px rgba(111,66,193,0.08); border: 1px solid rgba(111,66,193,0.08); padding: 12px 16px; display:flex; gap:12px; align-items:flex-start; max-width:360px; }
.news-banner .nb-left { width:8px; background:linear-gradient(180deg,#6f42c1,#8b5cf6); border-radius:4px; flex:0 0 8px; }
.news-banner .nb-content { flex:1; }
.news-banner .nb-title { font-weight:800; font-size:18px; color:#2b1b59; }
.news-banner .nb-body { margin-top:6px; font-size:13px; color:#5b4f6e; }
.news-banner .nb-close { margin-left:8px; background:transparent; border:0; color:#6f42c1; font-weight:700; cursor:pointer; }

@media (max-width:520px) { .news-banner { right:10px; left:10px; max-width:unset; } }

/* Center text for header, modals and user blocks */
.site-header, .site-header .header-inner, .tabs, .stats-summary, .profile-meta, .profile-row { text-align: center }
/* Avoid globally centering modal content; many modals rely on stretch alignment.
	Notifications modal expects children to stretch so the left accent can align flush. */
.profile-row { justify-content: center }


/* Top-left icons */
#top-left-icons{position:fixed;left:12px;top:12px;display:flex;gap:8px;z-index:600}
.icon{background:linear-gradient(180deg,#fff,#fbf8ff);border-radius:999px;padding:8px;border:1px solid var(--border);cursor:pointer;box-shadow:0 8px 28px rgba(111,66,193,0.06);display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px}

/* Badge tweaks for header */
.header-stats .badge{padding:6px 10px;border-radius:14px;font-size:13px}

/* Top-right badges */
/* Top-right icon cluster */
#top-right{position:fixed;right:18px;top:12px;display:flex;gap:10px;align-items:center;z-index:700;flex-wrap:wrap;max-width:calc(100vw - 36px);justify-content:flex-end}

@media (max-width: 640px) {
  #top-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    right: 8px;
    top: 8px;
    max-width: calc(100vw - 16px);
    width: 96px;
  }
  
  #top-right .icon.small {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
  
  #top-right #levelBtn {
    grid-column: 1 / -1;
    width: 100%;
  }
}
.badge{background:linear-gradient(180deg,#fff,#fbf8ff);padding:10px 16px;border-radius:20px;border:1px solid var(--border);font-size:14px;box-shadow:0 10px 26px rgba(111,66,193,0.06)}
.icon.small{padding:8px;font-size:16px;display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:999px}

/* Level button - special styling */
#levelBtn {
  background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
  border: none !important;
  box-shadow: 0 8px 24px rgba(255, 215, 0, 0.2) !important;
  padding: 0 !important;
}

#levelBtn:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 12px 32px rgba(255, 215, 0, 0.3) !important;
}

#levelBtn:active {
  transform: translateY(-1px) !important;
}

.level-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 2px;
}

.level-number {
  font-weight: 900;
  font-size: 18px;
  color: #333;
  line-height: 1;
}
.icon.small i{font-size:18px}

/* Make icons look like the attached style: circular white button with subtle shadow and accent-colored outline icon */
#top-right .icon i, #top-left-icons .icon i { color: var(--accent); }
#top-right .icon, #top-left-icons .icon { background: #fff; border: 1px solid rgba(111,66,193,0.06); }

/* Explicit styling for battles button */
#battlesBtn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  visibility: visible !important;
  opacity: 1 !important;
}

#battlesBtn i {
  display: inline !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-size: 18px !important;
  color: var(--accent) !important;
}

.top-right-actions { display:flex; gap:8px; align-items:center }

.badge strong { color: var(--accent) }

#controls{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;z-index:600;padding:10px;backdrop-filter: blur(6px)}
.button-group button{background:linear-gradient(180deg,#fff,#f6f4ff);border-radius:18px;padding:10px 18px;border:1px solid var(--border);cursor:pointer;box-shadow:0 10px 30px rgba(111,66,193,0.06)}
.button-group button.active{background:linear-gradient(180deg,var(--accent),var(--accent-2));color:#fff;border-color:transparent;box-shadow:0 14px 40px rgba(111,66,193,0.2)}

/* Palette mode toggle button - REMOVED */

/* Palette-specific action button styling */
.palette-count {
  font-size: 11px;
  color: #666;
  font-weight: 600;
  padding: 4px 8px;
  background: transparent;
  border-radius: 0;
  text-align: center;
}

.palette-action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 12px 10px 12px;
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
}

#paletteConfirm,
#paletteErase,
#paletteCancel {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px !important;
  border-radius: 4px !important;
  border: 1px solid #ddd !important;
  background: #fff !important;
  color: #666 !important;
  cursor: pointer;
  transition: all 0.15s ease !important;
  box-shadow: none !important;
}

#paletteConfirm:hover,
#paletteErase:hover,
#paletteCancel:hover {
  transform: none !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  background: #f5f5f5 !important;
  border-color: #999 !important;
}

#paletteConfirm {
  background: #6f42c1 !important;
  color: #fff !important;
  border-color: #6f42c1 !important;
}

#paletteConfirm:hover {
  background: #5a3499 !important;
  border-color: #5a3499 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
}

#paletteErase {
  background: #fff !important;
  color: #666 !important;
  border-color: #ddd !important;
}

#paletteErase:hover {
  background: #f5f5f5 !important;
  border-color: #999 !important;
}

#paletteCancel {
  background: #fff !important;
  color: #666 !important;
  border-color: #ddd !important;
}

#paletteCancel:hover {
  background: #f5f5f5 !important;
  border-color: #999 !important;
}
#toolOptions{display:flex;align-items:center;gap:10px;align-items:center}
.swatch{width:36px;height:36px;border-radius:6px;border:2px solid rgba(111,66,193,0.2);cursor:pointer;transition:all 0.2s cubic-bezier(0.2,0.9,0.2,1);box-shadow:0 4px 12px rgba(111,66,193,0.1);background-color:#ccc;flex-shrink:0}
.swatch:hover{transform:translateY(-3px);box-shadow:0 8px 20px rgba(111,66,193,0.15);border-color:rgba(111,66,193,0.4)}
.swatch:active{transform:scale(0.92)}
.swatch.active{box-shadow:0 0 0 2px rgba(111,66,193,0.3), 0 8px 20px rgba(111,66,193,0.15);border-color:rgba(111,66,193,0.6);transform:scale(1.08)}

/* Center controls: always visible at bottom with minimal styling */
#controls {
  position: fixed !important;
  bottom: 16px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 799 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 6px 10px !important;
  border-radius: 16px !important;
  background: transparent !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  border: none !important;
  box-sizing: border-box !important;
  pointer-events: auto !important;
}

#controls .button-group {
  display: flex !important;
  gap: 4px !important;
  align-items: center !important;
}

#toolOptions {
  display: flex !important;
  gap: 8px !important;
  align-items: center !important;
}
#colorPicker{width:46px;height:40px;border-radius:10px;border:1px solid rgba(0,0,0,0.06);padding:4px}
.selected-color{width:40px;height:34px;border-radius:10px;border:1px solid rgba(0,0,0,0.06);box-shadow:0 6px 18px rgba(0,0,0,0.04);background:#ff4757;cursor:default;margin-right:8px}

/* Hide the selected color preview when user requested it */
#selectedColor{display:none !important}
#info{background:linear-gradient(180deg,#fff,#fbf8ff);padding:10px 14px;border-radius:18px;border:1px solid var(--border);box-shadow:0 10px 30px rgba(111,66,193,0.06)}

/* Charge / capacity pill in tool options */
.charge-pill{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;background:linear-gradient(180deg,#fff,#faf8ff);border:1px solid rgba(0,0,0,0.04);font-weight:700;color:var(--accent)}
.charge-pill #hdr-charge{color:#e04444}
.charge-pill #hdr-capacity{color:#6b6f78;font-weight:600}
.charge-pill #hdr-countdown{font-weight:600;color:#4a4a4a;background:rgba(0,0,0,0.03);padding:4px 6px;border-radius:6px;font-size:12px}

/* Palette system - White/Purple game theme */
#palettePanel {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e0e0e0;
  z-index: 999;
  display: none;
  opacity: 0;
  transform: translateX(-50%) translateY(10px) scale(0.98);
  transition: all 0.2s ease;
  pointer-events: none;
  flex-direction: column;
  gap: 0;
  backdrop-filter: none;
  max-width: 90vw;
  overflow: hidden;
}

#palettePanel.open {
  display: flex;
  flex-direction: column;
  gap: 0;
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}

@keyframes panelPulse {
  0% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

/* Palette header styling */
.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #e0e0e0;
  gap: 10px;
}

.palette-title {
  font-size: 11px;
  font-weight: 700;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Palette actions container */
.palette-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

#paletteCount {
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: rgba(147, 112, 219, 0.8);
  font-weight: 700;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

#paletteGrid {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 12px;
  min-height: 50px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
  background: #fafafa;
}

#paletteGrid::-webkit-scrollbar {
  height: 6px;
}

#paletteGrid::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

#paletteGrid::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

#paletteGrid::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.palette-swatch {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: none;
  padding: 0;
  background-color: #ccc;
  font-size: 0;
  flex-shrink: 0;
  position: relative;
}

.palette-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: none;
  pointer-events: none;
}

.palette-swatch:hover {
  transform: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-color: rgba(111, 66, 193, 0.3);
}

.palette-swatch:active {
  transform: none;
}

.palette-swatch.active {
  box-shadow: 0 0 0 2px rgba(111, 66, 193, 0.6);
  border-color: rgba(111, 66, 193, 0.8);
  transform: none;
}


/* Responsive: Tablet */
@media (max-width: 768px) {
  #palettePanel {
    bottom: 75px;
    padding: 0;
    gap: 0;
    width: calc(100% - 20px);
    margin: 0 10px;
  }

  #paletteGrid {
    gap: 5px;
    padding: 8px 10px;
  }

  .palette-swatch {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .palette-action-buttons {
    gap: 5px;
    padding: 8px 10px 10px 10px;
  }

  #paletteConfirm,
  #paletteErase,
  #paletteCancel {
    padding: 4px 8px !important;
    font-size: 10px !important;
  }
}

/* Responsive: Mobile */
@media (max-width: 480px) {
  #palettePanel {
    bottom: 70px;
    left: 50%;
    width: calc(100% - 16px);
    max-width: 95vw;
    padding: 0;
    gap: 0;
    transform: translateX(-50%);
  }

  #palettePanel.open {
    transform: translateX(-50%) translateY(0) scale(1);
  }

  #turnstileWidget {
    padding: 8px 10px;
    display: flex;
  }

  #paletteGrid {
    gap: 4px;
    padding: 8px 10px;
    min-height: 48px;
  }

  .palette-swatch {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .palette-action-buttons {
    gap: 4px;
    padding: 8px 10px 10px 10px;
  }

  #paletteConfirm,
  #paletteErase,
  #paletteCancel {
    padding: 4px 6px !important;
    font-size: 9px !important;
  }

  .palette-count {
    font-size: 10px !important;
  }

  #controls {
    bottom: 12px;
    gap: 8px;
    padding: 8px;
  }

  .button-group button {
    padding: 8px 14px;
    font-size: 13px;
  }

  #toolOptions {
    gap: 6px;
  }

  .icon.small {
    width: 38px !important;
    height: 38px !important;
  }
}


.icon, .button-group button { transition: transform .12s ease, box-shadow .12s ease, background .12s ease }
.icon:active, .button-group button:active { transform: translateY(1px) }

#promo{position:fixed;left:50%;transform:translateX(-50%);bottom:90px;background:#ff8a65;color:#fff;padding:10px 18px;border-radius:18px;z-index:400;box-shadow:0 6px 20px rgba(0,0,0,0.12)}
#promo .x{margin-left:12px;opacity:0.9}
#footer{position:fixed;right:18px;bottom:18px;color:#c0d3e6;font-size:12px;text-align:right}
#footer a{color:#9b6ef2;text-decoration:none;margin-left:12px;transition:color 0.2s ease}
#footer a:hover{color:#6f42c1}
.leaflet-control-zoom{display:none}

/* Modals */

.modal{position:fixed;inset:0;background:rgba(15,10,25,0.45);display:flex;align-items:center;justify-content:center;z-index:900}
.modal[hidden]{display:none !important}
.modal.open{display:flex !important}
.modal .modal-content{position:relative;background:linear-gradient(180deg,#ffffff,#fbf8ff);padding:22px;border-radius:14px;min-width:320px;border:1px solid var(--border);box-shadow:0 30px 80px rgba(30,20,60,0.12);transition:transform 220ms cubic-bezier(.2,.9,.3,1),opacity 180ms ease;transform-origin:center center;transform:translateY(6px) scale(.99);opacity:0;display:flex;flex-direction:column;align-items:stretch;max-width:720px;width:min(96%,720px);max-height:calc(100vh - 96px);box-sizing:border-box;overflow:auto}
.modal.open .modal-content{transform:translateY(0) scale(1);opacity:1}
.modal.closing .modal-content{transform:translateY(6px) scale(.985);opacity:0}
.modal .close{margin-top:12px}

/* Inputs and buttons inside modals */
.modal .input{width:100%;padding:10px 12px;border-radius:10px;border:1px solid var(--border);margin-top:6px;margin-bottom:8px}
.modal .label{font-size:12px;color:#5d4aa1;margin-bottom:6px;display:block}
.btn{display:inline-flex;align-items:center;gap:8px;padding:8px 14px;border-radius:8px;cursor:pointer;font-weight:600;border:1px solid transparent;transition:all 0.2s cubic-bezier(0.2,0.9,0.2,1)}
.btn-primary{background:linear-gradient(135deg,#6f42c1,#9b6ef2);color:#fff;box-shadow:0 6px 20px rgba(111,66,193,0.25)}
.btn-primary:hover{transform:translateY(-2px);box-shadow:0 10px 28px rgba(111,66,193,0.35)}
.btn-primary:active{transform:translateY(0);box-shadow:0 4px 12px rgba(111,66,193,0.25)}
.btn-secondary{background:linear-gradient(135deg,#e8e6f0,#f3f0ff);color:#4b3a88;border:1px solid rgba(111,66,193,0.15);box-shadow:0 2px 8px rgba(30,20,60,0.05)}
.btn-secondary:hover{transform:translateY(-2px);box-shadow:0 6px 16px rgba(30,20,60,0.08);background:linear-gradient(135deg,#f0eef8,#f8f5ff)}
.btn-secondary:active{transform:translateY(0)}
.btn-icon{padding:8px;width:40px;height:40px;min-width:40px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center}


/* Tabs for user panel */
.tabs{display:block}
.tab-buttons{display:flex;gap:8px;margin-bottom:12px;justify-content:center}
.tab-btn{background:linear-gradient(180deg,#fff,#f6f4ff);border:1px solid var(--border);padding:8px 12px;border-radius:10px;cursor:pointer}
.tab-btn.active{background:linear-gradient(180deg,var(--accent),var(--accent-2));color:#fff;border-color:transparent;box-shadow:0 12px 30px rgba(111,66,193,0.12)}
.tab-content{display:block;padding:6px 2px}

/* Main pill tabs for statistics (Regions / Countries / Players / Alliances) */
.stats-main-tabs { display:flex; gap:8px; justify-content:center; }
.main-tab { background: #fff; border: 1px solid var(--border); padding:8px 14px; border-radius:24px; cursor:pointer; font-weight:700; color:var(--accent); }
.main-tab.active { background: linear-gradient(180deg,var(--accent),var(--accent-2)); color:#fff; box-shadow:0 14px 36px rgba(111,66,193,0.12); border-color: transparent }

/* Range tabs under main tabs (Today / Week / Month / All time) */
.stats-range-tabs { display:flex; gap:12px; justify-content:center; }
.range-tab { background: transparent; border: none; padding:6px 8px; cursor:pointer; color:#6b5aa3; font-weight:700; border-radius:6px; }
.range-tab.active { color:var(--accent); position:relative; }
.range-tab.active::after { content: ''; position:absolute; left:6px; right:6px; bottom:-8px; height:3px; background:var(--accent); border-radius:4px; }

/* Statistics modal specific styles */
.stats-modal-body{display:flex;flex-direction:column;gap:12px;max-height:60vh;overflow:hidden}
.tab-buttons{display:flex;gap:8px;justify-content:center}
.tab-btn{background:linear-gradient(180deg,#fff,#f6f4ff);border:1px solid var(--border);padding:8px 12px;border-radius:10px;cursor:pointer}
.tab-btn.active{background:linear-gradient(180deg,var(--accent),var(--accent-2));color:#fff;border-color:transparent;box-shadow:0 12px 30px rgba(111,66,193,0.12)}
.tab-content-wrap{overflow:auto;padding:6px 4px}
.table-wrap{max-height:48vh;overflow:auto;border-radius:8px;border:1px solid rgba(0,0,0,0.04);background:#fff}
.stats-table{width:100%;border-collapse:collapse;font-size:14px}
.stats-table thead th{position:sticky;top:0;background:linear-gradient(180deg,#fff,#faf8ff);padding:10px 12px;text-align:left;border-bottom:1px solid rgba(0,0,0,0.06);font-weight:800;color:var(--accent)}
.stats-table tbody td{padding:10px 12px;border-bottom:1px solid rgba(0,0,0,0.04)}
.stats-table tbody tr:nth-child(even){background:rgba(111,66,193,0.02)}
.stats-table tbody tr:hover{background:rgba(111,66,193,0.04)}
.stats-table td:first-child{width:48px;font-weight:800}

/* Make stats modal responsive */
@media (max-width:720px){
	.stats-modal-body{max-height:70vh}
	.stats-table thead th, .stats-table tbody td{padding:8px}
}
.profile-row{display:flex;gap:12px;align-items:flex-start}
.profile-row .avatar{width:72px;height:72px;border-radius:12px;font-size:22px}
.profile-meta{display:flex;flex-direction:column}
.profile-name{font-weight:800;font-size:16px}
.profile-id{font-size:12px;color:#6b5aa3}
.profile-bio{margin-top:8px;color:#444;max-width:420px}


/* Account menu */
#accountMenu { font-size:14px }

/* Account menu styling */
#accountMenu { background: #fff; border: 1px solid var(--border); padding:10px; border-radius:10px }
#accountMenu button { background: linear-gradient(180deg,#fff,#f6f4ff); border:1px solid var(--border); padding:8px 10px; border-radius:8px; cursor:pointer; color:#4b3a88; font-weight:600 }

/* User panel buttons */
.modal-content button { background: linear-gradient(180deg,#fff,#f6f4ff); border:1px solid var(--border); padding:10px 14px; border-radius:10px; cursor:pointer; font-weight:600; color:#4b3a88 }
.modal-content button:hover { box-shadow:0 12px 30px rgba(111,66,193,0.08); transform: translateY(-1px) }

/* Bulk selection actions (floating) - match modal button styles for consistency */
/* Bulk action bar — spaced confirm/cancel and add entrance animation */
#bulkActions { display:flex; gap:18px; align-items:center; justify-content:space-between; z-index:1100; background:#fff; padding:12px 18px; border-radius:14px; border:1px solid var(--border); box-shadow:0 18px 50px rgba(30,20,60,0.08); min-width:320px; transform-origin:center bottom; opacity:0; transform: translateY(8px) scale(0.98); transition: opacity 220ms cubic-bezier(.2,.9,.2,1), transform 220ms cubic-bezier(.2,.9,.2,1); position:relative; }
#bulkActions.open { opacity:1; transform: translateY(0) scale(1); }
#bulkActions button { background: linear-gradient(180deg,#fff,#f6f4ff); border:1px solid var(--border); padding:12px 18px; border-radius:12px; cursor:pointer; font-weight:700; min-width:140px; transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease; color:#4b3a88 }
#bulkActions button:hover { box-shadow:0 14px 36px rgba(111,66,193,0.12); transform: translateY(-3px) }
#bulkActions .btn.btn-primary { background: linear-gradient(180deg,var(--accent),var(--accent-2)); color:#fff; border-color:transparent; box-shadow:0 18px 48px rgba(111,66,193,0.14); margin-left:auto; margin-right:auto; }

/* Icon-styled cancel button (Font Awesome X) inside bulk actions */
#bulkActions .btn.btn-icon { width:44px; height:44px; padding:0; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; min-width:44px; background: linear-gradient(180deg,#fff,#faf8ff); border:1px solid rgba(0,0,0,0.06); box-shadow:0 8px 24px rgba(30,20,60,0.06); transition: transform 140ms ease, box-shadow 140ms ease, color 140ms ease }
#bulkActions .btn.btn-icon i { font-size:18px; color:#6b6f78 }
#bulkActions .btn.btn-icon:hover { transform: translateY(-3px); color: var(--accent); box-shadow:0 14px 36px rgba(111,66,193,0.08) }

/* Slightly larger confirm button to match the attached design */
#bulkActions .btn.btn-primary { padding:12px 26px; border-radius:16px; font-size:15px }

/* Explore info card (bottom-left) */
#exploreCard { background: linear-gradient(180deg,#ffffff,#fbf8ff); padding:12px; border-radius:10px; border:1px solid var(--border); box-shadow:0 12px 40px rgba(30,20,60,0.08); color:#222; font-size:14px; min-width:240px; }
.explore-row{display:flex;align-items:center;gap:10px}
.explore-avatar{width:44px;height:44px;border-radius:8px;background:linear-gradient(180deg,var(--accent),var(--accent-2));color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800}
.explore-avatar.explore-avatar-empty{background:#f3f2fb;color:var(--accent);font-weight:700}
.explore-meta{flex:1}
.explore-name{font-weight:800;color:var(--accent);font-size:15px}
.explore-name{font-weight:800;color:#111;font-size:15px}
.explore-name .explore-id{color:#9aa0b4;font-weight:600;margin-left:8px;font-size:12px}
.explore-sub{color:#6b5aa3;font-size:12px;margin-top:4px}
.explore-bottom{display:flex;align-items:center;justify-content:space-between;margin-top:10px;gap:12px}
.explore-swatch{flex:1;height:40px;border-radius:10px;border:1px solid rgba(0,0,0,0.06);box-shadow:0 6px 18px rgba(30,20,60,0.04)}
.explore-actions .btn{min-width:86px;padding:8px 10px}

/* Make explore action buttons match modal/button styles */
.explore-actions .btn{background: linear-gradient(180deg,#fff,#f6f4ff); border:1px solid var(--border); padding:8px 10px; border-radius:10px; cursor:pointer; font-weight:700}
.explore-actions .btn.close{min-width:88px}
.explore-actions .btn:hover{box-shadow:0 12px 30px rgba(111,66,193,0.08); transform: translateY(-1px)}
.explore-empty{color:#6b6f78}


/* Selection mode: show pixel crosshair from assets and hide the custom follower cursor */
#map.select-mode { cursor: url('/assets/pixelcross.png') 12 12, crosshair }
.select-mode #customCursor { display: none !important }

/* Canvas overlay should sit above map tiles. Only disable pointer-events
	for our overlay canvas so the map's own canvas keeps mouse interactions. */
#overlayCanvas { pointer-events: none }


/* Custom cursor: hidden native cursor over map, draw smooth follower */
#map.custom-cursor { cursor: none }
#customCursor{position:fixed;pointer-events:none;z-index:1200;width:22px;height:22px;border-radius:50%;transform:translate(-50%,-50%) scale(1);transition:transform 120ms cubic-bezier(.2,.9,.3,1),width 120ms ease,height 120ms ease,background 120ms ease,box-shadow 120ms ease;display:none}
#customCursor.core{background:rgba(111,66,193,0.12);box-shadow:0 6px 18px rgba(111,66,193,0.12);border:2px solid rgba(111,66,193,0.2)}
#customCursor.hit{transform:translate(-50%,-50%) scale(0.85);box-shadow:0 6px 26px rgba(111,66,193,0.2)}

/* Pixel-perfect tile/grid fixes: ensure map tiles and overlay canvas render crisply
   and align to integer pixels to avoid half-pixel seams and blurry borders. */
.maplibregl-canvas, .maplibregl-tile, .maplibregl-tiles img, .leaflet-tile, .leaflet-tile-pane, #overlayCanvas, canvas {
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	image-rendering: -moz-crisp-edges;
	image-rendering: -webkit-crisp-edges;
	-ms-interpolation-mode: nearest-neighbor;
	backface-visibility: hidden;
	transform: translateZ(0);
	will-change: transform, left, top;
}

#overlayCanvas {
	/* ensure overlay canvas covers map exactly and snaps to pixel grid */
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	image-rendering: -moz-crisp-edges;
}

.maplibregl-canvas, .leaflet-tile {
	/* keep transform origin at top-left to avoid sub-pixel translation */
	transform-origin: 0 0;
}

/* Visible focus for accessible elements */
.icon:focus, .btn:focus, .swatch:focus { outline: 3px solid rgba(111,66,193,0.16); outline-offset: 2px }

/* Small utility: subtle floating shadow for controls */
.floating { box-shadow: 0 18px 50px rgba(30,20,60,0.06); border-radius:12px }

/* Disabled state for buttons that depend on the map being loaded */
.disabled, button[aria-disabled="true"], .icon[aria-disabled="true"] {
	opacity: 0.45 !important;
	pointer-events: none !important;
	cursor: default !important;
	filter: grayscale(20%);
}

.disabled:focus, button[aria-disabled="true"]:focus { outline: none }

/* MapLibre control buttons (zoom/rotate) disabled styling */
.maplibregl-ctrl.disabled, .maplibregl-ctrl button[aria-disabled="true"] {
	opacity: 0.45 !important;
	pointer-events: none !important;
}

/* Respect the [hidden] attribute so injected modals stay hidden by default */
.modal[hidden]{display:none !important}

/* Modal close (top-right) */
.modal-close{position:absolute;top:12px;right:12px;z-index:1050;border-radius:10px;padding:8px 10px;border:1px solid rgba(0,0,0,0.06);background:linear-gradient(180deg,#fff,#fbf8ff);box-shadow:0 8px 24px rgba(30,20,60,0.06);cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.modal-close i{font-size:16px;color:var(--accent)}
.modal-close:focus{outline:3px solid rgba(111,66,193,0.14);outline-offset:3px}
.modal-close:hover{transform:translateY(-2px)}

/* When Tools tab is active, expand the user panel modal to give room for moderator/admin controls */
.modal.tools-expanded .modal-content{max-width:960px;width:min(96%,960px);max-height:calc(100vh - 48px)}

/* Slightly larger fonts and denser layout for admin/moderation tools */
.modal.tools-expanded .admin-actions, .modal.tools-expanded .moderator-actions { font-size:15px }
.modal.tools-expanded .table-wrap{max-height:64vh}
.modal.tools-expanded .stats-table tbody td{padding:12px 14px}

/* Slight polish for report modal inputs */
#reportModal .modal-content{max-width:640px}
#reportModal .input, #reportModal select, #reportModal textarea{border-radius:10px;border:1px solid rgba(0,0,0,0.06);padding:10px}
#reportModal .label{margin-top:8px}

/* Tile info card: when moved inside #map we use absolute positioning; when outside we fall back to fixed */
.tile-info{position:fixed;left:24px;bottom:24px;padding:8px 12px;border-radius:10px;z-index:600;color:#20303a;background:rgba(255,255,255,0.92);backdrop-filter:blur(6px);border:1px solid rgba(0,0,0,0.06);box-shadow:0 10px 30px rgba(30,20,60,0.06);font-size:13px;font-weight:700;display:inline-flex;gap:8px;align-items:center;transition:transform 160ms cubic-bezier(.2,.9,.2,1),opacity 160ms ease;border-left:4px solid var(--accent)}
	.tile-info{position:fixed;left:24px;bottom:24px;padding:8px 12px;border-radius:10px;z-index:1300;color:#20303a;background:rgba(255,255,255,0.92);backdrop-filter:blur(6px);border:1px solid rgba(0,0,0,0.06);box-shadow:0 10px 30px rgba(30,20,60,0.06);font-size:13px;font-weight:700;display:inline-flex;gap:8px;align-items:center;transition:transform 160ms cubic-bezier(.2,.9,.2,1),opacity 160ms ease;border-left:4px solid var(--accent)}

/* When tile info lives inside the #map container, prefer absolute coordinates relative to the map */
#map .tile-info{position:absolute;left:12px;bottom:12px}

/* Small pulsing animation to draw eye when tile info updates */
.tile-info.updated{animation:tilePulse 700ms ease}
@keyframes tilePulse{0%{transform:scale(1)}50%{transform:scale(1.04)}100%{transform:scale(1)}}

/* Make modal overlay a little softer and animate opacity */
.modal{position:fixed;inset:0;background:linear-gradient(rgba(10,8,16,0.35),rgba(10,8,16,0.45));display:flex;align-items:center;justify-content:center;z-index:900}

/* Improve buttons and transitions globally */
.btn, .icon, .button-group button { transition: transform .14s cubic-bezier(.2,.9,.2,1), box-shadow .14s ease, background .12s ease }
.btn:hover, .icon:hover, .button-group button:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(30,20,60,0.08) }

/* Subtle entrance for floating cards (explore, tile info) */
.floating, .tile-info, .stats-summary { transform: translateY(6px); opacity:0; animation:floatIn 360ms cubic-bezier(.2,.9,.2,1) forwards }
@keyframes floatIn{to{transform:none;opacity:1}}

/* Chat styles (appended) */
.chat-message{display:flex;flex-direction:column;background:#fff;padding:8px;border-radius:8px;border:1px solid rgba(0,0,0,0.04);box-shadow:0 6px 18px rgba(111,66,193,0.04)}

/* Shop modal specific styles */
.shop-modal .modal-content{max-width:960px;width:min(96%,960px);padding:20px 28px}
.shop-header .muted{color:#6b5aa3}
.shop-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:18px}
.shop-card{background:linear-gradient(180deg,#f8f7ff,#fff);border-radius:12px;padding:12px;border:1px solid rgba(0,0,0,0.04);box-shadow:0 10px 30px rgba(30,20,60,0.04);}
.shop-card-inner{display:flex;gap:14px;align-items:center}
.shop-card-icon{width:76px;height:76px;border-radius:12px;background:linear-gradient(180deg,#fff,#f3f2fb);display:flex;align-items:center;justify-content:center;font-size:28px;color:var(--accent);box-shadow:0 8px 24px rgba(111,66,193,0.06)}
.shop-card-body{flex:1;display:flex;flex-direction:column;gap:8px}
.shop-card-title{font-weight:800;font-size:18px;color:#25123a}
.shop-card-desc{font-size:13px;color:#6b5aa3}
.shop-card-controls{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px}
.qty-controls{display:inline-flex;align-items:center;gap:8px}
.qty-controls button{width:36px;height:36px;border-radius:10px;border:1px solid var(--border);background:#fff;cursor:pointer;font-weight:800}
.qty-input{width:48px;padding:8px;border-radius:10px;border:1px solid var(--border);text-align:center}
.shop-card-action{display:flex;align-items:center}
.shop-price{font-weight:800;color:var(--accent);font-size:15px}
.shop-card .btn.btn-primary{background:linear-gradient(180deg,var(--accent),var(--accent-2));color:#fff;border-color:transparent;padding:10px 14px;border-radius:10px}

@media (max-width:880px){
	.shop-grid{grid-template-columns:1fr}
	.shop-modal .modal-content{max-width:92%;padding:16px}
}

/* Top-up '+' button styling in shop header */
.topup-btn{width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--border);background:#fff;color:var(--accent);cursor:pointer}
.topup-btn i{font-size:14px}

/* Toast / transient notification container */
.toast-container { position: fixed; right: 20px; top: 20px; z-index: 14000; display:flex; flex-direction:column; gap:10px; align-items:flex-end; }
.toast { min-width: 220px; max-width: 420px; background: linear-gradient(180deg,#ffffff,#fbf8ff); border: 1px solid rgba(111,66,193,0.08); box-shadow: 0 12px 40px rgba(111,66,193,0.08); padding: 12px 14px; border-radius: 12px; display:flex; gap:10px; align-items:flex-start; color:#2b1b59; animation: toastIn .18s ease; }
.toast .t-left { width:8px; height:40px; border-radius:6px; background: linear-gradient(180deg,#6f42c1,#8b5cf6); flex:0 0 8px; }
.toast .t-body { flex:1; }
.toast .t-title { font-weight:800; font-size:14px; color:#331a70; }
.toast .t-text { margin-top:6px; font-size:13px; color:#544b66; }
.toast .t-close { background:transparent; border:0; color:#6f42c1; font-weight:700; cursor:pointer; margin-left:8px; }
.toast.success .t-left { background: linear-gradient(180deg,#28a745,#66d28c); }
.toast.error .t-left { background: linear-gradient(180deg,#e55353,#ff9a9a); }
.toast.info .t-left { background: linear-gradient(180deg,#6f42c1,#8b5cf6); }
.toast.warn .t-left { background: linear-gradient(180deg,#ffb020,#ffd58a); }
@keyframes toastIn { from { transform: translateY(-6px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes toastOut { from { transform: none; opacity: 1 } to { transform: translateY(-6px); opacity: 0 } }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3 } 30% { opacity: 1 } }

.chat-who{font-weight:800;color:var(--accent);font-size:13px}
.chat-time{font-size:11px;color:#9b8fbf;margin-top:4px}
.chat-text{margin-top:6px;font-size:14px;color:#2b2344}
.chat-message + .chat-message{margin-top:6px}
.chat-list .muted{color:#6b6f78}

/* Hide redundant bottom 'Close' button in the Report modal (keep top-right modal-close) */
#reportModal .close { display: none !important; }

/* Avatar + content layout */
.chat-row{display:flex;gap:10px;align-items:flex-start}
.chat-avatar{width:40px;flex:0 0 40px;height:40px;border-radius:10px;background:linear-gradient(180deg,var(--accent),var(--accent-2));display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:14px;overflow:hidden}
.chat-avatar img{width:100%;height:100%;object-fit:cover;display:block}
.chat-initials{width:100%;height:100%;display:flex;align-items:center;justify-content:center}
.chat-content{flex:1;display:flex;flex-direction:column}
.chat-header{display:flex;gap:8px;align-items:center}
.chat-who{font-weight:800;color:var(--accent);font-size:13px}
.chat-time{font-size:11px;color:#9b8fbf;margin-left:auto}
.chat-text{margin-top:4px;font-size:14px;color:#2b2344;white-space:pre-wrap}

/* Ensure quick admin ban/unban inputs are vertically centered and consistent */
#admin-ban-wrap input {
	height:44px;
	padding:10px 12px;
	box-sizing:border-box;
	line-height:20px;
	font-size:14px;
	vertical-align:middle;
}
#admin-ban-wrap button { height:44px; align-items:center; display:inline-flex }

/* ---------------- Palette V2 — full rebuild to match screenshot ------------- */
/* Make this block last so it overrides older palette rules in this stylesheet. */

@media (min-width:720px) {
	/* Card stretches full width minus 32px gaps on each side */
	#paletteContainer { left: 0; right: 0; pointer-events: none; }
	#paletteCard { display:none !important; }

	/* Inner wrapper layout: actions row at the bottom right, swatches above it */
	#paletteCard .palette-inner { display:flex; flex-direction:column; gap:12px; }

	/* Top capsule strip that contains the main palette swatches */
	.palette-strip { width: 100%; display:block; }
	#paletteSwatches {
		display:flex !important;
		flex-wrap:nowrap !important;
		gap: 10px !important;
		align-items:center !important;
		overflow-x:auto !important;
		padding: 0 !important;
		border-radius: 0 !important;
		background: transparent !important;
		box-shadow: none !important;
		scroll-snap-type: x proximity !important;
		-webkit-overflow-scrolling: touch !important;
	}

	/* Secondary packs row (smaller pills) */
	.palette-secondary { width:100%; display:flex; justify-content:flex-start; padding:0 6px; }
	.palette-secondary-swatches { display:flex; gap:10px; padding:8px 12px; }

	/* Swatch appearance: small square cards */
	#paletteSwatches .swatch, .palette-secondary-swatches .swatch {
		width:38px !important; height:38px !important; border-radius:6px !important;
		border: 2px solid rgba(255,255,255,0.2) !important; box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important; flex:0 0 auto !important;
	}

	/* Larger highlighted swatch when active */
	#paletteSwatches .swatch.active { transform: scale(1.1); box-shadow: 0 0 0 2px rgba(255,255,255,0.3), 0 8px 20px rgba(0,0,0,0.3) !important; }

	/* Right-aligned actions row inside the card */
	#paletteActions { display:flex !important; justify-content:flex-end !important; gap:8px !important; align-items:center !important; }
	#paletteActions .btn { padding:6px 12px !important; border-radius:6px !important; min-width:auto !important; box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important; font-size:12px !important; }
	#paletteActions .btn.btn-primary { background: linear-gradient(135deg,#6f42c1,#9b6ef2) !important; color:#fff !important; border-color:transparent !important; }

	/* Scrollbar styling */
	#paletteSwatches::-webkit-scrollbar { height:6px; }
	#paletteSwatches::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius:3px; }
}

/* Mobile: full-width single horizontal strip with actions below (centered) */
@media (max-width:719px) {
	#paletteCard { left: 12px !important; right: 12px !important; width: calc(100% - 24px) !important; bottom: calc(120px + env(safe-area-inset-bottom,12px)) !important; }
	#paletteSwatches { display:flex !important; gap:10px !important; overflow-x:auto !important; padding:10px 8px !important; }
	#paletteActions { justify-content:center !important; }
}

/* Hide legacy palette container (we replace it with #palet) */
#paletteContainer { display: none !important; }

/* Palet (new) styles to match game CSS: floating white card with capsule swatches */
#palet.palet-card { position: fixed; left: 12px; right: 12px; bottom: calc(120px + env(safe-area-inset-bottom,12px)); z-index: 2147483646; display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 14px; background: linear-gradient(180deg,#fff,#fbf8ff); box-shadow: 0 30px 80px rgba(30,20,60,0.12); border: 1px solid rgba(0,0,0,0.06); box-sizing: border-box; }
#palet .palet-swatches { display: flex; gap: 12px; overflow-x: auto; padding: 8px; align-items: center; }
#palet .palet-swatches::-webkit-scrollbar { height: 8px; }
#palet .palet-swatches::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 999px; }
#palet .swatch.palet-swatch { width: 44px; height: 44px; border-radius: 999px; border: 4px solid rgba(255,255,255,0.95); box-shadow: 0 8px 22px rgba(30,20,60,0.08); background-clip: padding-box; cursor: pointer; }

/* ========== LEVEL SYSTEM ========== */

/* Avatar frame container */
.avatar-frame {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

/* Avatar styling */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 8px 30px rgba(111, 66, 193, 0.14);
}

/* Level badge on top of avatar - positioning now handled in avatar-frame rule */

/* XP Progress Bar */
.xp-progress-bar {
  width: 100%;
  height: 8px;
  background: #e8e8e8;
  border-radius: 4px;
  overflow: hidden;
  margin: 16px 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.xp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ffed4e);
  border-radius: 4px;
  transition: width 0.4s ease;
  width: calc(var(--xp-percentage, 0) * 1%);
}

.xp-percentage {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #6b5aa3;
  margin-top: 6px;
}

/* Level Modal */
.level-modal-content {
  max-width: 520px;
  background: linear-gradient(180deg, #ffffff, #fbf8ff);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(30, 20, 60, 0.12);
  border: 1px solid var(--border);
}

.level-modal-header {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  padding: 28px 24px;
  text-align: center;
  color: #fff;
}

.level-modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.level-modal-title i {
  font-size: 18px;
}

.level-display-large {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.level-number-large {
  font-size: 48px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.level-modal-body {
  padding: 28px;
  max-height: 60vh;
  overflow-y: auto;
}

.level-modal-body::-webkit-scrollbar {
  width: 6px;
}

.level-modal-body::-webkit-scrollbar-track {
  background: rgba(111, 66, 193, 0.05);
  border-radius: 3px;
}

.level-modal-body::-webkit-scrollbar-thumb {
  background: rgba(111, 66, 193, 0.3);
  border-radius: 3px;
}

/* Level info grid */
.level-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.level-stat {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #fbf8ff);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 11px;
  color: #6b5aa3;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 18px;
  font-weight: 900;
  color: var(--accent);
}

/* Level benefits section */
.level-benefits {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.level-benefits h4 {
  font-size: 12px;
  font-weight: 900;
  color: #333;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.benefits-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.benefit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.benefit-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(111, 66, 193, 0.08);
}

.benefit-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.benefit-text {
  flex: 1;
}

.benefit-label {
  font-size: 11px;
  color: #999;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.benefit-value {
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
  margin-top: 2px;
}

/* Level rewards section */
.level-rewards {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.level-rewards h4 {
  font-size: 12px;
  font-weight: 900;
  color: #333;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rewards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reward-item {
  padding: 10px 12px;
  background: linear-gradient(180deg, #fffaf0, #fffcff);
  border-radius: 8px;
  border-left: 3px solid #ffd700;
  font-size: 12px;
  border: 1px solid rgba(255, 215, 0, 0.2);
  transition: all 0.3s ease;
}

.reward-item:hover {
  transform: translateX(2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.12);
}

.reward-item.unlocked {
  background: linear-gradient(180deg, #e6ffe6, #fffcff);
  border-left-color: #4CAF50;
  border-color: rgba(76, 175, 80, 0.2);
  font-weight: 600;
  color: #2d6a2d;
}

.reward-item.locked {
  opacity: 0.55;
  color: #aaa;
}

/* ===== Auth Modal Styles ===== */
/* Auth modals use standard .modal-content styling */

.auth-header {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  padding: 20px 0px;
  margin: -22px -22px 20px -22px;
  text-align: center;
  color: #fff;
  border-radius: 14px 14px 0 0;
}

.auth-header h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 4px 0;
  letter-spacing: -0.3px;
}

.auth-header p {
  font-size: 12px;
  opacity: 0.9;
  margin: 0;
  font-weight: 500;
}

.auth-body {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  align-items: center;
  justify-items: center;
}

.auth-form-group {
  margin-bottom: 14px;
}

.auth-form-group:last-of-type {
  margin-bottom: 18px;
}

.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #222;
  transition: all 0.25s ease;
  box-sizing: border-box;
  font-family: inherit;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(111, 66, 193, 0.08);
}

.auth-input::placeholder {
  color: #aaa;
}

.auth-submit-btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
  box-shadow: 0 6px 18px rgba(111, 66, 193, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(111, 66, 193, 0.28);
}

.auth-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(111, 66, 193, 0.2);
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  gap: 10px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider-text {
  font-size: 12px;
  color: #999;
  font-weight: 600;
  white-space: nowrap;
}

/* Vertical Divider */
.auth-divider-vertical {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.auth-divider-vertical::before,
.auth-divider-vertical::after {
  content: '';
  width: 1px;
  height: 20px;
  background: rgba(111, 66, 193, 0.2);
}

/* Form Wrapper */
.auth-form-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  grid-column: 2;
  justify-self: stretch;
}

/* Social Login Buttons */
.auth-social-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0;
  grid-column: 1;
  grid-row: 1 / -1;
  justify-self: center;
  align-self: stretch;
}

.auth-social-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 14px;
  border: 1px solid rgba(111, 66, 193, 0.15);
  border-radius: 9px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff !important;
  cursor: pointer;
  transition: all 0.25s ease;
  font-size: 14px;
  font-weight: 600;
  gap: 10px;
}

.auth-social-label {
  color: #fff !important;
  display: block;
}

.auth-social-btn-vertical {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  min-height: 75px;
  padding: 12px 10px;
}

.auth-social-btn:hover {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.3);
}

.auth-social-btn:active {
  transform: translateY(0);
}

.auth-social-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.3);
  color: #fff !important;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.auth-social-btn:hover .auth-social-icon {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.auth-social-btn-vertical .auth-social-icon {
  font-size: 28px;
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

.auth-social-label {
  display: block;
  margin-top: 4px;
}

/* Toggle Auth Forms */
.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-top: 12px;
}

.auth-toggle a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-toggle a:hover {
  color: var(--accent-2);
}

/* Error message styling */
.auth-error {
  background: rgba(255, 68, 68, 0.08);
  border: 1px solid rgba(255, 68, 68, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #d32f2f;
  font-weight: 600;
  display: none;
}

.auth-error.show {
  display: block;
  animation: shake 0.35s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Modal overlay specific */
#loginModal.modal,
#signupModal.modal {
  background: rgba(15, 10, 25, 0.5);
  backdrop-filter: blur(2px);
}

#loginModal .modal-content,
#signupModal .modal-content {
  max-width: 540px;
  width: min(95%, 540px);
}

/* Responsive */
@media (max-width: 480px) {
  .auth-modal-content {
    max-width: 100%;
    border-radius: 12px;
  }

  .auth-header {
    padding: 16px 20px;
  }

  .auth-header h2 {
    font-size: 18px;
  }

  .auth-body {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .auth-social-group {
    grid-column: 1;
    grid-row: auto;
    flex-direction: row;
    gap: 6px;
  }

  .auth-form-wrapper {
    grid-column: 1;
  }

  .auth-social-btn-vertical {
    min-height: 60px;
    padding: 8px 6px;
  }

  .auth-social-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
  }

  .auth-body {
    padding: 20px;
  }

  .auth-social-group {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .auth-social-btn {
    min-height: 65px;
    padding: 10px 6px;
    color: #fff !important;
  }

  .auth-social-icon {
    font-size: 24px;
    width: 36px;
    height: 36px;
  }
}
