/* ===== Reset & base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #fdfaf6;
  color: #1a2035;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Layout ===== */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1rem;
}

main.container {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

/* ===== Header ===== */
header {
  background: #1a2035;
  color: #fdfaf6;
  padding: 0.75rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  color: #f4a228;
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.5px;
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

nav a {
  color: #fdfaf6;
  text-decoration: none;
  font-size: 0.95rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}

nav a:hover {
  opacity: 1;
}

.nav-user {
  color: #f4a228;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ===== Footer ===== */
footer {
  background: #1a2035;
  color: rgba(253, 250, 246, 0.5);
  padding: 1rem 0;
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 12px rgba(26, 32, 53, 0.08);
}

.center-card {
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
}

/* ===== Typography ===== */
h1 {
  font-size: 2.2rem;
  color: #1a2035;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.subtitle {
  color: #555;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* ===== Forms ===== */
.name-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.name-form label {
  font-size: 1.1rem;
  font-weight: 600;
}

.name-form input[type="text"] {
  font-size: 1.2rem;
  padding: 0.6rem 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  width: 100%;
  max-width: 300px;
  text-align: center;
  transition: border-color 0.15s;
}

.name-form input[type="text"]:focus {
  outline: none;
  border-color: #f4a228;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #f4a228;
  color: #1a2035;
}

.btn-primary:hover {
  background: #e0911a;
}

.btn-secondary {
  background: #e8e4de;
  color: #1a2035;
}

.btn-secondary:hover {
  background: #d8d3cc;
}

.btn-link {
  background: none;
  border: none;
  color: #fdfaf6;
  font-size: 0.95rem;
  opacity: 0.85;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-link:hover {
  opacity: 1;
}

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.alert-error {
  background: #fde8e8;
  color: #c0392b;
  border: 1px solid #f5c6cb;
}

.hint {
  margin-top: 1.5rem;
  color: #888;
  font-size: 0.85rem;
}

/* ===== Quiz ===== */
.quiz-wrapper {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.progress-text {
  font-size: 1rem;
  color: #666;
}

.timer {
  font-size: 1.4rem;
  font-weight: 700;
  color: #f4a228;
  font-variant-numeric: tabular-nums;
}

.question-display {
  font-size: 3rem;
  font-weight: 700;
  color: #1a2035;
  margin: 1rem 0 2rem;
  line-height: 1.1;
}

.answer-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#answer-input {
  font-size: 2rem;
  width: 140px;
  text-align: center;
  padding: 0.4rem 0.5rem;
  border: 3px solid #ddd;
  border-radius: 10px;
  transition: border-color 0.15s;
}

#answer-input:focus {
  outline: none;
  border-color: #f4a228;
}

.answer-feedback {
  min-height: 2rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.feedback-correct {
  color: #2ecc71;
}

.feedback-wrong {
  color: #e74c3c;
}

/* ===== Result ===== */
.result-score {
  font-size: 3rem;
  font-weight: 700;
  color: #1a2035;
  margin: 0.5rem 0;
}

.result-time {
  font-size: 1.3rem;
  color: #555;
  margin-bottom: 1rem;
}

.badge-perfect {
  display: inline-block;
  background: #2ecc71;
  color: #fff;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0.5rem 0 1.5rem;
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* ===== Leaderboard ===== */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.leaderboard-table th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.leaderboard-table tr:first-child td {
  color: #f4a228;
  font-weight: 700;
}

.leaderboard-table tr:hover td {
  background: #fdf6ec;
}

.rank-num {
  color: #888;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  text-align: center;
  color: #888;
  padding: 2rem 0;
}

/* ===== Profile ===== */
.chart-container {
  position: relative;
  height: 320px;
  margin-top: 1.5rem;
}

.session-legend {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.dot-perfect { background: #2ecc71; }
.dot-imperfect { background: #f4a228; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
  h1 { font-size: 1.7rem; }
  .question-display { font-size: 2.2rem; }
  #answer-input { font-size: 1.6rem; width: 110px; }
  .card { padding: 1.25rem; }
}

/* ===== Login link box ===== */
.login-link-box {
  background: #f5f2ee;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  word-break: break-all;
  font-size: 0.9rem;
  text-align: left;
}

/* ===== Mistakes table ===== */
.mistakes-section {
  margin-top: 1.5rem;
  text-align: left;
}
.mistakes-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #333;
}
.mistakes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.mistakes-table th,
.mistakes-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  text-align: center;
}
.mistakes-table th {
  font-weight: 600;
  color: #555;
}
.wrong-answer {
  color: #c0392b;
  font-weight: 600;
}
.correct-answer {
  color: #27ae60;
  font-weight: 600;
}
