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

:root {
  --red: #c60b1e;
  --red-dark: #a00918;
  --yellow: #ffc400;
  --yellow-light: #ffd740;
  --yellow-dark: #e0ac00;
  --bg: #fefbf0;
  --text: #2d2d2d;
  --text-light: #666;
  --white: #fff;
  --gray: #e8e8e8;
  --gray-dark: #bbb;
  --green: #27ae60;
  --green-light: #d4efdf;
  --red-light: #f5c6cb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
.header {
  background: var(--red);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
}

.header-score {
  background: var(--yellow);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
}

.header-back {
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 0 8px;
}

/* Screens */
.screen {
  display: none;
  padding: 20px;
  min-height: calc(100vh - 60px);
}

.screen.active {
  display: block;
}

/* Auth screens */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}

.auth-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--text-light);
  margin-bottom: 32px;
}

.auth-form {
  width: 100%;
  max-width: 320px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--gray);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--yellow);
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--red);
  color: var(--white);
}

.btn-primary:active {
  background: var(--red-dark);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--yellow);
  color: var(--text);
}

.btn-secondary:active {
  background: var(--yellow-dark);
  transform: scale(0.98);
}

.btn-outline {
  background: none;
  border: 2px solid var(--gray-dark);
  color: var(--text);
}

.btn-small {
  padding: 10px 16px;
  font-size: 14px;
  width: auto;
  display: inline-block;
}

.btn-danger {
  background: var(--red);
  color: var(--white);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-light);
}

.auth-switch a {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
}

.error-msg {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* Home screen */
.unit-list {
  list-style: none;
}

.unit-card {
  background: var(--white);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.unit-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.unit-info h3 {
  font-size: 18px;
  font-weight: 700;
}

.unit-info p {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.unit-badges {
  font-size: 22px;
  display: flex;
  gap: 4px;
}

.unit-resume {
  font-size: 11px;
  color: var(--yellow-dark);
  font-weight: 600;
  margin-top: 2px;
}

.nav-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.nav-buttons .btn {
  flex: 1;
}

/* Quiz screen */
.quiz-progress {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 32px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.quiz-settings-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
}

.quiz-word {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 20px;
}

.quiz-word-label {
  font-size: 13px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.quiz-word-text {
  font-size: 32px;
  font-weight: 800;
  color: var(--red);
}

.quiz-review-tag {
  display: inline-block;
  background: var(--yellow);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  margin-top: 8px;
}

.quiz-input-area {
  margin-bottom: 20px;
}

.quiz-input-area input {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--gray);
  border-radius: 12px;
  font-size: 18px;
  text-align: center;
  outline: none;
  margin-bottom: 12px;
}

.quiz-input-area input:focus {
  border-color: var(--yellow);
}

.quiz-buttons {
  display: flex;
  gap: 10px;
}

.quiz-buttons .btn {
  flex: 1;
}

/* Result display */
.quiz-result {
  text-align: center;
  padding: 20px;
  border-radius: 16px;
  margin-bottom: 20px;
  display: none;
}

.quiz-result.correct {
  background: var(--green-light);
  display: block;
}

.quiz-result.wrong {
  background: var(--red-light);
  display: block;
}

.quiz-result-label {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.quiz-result.correct .quiz-result-label {
  color: var(--green);
}

.quiz-result.wrong .quiz-result-label {
  color: var(--red);
}

.quiz-result-answer {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.quiz-result-yours {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
}

.quiz-result-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

/* Reveal rating buttons */
.reveal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.reveal-buttons .btn {
  flex: 1;
}

.btn-wrong {
  background: var(--red);
  color: var(--white);
}

.btn-meh {
  background: var(--yellow);
  color: var(--text);
}

.btn-right {
  background: var(--green);
  color: var(--white);
}

/* Completion screen */
.completion {
  text-align: center;
  padding-top: 40px;
}

.completion-badge {
  font-size: 80px;
  margin-bottom: 16px;
}

.completion-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 8px;
}

.completion-perfect {
  font-size: 18px;
  color: var(--yellow-dark);
  font-weight: 700;
  margin-bottom: 16px;
}

.completion-stats {
  background: var(--white);
  border-radius: 16px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.completion-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 16px;
}

.completion-stat-label {
  color: var(--text-light);
}

.completion-stat-value {
  font-weight: 700;
}

/* Scoreboard */
.scoreboard-list {
  list-style: none;
}

.scoreboard-item {
  background: var(--white);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.scoreboard-rank {
  font-size: 24px;
  font-weight: 800;
  color: var(--red);
  min-width: 36px;
  text-align: center;
}

.scoreboard-rank.first {
  color: var(--yellow-dark);
}

.scoreboard-info {
  flex: 1;
}

.scoreboard-name {
  font-size: 18px;
  font-weight: 700;
}

.scoreboard-badges {
  font-size: 14px;
  margin-top: 4px;
}

.scoreboard-points {
  font-size: 18px;
  font-weight: 800;
  color: var(--red);
}

/* Settings */
.settings-section {
  background: var(--white);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--red);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.setting-label {
  font-size: 15px;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 52px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gray-dark);
  border-radius: 28px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--green);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* Admin */
.admin-user-card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.admin-user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.admin-user-name {
  font-size: 18px;
  font-weight: 700;
}

.admin-user-score {
  font-size: 14px;
  color: var(--text-light);
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-actions .btn {
  flex: none;
}

/* Quiz settings dropdown */
.quiz-menu {
  display: none;
  position: absolute;
  top: 56px;
  right: 20px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 8px 0;
  z-index: 200;
}

.quiz-menu.open {
  display: block;
}

.quiz-menu-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
}

.quiz-menu-item:active {
  background: var(--gray);
}

.quiz-menu-item.danger {
  color: var(--red);
}

/* Overlay for quiz menu */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 150;
}

.overlay.open {
  display: block;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-buttons .btn {
  flex: 1;
}
