* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

html, body {
  touch-action: none;
  overflow: hidden;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  height: 100vh;
  width: 100vw;
  background-color: #020205;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: white;
}

#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}

#gameCanvas:active {
  cursor: grabbing;
}

/* OVERRIDE BROWSER AUTOFILL WHITE BACKGROUND */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0f172a inset !important;
    -webkit-text-fill-color: #ffffff !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* RESPONSIVE AAA INTRO SPLASH SCREEN WITH GAME COVER ART */
.app-launch-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  background: radial-gradient(circle at center, #0f172a 0%, #020205 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 88%;
  max-width: 400px;
}

/* EPIC FRAMED GAME LOGO COVER CARD */
.splash-logo-card {
  position: relative;
  border-radius: 24px;
  padding: 5px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.6), rgba(99, 102, 241, 0.4), rgba(244, 63, 94, 0.6));
  box-shadow: 0 0 35px rgba(56, 189, 248, 0.5);
  animation: logoFloat 3s ease-in-out infinite alternate;
  margin-bottom: 20px;
}

.splash-logo-img {
  width: 220px;
  height: 220px;
  max-width: 65vw;
  max-height: 32vh;
  object-fit: cover;
  border-radius: 20px;
  display: block;
}

@keyframes logoFloat {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(-10px) scale(1.03); }
}

.splash-title {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #38bdf8, #818cf8, #f43f5e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.splash-subtitle {
  color: #64748b;
  font-size: 0.72rem;
  letter-spacing: 2px;
  font-weight: bold;
  margin-bottom: 22px;
}

.splash-loader-box {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.3);
  margin-bottom: 10px;
}

.splash-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #4ade80);
  box-shadow: 0 0 12px #38bdf8;
  transition: width 0.15s linear;
}

.splash-status-text {
  font-size: 0.75rem;
  color: #38bdf8;
  font-weight: bold;
  letter-spacing: 1px;
}

.splash-start-btn {
  width: 100%;
  padding: 0.95rem;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-weight: 900;
  font-size: 0.98rem;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 0 25px rgba(34, 197, 94, 0.6);
  animation: pulseGlow 1.2s infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: scale(0.98); opacity: 0.9; }
  100% { transform: scale(1.02); opacity: 1; }
}

/* OFFICIAL GOOGLE SIGN-IN BUTTON */
.google-btn {
  width: 100%;
  padding: 0.78rem 1rem;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 12px;
  color: #1f2937;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease-in-out;
}

.google-btn:hover {
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

.google-svg-logo {
  flex-shrink: 0;
}

/* INPUT FIELDS STYLING */
#authEmailInput, #authUsernameInput, .auto-scroll-input {
  width: 100%;
  padding: 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(15, 23, 42, 0.9) !important;
  color: #ffffff !important;
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 0.8rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#authEmailInput:focus, #authUsernameInput:focus, .auto-scroll-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

/* CUSTOM THIN SCROLLBAR */
.card::-webkit-scrollbar, .skins-list::-webkit-scrollbar, .leaderboard-table-wrapper::-webkit-scrollbar, .manual-content::-webkit-scrollbar {
  width: 5px;
}

.card::-webkit-scrollbar-track, .skins-list::-webkit-scrollbar-track, .leaderboard-table-wrapper::-webkit-scrollbar-track, .manual-content::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 10px;
}

.card::-webkit-scrollbar-thumb, .skins-list::-webkit-scrollbar-thumb, .leaderboard-table-wrapper::-webkit-scrollbar-thumb, .manual-content::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.4);
  border-radius: 10px;
}

#countdownOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
  background: rgba(2, 2, 5, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

#countdownText {
  font-size: 6rem;
  font-weight: 900;
  color: #38bdf8;
  text-shadow: 0 0 30px #38bdf8, 0 0 60px #818cf8;
  animation: pulseZoom 0.8s infinite alternate;
}

@keyframes pulseZoom {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 1; }
}

.server-badge {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
  display: inline-block;
  margin-bottom: 0.8rem;
}

.card {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(8, 12, 24, 0.96);
  padding: 1.4rem 1.2rem 1rem 1.2rem;
  border-radius: 20px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.95);
  text-align: center;
  max-width: 420px;
  width: 90%;
  max-height: 82vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.guest-input-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 8px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.guest-input-box input {
  width: 100%;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: rgba(2, 2, 5, 0.8);
  color: white;
  text-align: center;
  font-size: 0.9rem;
  outline: none;
}

.launch-btn {
  font-size: 1.05rem;
  padding: 0.85rem;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.auth-sub-links {
  margin-top: 12px;
  font-size: 0.85rem;
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
}

.auth-sub-links a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: bold;
  transition: color 0.2s;
}

.auth-sub-links a:hover {
  color: #60a5fa;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  justify-content: center;
}

.auth-tab-btn {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #94a3b8;
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: bold;
  width: 50%;
}

.auth-tab-btn.active {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: white;
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.subtitle {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.top-menu-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.player-welcome {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #e2e8f0;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.player-welcome strong {
  color: #38bdf8;
}

.settings-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  cursor: pointer;
}

.password-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 0.8rem;
}

.password-wrapper input {
  width: 100%;
  padding: 0.8rem 2.5rem 0.8rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.95) !important;
  color: white !important;
  font-size: 0.9rem;
  text-align: center;
  outline: none;
}

.password-wrapper input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.eye-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.85;
  user-select: none;
}

.error-msg {
  color: #ef4444;
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
  font-weight: bold;
  min-height: 18px;
}

.primary-btn {
  width: 100%;
  padding: 0.8rem;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border: none;
  border-radius: 10px;
  color: white;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
}

.install-app-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  font-weight: bold;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
  width: 100%;
}

.revive-btn {
  background: linear-gradient(135deg, #22c55e, #15803d) !important;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

h1 {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #38bdf8, #818cf8, #f43f5e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.2rem;
}

p {
  color: #94a3b8;
  margin-bottom: 0.8rem;
  font-size: 0.82rem;
}

.coin-balance {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-weight: bold;
  padding: 5px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 0.8rem;
  font-size: 0.88rem;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-btn, .shop-btn, .leaderboard-btn {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.75rem;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.leaderboard-btn {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.12);
  font-weight: bold;
}

.shop-btn {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  font-weight: bold;
}

.mode-btn span, .shop-btn span, .leaderboard-btn span {
  font-size: 0.9rem;
  font-weight: bold;
}

.mode-btn small {
  color: #94a3b8;
  font-size: 0.72rem;
  margin-top: 2px;
}

#settingsContainer h3, #pauseOverlay h2, #leaderboardContainer h3, #shopContainer h3, #howToPlayModal h3, #authScreen h2 {
  margin-bottom: 0.8rem;
  color: #38bdf8;
  letter-spacing: 1px;
  font-size: 1.2rem;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: center;
}

.tab-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #38bdf8;
  color: white;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
}

.tab-btn.active {
  background: #38bdf8;
  color: #020205;
  font-weight: bold;
}

.leaderboard-wrapper-relative {
  position: relative;
  width: 100%;
  min-height: 200px;
  margin-bottom: 0.8rem;
}

.leaderboard-table-wrapper {
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.guest-blur-mode {
  filter: blur(5px);
  opacity: 0.35;
  pointer-events: none;
}

.guest-lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 12, 24, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  padding: 12px;
  z-index: 5;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.lock-card-content {
  text-align: center;
  color: white;
}

.lock-card-content h4 {
  color: #38bdf8;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.lock-card-content p {
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-bottom: 10px;
  line-height: 1.3;
}

.skins-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 0.8rem;
}

.skin-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
  gap: 10px;
}

.skin-preview-canvas {
  width: 44px;
  height: 44px;
  background: rgba(2, 2, 5, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  flex-shrink: 0;
}

.skin-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.skin-title {
  font-weight: bold;
  font-size: 0.85rem;
  color: #f1f5f9;
}

.skin-desc {
  font-size: 0.68rem;
  color: #94a3b8;
}

.skin-card button {
  background: #38bdf8;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  color: #020205;
  font-weight: bold;
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 80px;
  text-align: center;
  flex-shrink: 0;
}

.skin-card button.equipped {
  background: #22c55e;
  color: white;
}

.skin-card button.buy-btn {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #020205;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  margin-bottom: 0.7rem;
  background: rgba(15, 23, 42, 0.7);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-group.row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.settings-group label {
  font-size: 0.8rem;
  color: #cbd5e1;
}

.settings-group input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
}

.toggle-btn {
  background: #ef4444;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.8rem;
}

.manual-content {
  text-align: left;
  font-size: 0.78rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 0.8rem;
}

.manual-content h4 {
  color: #38bdf8;
  margin: 8px 0 4px 0;
}

.manual-content ul {
  padding-left: 16px;
  color: #cbd5e1;
}

.manual-content li {
  margin-bottom: 4px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.leaderboard-table th {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  padding: 6px;
  text-align: center;
}

.leaderboard-table td {
  padding: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table .highlight-row {
  background: rgba(251, 191, 36, 0.15) !important;
  color: #fbbf24;
  font-weight: bold;
}

.logout-btn {
  width: 100%;
  padding: 8px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.8rem;
}

#progressBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.1s linear;
}

.back-btn {
  margin-top: 6px;
  padding: 0.7rem 1.2rem;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border: none;
  border-radius: 10px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  font-size: 0.9rem;
}

.footer-credit {
  margin-top: 0.8rem;
  font-size: 0.72rem;
  color: #64748b;
  letter-spacing: 1px;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.hud-item {
  background: rgba(8, 12, 24, 0.85);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: bold;
}

.hud-item.highlight span {
  color: #fbbf24;
}

#pauseBtn {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.5);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

#touchControls {
  position: fixed;
  bottom: 15px;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 15px;
  pointer-events: none;
}

#dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.dpad-middle {
  display: flex;
  gap: 30px;
  margin: -4px 0;
}

.arrow-btn {
  width: 52px;
  height: 52px;
  background: rgba(15, 23, 42, 0.8);
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  border-radius: 12px;
  color: #38bdf8;
  font-size: 1.3rem;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  touch-action: manipulation;
}

#fireBtn {
  width: 68px;
  height: 68px;
  background: radial-gradient(circle, #f43f5e, #9f1239);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: white;
  font-weight: bold;
  pointer-events: auto;
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  touch-action: manipulation;
}

/* ==========================================
   RESPONSIVE DESIGN & MOBILE ENHANCEMENTS
   ========================================== */
@media (max-width: 600px) {
  #hud {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 4px;
  }

  .hud-item {
    padding: 4px 6px;
    font-size: 0.68rem;
    white-space: nowrap;
    letter-spacing: 0;
  }

  #pauseBtn {
    padding: 4px 8px;
    font-size: 0.85rem;
  }

  .card {
    padding: 1.1rem 0.9rem 0.8rem 0.9rem;
    max-height: 86vh;
    width: 94%;
  }

  h1 {
    font-size: 1.45rem;
  }

  .splash-title {
    font-size: 1.6rem;
  }

  .arrow-btn {
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
  }

  .dpad-middle {
    gap: 22px;
  }

  #fireBtn {
    width: 58px;
    height: 58px;
    font-size: 0.82rem;
  }
}

@media (max-width: 380px) {
  #hud {
    top: 6px;
    left: 4px;
    right: 4px;
    gap: 2px;
  }

  .hud-item {
    font-size: 0.62rem;
    padding: 3px 4px;
  }

  .hud-item:first-child {
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}