/* Word Alchemist - Stylesheet */
:root {
  --navy: #0f172a;
  --purple-magic: #7c3aed;
  --potion-green: #10b981;
  --potion-glow: #34d399;
  --amber: #f59e0b;
  --sky: #0ea5e9;
  --coral: #ef4444;
  --bg: #f5f3ff;
  --surface: #ffffff;
  --line: #e2e8f0;
  --muted: #64748b;
  --text: #1e293b;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Lexend', system-ui, sans-serif;
  --radius-lg: 20px;
  --radius-md: 12px;
  --shadow: 0 10px 25px -5px rgba(124, 58, 237, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  padding: 0.8rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.back-link {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  background: #ede9fe;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: all 0.2s;
}
.back-link:hover { color: var(--purple-magic); background: #ddd6fe; }
.logo-icon {
  font-size: 2rem;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: #5b21b6;
  line-height: 1.1;
}
.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Header Stats */
.header-stats {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.stat-pill {
  background: #ede9fe;
  border: 1px solid #ddd6fe;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stat-label { color: #5b21b6; font-weight: 600; }
.stat-val { color: #4c1d95; font-weight: 800; }
.ctrl-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.ctrl-btn:hover { background: #f8fafc; border-color: var(--muted); }

/* Main Container */
.main-container {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.2rem;
  width: 100%;
  flex: 1;
}

/* Mode Navigation Tabs */
.mode-tabs {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  background: #ede9fe;
  padding: 0.35rem;
  border-radius: 16px;
  overflow-x: auto;
}
.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 700;
  color: #6d28d9;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.mode-tab:hover { color: #4c1d95; }
.mode-tab.active {
  background: var(--surface);
  color: #5b21b6;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Views */
.game-view { display: none; }
.game-view.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.view-intro {
  margin-bottom: 1.5rem;
}
.view-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #6d28d9;
  background: #ede9fe;
  border: 1px solid #ddd6fe;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}
.view-intro h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--navy);
}
.view-intro p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* VIEW 1: ALCHEMIST WORKSPACE */
.alchemist-workspace {
  display: grid;
  grid-template-columns: 1fr 460px;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 950px) {
  .alchemist-workspace { grid-template-columns: 1fr; }
}

.ingredients-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.shelf-group {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 1.2rem;
}
.shelf-group:last-child { border-bottom: none; padding-bottom: 0; }
.shelf-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #5b21b6;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.shelf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.morpheme-chip {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}
.chip-prefix { background: #fee2e2; color: #991b1b; }
.chip-prefix:hover, .chip-prefix.active { border-color: #ef4444; background: #fecaca; }

.chip-root { background: #e0f2fe; color: #075985; }
.chip-root:hover, .chip-root.active { border-color: #0284c7; background: #bae6fd; }

.chip-suffix { background: #dcfce7; color: #166534; }
.chip-suffix:hover, .chip-suffix.active { border-color: #10b981; background: #bbf7d0; }

/* Cauldron Panel */
.cauldron-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.cauldron-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.active-formula-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.formula-slot {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}
.formula-plus { font-size: 1.2rem; font-weight: 800; color: #5b21b6; }
.slot-prefix.filled { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.slot-root.filled { background: #e0f2fe; border-color: #0284c7; color: #075985; }
.slot-suffix.filled { background: #dcfce7; border-color: #10b981; color: #166534; }

/* Bubbling Cauldron Animation */
.bubbling-cauldron-wrap {
  width: 160px;
  height: 120px;
  margin: 0 auto 1.5rem;
  position: relative;
}
.cauldron-pot {
  width: 140px;
  height: 95px;
  background: #1e1b4b;
  border-radius: 10px 10px 70px 70px;
  margin: 20px auto 0;
  position: relative;
  border: 4px solid #312e81;
  box-shadow: inset 0 -10px 20px rgba(0,0,0,0.5), 0 10px 20px rgba(76, 29, 149, 0.2);
  overflow: hidden;
}
.potion-liquid {
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  border-radius: 50% 50% 0 0;
  opacity: 0.9;
  filter: drop-shadow(0 0 10px #34d399);
}
.bubble {
  position: absolute;
  background: #a7f3d0;
  border-radius: 50%;
  animation: floatUp 2s infinite ease-in;
  opacity: 0.8;
}
.b1 { width: 14px; height: 14px; left: 30px; bottom: 10px; animation-delay: 0s; }
.b2 { width: 18px; height: 18px; left: 70px; bottom: 15px; animation-delay: 0.6s; }
.b3 { width: 12px; height: 12px; left: 105px; bottom: 8px; animation-delay: 1.2s; }
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  50% { opacity: 0.9; }
  100% { transform: translateY(-40px) scale(1.1); opacity: 0; }
}

.brew-btn {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.8rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}
.brew-btn:hover { background: #5b21b6; transform: translateY(-2px); }

/* Discovery Card */
.word-discovery-card {
  background: #fdf4ff;
  border: 2px solid #e879f9;
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow);
}
.discovery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.pos-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: #c026d3;
  background: #fae8ff;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  text-transform: uppercase;
}
#brewed-word-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: #581c87;
  letter-spacing: 0.04em;
}
.word-definition { font-size: 1rem; color: #701a75; line-height: 1.45; margin-bottom: 0.8rem; }
.etymology-breakdown {
  background: #fff;
  border: 1px solid #f0abfc;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.88rem;
  color: #86198f;
  margin-bottom: 1rem;
}
.example-sentence-box {
  background: rgba(255,255,255,0.6);
  border-left: 4px solid #d946ef;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
}
.ex-label { font-size: 0.72rem; font-weight: 800; color: #a21caf; text-transform: uppercase; }
#word-sentence { font-size: 0.88rem; color: #701a75; font-style: italic; margin-top: 0.2rem; }

/* VIEW 2: WORD DISSECTOR */
.dissector-arena { max-width: 780px; margin: 0 auto; }
.dissector-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.dissect-mission-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: #6d28d9;
  background: #ede9fe;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 0.8rem;
}
.dissect-target-word {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 800;
  color: #4c1d95;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.dissect-hint { font-size: 0.9rem; color: var(--muted); margin-bottom: 1.8rem; }

.dissect-buckets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (max-width: 650px) { .dissect-buckets-grid { grid-template-columns: 1fr; } }

.dissect-bucket {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 1rem;
}
.bucket-label { font-size: 0.78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; display: block; margin-bottom: 0.5rem; }
.bucket-drop-zone {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
  border-radius: 8px;
}

.morpheme-tiles-rack {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.morpheme-tile {
  background: #ede9fe;
  border: 2px solid #8b5cf6;
  color: #4c1d95;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.06);
  transition: all 0.2s;
}
.morpheme-tile:hover { transform: translateY(-2px); background: #ddd6fe; }

.target-feedback { font-size: 1rem; font-weight: 700; min-height: 24px; margin-top: 1rem; }
.action-btn {
  background: #5b21b6;
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.action-btn:hover { background: #4c1d95; }

/* VIEW 3: QUIZ */
.duel-wrap { max-width: 720px; margin: 0 auto; }
.duel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  box-shadow: var(--shadow);
}
.duel-header { display: flex; justify-content: space-between; margin-bottom: 1.2rem; }
.duel-badge { font-size: 0.8rem; font-weight: 800; color: #6d28d9; background: #ede9fe; padding: 0.25rem 0.7rem; border-radius: 999px; }
.duel-score { font-size: 0.88rem; font-weight: 700; color: var(--amber); }
.duel-question { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--navy); margin-bottom: 1.8rem; line-height: 1.35; }
.duel-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
@media (max-width: 600px) { .duel-options { grid-template-columns: 1fr; } }
.duel-btn {
  background: #f8fafc;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.duel-btn:hover { background: #f1f5f9; border-color: var(--navy); }
.duel-btn.correct { background: #ecfdf5; border-color: #10b981; color: #047857; }
.duel-btn.wrong { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.duel-feedback { text-align: center; font-size: 1.05rem; font-weight: 700; margin-top: 1.2rem; min-height: 28px; }
