:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --border: #e5e5e5;
  --border-active: #58cc02;
  --text: #3c3c3c;
  --text-muted: #777;
  --success: #58cc02;
  --success-light: #d7ffb8;
  --danger: #ff4b4b;
  --danger-light: #ffebeb;
  --primary: #1cb0f6;
  --primary-hover: #1899d6;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius-sm: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg);
}

/* Top Bar */
.top-bar {
  background: var(--surface);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.progress-track {
  height: 16px;
  background: #e5e5e5;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 8px;
  transition: width 0.3s ease;
  width: 0%;
}
.top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}
.counter { color: var(--text-muted); }
.mode-badge {
  background: var(--success-light);
  color: var(--success);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

/* Question Card */
.question-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}
.question-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.4;
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 2px 0 #e5e5e5;
}
.option:active { transform: translateY(2px); box-shadow: none; }
.option .opt-letter {
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Option states */
.option.correct {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
  box-shadow: 0 2px 0 #58cc02;
}
.option.correct .opt-letter { background: var(--success); color: #fff; }

.option.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
  box-shadow: 0 2px 0 #ff4b4b;
}
.option.wrong .opt-letter { background: var(--danger); color: #fff; }

.option.selected {
  border-color: var(--primary);
  background: #e8f7fe;
  box-shadow: 0 2px 0 var(--primary);
}
.option.selected .opt-letter { background: var(--primary); color: #fff; }

.option.disabled { pointer-events: none; }

/* Animations */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.shake { animation: shake 0.4s ease; }
.pop { animation: pop 0.3s ease; }
.slide-up { animation: slideUp 0.3s ease; }

/* Feedback Panel */
.feedback-panel {
  padding: 0 16px;
  display: none;
}
.feedback-panel.show {
  display: block;
  animation: slideUp 0.3s ease;
}
.feedback-box {
  border-radius: var(--radius-lg);
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
}
.feedback-box.correct {
  background: var(--success-light);
  color: var(--success);
  border: 2px solid var(--success);
}
.feedback-box.wrong {
  background: var(--danger-light);
  color: var(--danger);
  border: 2px solid var(--danger);
}

/* Bottom Action */
.bottom-action {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.action-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--border);
  color: #aaa;
  box-shadow: 0 4px 0 #d0d0d0;
}
.action-btn:active { transform: translateY(4px); box-shadow: none; }
.action-btn.active {
  background: var(--success);
  color: #fff;
  box-shadow: 0 4px 0 #48a002;
}
.action-btn.active.wrong-state {
  background: var(--danger);
  box-shadow: 0 4px 0 #d43a3a;
}

/* Bottom Nav */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}
.nav-btn .nav-icon { font-size: 22px; }
.nav-btn.active { color: var(--success); }

/* Study mode: show correct immediately */
#studyMode .option.correct { animation: pop 0.3s ease; }

/* Test stats overlay */
.test-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.stat-pill {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
}
.stat-pill.good { border-color: var(--success); color: var(--success); background: var(--success-light); }
.stat-pill.bad { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }

/* Swipe hint */
.swipe-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Scrollbar hide */
.content::-webkit-scrollbar { display: none; }
.content { scrollbar-width: none; }

/* Desktop: center and limit width */
@media (min-width: 601px) {
  body { background: #e8e8e8; }
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
