:root {
  --lmu-green: #00883A;
  --lmu-green-dark: #00682C;
  --lmu-green-light: #E8F5E9;
  --lmu-green-accent: #22C55E;
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50: #F8FAFC;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, a, .option-item, .tab-btn {
  touch-action: manipulation;
}

body {
  font-family: var(--font-sans);
  background-color: var(--slate-50);
  color: var(--slate-800);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Chemische Hoch- und Tiefstellung */
sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.2em;
}

/* Header */
.site-header {
  background: white;
  border-bottom: 1px solid var(--slate-200);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lmu-badge {
  background-color: var(--lmu-green);
  color: white;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 136, 58, 0.25);
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.8rem;
  color: var(--slate-600);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-600);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--lmu-green);
  background-color: var(--lmu-green-light);
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1000px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--slate-200);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  padding: 2rem;
  margin-bottom: 2rem;
}

/* Rule Banner */
.rule-banner {
  background: linear-gradient(135deg, #00883A 0%, #005A27 100%);
  color: white;
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 15px -3px rgba(0, 136, 58, 0.2);
}

.rule-banner h2 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.rule-banner p {
  opacity: 0.95;
  font-size: 0.95rem;
  line-height: 1.6;
}

.bonus-badge-highlight {
  display: inline-block;
  background-color: #FEF08A;
  color: #854D0E;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin: 0 0.2rem;
}

.topics-overview {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  font-size: 0.88rem;
}

.topics-overview-title {
  display: block;
  margin-bottom: 0.6rem;
  color: #FEF08A;
  font-weight: 700;
  font-size: 0.92rem;
}

.topics-list {
  margin: 0;
  padding-left: 1.35rem;
  line-height: 1.6;
  columns: 2;
  column-gap: 2rem;
}

.topics-list li {
  margin-bottom: 0.25rem;
  break-inside: avoid;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 0.4rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--slate-200);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--slate-800);
  background-color: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--lmu-green);
  box-shadow: 0 0 0 3px rgba(0, 136, 58, 0.15);
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--lmu-green-dark);
  box-shadow: 0 4px 6px -1px rgba(0, 136, 58, 0.3);
}

.btn-primary:disabled {
  background-color: var(--slate-200);
  color: var(--slate-600);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-secondary {
  background-color: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.btn-secondary:hover {
  background-color: var(--slate-200);
  color: var(--slate-900);
}

.btn-danger {
  background-color: #FEE2E2;
  color: #DC2626;
  border: 1px solid #FCA5A5;
}

.btn-danger:hover {
  background-color: #DC2626;
  color: white;
}

.btn-block {
  width: 100%;
}

/* Tabs */
.tab-container {
  display: flex;
  border-bottom: 2px solid var(--slate-200);
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--slate-600);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--lmu-green);
  border-bottom-color: var(--lmu-green);
}

/* Quiz UI Components */
.quiz-header {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--slate-200);
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.category-tag {
  background-color: var(--lmu-green-light);
  color: var(--lmu-green-dark);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.score-tag {
  background-color: var(--slate-100);
  color: var(--slate-800);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
}

.progress-bar-container {
  background-color: var(--slate-100);
  border-radius: 10px;
  height: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  background: linear-gradient(90deg, var(--lmu-green) 0%, var(--lmu-green-accent) 100%);
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s ease;
}

.question-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--slate-200);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--slate-900);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border: 2px solid var(--slate-200);
  border-radius: 10px;
  background-color: white;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1rem;
  user-select: none;
}

.option-item:hover:not(.locked) {
  border-color: var(--lmu-green);
  background-color: #F0FDF4;
  transform: translateY(-1px);
}

.option-item.selected {
  border-color: var(--lmu-green);
  background-color: #F0FDF4;
  box-shadow: 0 0 0 2px rgba(0, 136, 58, 0.2);
}

.option-item.correct {
  border-color: var(--success) !important;
  background-color: #ECFDF5 !important;
  color: #065F46;
  font-weight: 600;
}

.option-item.wrong {
  border-color: var(--danger) !important;
  background-color: #FEF2F2 !important;
  color: #991B1B;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--slate-100);
  font-weight: 700;
  color: var(--slate-700);
  flex-shrink: 0;
}

.option-item.selected .option-letter {
  background-color: var(--lmu-green);
  color: white;
}

.option-item.correct .option-letter {
  background-color: var(--success);
  color: white;
}

.option-item.wrong .option-letter {
  background-color: var(--danger);
  color: white;
}

/* Explanation Box */
.explanation-box {
  background-color: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-left: 5px solid var(--lmu-green);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  animation: fadeIn 0.3s ease-out;
}

.explanation-box.correct {
  border-left-color: var(--success);
  background-color: #F0FDF4;
}

.explanation-box.wrong {
  border-left-color: var(--danger);
  background-color: #FFF1F2;
}

.explanation-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.explanation-text {
  font-size: 0.95rem;
  color: var(--slate-700);
  line-height: 1.6;
}

.timer-notice {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-700);
}

.countdown-badge {
  background-color: var(--slate-800);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 540px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  animation: scaleUp 0.2s ease-out;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 1rem;
}

/* Admin Styles */
.admin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--slate-200);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.kpi-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--slate-900);
}

.data-table-container {
  overflow-x: auto;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: white;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.data-table th {
  background-color: var(--slate-100);
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--slate-700);
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sortable-th:hover {
  background-color: #E2E8F0 !important;
  color: var(--slate-900) !important;
}

.sort-icon {
  display: inline-block;
  font-size: 0.72rem;
  margin-left: 0.35rem;
  opacity: 0.4;
  vertical-align: middle;
}

.sortable-th.active {
  background-color: #E2E8F0;
  color: var(--lmu-green-dark);
}

.sortable-th.active .sort-icon {
  opacity: 1;
  color: var(--lmu-green-dark);
  font-weight: 900;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
  font-weight: 600;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--slate-200);
  color: var(--slate-800);
  white-space: nowrap;
}

.data-table tr:hover {
  background-color: #F8FAFC;
}

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
}

.status-badge.in_progress {
  background-color: #FEF3C7;
  color: #B45309;
}

.status-badge.completed {
  background-color: #D1FAE5;
  color: #047857;
}

.status-badge.bonus {
  background-color: #DCFCE7;
  color: #15803D;
  font-weight: 800;
}

/* KaTeX formula fine-tuning */
.katex {
  font-size: 1.05em;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
  -webkit-overflow-scrolling: touch;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ====================================================== */
/* MOBILE SMARTPHONE OPTIMIERUNG (iOS & Android)          */
/* ====================================================== */
@media (max-width: 640px) {
  /* Layout & Abstände */
  .main-content {
    margin: 0.75rem auto 1.5rem;
    padding: 0 0.85rem;
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .header-container {
    padding: 0.65rem 0.85rem;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }

  .logo-group {
    gap: 0.6rem;
  }

  .lmu-badge {
    font-size: 1.05rem;
    padding: 0.25rem 0.55rem;
  }

  .logo-text h1 {
    font-size: 0.95rem;
    line-height: 1.15;
  }

  .logo-text p {
    font-size: 0.72rem;
  }

  .nav-link {
    font-size: 0.78rem;
    padding: 0.35rem 0.55rem;
  }

  /* Cards & Banner */
  .card, .question-card {
    padding: 1.15rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
  }

  .rule-banner {
    padding: 1.15rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
  }

  .rule-banner h2 {
    font-size: 1.15rem;
    gap: 0.4rem;
  }

  .rule-banner p {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  .topics-overview {
    padding: 0.85rem 0.9rem;
  }

  .topics-overview-title {
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
  }

  .topics-list {
    columns: 1;
    font-size: 0.84rem;
    line-height: 1.45;
    padding-left: 1.25rem;
  }

  .topics-list li {
    margin-bottom: 0.2rem;
  }

  /* Formular: Einspaltig auf Smartphones & kein iOS-Zoom */
  .form-row-2col {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-input, .form-select {
    font-size: 16px !important; /* Verhindert automatisches Hineinzoomen auf iPhones/iPads */
    padding: 0.75rem 0.85rem;
    border-radius: 8px;
  }

  .tab-container {
    gap: 0.5rem;
    margin-bottom: 1.25rem;
  }

  .tab-btn {
    padding: 0.65rem 0.5rem;
    font-size: 0.88rem;
  }

  /* Quiz Meta & Header */
  .quiz-header {
    padding: 0.85rem 0.9rem;
    margin-bottom: 1rem;
    border-radius: 10px;
  }

  .quiz-meta {
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }

  .category-tag {
    width: 100%;
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
  }

  #question-tracker {
    font-size: 0.88rem !important;
    text-align: center;
  }

  .score-tag {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    text-align: center;
    display: block;
  }

  /* Frage & Antwortkarten für Touchbedienung */
  .question-text {
    font-size: 1.08rem;
    line-height: 1.45;
    margin-bottom: 1.25rem;
    word-break: break-word;
  }

  .options-grid {
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .option-item {
    padding: 0.85rem 0.9rem;
    font-size: 0.95rem;
    gap: 0.75rem;
    border-radius: 8px;
    min-height: 52px; /* Ergonomische Touch-Trefferzone für Daumen (Apple HIG > 44px) */
    line-height: 1.35;
  }

  .option-item:active:not(.locked) {
    transform: scale(0.985);
  }

  .option-letter {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
    flex-shrink: 0;
  }

  .option-text {
    flex: 1;
    word-break: break-word;
  }

  /* Vollbreite Buttons für Daumen auf Smartphones */
  #action-area {
    justify-content: stretch !important;
    margin-top: 1rem;
  }

  #submit-answer-btn, #next-question-btn {
    width: 100% !important;
    padding: 0.85rem 1rem !important;
    font-size: 1.02rem !important;
    justify-content: center;
  }

  /* Didaktische Erklärungsbox */
  .explanation-box {
    padding: 1rem 0.85rem;
    margin-top: 1.25rem;
    border-radius: 8px;
  }

  .explanation-title {
    font-size: 0.95rem;
  }

  .explanation-text {
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
  }

  .timer-notice {
    flex-direction: column;
    gap: 0.4rem;
    text-align: center;
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Modale Dialoge */
  .modal-content {
    padding: 1.25rem 1rem;
    margin: 0.5rem;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 10px;
  }

  .modal-title {
    font-size: 1.15rem;
  }

  /* Zusammenfassung / Auswertung */
  #summary-view .card {
    padding: 1.5rem 1rem !important;
  }

  #summary-title {
    font-size: 1.35rem !important;
  }

  #summary-subtitle {
    font-size: 0.9rem !important;
  }

  #summary-result-box {
    padding: 1.15rem 1rem !important;
  }
}
