:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #666;
  --border: #e0e0e0;
  --green: #4CAF50;
  --blue: #2196F3;
  --orange: #FF9800;
  --red: #f44336;
  --gold: #FFD700;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --card: #16213e;
  --text: #eee;
  --text-secondary: #aaa;
  --border: #2a2a4a;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  padding-top: 56px;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.8em; text-align: center; margin: 16px 0; }
h2 { font-size: 1.3em; margin: 12px 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  color: white;
  margin-bottom: 10px;
  text-align: left;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-orange { background: var(--orange); }

.btn-answer {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
  text-align: left;
  padding: 14px 18px;
  font-size: 1em;
  line-height: 1.4;
}

.btn-answer:hover { border-color: var(--blue); }

.btn-answer.correct {
  background: var(--green) !important;
  color: white !important;
  border-color: var(--green) !important;
  animation: correctPulse 0.5s ease;
}

.btn-answer.wrong {
  background: var(--red) !important;
  color: white !important;
  border-color: var(--red) !important;
  animation: shake 0.4s ease;
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin: 12px 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 0.9em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1em;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.topic-btn {
  display: inline-block;
  padding: 10px 16px;
  margin: 4px;
  border-radius: 12px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  border: none;
  color: white;
}

.subject-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
  font-weight: 700;
}

.subject-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.clue-popup {
  background: #fff3cd;
  color: #856404;
  padding: 12px 16px;
  border-radius: 12px;
  margin-top: 12px;
  font-size: 0.95em;
  display: none;
}

[data-theme="dark"] .clue-popup {
  background: #3d3200;
  color: #ffc107;
}

.feedback-msg {
  text-align: center;
  font-size: 1.3em;
  font-weight: 700;
  margin: 12px 0;
  min-height: 40px;
}

.stars { text-align: center; font-size: 2.5em; margin: 16px 0; }

.score-display { text-align: center; font-size: 1.5em; font-weight: 700; margin: 8px 0; }

.weak-list { list-style: none; padding: 0; }
.weak-list li {
  padding: 8px 12px;
  border-left: 3px solid var(--orange);
  margin: 6px 0;
  font-size: 0.9em;
  color: var(--text-secondary);
}

.dark-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: auto;
}

.question-type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.75em;
  font-weight: 600;
  color: white;
  margin-bottom: 8px;
}

.timer {
  text-align: center;
  font-size: 1.5em;
  font-weight: 700;
  color: var(--orange);
  margin: 8px 0;
}

.screen { display: none; }
.screen.active { display: block; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

/* Auth */
.auth-switch {
  text-align: center;
  margin-top: 12px;
  font-size: 0.9em;
  color: var(--text-secondary);
}
.auth-switch a { color: var(--blue); text-decoration: none; font-weight: 600; }
.error-msg { color: var(--red); text-align: center; font-size: 0.9em; min-height: 20px; margin-bottom: 8px; }

/* User bar */
.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9em;
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.85em;
  cursor: pointer;
  color: var(--text-secondary);
}

/* Coin display */
.coin-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 1.1em;
  color: var(--gold);
}
.coin-icon {
  font-size: 1.3em;
  transition: transform 0.3s;
}
.coin-icon.bounce {
  animation: coin-bounce 0.4s ease;
}
@keyframes coin-bounce {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.35); }
  70% { transform: scale(0.95); }
}
.coin-icon.glow {
  filter: drop-shadow(0 0 6px var(--gold));
}
.coin-count {
  min-width: 24px;
}

/* Floating coin animation */
#coin-float-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 300;
}
.coin-float {
  position: absolute;
  font-size: 1.4em;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  animation: float-up 1.2s ease-out forwards;
  pointer-events: none;
}
@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-60px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-90px) scale(0.8); }
}

/* Result coins */
.result-coins {
  text-align: center;
  margin-top: 16px;
  font-size: 1.2em;
}
.result-coins .coins-line {
  color: var(--gold);
  font-weight: 700;
  margin: 4px 0;
}
.result-coins .perfect-bonus {
  font-size: 1.3em;
  animation: coin-bounce 0.6s ease infinite;
  color: var(--gold);
}

/* ===== AUTH SCREEN OVERHAUL ===== */
#auth-screen h1 {
  font-size: 2.2em;
  margin-bottom: 8px;
}

#auth-screen .card {
  max-width: 380px;
  margin: 20px auto;
  padding: 28px 24px;
}

#auth-screen .card h2 {
  text-align: center;
  font-size: 1.4em;
  margin-bottom: 20px;
  color: var(--text);
}

/* Input group styling */
.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.05em;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 0;
}

.input-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.input-group .input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(15%);
  font-size: 1.1em;
  opacity: 0.4;
  pointer-events: none;
}

/* Password toggle */
.password-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(15%);
  background: none;
  border: none;
  font-size: 1.1em;
  cursor: pointer;
  opacity: 0.5;
  padding: 4px;
  transition: opacity 0.2s;
}
.password-toggle:hover { opacity: 0.8; }

/* Auth buttons */
#auth-screen .btn {
  margin-top: 8px;
  text-align: center;
  font-size: 1.05em;
  padding: 14px 24px;
  border-radius: var(--radius);
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9em;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}
.auth-switch a:hover { color: var(--green); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-secondary);
  font-size: 0.85em;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.error-msg {
  color: var(--red);
  text-align: center;
  font-size: 0.88em;
  min-height: 20px;
  margin: 8px 0;
  padding: 0 8px;
}

/* Welcome subtitle */
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1em;
  margin-bottom: 20px;
}

/* I Don't Know button */
.idk-container { margin-top: 8px; }
.btn-idk {
  background: transparent;
  color: var(--text-secondary);
  border: 2px dashed var(--border);
  text-align: center;
  font-size: 0.95em;
  font-weight: 500;
  padding: 12px 18px;
  opacity: 0.75;
  transition: opacity 0.2s, border-color 0.2s;
}
.btn-idk:hover { opacity: 1; border-color: var(--text-secondary); }

/* Learning screen */
.learning-card { text-align: center; }
.learning-icon { font-size: 3em; margin-bottom: 8px; }
.learning-answer {
  background: var(--green);
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 1.15em;
  font-weight: 700;
  margin: 16px 0;
  display: inline-block;
}
.learning-clue {
  background: #fff3cd;
  color: #856404;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.95em;
  margin: 12px 0;
}
[data-theme="dark"] .learning-clue {
  background: #3d3200;
  color: #ffc107;
}
.learning-explanation {
  font-size: 1.05em;
  line-height: 1.6;
  color: var(--text);
  margin: 16px 0 8px;
  text-align: left;
  padding: 0 8px;
}
