:root {
  /* Core Colors */
  --bg-core: #050505;
  --bg-gradient: radial-gradient(circle at top, #1a1a1a, #000000);
  --text-main: #ffffff;
  --text-muted: #a3a3a3;

  /* Accent Colors */
  --accent-color: #b8e5fc;
  --accent-hover: #93c5fd;
  --text-on-accent: #020617;

  /* Glassmorphism */
  --glass-bg: rgba(20, 20, 20, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-core);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  font: 14px/1.6 "Comfortaa", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  /* Removed bottom padding so footer sticks to the very bottom */
  padding: 20px 10px 0 10px;
  min-height: 100vh;
}

/* --- SNOW EFFECT --- */
#snow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1; /* Behind UI but visible */
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -10px;
  background: white;
  border-radius: 50%;
  opacity: 0.8;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    transform: translateY(110vh);
  }
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
  /* Allows clicking through empty areas */
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid var(--glass-border);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;

  /* Critical for fading out */
  transition: all 0.5s ease;
  opacity: 1;
  transform: translateY(0);

  animation: slideDown 0.3s ease forwards;
  pointer-events: auto;
}

/* Fade out state (added by JS) */
.toast.fade-out {
  opacity: 0;
  transform: translateY(-20px);
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.success {
  border-left: 4px solid #22c55e;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- TOP MENU BAR --- */
.topbar {
  width: 100%;
  max-width: 960px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-color);
}

.top-left i {
  font-size: 16px;
}

.top-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.top-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.top-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}

.top-value {
  font-weight: 700;
  color: var(--accent-color);
  font-size: 13px;
}

.top-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.top-right button {
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  box-shadow: none !important;
  transition: all 0.2s ease;
}

.top-right button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-color);
}

/* Mobile Responsive Menu Logic */
#fullscreenBtn {
  display: none; /* Hidden on desktop by default */
}

@media (max-width: 768px) {
  .top-right .btn-text {
    display: none; /* Hide text on mobile */
  }
  
  .top-right button {
    padding: 8px 10px; /* Adjust padding for icon-only buttons */
  }

  .top-right button i {
    font-size: 16px;
  }

  #fullscreenBtn {
    display: flex; /* Show fullscreen button on mobile */
  }
}

/* --- HUD --- */
.hud {
  display: none;
}

/* --- GAME WRAPPER --- */
.game-shell {
  position: relative;
  width: 100%;
  max-width: 960px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  z-index: 5;
  /* Ensure margins on mobile so it doesn't touch menu/tabs */
  margin: 10px 0; 
}

@media (max-width: 768px) {
  .game-shell {
    margin: 20px 0; /* More spacing on mobile */
  }
}

canvas {
  width: 100%;
  max-width: 960px;
  height: auto;
  border-radius: 16px;
  background: #000;
  display: block;
  border: 1px solid #b8e5fc;
}

/* --- OVERLAYS --- */
.lives-overlay {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 22px;
  color: #ef4444;
  pointer-events: none;
}

.score-overlay {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  pointer-events: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.game-overlay.active {
  display: flex;
  pointer-events: auto;
}

.overlay-inner {
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px 32px;
  text-align: center;
  width: 90%;
  max-width: 300px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  /* Ensure it doesn't overflow the game area on small screens */
  max-height: 90%;
  overflow-y: auto;
}

.overlay-title {
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--accent-color);
}

.overlay-score {
  font-size: 14px;
  margin-bottom: 16px;
  color: var(--text-main);
  min-height: 20px;
}

.overlay-inner button {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(184, 229, 252, 0.25);
}

/* --- UI ELEMENTS --- */
.flash {
  animation: flash .2s ease;
}

@keyframes flash {
  from {
    background: rgba(184, 229, 252, 0.3);
  }

  to {
    background: transparent;
  }
}

button {
  background: var(--accent-color);
  color: var(--text-on-accent);
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(184, 229, 252, 0.2);
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

button:active {
  transform: translateY(1px);
}

/* --- TABS --- */
.tab-container {
  width: 100%;
  max-width: 960px;
  margin-top: 15px;
  z-index: 5;
}

.tab-header {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.tab-header button {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  box-shadow: none;
  text-transform: none;
  letter-spacing: normal;
}

.tab-header button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.tab-header button.active {
  background: var(--accent-color);
  color: var(--text-on-accent);
  border-color: var(--accent-color);
}

.tab-body {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px 24px;
  min-height: 200px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- LEADERBOARD --- */
.lb-wrapper {
  width: 100%;
  overflow-x: auto;
  margin-top: 10px;
}

.lb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.lb-table th,
.lb-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.lb-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-color);
  opacity: 0.9;
}

.lb-table td:nth-child(4) {
  text-align: center;
}

/* Current user highlight style */
.current-user-row td {
  background: rgba(184, 229, 252, 0.1);
  /* Light highlight */
  color: #fff;
  font-weight: bold;
  border-top: 1px solid rgba(184, 229, 252, 0.3);
  border-bottom: 1px solid rgba(184, 229, 252, 0.3);
}

.holder-yes {
  color: #22c55e;
}

.holder-no {
  color: #ef4444;
}

.lb-pagination {
  margin-top: 16px;
  display: flex;
  gap: 6px;
  justify-content: center;
}

.lb-pagination button {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
  color: var(--text-muted);
}

.lb-pagination button.active {
  background: var(--accent-color);
  color: var(--text-on-accent);
}

/* --- FOOTER --- */
.footer {
  width: 100%;
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--glass-border);
  margin-top: auto;
  /* Glass effect for footer too */
  background: rgba(20, 20, 20, 0.4);
  backdrop-filter: blur(8px);
}

.footer-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copyright {
  font-size: 12px;
}

.socials {
  display: flex;
  gap: 15px;
}

.socials a {
  color: var(--text-muted);
  font-size: 18px;
  transition: color 0.2s ease, transform 0.2s;
}

.socials a:hover {
  color: var(--accent-color);
  transform: translateY(-2px);
}

/* --- AUTH OVERLAY --- */
.auth-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  /* Use flex via JS class only to prevent flash */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* This class is added by JS to show it */
.auth-container.active {
  display: flex;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  border-radius: 24px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px;
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none !important;
  border: none;
  font-size: 13px;
}

.auth-tab.active {
  background: var(--accent-color);
  color: var(--text-on-accent);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 15px;
  animation: fadeIn 0.3s ease;
}

.auth-form.active {
  display: flex;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.input-group label {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

.input-group .req {
  color: #ef4444;
}

.input-group .opt {
  color: #64748b;
  font-size: 10px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 12px 12px 40px;
  color: #fff;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.input-wrapper input:focus {
  border-color: var(--accent-color);
}

.auth-submit-btn {
  margin-top: 10px;
  width: 100%;
  padding: 14px;
  font-size: 15px;
}

/* New Warning Text Styles */
.auth-warnings {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 15px;
}

.auth-warnings p {
  margin: 0;
}

.auth-warnings i {
  margin-right: 5px;
  color: var(--accent-color);
}

/* --- FULLSCREEN MODE STYLES --- */

/* When the body has this class, we hide almost everything except the game */
body.fullscreen-active {
  overflow: hidden; /* Prevent scrolling */
  background: #000; /* Black background for immersive feel */
  justify-content: center;
  padding: 0;
}

/* Hide elements in fullscreen */
body.fullscreen-active .topbar,
body.fullscreen-active .tab-container,
body.fullscreen-active .auth-container,
body.fullscreen-active .hud,
body.fullscreen-active footer,
body.fullscreen-active .footer {
  display: none !important;
}

/* Make the game shell take up 90% of the screen */
body.fullscreen-active .game-shell {
  width: 95vw;
  height: 90vh;
  max-width: none; /* Override the 960px limit */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none; /* Clean look */
  margin: 0; /* Reset margins in fullscreen */
}

/* Ensure canvas fits nicely */
body.fullscreen-active canvas {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Keeps aspect ratio correct */
  border: none;
}

/* --- ROTATE OVERLAY (Mobile Fullscreen) --- */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(0, 0, 0, 0.9);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  padding: 20px;
}

.rotate-overlay i {
  font-size: 48px;
  margin-bottom: 20px;
  color: var(--accent-color);
  animation: rotateIcon 2s infinite ease-in-out;
}

.rotate-overlay p {
  font-size: 18px;
  font-weight: bold;
}

@keyframes rotateIcon {
  0% { transform: rotate(270deg); }
  50% { transform: rotate(360deg); }
  100% { transform: rotate(270deg); }
}

/* Show rotate overlay ONLY when:
   1. Fullscreen is active
   2. Orientation is Portrait
*/
body.fullscreen-active .rotate-overlay {
  display: none; /* Hidden by default, JS/Media query will toggle */
}

@media (orientation: portrait) {
  body.fullscreen-active .rotate-overlay {
    display: flex;
  }
  /* Hide the game behind the overlay so they don't play in portrait */
  body.fullscreen-active .game-shell {
    visibility: hidden;
  }
}