/* ==========================================================================
   병의원 CTO & FDE 역방향 시각 퀴즈 - Dark Slate/Navy Theme (Mobile-First)
   ========================================================================== */

:root {
  --bg-base: #0a0f1c;
  --bg-surface: #111827;
  --bg-card: #182235;
  --bg-elevated: #1f2d45;
  --border-subtle: #2a3a54;
  --border-strong: #3b5073;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-cyan: #38bdf8;
  --accent-cyan-soft: rgba(56, 189, 248, 0.14);
  --accent-indigo: #818cf8;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.14);
  --success-border: rgba(16, 185, 129, 0.55);

  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.14);
  --danger-border: rgba(244, 63, 94, 0.55);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition-fast: 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
    'Noto Sans KR', 'Segoe UI', Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 14px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--bg-card) 0%, #131c2e 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-badge {
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.app-header h1 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.subtitle {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Control Panel: Filters & Mode */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.chip:active {
  transform: scale(0.96);
}

.chip.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #061224;
}

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-mode {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-mode:hover {
  border-color: var(--warning);
  color: var(--text-primary);
}

.btn-mode[aria-pressed='true'] {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: #fde68a;
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.btn-mode[aria-pressed='true'] .mode-dot {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.badge-count {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.btn-ghost {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* HUD Panel */
.hud-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-value.streak {
  color: #fbbf24;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-indigo));
  border-radius: 999px;
  transition: width 260ms ease;
}

/* Quiz Card */
.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.track-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: var(--accent-cyan-soft);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
}

.persona-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.persona-director {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.35);
}

.persona-it {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.35);
}

.persona-crisis {
  background: rgba(244, 63, 94, 0.16);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
}

.persona-cto {
  background: rgba(167, 139, 250, 0.16);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.35);
}

.question-id {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.question-text {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text-primary);
  word-break: keep-all;
}

/* Options List */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.48;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast),
    transform var(--transition-fast);
  word-break: keep-all;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  background: var(--bg-elevated);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.option-btn:disabled {
  cursor: default;
}

.option-index {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.option-label {
  flex: 1;
}

/* Feedback States */
.option-btn.correct {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: #ecfdf5;
}

.option-btn.correct .option-index {
  background: var(--success);
  border-color: var(--success);
  color: #052e16;
}

.option-btn.wrong {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #fff1f2;
}

.option-btn.wrong .option-index {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.option-btn.dimmed {
  opacity: 0.55;
}

/* Visual Explanation Card */
.explanation-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideUpFade 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
}

.result-banner.is-correct {
  background: var(--success-bg);
  color: #6ee7b7;
  border: 1px solid var(--success-border);
}

.result-banner.is-wrong {
  background: var(--danger-bg);
  color: #fda4af;
  border: 1px solid var(--danger-border);
}

/* SVG Diagram Container */
.svg-stage {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  overflow: hidden;
}

.svg-stage svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* 3 Concise Takeaways */
.insight-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.insight-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.insight-body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: keep-all;
}

.cto-box {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(129, 140, 248, 0.14));
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.cto-box .insight-title {
  color: #7dd3fc;
}

.cto-box .insight-body {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.92rem;
}

/* Primary Action Button */
.btn-primary {
  appearance: none;
  width: 100%;
  background: var(--accent-cyan);
  color: #061224;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary:active {
  transform: scale(0.985);
}

/* Summary / Empty States */
.state-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.state-card h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.state-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 460px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin: 6px 0;
}

.summary-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-pill strong {
  font-size: 1.1rem;
  color: var(--accent-cyan);
}

.summary-pill span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.state-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.btn-secondary {
  appearance: none;
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-elevated);
}

.loading-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Footer */
.app-footer {
  text-align: center;
  padding-top: 4px;
}

.app-footer p {
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Focus Accessibility */
button:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* Tablet / Desktop Enhancements */
@media (min-width: 600px) {
  .app-shell {
    padding: 24px 20px 44px;
    gap: 16px;
  }

  .app-header {
    padding: 18px 22px;
  }

  .app-header h1 {
    font-size: 1.32rem;
  }

  .quiz-card,
  .explanation-card {
    padding: 22px;
  }

  .question-text {
    font-size: 1.1rem;
  }

  .state-actions {
    flex-direction: row;
  }
}
