:root {
  --primary: #4338ca;
  --primary-light: #6366f1;
  --primary-bg: #eef2ff;
  --secondary: #0d9488;
  --amber: #f59e0b;
  --rose: #e11d48;
  --emerald: #10b981;
  --ink: #1e293b;
  --muted: #64748b;
  --border: #cbd5e1;
  --surface: #ffffff;
  --bg: #f8fafc;
  --parchment: #fdfbf7;
  --display-font: "Bricolage Grotesque", system-ui, sans-serif;
  --body-font: "Lexend", system-ui, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 14px 28px rgba(30, 41, 59, 0.12);
}

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

body {
  font-family: var(--body-font);
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 2px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.back-link {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  background: var(--primary-bg);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: all 0.2s;
}

.back-link:hover {
  background: #e0e7ff;
}

.logo-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.brand h1 {
  font-family: var(--display-font);
  font-size: 1.45rem;
  font-weight: 800;
  color: #1e1b4b;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-label {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.stat-val {
  font-weight: 800;
  color: var(--ink);
}

.ctrl-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  font-size: 1.1rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn:hover {
  background: #e2e8f0;
}

/* Main Container */
.main-container {
  max-width: 1060px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Mode Navigation Tabs */
.mode-tabs {
  display: flex;
  gap: 0.75rem;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: 999px;
  align-self: center;
  max-width: 100%;
  overflow-x: auto;
}

.mode-tab {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.mode-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Level Bar */
.level-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.level-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.level-buttons {
  display: flex;
  gap: 0.5rem;
}

.level-btn {
  font-family: var(--body-font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
}

.level-btn:hover {
  background: #f1f5f9;
}

.level-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Game Views */
.game-view {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeIn 0.3s ease;
}

.game-view.active {
  display: flex;
}

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

/* VIEW 1: STORY SEQUENCING */
.story-info-card {
  background: var(--parchment);
  border: 2px solid #e7dfd5;
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.story-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  margin-bottom: 0.5rem;
}

.story-title {
  font-family: var(--display-font);
  font-size: 1.6rem;
  font-weight: 800;
  color: #1e1b4b;
}

.story-prompt {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Sequence Timeline */
.sequence-timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 820px) {
  .sequence-timeline {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .sequence-timeline {
    grid-template-columns: 1fr;
  }
}

.timeline-slot {
  background: var(--surface);
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  transition: all 0.2s;
  position: relative;
}

.timeline-slot.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.timeline-slot.correct {
  border-color: var(--emerald);
  border-style: solid;
  background: #f0fdf4;
}

.timeline-slot.incorrect {
  border-color: var(--rose);
  border-style: solid;
  background: #fff1f2;
}

.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.4rem;
}

.slot-num {
  background: #334155;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.slot-target {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.slot-hint {
  font-size: 0.85rem;
  color: #94a3b8;
  font-style: italic;
  pointer-events: none;
}

/* Cards Pool */
.cards-pool-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 0.5rem;
}

.cards-pool {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  min-height: 110px;
  background: #f1f5f9;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.story-card-item {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.6rem;
}

.story-card-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.story-card-item:active {
  cursor: grabbing;
}

.card-num-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

.seq-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.action-btn {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.75rem 1.6rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.action-btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(67, 56, 202, 0.3);
}

.action-btn.primary:hover {
  background: #3730a3;
  transform: translateY(-2px);
}

.action-btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.action-btn.secondary:hover {
  background: #f1f5f9;
}

.action-btn.sm {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
}

/* VIEW 2: FACT VS OPINION */
.fo-prompt-box {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 2.2rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.fo-counter {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f1f5f9;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
}

.fo-statement-card {
  max-width: 800px;
}

.fo-statement-text {
  font-family: var(--display-font);
  font-size: clamp(1.25rem, 3.2vw, 1.8rem);
  font-weight: 700;
  line-height: 1.35;
  color: #1e1b4b;
}

.fo-bins {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .fo-bins {
    grid-template-columns: 1fr;
  }
}

.fo-bin {
  font-family: var(--body-font);
  border: 3px solid;
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.4rem;
  cursor: pointer;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}

.fact-bin {
  border-color: #0284c7;
}

.fact-bin:hover {
  background: #f0f9ff;
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(2, 132, 199, 0.2);
}

.opinion-bin {
  border-color: #d97706;
}

.opinion-bin:hover {
  background: #fffbeb;
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(217, 119, 6, 0.2);
}

.bin-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.bin-title {
  font-family: var(--display-font);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.fact-bin .bin-title {
  color: #0369a1;
}

.opinion-bin .bin-title {
  color: #b45309;
}

.bin-sub {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 280px;
}

.fo-explanation {
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  font-size: 0.95rem;
  line-height: 1.5;
  display: none;
  animation: fadeIn 0.3s;
}

.fo-explanation.show {
  display: block;
}

.fo-explanation.correct {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.fo-explanation.wrong {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

/* VIEW 3: READING DETECTIVE */
.comp-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
}

@media (max-width: 820px) {
  .comp-layout {
    grid-template-columns: 1fr;
  }
}

.passage-panel {
  background: var(--parchment);
  border: 2px solid #e7dfd5;
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  border-bottom: 2px solid #e7dfd5;
  padding-bottom: 0.8rem;
}

.panel-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #854d0e;
  background: #fef9c3;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 0.3rem;
}

.passage-title {
  font-family: var(--display-font);
  font-size: 1.4rem;
  font-weight: 800;
  color: #1e1b4b;
}

.passage-body {
  font-size: 0.96rem;
  line-height: 1.7;
  color: #334155;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.passage-body p {
  margin-bottom: 0.85rem;
}

.question-panel {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.comp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.skill-tag {
  background: #e0e7ff;
  color: #3730a3;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.comp-question {
  font-family: var(--display-font);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  color: #0f172a;
}

.comp-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.comp-opt-btn {
  font-family: var(--body-font);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  border: 2px solid #e2e8f0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.comp-opt-btn:hover {
  border-color: var(--primary-light);
  background: #f8fafc;
}

.comp-opt-btn.correct {
  border-color: var(--emerald);
  background: #f0fdf4;
  color: #166534;
  font-weight: 700;
}

.comp-opt-btn.wrong {
  border-color: var(--rose);
  background: #fff1f2;
  color: #9f1239;
}

.comp-feedback {
  font-size: 0.9rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  line-height: 1.45;
  display: none;
}

.comp-feedback.show {
  display: block;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 2.2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 0.8rem;
}

.modal-card h3 {
  font-family: var(--display-font);
  font-size: 1.6rem;
  font-weight: 800;
  color: #1e1b4b;
}

.modal-card p {
  color: var(--muted);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.modal-stars {
  font-size: 2rem;
  letter-spacing: 0.3rem;
  margin: 1rem 0 0.5rem;
}
