/* ════════════════════ RESET & BASE ════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --green: #58CC02;
  --green-dark: #46A302;
  --green-bg: #E8F5E9;
  --blue: #1CB0F6;
  --blue-bg: #E3F2FD;
  --red: #FF4B4B;
  --red-bg: #FFF3F0;
  --gold: #FFC800;
  --gold-bg: #FFF8E1;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --max-w: 480px;
}

html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ════════════════════ TOP BAR ════════════════════ */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: white;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
}

.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.stat {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--green-bg);
  color: var(--green-dark);
  border-radius: 20px;
}
.stat.streak {
  background: var(--gold-bg);
  color: #B8860B;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.15s;
}
.icon-btn:active { background: #F0F0F0; }

/* ════════════════════ SETTINGS PANEL ════════════════════ */
.panel {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 200;
  overflow-y: auto;
  animation: slideIn 0.25s ease;
  max-width: var(--max-w);
  left: 50%;
  transform: translateX(-50%);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 18px; }

.panel-body {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.panel-body input,
.panel-body select {
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s;
}

.panel-body input:focus,
.panel-body select:focus {
  outline: none;
  border-color: var(--blue);
}

.hint {
  font-size: 13px;
  color: var(--text-secondary);
}
.hint a { color: var(--blue); }

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--green);
  color: white;
}
.btn-primary:active { background: var(--green-dark); }

.btn-secondary {
  background: var(--blue);
  color: white;
}

/* ════════════════════ MAIN AREA ════════════════════ */
#interaction-area {
  padding: 12px 0 80px;
  min-height: calc(100vh - 52px);
}

/* ════════════════════ LOADING ════════════════════ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════ INTERACTION CARDS ════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin: 12px 16px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s ease;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.badge {
  background: var(--green-bg);
  color: var(--green-dark);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.xp-badge {
  background: var(--gold-bg);
  color: #B8860B;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.question {
  font-size: 19px;
  line-height: 1.5;
  margin-bottom: 20px;
  font-weight: 500;
}

/* ── Multiple Choice ── */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: white;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.option-btn:active {
  transform: scale(0.98);
  border-color: var(--blue);
}

.option-btn.disabled {
  opacity: 0.6;
  cursor: default;
}
.option-btn.disabled:active { transform: none; }

.option-btn.selected { border-color: var(--blue); background: var(--blue-bg); }
.option-btn.correct { border-color: var(--green); background: var(--green-bg); }
.option-btn.wrong { border-color: var(--red); background: var(--red-bg); }

.option-letter {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Binary Choice ── */
.binary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.binary-btn {
  padding: 28px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  text-align: center;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  background: white;
}

.binary-btn:active { transform: scale(0.96); }
.binary-btn.disabled { opacity: 0.6; cursor: default; }
.binary-btn.disabled:active { transform: none; }

.binary-btn.a-btn { border-color: var(--blue); }
.binary-btn.a-btn.selected { background: var(--blue-bg); }
.binary-btn.b-btn { border-color: var(--gold); }
.binary-btn.b-btn.selected { background: var(--gold-bg); }
.binary-btn.correct { border-color: var(--green); background: var(--green-bg); }
.binary-btn.wrong { border-color: var(--red); background: var(--red-bg); }

/* ── Text Input ── */
.text-input-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-input-area textarea {
  width: 100%;
  min-height: 80px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.15s;
}

.text-input-area textarea:focus {
  outline: none;
  border-color: var(--blue);
}

/* ── Vocab Cards ── */
.vocab-card {
  text-align: center;
  padding: 32px 20px;
}

.vocab-word {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.vocab-pronunciation {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.vocab-translation {
  font-size: 20px;
  color: var(--blue);
  font-weight: 500;
  margin-bottom: 20px;
}

.vocab-example {
  font-size: 15px;
  color: var(--text-secondary);
  font-style: italic;
  padding: 14px;
  background: #F5F5F5;
  border-radius: 10px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.vocab-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: center;
}

.vocab-dots {
  display: flex;
  gap: 6px;
}

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

.vocab-dot.active { background: var(--green); }

/* ── Scene ── */
.scene-card {
  background: var(--card);
  border-radius: var(--radius);
  margin: 12px 16px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s ease;
  overflow: hidden;
}

.scene-header {
  padding: 16px 20px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.scene-context {
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
}

.scene-dialogue {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scene-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
}

.scene-bubble.npc {
  align-self: flex-start;
  background: #F0F0F0;
  border-bottom-left-radius: 4px;
}

.scene-bubble.user {
  align-self: flex-end;
  background: var(--blue-bg);
  border-bottom-right-radius: 4px;
}

.scene-hint {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  background: #F9FAFB;
  border-top: 1px solid var(--border);
}

.scene-input-area {
  padding: 12px 20px 20px;
  display: flex;
  gap: 8px;
}

.scene-input-area textarea {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
}

.scene-input-area textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.scene-send {
  padding: 0 18px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
}

/* ── Feedback ── */
.feedback-card {
  margin: 12px 16px;
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp 0.3s ease;
}

.feedback-card.correct { border: 2px solid var(--green); }
.feedback-card.incorrect { border: 2px solid var(--red); }

.feedback-inner {
  padding: 20px;
}

.feedback-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.feedback-card.correct .feedback-title { color: var(--green-dark); }
.feedback-card.incorrect .feedback-title { color: var(--red); }

.feedback-explanation {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.feedback-xp {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 16px;
}

.feedback-card.correct .feedback-bg { background: var(--green-bg); }
.feedback-card.incorrect .feedback-bg { background: var(--red-bg); }

/* ── Menu Grid ── */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.menu-card {
  padding: 24px 12px;
  text-align: center;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease;
  animation: fadeUp 0.3s ease;
}

.menu-card:active { transform: scale(0.96); }

.menu-icon { font-size: 36px; margin-bottom: 8px; }

.menu-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.menu-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ── Back Button ── */
.back-row {
  padding: 8px 16px 0;
}

.back-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

/* ── Submenu ── */
.submenu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.submenu-item {
  padding: 16px 20px;
  background: white;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, transform 0.1s;
}

.submenu-item:active {
  transform: scale(0.98);
  border-color: var(--blue);
}

/* ── Summary ── */
.summary-card {
  background: white;
  border-radius: var(--radius);
  margin: 12px 16px;
  padding: 28px 20px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s ease;
  text-align: center;
}

.summary-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 20px;
}

.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  text-align: center;
  padding: 16px;
  background: #F9FAFB;
  border-radius: 12px;
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.summary-section {
  text-align: left;
  margin-bottom: 16px;
}

.summary-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--green-bg);
  color: var(--green-dark);
  border-radius: 20px;
  font-size: 13px;
  margin: 2px 4px 2px 0;
}

.summary-tag.mistake {
  background: var(--red-bg);
  color: var(--red);
}

.summary-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ── Progress ── */
.progress-card {
  background: white;
  border-radius: var(--radius);
  margin: 12px 16px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s ease;
}

.progress-level-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.progress-level-badge {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

.progress-xp-bar {
  flex: 1;
}

.progress-xp-bar .bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-xp-bar .bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-xp-bar .bar-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Welcome Screen ── */
.welcome {
  text-align: center;
  padding: 48px 20px 24px;
}

.welcome h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.welcome p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.welcome .btn {
  margin-top: 8px;
}

/* ════════════════════ PROGRESS FOOTER ════════════════════ */
#progress-footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: var(--max-w);
  padding: 10px 16px 16px;
  background: white;
  border-top: 2px solid var(--border);
  z-index: 50;
}

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.4s ease;
}

#step-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ════════════════════ RESPONSIVE ════════════════════ */
@media (min-width: 481px) {
  body { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .panel { left: 50%; transform: translateX(-50%); }
  @keyframes slideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
}

@media (max-width: 360px) {
  .menu-grid { gap: 8px; }
  .menu-card { padding: 16px 8px; }
  .menu-icon { font-size: 28px; }
  .menu-title { font-size: 13px; }
}

/* ══ LESSON INTRO CARD ══ */
.lesson-intro-card {
  padding: 20px 16px;
  max-width: 600px;
  margin: 0 auto;
}

.intro-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.intro-explanation {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: #f8f9fa;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  border-left: 4px solid var(--green);
}

.intro-section {
  margin-bottom: 20px;
}

.intro-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.intro-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.intro-section li {
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: #f8f9fa;
  border-radius: 10px;
  color: var(--text-primary);
}

.correct-section li {
  border-left: 3px solid var(--green);
}

.incorrect-section li {
  border-left: 3px solid var(--red);
}

.start-lesson-btn {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  margin-top: 8px;
}
