/* ==========================================================================
   Bătălia Județelor — Design tokens
   Palette: near-black navy base + hot-pink / gold / lime accents.
   High-saturation, high-contrast on purpose: needs to read well on a phone
   camera during a live stream, not just on a calibrated monitor.
   ========================================================================== */
:root {
  --bg: #090b16;
  --bg-soft: #0e1120;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.09);
  --panel-blur: 18px;

  --text: #f4f5fb;
  --text-muted: #9aa0b4;

  --pink: #ff2e7e;         /* primary accent */
  --pink-glow: rgba(255, 46, 126, 0.55);
  --gold: #ffc93c;         /* secondary accent / leader */
  --gold-glow: rgba(255, 201, 60, 0.55);
  --lime: #6dffb0;         /* success / free slots */
  --lime-glow: rgba(109, 255, 176, 0.45);
  --sky: #4fc3ff;          /* info / standard tier */

  --danger: #ff5468;

  --county-fill: #171b30;
  --county-fill-hover: #202544;
  --county-stroke: rgba(255, 255, 255, 0.16);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --header-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(255, 46, 126, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(79, 195, 255, 0.10), transparent 55%),
    var(--bg);
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }

.glass {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ============================== HEADER ================================= */
.topbar {
  height: var(--header-h);
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  gap: 14px;
  padding-inline: 16px;
  background: rgba(9, 11, 22, 0.75);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 17px;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.brand-mark { filter: drop-shadow(0 0 6px var(--pink-glow)); }
.brand .accent {
  background: linear-gradient(90deg, var(--pink), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.stat-pills::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 14px;
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--panel-border);
  min-width: 84px;
  position: relative;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03) inset, 0 4px 14px -6px rgba(0,0,0,0.5);
}
.pill-label { font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.pill-value { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.pill-sold {
  border-color: rgba(255, 46, 126, 0.45);
  box-shadow: 0 0 18px -4px var(--pink-glow), 0 4px 14px -6px rgba(0,0,0,0.5);
}
.pill-sold .pill-value { color: var(--pink); text-shadow: 0 0 12px var(--pink-glow); }
.pill-free {
  border-color: rgba(109, 255, 176, 0.45);
  box-shadow: 0 0 18px -4px var(--lime-glow), 0 4px 14px -6px rgba(0,0,0,0.5);
}
.pill-free .pill-value { color: var(--lime); text-shadow: 0 0 12px var(--lime-glow); }
.pill-leader {
  border-color: rgba(255, 201, 60, 0.55);
  box-shadow: 0 0 22px -3px var(--gold-glow), 0 4px 14px -6px rgba(0,0,0,0.5);
  animation: pill-pulse 2.4s ease-in-out infinite;
}
.pill-leader .pill-value { color: var(--gold); text-shadow: 0 0 14px var(--gold-glow); }
@keyframes pill-pulse {
  0%, 100% { box-shadow: 0 0 22px -3px var(--gold-glow), 0 4px 14px -6px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 0 32px 0px var(--gold-glow), 0 4px 14px -6px rgba(0,0,0,0.5); }
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-btn.small { width: 30px; height: 30px; font-size: 14px; }
.icon-btn:active { transform: scale(0.94); }

/* ============================== STAGE =================================== */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg-soft);
}

.map-toolbar {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-md);
  z-index: 20;
}
.tool-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 17px;
}
.tool-btn.active {
  background: linear-gradient(135deg, var(--pink), #ff6a9c);
  box-shadow: 0 0 14px -2px var(--pink-glow);
}
.tool-sep { height: 1px; background: var(--panel-border); margin: 2px 4px; }

.tier-picker {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  z-index: 20;
  max-width: calc(100vw - 28px);
}
.tier-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tier-chip em { font-style: normal; opacity: 0.7; font-weight: 500; }
.tier-chip.active {
  color: var(--bg);
  background: var(--text);
}
.tier-swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.tier-swatch-micro { background: var(--sky); }
.tier-swatch-standard { background: var(--gold); }
.tier-swatch-mega { background: var(--pink); }

/* Tooltip */
.tooltip {
  position: absolute;
  z-index: 30;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  max-width: 240px;
  pointer-events: none;
}
.tooltip img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.tooltip-title { font-weight: 700; font-size: 13px; }
.tooltip-county { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.tooltip a { color: var(--sky); font-size: 12px; pointer-events: auto; }

.cart-fab {
  position: absolute;
  right: 16px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 25;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 13px;
  color: var(--bg);
  background: linear-gradient(135deg, var(--lime), #33e39b);
  box-shadow: 0 6px 20px -4px var(--lime-glow);
}

/* ============================ CART SIDEBAR =============================== */
.cart-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100dvh;
  width: 340px;
  padding-top: calc(var(--header-h) + var(--safe-top) + 16px);
  padding-inline: 16px;
  padding-bottom: 16px;
  background: rgba(12, 14, 26, 0.92);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(0);
  transition: transform 0.25s ease;
}
.cart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cart-header h2 { font-size: 16px; margin: 0; }
.cart-count-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255, 201, 60, 0.12);
  border: 1px solid rgba(255, 201, 60, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

.cart-empty { color: var(--text-muted); font-size: 13px; margin-top: 20px; }
.cart-empty p { margin: 4px 0; }

.cart-list {
  list-style: none;
  margin: 0; padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 13px;
}
.cart-item-left { display: flex; align-items: center; gap: 8px; }
.cart-item button {
  background: none; border: none; color: var(--text-muted); font-size: 15px;
}
.cart-item button:hover { color: var(--danger); }

.cart-footer {
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
  margin-top: 10px;
}
.cart-total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px; font-size: 14px;
}
.cart-total-row strong { font-size: 20px; color: var(--gold); }

.btn-primary {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-weight: 700;
  font-size: 14px;
  color: #14051a;
  background: linear-gradient(135deg, var(--gold), var(--pink));
  box-shadow: 0 8px 22px -6px var(--pink-glow);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }

/* =============================== MODALS =================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 5, 12, 0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
}
.modal {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  background: rgba(16, 18, 33, 0.95);
}
.modal h2 { margin-top: 0; font-size: 18px; }
.modal-close { position: absolute; top: 14px; right: 14px; }

#checkout-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
#checkout-form label { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 5px; }
#checkout-form input[type=text],
#checkout-form input[type=email],
#checkout-form input[type=url] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
}
#checkout-form input:focus { outline: 2px solid var(--pink); outline-offset: 1px; }
.upload-field input[type=file] {
  font-size: 12px;
  color: var(--text-muted);
}
.upload-preview { margin-top: 6px; }
.upload-preview img { width: 100%; max-height: 140px; object-fit: contain; border-radius: var(--radius-sm); background: rgba(255,255,255,0.03); }

.form-error {
  background: rgba(255, 84, 104, 0.12);
  border: 1px solid rgba(255, 84, 104, 0.35);
  color: #ffb3bd;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.fineprint { font-size: 11px; color: var(--text-muted); text-align: center; margin: 4px 0 0; }

.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(20,5,26,0.35);
  border-top-color: #14051a;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Leaderboard */
.leaderboard-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.leaderboard-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 13px;
}
.lb-rank { width: 22px; text-align: center; font-weight: 800; color: var(--text-muted); }
.leaderboard-list li:nth-child(1) .lb-rank { color: var(--gold); }
.leaderboard-list li:nth-child(2) .lb-rank { color: #d7dbe6; }
.leaderboard-list li:nth-child(3) .lb-rank { color: #d99a5b; }
.lb-name { flex: 1; font-weight: 600; }
.lb-bar-track { width: 70px; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.lb-bar-fill { height: 100%; background: linear-gradient(90deg, var(--pink), var(--gold)); }
.lb-pct { width: 42px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* =============================== TOASTS ==================================== */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: rgba(20, 22, 38, 0.95);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.5);
  animation: toast-in 0.2s ease;
  white-space: nowrap;
}
.toast.error { border-color: rgba(255,84,104,0.5); color: #ffb3bd; }
.toast.success { border-color: rgba(109,255,176,0.5); color: var(--lime); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================ RESPONSIVE =================================== */
@media (max-width: 860px) {
  .cart-panel {
    width: 100%;
    top: auto;
    bottom: 0;
    height: auto;
    max-height: 78dvh;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    border-radius: 20px 20px 0 0;
    padding-top: 16px;
    transform: translateY(100%);
  }
  .cart-panel.open { transform: translateY(0); }
  .cart-fab { display: flex !important; align-items: center; gap: 6px; }

  .brand-name { font-size: 14px; }
  .pill { min-width: 72px; padding: 5px 10px; }
  .pill-label { font-size: 9px; }
  .pill-value { font-size: 12.5px; }

  .map-toolbar { top: 10px; left: 10px; }
  .tool-btn { width: 36px; height: 36px; font-size: 15px; }

  .tier-picker { bottom: calc(14px + var(--safe-bottom)); }
  .tier-chip { padding: 7px 9px; font-size: 11px; }
}

@media (min-width: 861px) {
  .cart-fab { display: none !important; }
}
