@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
  /* Material Design Light Theme */
  --bg-color: #FAFAFA;
  --surface-color: #FFFFFF;
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.60);
  
  --primary-color: #1976D2; /* Blue 700 */
  --primary-hover: #1565C0; /* Blue 800 */
  --primary-light: #BBDEFB;
  
  --secondary-color: #03DAC6;
  --error-color: #B00020;
  --success-color: #388E3C;
  --warning-color: #F57C00;
  
  --divider-color: rgba(0, 0, 0, 0.12);
  --shadow-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-2: 0 0 15px rgba(25, 118, 210, 0.35);
  --shadow-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.dark-mode {
  --bg-color: #121212;
  --surface-color: #1E1E1E;
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.70);
  
  --primary-color: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-light: #1E3A8A;
  
  --divider-color: rgba(255, 255, 255, 0.12);
  --shadow-1: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-2: 0 0 15px rgba(59, 130, 246, 0.45);
}

.night-mode {
  --bg-color: #000000;
  --surface-color: #110000;
  --text-primary: #FF3333;
  --text-secondary: #CC0000;
  
  --primary-color: #AA0000;
  --primary-hover: #FF0000;
  --primary-light: #330000;
  
  --error-color: #FF5555;
  --success-color: #00FF00;
  --warning-color: #CC0000;
  
  --divider-color: #330000;
  --shadow-1: none;
  --shadow-2: 0 0 10px rgba(255, 0, 0, 0.2);
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 20px;
  max-width: 1000px;
  margin: 0 auto;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 24px;
}

h1 {
  font-size: 2rem;
  color: var(--primary-color);
}

/* Material Cards */
.hud-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.card, .hud-panel {
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow var(--transition-fast), background-color var(--transition-normal);
  border: 1px solid var(--divider-color);
  flex: 1;
  min-width: 300px;
}

.card:hover, .hud-panel:hover {
  box-shadow: var(--shadow-2);
}

.section-title {
  font-size: 0.85rem;
  color: var(--primary-color);
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 8px;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

/* Material Buttons */
button {
  background-color: var(--primary-color);
  color: #FFFFFF;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform 0.1s;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
  letter-spacing: 0.5px;
}

button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-2);
}

button:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-1);
}

.dark-mode button { color: #000; }
.night-mode button { color: #fff; }

.btn-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--divider-color);
  box-shadow: none;
}
.btn-secondary:hover {
  background-color: var(--primary-light);
  box-shadow: none;
}
.dark-mode .btn-secondary, .night-mode .btn-secondary { color: var(--text-primary); }

.btn-warning { background-color: var(--warning-color); color: #fff; }
.btn-warning:hover { background-color: #E65100; }

.btn-danger { background-color: var(--error-color); color: #fff; }
.btn-danger:hover { background-color: #D32F2F; }

/* Grid Layouts */
.btn-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.btn-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }

/* Toggles */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider-color);
  font-weight: 500;
}

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider-round {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--divider-color); transition: .3s; border-radius: 24px;
}
.slider-round:before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: white; transition: .3s; border-radius: 50%; box-shadow: var(--shadow-1);
}
input:checked + .slider-round { background-color: var(--primary-color); }
input:checked + .slider-round:before { transform: translateX(20px); }

/* Topic Selection */
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.topic-label {
  display: flex; align-items: center; gap: 10px; font-size: 0.85rem; cursor: pointer;
  background: var(--surface-color); padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--divider-color); transition: background-color var(--transition-fast);
}
.topic-label:hover { background-color: var(--primary-light); }

/* Inputs & Textareas */
input[type="text"], textarea {
  width: 100%; padding: 14px; margin-bottom: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--divider-color); font-family: 'Roboto', monospace;
  font-size: 1rem; box-sizing: border-box; background: var(--surface-color);
  color: var(--text-primary); transition: border-color var(--transition-fast);
}
input[type="text"]:focus, textarea:focus {
  outline: none; border-color: var(--primary-color); border-width: 2px; padding: 13px;
}

/* Stats */
.stats-container { display: flex; flex-direction: column; gap: 16px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-color); padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--divider-color); font-weight: 500;
}
.stat-val { font-size: 1.25rem; font-weight: 700; color: var(--primary-color); }

/* Progress Bar */
.progress-container {
  width: 100%; background-color: var(--divider-color);
  border-radius: var(--radius-sm); height: 8px; margin-bottom: 24px; overflow: hidden;
}
.progress-bar {
  height: 100%; background-color: var(--primary-color);
  transition: width 0.4s ease-in-out; border-radius: var(--radius-sm);
}

.sector-bar { width: 100%; background: var(--divider-color); height: 8px; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.sector-fill { height: 100%; transition: width 0.5s ease-out; }

/* Quiz Interface */
#quiz-header {
  display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 16px;
  font-size: 0.95rem; align-items: center; color: var(--text-secondary);
}
.question-topic { font-size: 0.8rem; color: var(--primary-color); font-weight: 700; text-transform: uppercase; margin-bottom: 12px; letter-spacing: 1px; }
.question-text { font-size: 1.2rem; font-weight: 500; margin-bottom: 32px; white-space: pre-wrap; line-height: 1.5; color: var(--text-primary); }

.choice {
  display: flex; align-items: center; background: var(--surface-color);
  border: 1px solid var(--divider-color); padding: 16px 20px; margin-bottom: 12px;
  border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition-fast);
  font-size: 1.05rem; color: var(--text-primary); position: relative; overflow: hidden;
}
.choice:hover:not(.locked) {
  background: var(--primary-light);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-1);
}
.key-hint {
  background: var(--divider-color); color: var(--text-secondary); border-radius: 4px;
  padding: 4px 10px; font-size: 0.85rem; margin-right: 16px; font-weight: 700;
}

.correct { background: rgba(56, 142, 60, 0.1) !important; border-color: var(--success-color) !important; color: var(--success-color) !important; font-weight: 700; }
.incorrect { background: rgba(176, 0, 32, 0.1) !important; border-color: var(--error-color) !important; color: var(--error-color) !important; }
.selected { background: var(--primary-light) !important; border-color: var(--primary-color) !important; }
.locked { cursor: default; }

/* Flashcard Flip Mode */
.flashcard-overlay {
  position: absolute; inset: 0; z-index: 10; cursor: pointer;
  display: flex; justify-content: center; align-items: center;
  background: var(--surface-color); border: 2px dashed var(--primary-color);
  border-radius: var(--radius-sm); transition: opacity 0.3s, visibility 0.3s;
}
.flashcard-content {
  background: var(--primary-color); color: white; padding: 10px 20px;
  border-radius: 20px; font-weight: 700; text-transform: uppercase;
  box-shadow: var(--shadow-1);
}

/* Hint Drawer */
.hint-drawer {
  background-color: rgba(245, 124, 0, 0.05); border-left: 4px solid var(--warning-color);
  padding: 16px; margin-top: 24px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: none; animation: slideDown 0.3s ease-out forwards;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.btn-hint-trigger {
  background-color: transparent; border: 1px dashed var(--warning-color);
  color: var(--warning-color); padding: 10px 16px; font-size: 0.85rem;
  margin-top: 16px; margin-bottom: 8px; width: 100%; text-align: left;
  transition: all var(--transition-fast); display: flex; align-items: center; gap: 8px;
  box-shadow: none;
}
.btn-hint-trigger:hover {
  background-color: rgba(245, 124, 0, 0.1); box-shadow: none;
}

/* Badges */
.level-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.lvl-bronze { background: #cd7f32; color: white; }
.lvl-silver { background: #9E9E9E; color: white; }
.lvl-gold { background: #FFC107; color: #000; }

.nav-buttons { display: flex; gap: 16px; margin-top: 32px; }
.hidden { display: none !important; }

/* Details & Summaries (References) */
details {
  background: var(--surface-color); border: 1px solid var(--divider-color);
  border-radius: var(--radius-sm); margin-bottom: 12px; padding: 12px 16px;
  transition: all var(--transition-fast); box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
details[open] { box-shadow: var(--shadow-1); padding-bottom: 16px; }
summary {
  font-weight: 700; font-size: 0.95rem; cursor: pointer; color: var(--text-primary);
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  text-transform: uppercase;
}
summary::-webkit-details-marker { display: none; }
summary:after { content: "▼"; color: var(--primary-color); font-size: 0.8rem; transition: transform 0.3s; }
details[open] summary:after { transform: rotate(180deg); }
.ref-content { margin-top: 16px; font-size: 0.95rem; line-height: 1.6; border-top: 1px solid var(--divider-color); padding-top: 12px; color: var(--text-secondary); }

/* Animation Utils */
.slide-in-right { animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Modal */
#welcome-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex;
  justify-content: center; align-items: center; z-index: 1000; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--surface-color); padding: 32px; border-radius: var(--radius-md);
  max-width: 500px; border: none; box-shadow: var(--shadow-3);
}

mark { background-color: rgba(255, 235, 59, 0.6); color: inherit; padding: 2px 4px; border-radius: 2px; }
.dark-mode mark { background-color: rgba(255, 192, 45, 0.4); }

/* Mobile Layout Overrides */
@media (max-width: 768px) {
  #menu-screen {
    flex-direction: column-reverse;
  }
}
