html, body { margin:0; padding:0; height:100%; overflow:hidden; background:#0b0f14; color:#e7f2ff; font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,Helvetica,Arial,'Apple Color Emoji','Segoe UI Emoji'; touch-action: none; }
#game { position:absolute; inset:0; z-index:0; touch-action: none; cursor: crosshair; }
#ui { position:absolute; inset:0; pointer-events:none; z-index:10; }
#topbar { position:absolute; left:0; right:0; top:0; display:flex; align-items:center; justify-content:space-between; padding:10px 14px; background:linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0)); font-weight:600; letter-spacing:.3px; text-shadow:0 1px 0 rgba(0,0,0,.4); }
.brand { opacity:.9 }

/* Quit Button */
#quitBtn {
  background: rgba(255, 64, 129, 0.2);
  border: 1px solid rgba(255, 64, 129, 0.45);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto;
  margin-left: 10px;
}

#quitBtn:hover {
  background: rgba(255, 64, 129, 0.3);
}

/* Quit Confirmation Overlay */
#quitOverlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  pointer-events: all; /* Changed from auto to all to ensure it captures all events */
}

#quitOverlay .overlay-panel {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#quitOverlay h3 {
  margin: 0 0 20px;
  font-size: 18px;
  color: #e7f2ff;
}

.quit-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

#quitConfirmBtn, #quitCancelBtn {
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#quitConfirmBtn {
  background: rgba(255, 64, 129, 0.2);
  border: 1px solid rgba(255, 64, 129, 0.45);
  color: #fff;
}

#quitConfirmBtn:hover {
  background: rgba(255, 64, 129, 0.3);
}

#quitCancelBtn {
  background: rgba(0, 229, 255, 0.2);
  border: 1px solid rgba(0, 229, 255, 0.45);
  color: #fff;
}

#quitCancelBtn:hover {
  background: rgba(0, 229, 255, 0.3);
}
#leaderboard { position:absolute; right:12px; top:54px; width:230px; background:rgba(0,0,0,.35); border:1px solid rgba(255,255,255,.12); border-radius:10px; padding:8px 10px; backdrop-filter: blur(2px); }
#leaderboard.hidden { display:none; }
#leaderboard h3 { margin:6px 0 8px; font-size:14px; opacity:.9; }
#leaderboard .row { display:flex; justify-content:space-between; padding:3px 0; font-size:13px; border-bottom:1px dashed rgba(255,255,255,.08); }
#leaderboard .row:last-child { border-bottom:0; }
#respawn { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); font-size:28px; font-weight:800; padding:18px 26px; color:#fff; background:rgba(255,64,129,.18); border:1px solid rgba(255,64,129,.45); border-radius:14px; letter-spacing:1.5px; }
#respawn.hidden { display:none; }
#crosshair { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); font-weight:800; font-size:20px; opacity:.25; pointer-events:none; user-select:none; }
.badge { display:inline-block; padding:2px 6px; border-radius:6px; font-size:12px; font-weight:700; letter-spacing:.3px; margin-left:10px; background:rgba(0,229,255,.15); border:1px solid rgba(0,229,255,.45); }
/* Nudge the first HUD badge (Score) slightly left so it isn't indented */
#hud .badge:first-child { margin-left: 0; }

/* Start Overlay - Diep.io/Agar.io inspired */
#startOverlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: auto;
  background: #0a0e13;
}
#startOverlay.show {
  display: flex;
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Animated Grid Background */
#gridCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.35;
}

/* Top Navigation Bar */
.top-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(0,0,0,0.4), transparent);
}
.nav-links {
  display: flex;
  gap: 20px;
}
.nav-link {
  color: rgba(231,242,255,0.85);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  transition: all 0.2s;
}
.nav-link:hover {
  color: #22d3ee;
  transform: translateY(-1px);
}
.player-count-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(96,165,250,0.3);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #22d3ee;
}
.status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* Main Content */
.main-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 600px;
  padding: 20px;
}

/* Logo Section */
.logo-section {
  text-align: center;
  animation: slideDown 0.6s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}
.game-title {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 3px;
  margin: 0;
  background: linear-gradient(135deg, #22d3ee, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(34,211,238,0.6));
  animation: titleGlow 3s ease-in-out infinite;
}
@keyframes titleGlow {
  0%, 100% {
    filter: drop-shadow(0 0 20px rgba(34,211,238,0.6));
  }
  50% {
    filter: drop-shadow(0 0 40px rgba(96,165,250,0.9)) drop-shadow(0 0 60px rgba(167,139,250,0.6));
  }
}
.game-subtitle {
  margin: 8px 0 0;
  font-size: 16px;
  font-weight: 500;
  color: rgba(231,242,255,0.7);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Play Section */
.play-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  animation: fadeInUp 0.7s ease-out 0.2s both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
#nameInput {
  width: 100%;
  height: 54px;
  padding: 0 20px;
  background: rgba(17,24,39,0.85);
  border: 2px solid rgba(96,165,250,0.3);
  border-radius: 12px;
  color: #e7f2ff;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: all 0.3s;
}
#nameInput::placeholder {
  color: rgba(231,242,255,0.4);
  font-weight: 500;
}
#nameInput:focus {
  border-color: #22d3ee;
  box-shadow: 0 0 0 4px rgba(34,211,238,0.15), 0 8px 24px rgba(34,211,238,0.2);
  transform: translateY(-2px);
}
.play-button {
  width: 100%;
  height: 60px;
  padding: 0;
  background: linear-gradient(135deg, #22d3ee, #60a5fa);
  border: none;
  border-radius: 12px;
  color: #001;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(34,211,238,0.4);
}
.play-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(34,211,238,0.6);
  filter: brightness(1.1);
}
.play-button:active {
  transform: translateY(-1px);
}
.play-icon {
  font-size: 16px;
}
.play-text {
  position: relative;
}

/* Info Cards */
.info-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  margin-top: 8px;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}
.info-card {
  background: rgba(17,24,39,0.6);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  transition: all 0.3s;
}
.info-card:hover {
  background: rgba(17,24,39,0.8);
  border-color: rgba(96,165,250,0.4);
  transform: translateY(-4px);
}
.card-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  color: #e7f2ff;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.card-desc {
  font-size: 11px;
  color: rgba(231,242,255,0.6);
  line-height: 1.4;
}

/* Controls Section */
.controls-section {
  width: 100%;
  background: rgba(17,24,39,0.5);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: 10px;
  padding: 14px 16px;
  animation: fadeInUp 0.9s ease-out 0.4s both;
}
.controls-toggle {
  font-size: 14px;
  font-weight: 700;
  color: #22d3ee;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.4px;
  list-style: none;
}
.controls-toggle:hover {
  color: #60a5fa;
}
.controls-toggle::-webkit-details-marker {
  display: none;
}
.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(96,165,250,0.15);
}
.control-item {
  font-size: 13px;
  color: rgba(231,242,255,0.85);
  line-height: 1.5;
}
.control-item strong {
  color: #60a5fa;
  font-weight: 600;
}

/* Bottom Links */
.bottom-links {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.bottom-link {
  color: rgba(231,242,255,0.5);
  text-decoration: none;
  transition: color 0.2s;
}
.bottom-link:hover {
  color: #22d3ee;
}
.link-separator {
  color: rgba(231,242,255,0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .game-title {
    font-size: 38px;
    letter-spacing: 2px;
  }
  .info-cards {
    grid-template-columns: 1fr;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
  .top-nav {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }
  .nav-links {
    gap: 14px;
  }
}

.hidden { display:none !important; }


/* Queue / system message */
.arena-msg { margin: 8px auto 12px; max-width: 880px; padding:10px 12px; border-radius:10px; font-weight:600; text-align:center; background:rgba(33,150,243,0.12); border:1px solid rgba(33,150,243,0.35); color:#b3daff; }
/* Hide the bar entirely when there's no text content */
.arena-msg:empty { display: none; }

/* Player count display */
.player-count { margin: 10px auto 8px; text-align: center; font-size: 15px; font-weight: 600; color: #66ff99; opacity: 0.95; }

/* Dim effect when lobby overlay is up (queued) */
.canvas.dimmed { filter: blur(1px) brightness(0.8); }

/* Updates section styling */
.updates-section {
  color: #4ade80 !important; /* Bright green color */
}
.updates-section ul ul {
  margin-top: 4px !important;
  margin-bottom: 8px !important;
  font-size: 0.95em;
}

/* Privacy policy link (bottom centre of start screen) */
#privacyLink {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: auto;
  color: #cfefff;
  background: rgba(255,255,255,0.02);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.15s ease;
}
#privacyLink:hover {
  background: rgba(255,255,255,0.05);
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

@media (max-width:640px) {
  #privacyLink { bottom: 8px; padding: 6px 10px; font-size:12px }
}

/* Advertisement Panel */
.ad-panel {
  position: relative;
  margin: 14px auto 0;
  max-width: 880px;
  padding: 10px 12px 14px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
.ad-panel .ad-slot {
  display: grid;
  place-items: center;
  /* Reserve sensible space for horizontal banners */
  min-height: 90px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 10px;
}
/* Show fallback message when ins is empty (no ad loaded) */
.ad-slot .adsbygoogle:empty::before {
  content: "Ad space - pending approval";
  display: block;
  padding: 12px 16px;
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  text-align: center;
}

/* On very small screens, keep the panel slim */
@media (max-width: 640px) {
  .ad-panel .ad-slot { min-height: 50px; }
}
.ad-panel .ad-disclaimer {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.65;
  text-align: center;
}
.ad-placeholder {
  width: min(100%, 728px);
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #cfefff;
  background: repeating-linear-gradient(45deg, rgba(96,165,250,0.12), rgba(96,165,250,0.12) 10px, rgba(255,255,255,0.03) 10px, rgba(255,255,255,0.03) 20px);
  border-radius: 8px;
}
.ad-placeholder-title { font-weight: 800; letter-spacing: .4px; }
.ad-placeholder-body { font-size: 12px; opacity: .8; }

@media (max-width: 800px) {
  .ad-placeholder { height: 250px; width: 300px; }
}

/* Cookie Consent Banner (GDPR/CCPA) */
.consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: linear-gradient(180deg, rgba(17,24,39,0.98), rgba(11,15,20,0.98));
  border-top: 1px solid rgba(255,255,255,0.15);
  padding: 16px 20px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  animation: slideUp 0.3s ease-out;
}
.consent-banner.hidden {
  display: none;
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.consent-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.consent-text {
  flex: 1;
  color: #e7f2ff;
}
.consent-text strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.consent-text p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.92;
}
.consent-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.consent-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  white-space: nowrap;
}
.consent-accept {
  background: linear-gradient(90deg, #22d3ee, #60a5fa);
  color: #00131b;
}
.consent-accept:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.consent-decline {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #e7f2ff;
}
.consent-decline:hover {
  background: rgba(255,255,255,0.12);
}
.consent-link {
  color: #60a5fa;
  font-size: 13px;
  text-decoration: underline;
  white-space: nowrap;
}
.consent-link:hover {
  color: #22d3ee;
}

@media (max-width: 768px) {
  .consent-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .consent-actions {
    width: 100%;
    justify-content: space-between;
  }
  .consent-btn {
    flex: 1;
    padding: 10px 12px;
    font-size: 13px;
  }
  .consent-link {
    flex-shrink: 0;
  }
}
