:root {
  --bg-main: #050816;
  --accent: #ffb347;
  --accent-alt: #ff6b6b;
  --panel-bg: rgba(11, 15, 25, 0.88);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.45);
  --radius-xl: 22px;
  --radius-full: 999px;
  --transition-fast: 0.18s ease-out;
html, body, .panel, .chat-window, .leaderboard-box, .poop-map-panel {
  transition: background-color 0.35s ease, 
              color 0.35s ease, 
              border-color 0.35s ease, 
              box-shadow 0.35s ease;
}

.background-gradient {
  transition: opacity 0.35s ease;
}

  --transition-slow: 0.35s cubic-bezier(0.22, 1, 0.36, 1);
} /* Light mode */
body.light {
  --bg-main: #f3f4f6;
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #475569;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);
} /* Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  min-height: 100vh;
  font-family: "Assistant", system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
}
.game-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 14px;
  padding: 8px 10px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
body.loading * {
  display: none !important;
}

body.loading {
  background: #050816; /* שלא יראה לבן */
}

.stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: block;
}
.stat .value {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-main);
} /* Background */
.background-gradient {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 10% 20%, #3b82f6 0, transparent 45%),
    radial-gradient(circle at 90% 10%, #f97316 0, transparent 50%),
    radial-gradient(circle at 50% 80%, #ec4899 0, transparent 55%);
  opacity: 0.34;
  pointer-events: none;
  z-index: 0;
} /* App shell */
.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px;
  position: relative;
  z-index: 2;
} /* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}
.brand-text h1 {
  margin: 0;
  font-size: 1.5rem;
}
.brand-text p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-photo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent);
} /* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
} /* Panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
} /* Panel headers */
.panel-header h2 {
  margin: 0;
  font-size: 1.3rem;
}
.subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
} /* Chat window */
.chat-window {
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  padding: 8px;
  height: 280px;
  overflow-y: auto;
}
body.light .chat-window {
  background: #fff;
} /* Message styles */
.message-row {
  display: flex;
  margin-bottom: 6px;
}
.message-bubble {
  max-width: 75%;
  padding: 6px 10px;
  border-radius: 12px;
  line-height: 1.25;
}
.message-row.own {
  justify-content: flex-end;
}
.message-row.own .message-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  color: #111;
}
.message-row.other .message-bubble {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.6);
}
.message-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  opacity: 0.85;
}
.message-text {
  margin: 0;
} /* Input row */
.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
} /* Inputs */
input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(156, 163, 175, 0.6);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
}
body.light input[type="text"] {
  background: #fff;
  color: #0f172a;
} /* Buttons */
.primary-btn,
.ghost-btn,
.google-btn {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  color: #111;
}
.ghost-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: var(--text-main);
} /* Google Login button */
.google-btn {
  background: #fff;
  color: #444;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  border: 1px solid #ddd;
}
.google-btn img {
  width: 20px;
} /* Login screen */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}
.login-box {
  background: var(--panel-bg);
  padding: 28px;
  border-radius: 18px;
  width: 320px;
  text-align: center;
  border: 1px solid var(--panel-border);
}
.error-text {
  color: #f87171;
  margin-top: 10px;
} /* Game section */
.canvas-wrapper {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42);
}
#poopCanvas {
  width: 100%;
  height: auto;
  touch-action: manipulation;
  pointer-events: auto;
} /* Game overlay */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.game-overlay.hidden {
  opacity: 0;
  pointer-events: none;
} /* Leaderboard */
.leaderboard-box {
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 10px;
}
#leaderboardList {
  list-style: none;
  padding: 0;
  margin: 0;
}
#leaderboardList li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
} /* Footer */
.app-footer {
  margin-top: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
} /* Hidden */
.hidden {
  display: none !important;
} /* Animation pulse for stats */
.stat .value.animate {
  animation: statPop 0.25s ease-out;
}
@keyframes statPop {
  0% {
    transform: scale(1);
    color: var(--text-main);
  }
  40% {
    transform: scale(1.25);
    color: var(--accent);
  }
  100% {
    transform: scale(1);
    color: var(--text-main);
  }
} /* ===== Edit Username Popup ===== */
.edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 500;
}
.edit-box {
  background: var(--panel-bg);
  padding: 22px;
  width: 300px;
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}
.edit-box h3 {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
}
.edit-box input {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 1rem;
}
body.light .edit-box {
  background: #fff;
}
.edit-actions {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
} /* Avatar preview inside edit box */
.edit-box img.avatar-preview {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 10px auto;
  display: block;
  border: 3px solid var(--accent);
} /* Hide file input */
.hidden {
  display: none !important;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.avatar-grid img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}
.avatar-grid img:hover {
  transform: scale(1.15);
} /* Leaderboard avatar */
.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 8px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
} /* Align the left side */
.lb-left {
  display: flex;
  align-items: center;
  gap: 6px;
} /* Name text in leaderboard */
.lb-name {
  font-size: 0.9rem;
  font-weight: 500;
} /* Score text */
.lb-score {
  font-weight: 600;
  font-size: 0.9rem;
} /* Golden glow for #1 */
.leader-item.first {
  position: relative;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
  border-radius: 12px;
}
.leader-item.first .lb-name {
  color: #facc15;
  font-weight: 700;
} /* Slight glow on avatar */
.leader-item.first .lb-avatar {
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
} /* Optional crown icon */
.leader-item.first::before {
  content: "👑";
  position: absolute;
  top: -10px;
  left: 6px;
  font-size: 18px;
} /* ================================ RESPONSIVE — MOBILE FIRST ================================ */ /* טלפונים עד 900px */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .panel {
    padding: 12px 14px;
  }
  .leaderboard-box {
    max-height: 120px;
  }
  .leader-item {
    padding: 6px 4px;
  } /* קנבס קטן יותר במובייל */
  #poopCanvas {
    width: 100% !important;
    height: auto !important;
  }
  .canvas-wrapper {
    height: auto;
  }
} /* טלפונים קטנים עד 600px */
@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    gap: 8px;
  }
  .brand-text h1 {
    font-size: 1.2rem;
  }
  .brand-text p {
    font-size: 0.75rem;
  }
  .user-photo {
    width: 34px;
    height: 34px;
  } /* צ'אט */
  .chat-window {
    max-height: 220px;
    padding-bottom: 6px;
  }
  .message-bubble {
    max-width: 85%;
    font-size: 0.88rem;
  } /* כפתורי משחק */
  .game-controls {
    flex-direction: column;
  } /* Leaderboard קטן יותר */
  .leaderboard-box h3 {
    font-size: 0.9rem;
  }
  input[type="text"]:focus {
    scroll-margin-bottom: 200px;
  } /* =========================== GLOBAL POOP MAP – FINAL FIX =========================== */
  .poop-map-panel {
    margin-top: 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.85);
    padding: 10px; /* חשוב – שיהיה באותו קו תחתון כמו הלידרבורד */
    height: 260px;
    display: flex;
    flex-direction: column;
  }
  .poop-map-title {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
    text-align: left;
  }
  #poopMap {
    flex: 1;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #1e293b;
  } /* Leaflet base */
  .leaflet-container {
    background: #dbeafe !important;
  }
  .leaflet-popup-content-wrapper {
    background: #fff;
    border-radius: 12px;
    padding: 6px 10px;
  }
  .leaflet-popup-tip {
    background: #fff;
  } /* עיצוב לאייקון המפה */
  .map-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    object-fit: cover;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
  }
  .map-username {
    font-weight: 600;
    color: #111827;
    margin-left: 6px;
  } /* Responsive */
  @media (max-width: 900px) {
    .poop-map-panel {
      height: 220px;
    }
  }
  @media (max-width: 600px) {
    .poop-map-panel {
      height: 200px;
      padding: 8px;
    }
    .poop-map-title {
      font-size: 0.85rem;
    }
  } /* Leaflet overrides */
  .leaflet-container {
    background: #d9e6f2;
  }
  .leaflet-popup-content-wrapper {
    background: #fff;
    border-radius: 10px;
  }
  .leaflet-popup-tip {
    background: #fff;
  }
  .lb-avatar-small {
    width: 22px;
    height: 22px;
    object-fit: cover;
    border-radius: 50%;
    margin-right: 4px;
  }
  .lb-name {
    font-size: 0.8rem;
  }
  .lb-score {
    font-size: 0.9rem;
  }
  .lb-avatar {
    width: 26px;
    height: 26px;
  }
} /* EXTRA SMALL PHONES */
@media (max-width: 420px) {
  .brand-text h1 {
    font-size: 1rem;
  }
  .panel-header h2 {
    font-size: 1.05rem;
  }
  #chatMessage {
    font-size: 0.85rem;
  }
  .primary-btn,
  .ghost-btn {
    font-size: 0.8rem;
    padding: 7px 13px;
  }
  #poopCanvas {
    height: 260px !important;
  }
}
/* Golden glow for #1 */
.leader-item.first {
  position: relative;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
  border-radius: 12px;
}

.leader-item.first .lb-name {
  color: #facc15;
  font-weight: 700;
}

/* Slight glow on avatar */
.leader-item.first .lb-avatar {
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}

/* Optional crown icon */
.leader-item.first::before {
  content: "👑";
  position: absolute;
  top: -10px;
  left: 6px;
  font-size: 18px;
}
/* ===============================
   LIGHT MODE FIX — PANELS + GAME
================================ */

body.light .panel {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(0,0,0,0.12);
}

body.light .leaderboard-box {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.12);
}

body.light .game-stats .stat {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.12);
  color: #0f172a;
}

body.light .game-overlay {
  background: rgba(255,255,255,0.95);
  color: #0f172a;
}

body.light #poopCanvas {
  background: #fafafa;
}

/* LIGHT MODE — LEADERBOARD TEXT */
body.light .lb-name,
body.light .lb-score {
  color: #0f172a;
}

/* LIGHT MODE — Chat window bubble colors */
body.light .message-row.other .message-bubble {
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.15);
}

body.light .message-row.own .message-bubble {
  color: #111;
}

body.light .chat-window {
  background: #fff;
  border-color: rgba(0,0,0,0.15);
}

/* LIGHT MODE — map panel */
body.light .poop-map-panel {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.12);
}

body.light #poopMap {
  background: #e5e7eb;
}

/* LIGHT MODE — leaderboard first place */
body.light .leader-item.first {
  background: rgba(253, 224, 71, 0.25);
  border-color: rgba(253, 224, 71, 0.6);
}
/* ============================================
   GLOBAL SMOOTH THEME TRANSITION (iOS style)
============================================ */
* {
  transition:
    background-color 0.35s ease,
    border-color 0.35s ease,
    color 0.35s ease,
    box-shadow 0.35s ease,
    backdrop-filter 0.35s ease;
}

/* Fade effect for whole body */
body.theme-fade {
  opacity: 0;
  transition: opacity 0.25s ease;
}
/* DIRECT LIST — משתמשים */
#directUsersList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#directUsersList li {
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148,163,184,0.4);
  cursor: pointer;
  transition: 0.2s;
}

body.light #directUsersList li {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.12);
}

#directUsersList li:hover {
  transform: translateX(4px);
  background: rgba(30,41,59,0.9);
}

body.light #directUsersList li:hover {
  background: #f3f4f6;
}
/* DIRECT CHAT WINDOW */
#dmWindow {
  height: 320px;
  overflow-y: auto;
  border-radius: 16px;
  background: rgba(15,23,42,0.85);
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 10px;
  margin-bottom: 10px;
}

body.light #dmWindow {
  background: #fff;
}
/* DIRECT CHAT bubbles */
#dmWindow .message-row {
  display: flex;
  margin-bottom: 6px;
}

#dmWindow .message-row.own {
  justify-content: flex-end;
}

#dmWindow .message-bubble {
  max-width: 75%;
  padding: 7px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.35;
}

#dmWindow .own .message-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  color: #111;
}

#dmWindow .other .message-bubble {
  background: rgba(15,23,42,0.92);
  border: 1px solid rgba(148,163,184,0.6);
  color: var(--text-main);
}

body.light #dmWindow .other .message-bubble {
  background: #fff;
  border-color: rgba(0,0,0,0.15);
}
