/* --- THEME COLORS & FONTS --- */
:root {
  --font-body: 'Nunito', sans-serif;
  --font-display: 'Fredoka One', cursive;
  --c-primary: #34A853;
  --c-accent: #FFA500;
  --c-background: #121212;
  --c-surface: #1E1E1E;
  --c-text-primary: #FFFFFF;
  --c-text-secondary: #AAB8C2;
  --c-border: #2F3336;
}
body.light-theme {
  --c-background: #F0F2F5;
  --c-surface: #FFFFFF;
  --c-text-primary: #0F1419;
  --c-text-secondary: #536471;
  --c-border: #EBEEF0;
}

/* --- FIX: Lock page layout and only leaderboard scrollable --- */
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

/* --- BASIC SETUP --- */
* {
  box-sizing: border-box;
}
body {
  font-family: var(--font-body);
  background-color: var(--c-background);
  color: var(--c-text-primary);
  transition: background-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.view {
  width: 100%;
  max-width: 450px;
  height: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  background-color: var(--c-background);
  transition: background-color 0.2s;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden {
  display: none !important;
}

/* --- AUTH VIEW STYLES --- */
#auth-view {
  justify-content: center;
  padding: 20px;
}
.auth-screen {
  background-color: var(--c-surface);
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  width: 100%;
  max-width: 380px;
  margin: auto;
  position: relative;
}
.auth-screen h2 {
  margin-top: 0;
  font-size: 28px;
  font-weight: 700;
}
.auth-screen input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
  background-color: var(--c-background);
  color: var(--c-text-primary);
  font-size: 16px;
}
.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}
.btn-primary {
  background-color: var(--c-primary);
  color: white;
}
.btn-secondary {
  background-color: var(--c-surface);
  color: var(--c-text-primary);
  border: 1px solid var(--c-border);
}
.separator {
  margin: 20px 0;
  font-style: italic;
  color: var(--c-text-secondary);
}
.back-btn {
  background: none;
  border: none;
  color: var(--c-text-primary);
  font-size: 24px;
  position: absolute;
  top: 20px;
  left: 20px;
  cursor: pointer;
}
#forgot-password-link {
  display: block;
  margin-top: 15px;
  color: var(--c-text-secondary);
  text-decoration: none;
  font-size: 14px;
}
#forgot-password-link:hover {
  text-decoration: underline;
}

/* --- HEADER --- */
.game-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--c-border);
  position: relative;
  flex-shrink: 0;
}
#global-counter {
  font-size: 52px;
  font-weight: 800;
  color: var(--c-primary);
  line-height: 1.1;
}
.global-clicks span {
  font-size: 14px;
  color: var(--c-text-secondary);
}
.user-info p {
  margin: 15px 0 5px;
  font-size: 16px;
  color: var(--c-text-secondary);
  word-break: break-word;
}
#user-clicks-today,
#username-display {
  color: var(--c-accent);
  font-weight: 700;
}
.ad-button {
  background-color: var(--c-accent);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin: 10px auto 0;
  transition: background-color 0.2s;
  display: block;
}
.ad-button:disabled {
  background-color: #555;
  cursor: not-allowed;
}
.powerup-timer {
  background-color: var(--c-primary);
  color: white;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 20px;
  margin: 10px auto 0;
  display: inline-block;
}
#logout-btn {
  background: var(--c-surface);
  color: var(--c-text-secondary);
  border: 1px solid var(--c-border);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 10px;
}
#theme-switcher {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--c-surface);
  border-radius: 50px;
  padding: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
#theme-switcher button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
}
#theme-switcher button.active {
  background-color: var(--c-primary);
  opacity: 1;
}

/* --- LEADERBOARD --- */
.leaderboard-section {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 20px;
}
.rankings-header {
  padding: 20px 0;
  display: flex;
  align-items: center;
  gap: 15px;
  background-color: var(--c-background);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.2s;
}
.rankings-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}
.tabs {
  display: flex;
  background-color: var(--c-surface);
  border-radius: 20px;
  padding: 4px;
}
.tab-btn {
  padding: 6px 16px;
  background: none;
  border: none;
  color: var(--c-text-secondary);
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  background-color: var(--c-primary);
  color: white;
}
#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
#leaderboard-list li {
  display: flex;
  align-items: center;
  padding: 16px 5px;
  font-size: 16px;
  border-bottom: 1px solid var(--c-border);
}
#leaderboard-list li.is-user {
  background-color: #34a85320;
  border-radius: 8px;
  font-weight: 700;
}
.rank-separator {
  text-align: center;
  font-weight: 800;
  color: var(--c-text-secondary);
  padding: 10px 0 !important;
}
.rank {
  flex-basis: 30px;
  color: var(--c-text-secondary);
}
.username {
  flex-grow: 1;
  padding-left: 15px;
  font-weight: 600;
}
.score {
  font-weight: 700;
}

/* --- CLICK AREA --- */
.click-area {
  background-color: var(--c-primary);
  position: relative;
  flex-shrink: 0;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#click-me-btn {
  background: none;
  border: none;
  color: white;
  font-family: var(--font-display);
  font-size: 90px;
  line-height: 1;
  cursor: pointer;
  width: 100%;
  height: 100%;
  text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s, color 0.2s;
}
#click-me-btn:disabled {
  background-color: #d32f2f;
  color: #ffcdd2;
  font-size: 48px;
}
.plus-one {
  position: absolute;
  font-family: var(--font-display);
  font-size: 32px;
  color: white;
  user-select: none;
  pointer-events: none;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  animation: float-up 1s ease-out forwards;
}
@keyframes float-up {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-80px);
  }
}
