/* ============================================================
   CSS VARIABLES — change these to restyle the entire app
   ============================================================ */
:root {
  --color-bg: #f0f4ff;
  --color-surface: #ffffff;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-secondary: #0ea5e9;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-chip: #ede9fe;
  --color-chip-text: #4f46e5;
  --color-chip-active: #4f46e5;
  --color-chip-active-text: #ffffff;
   
  --color-mode-chip: #e0f2fe;
  --color-mode-chip-text: #0369a1;
  --color-mode-chip-active: var(--color-secondary);
  --color-mode-chip-active-text: #ffffff;

  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);

  --transition: 0.15s ease;
}

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

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

body.teacher-lock-active {
  background: var(--color-primary);
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1rem;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: 0.5rem; }

.login-card h1 {
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: 1.5rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card input {
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  transition: border-color var(--transition);
  outline: none;
}

.login-card input:focus { border-color: var(--color-primary); }

.loading-msg {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: 1rem;
}

.error-msg {
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  margin-top: 0.25rem;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar-left { display: flex; align-items: center; gap: 0.5rem; }
.logo-small { font-size: 1.5rem; }
.welcome-name { font-weight: 600; color: var(--color-primary); }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.practice-main {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-size: var(--font-size-lg);
  margin-bottom: 1.25rem;
  color: var(--color-text);
}

/* ============================================================
   FILTER PANEL
   ============================================================ */
.filter-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-group label {
  display: block;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 2rem;
  align-items: center;
}

.set-chip-group {
  max-height: 180px;
  overflow-y: auto;
  padding: 0.25rem;
  border-radius: var(--radius-md);
}

/* ============================================================
   MY STUDY SETS
   ============================================================ */

.my-study-sets-group {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.my-study-set-chips {
  max-height: 180px;
  overflow-y: auto;
  padding: 0.25rem;
  border-radius: var(--radius-md);
}

.my-study-set-chip {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  background: #dcfce7;
  color: #15803d;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  user-select: none;
}

.my-study-set-chip:hover {
  border-color: var(--color-success);
  background: #bbf7d0;
}

.my-study-set-chip.active {
  background: var(--color-success);
  color: #ffffff;
  border-color: var(--color-success);
}

.chip {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  background: var(--color-chip);
  color: var(--color-chip-text);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  user-select: none;
}

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

.chip.active {
  background: var(--color-chip-active);
  color: var(--color-chip-active-text);
  border-color: var(--color-chip-active);
}

.filter-hint {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

.filter-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.filter-footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.card-count-preview {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.card-count-preview.has-cards { color: var(--color-success); font-weight: 600; }

.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.25rem 0;
}

/* ============================================================
   PRACTICE PANEL
   ============================================================ */
.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#practiceModeTitle {
  margin: 0 0 0.3rem;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--color-text);
}

.practice-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.set-label {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--color-primary);
}

.progress-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
}

.prompt-card {
  background: linear-gradient(135deg, #667eea22, #764ba222);
  border: 2px solid #667eea44;
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.prompt-text {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.response-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--color-border);
}

.response-display.correct { border-top-color: var(--color-success); }
.response-display.hinted  { border-top-color: var(--color-warning); }
.response-display.incorrect { border-top-color: var(--color-danger); }

.response-icon {
  font-size: var(--font-size-xl);
  font-weight: 700;
  flex-shrink: 0;
}

.response-text {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.response-display.correct .response-icon,
.response-display.correct .response-text { color: var(--color-success); }

.response-display.hinted .response-icon,
.response-display.hinted .response-text  { color: var(--color-warning); }

.response-display.incorrect .response-icon,
.response-display.incorrect .response-text { color: var(--color-danger); }

.correct-answer-display {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  margin-top: 0.4rem;
}

.correct-answer-display::before { content: '→ '; }


.answer-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.answer-area input {
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-lg);
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
}

.answer-area input:focus { border-color: var(--color-primary); }

.accent-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
}

.legend-label {
  font-weight: 600;
  margin-right: 0.25rem;
}

.accent-legend span:not(.legend-label) {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.4rem;
  font-family: monospace;
  font-size: var(--font-size-sm);
}

.answer-actions { display: flex; gap: 0.75rem; }

.feedback-text {
  font-weight: 600;
  font-size: var(--font-size-base);
  min-height: 1.4em;
}

.feedback-text.correct { color: var(--color-success); }
.feedback-text.incorrect { color: var(--color-danger); }
.feedback-text.hinted { color: var(--color-warning); }
.feedback-text.revealed { color: var(--color-secondary); }

.hint-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  min-height: 1.2em;
}

.practice-controls { border-top: 1px solid var(--color-border); padding-top: 1rem; }

.stats-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.stat {
  font-size: var(--font-size-sm);
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--color-bg);
}

.stat.correct { color: var(--color-success); }
.stat.incorrect { color: var(--color-danger); }
.stat.hinted { color: var(--color-warning); }
.stat.total { color: var(--color-text-muted); }

.end-practice-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.mode-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.mode-row select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
}

.mode-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mode-chip {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  background: var(--color-mode-chip);
  color: var(--color-mode-chip-text);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  user-select: none;
}

.mode-chip:hover {
  border-color: var(--color-secondary);
}

.mode-chip.active {
  background: var(--color-mode-chip-active);
  color: var(--color-mode-chip-active-text);
  border-color: var(--color-mode-chip-active);
}

.session-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.session-chip {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  background: #fee2e2;
  color: #dc2626;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  user-select: none;
}

.session-chip:hover {
  border-color: #ef4444;
}

.session-chip.active {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* ============================================================
   STUDY SET PANEL
   ============================================================ */

#studySetContainer {
  margin-top: 1rem;
}

.study-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.1rem;
}

.study-table th {
  background: #ef4444;
  color: #fff;
  padding: 0.9rem 1rem;
  text-align: left;
  font-weight: 700;
}

.study-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.study-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.study-table tbody tr:hover {
  background: #fef2f2;
}

.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  text-decoration: underline;
}

#backFromStudySet {
  position: fixed;
  bottom: 70px; /* space above footer */
  right: 1.5rem;
  z-index: 1000;
}

.study-tts-btn {
  margin-left: 0.4rem;
  padding: 0.15rem 0.3rem;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0.7;
  vertical-align: middle;
}

.study-tts-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.study-tts-btn:active {
  transform: scale(0.95);
}

.study-set-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.study-set-control-btn,
.study-set-practice-btn,
.study-set-copy-btn {
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}

/* Select All / Clear All */

.study-set-control-btn {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

.study-set-control-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Practice Selected */

.study-set-practice-btn {
  background: var(--color-primary);
  color: #ffffff;
}

.study-set-practice-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

/* Copy Selected */

.study-set-copy-btn {
  background: var(--color-secondary);
  color: #ffffff;
}

.study-set-copy-btn:hover:not(:disabled) {
  filter: brightness(0.9);
}

/* Disabled buttons */

.study-set-practice-btn:disabled,
.study-set-copy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================================
   CONVERSATION PRACTICE ENTRY
   ============================================================ */

.conversation-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: var(--radius-md);
}

.conversation-entry-text h3 {
  color: #15803d;
  font-size: var(--font-size-lg);
  margin-bottom: 0.3rem;
}

.conversation-entry-text p {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.conversation-entry-btn {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  border: 2px solid #22c55e;
  border-radius: var(--radius-md);
  background: #22c55e;
  color: white;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.conversation-entry-btn:hover {
  background: #16a34a;
  border-color: #16a34a;
}

/* ============================================================
   CONVERSATION LEVEL COLORS
   ============================================================ */

.conversation-level-0 {
  border-left: 6px solid #94a3b8;
}

.conversation-level-1 {
  border-left: 6px solid #22c55e;
}

.conversation-level-2 {
  border-left: 6px solid #eab308;
}

.conversation-level-3 {
  border-left: 6px solid #f97316;
}

.conversation-level-4 {
  border-left: 6px solid #ef4444;
}

.conversation-level-5 {
  border-left: 6px solid #8b5cf6;
}

/* ============================================================
   CONVERSATION SELECTION CARDS
   ============================================================ */

#conversationList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.conversation-list-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  overflow: hidden;

  border: 2px solid transparent;
  border-left-width: 7px;
  border-radius: var(--radius-md);

  text-align: left;
  font-family: var(--font-family);
  color: var(--color-text);

  cursor: pointer;
  box-shadow: none;

  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition);
}

.conversation-list-card:hover {
  transform: translateY(-1px);
}

.conversation-list-card:active {
  transform: translateY(0);
}

.conversation-list-content {
  padding: 0.7rem 0.9rem;
}

.conversation-list-meta {
  margin-bottom: 0.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conversation-list-content h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* ============================================================
   CONVERSATION LEVEL COLORS
   ============================================================ */

/* 0 = Grey */
.conversation-level-0 {
  background: #f1f5f9;
  border-left-color: #64748b;
}

.conversation-level-0:hover {
  border-color: #64748b;
}

/* 1 = Orange */
.conversation-level-1 {
  background: #ffedd5;
  border-left-color: #f97316;
}

.conversation-level-1:hover {
  border-color: #f97316;
}

/* 2 = Red */
.conversation-level-2 {
  background: #fee2e2;
  border-left-color: #ef4444;
}

.conversation-level-2:hover {
  border-color: #ef4444;
}

/* 3 = Green */
.conversation-level-3 {
  background: #dcfce7;
  border-left-color: #22c55e;
}

.conversation-level-3:hover {
  border-color: #22c55e;
}

/* 4 = Purple */
.conversation-level-4 {
  background: #ede9fe;
  border-left-color: #8b5cf6;
}

.conversation-level-4:hover {
  border-color: #8b5cf6;
}

/* 5 = Blue */
.conversation-level-5 {
  background: #dbeafe;
  border-left-color: #3b82f6;
}

.conversation-level-5:hover {
  border-color: #3b82f6;
}

/* ============================================================
   RESULTS PANEL
   ============================================================ */
/* ============================================================
   RESULTS / CELEBRATION
   ============================================================ */
#nachoConfetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 500;
}

#giantTaco {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16rem;
  z-index: 600;
  pointer-events: none;
}

#giantTaco.taco-drop {
  animation: tacoDrop 2s ease-out forwards,
             tacoDance 1s ease-in-out infinite;
  animation-delay: 0s, 2s;
}

@keyframes tacoDrop {
  0% {
    top: -200px;
    transform: translateX(-50%) rotate(0deg) scale(0.5);
  }

  55% {
    top: 40%;
    transform: translateX(-50%) rotate(360deg) scale(1.2);
  }

  65% {
    top: 35%;
    transform: translateX(-50%) rotate(390deg) scale(1.2);
  }

  75% {
    top: 40%;
    transform: translateX(-50%) rotate(360deg) scale(1.2);
  }

  85% {
    top: 38%;
    transform: translateX(-50%) rotate(375deg) scale(1.2);
  }

  100% {
    top: 40%;
    transform: translateX(-50%) rotate(360deg) scale(1);
  }
}

@keyframes tacoDance {
  0%, 100% {
    transform: translateX(-50%) rotate(360deg) scale(1);
  }

  25% {
    transform: translateX(-52%) rotate(370deg) scale(1.05);
  }

  50% {
    transform: translateX(-48%) rotate(350deg) scale(1);
  }

  75% {
    transform: translateX(-52%) rotate(370deg) scale(1.05);
  }
}

.nacho-piece {
  position: absolute;
  top: -60px;
  font-size: 2rem;
  animation: nachoFall linear forwards;
}

@keyframes nachoFall {
  from {
    transform: translateY(0) rotate(0deg);
  }

  to {
    transform: translateY(110vh) rotate(720deg);
  }
}

.celebration-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.celebration-icon {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.celebration-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.celebration-message {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  font-style: italic;
}

.nacho-counter-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
}

.nacho-counter-label {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: #92400e;
}

.nacho-count {
  font-weight: 800;
  font-size: var(--font-size-lg);
  color: #92400e;
}

.results-summary {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.7;
  word-break: break-word;
}

.results-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ============================================================
   HISTORY PANEL
   ============================================================ */
.history-panel { margin-top: 0; }

.history-toggle {
  width: 100%;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.history-notice {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.attempt-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.attempt-list li {
  font-size: var(--font-size-sm);
  padding: 0.6rem 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  border-left: 3px solid var(--color-primary);
}

.attempt-list .no-history {
  color: var(--color-text-muted);
  border-left-color: var(--color-border);
  font-style: italic;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }

.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { filter: brightness(0.9); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 2px solid var(--color-border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--color-text-muted); color: var(--color-text); }

#teacherModeBtn {
  position: fixed;
  bottom: 70px;
  left: 1rem;
  z-index: 1000;
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  opacity: 0.7;
}

#teacherModeBtn:hover {
  opacity: 1;
}

.multiple-choice-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}

.multiple-choice-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
}

.multiple-choice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* ============================================================
   MANAGE STUDY SETS
   ============================================================ */

.manage-study-sets-btn {
  margin-top: 0.75rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.manage-study-sets-btn:hover {
  border-color: var(--color-success);
  color: var(--color-success);
}

.manage-study-sets-box {
  max-width: 500px;
}

.manage-study-set-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.manage-study-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.manage-study-set-name {
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.manage-study-set-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.manage-study-set-actions button {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.manage-rename-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.manage-delete-btn:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ============================================================
   NACHO BUILDER INTRO
   ============================================================ */

.mode-intro {
  text-align: center;
  margin-bottom: 1.5rem;
}

.mode-intro h2 {
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.mode-intro p {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.how-to-play {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--color-border);
}

.how-to-play summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--color-primary);
}

.how-to-play div {
  margin-top: 0.75rem;
}

.how-to-play p {
  margin-bottom: 0.75rem;
  color: var(--color-text);
  font-size: var(--font-size-sm);
}

/* ============================================================
   NACHO BUILDER GAME LAYOUT
   ============================================================ */

.nacho-builder-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
}

/* Bowl progress */
.nacho-bowl-progress {
  text-align: center;
  min-height: 5rem;
}

.nacho-bowl-emoji {
  width: 100%;
  text-align: center;
  font-size: clamp(1.75rem, 7vw, 3.5rem);
  line-height: 1.2;
  white-space: nowrap;
}

.nacho-bowl-label {
  margin-top: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Hidden word */
.nacho-word-display {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.4rem;
  text-align: center;
  color: var(--color-primary);
}

/* Guessed letters area */
.nacho-guesses {
  text-align: center;
}

.nacho-guesses h3 {
  margin-bottom: 0.5rem;
}

#nachoBackBtn {
  position: fixed;
  bottom: 70px;
  right: 1.5rem;
  z-index: 1000;
}

.nacho-practice-sets {
  width: min(100%, 600px);
  margin: 0.75rem auto 1rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.nacho-practice-sets strong {
  color: var(--color-text);
}

/* ============================================================
   NACHO BUILDER KEYBOARD
   ============================================================ */

.nacho-keyboard {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 560px;
}

.nacho-letter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  width: 100%;
  height: 55px;

  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);

  background: var(--color-surface);
  color: var(--color-text);

  cursor: pointer;
  font-family: var(--font-family);

  transition: all var(--transition);
}

.nacho-letter-btn strong {
  font-size: 1.2rem;
}

.nacho-letter-btn span {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.nacho-letter-btn.correct {
  background: #d4edda;
  border-color: #28a745;
}

.nacho-letter-btn.wrong {
  background: #f8d7da;
  border-color: #dc3545;
}

.nacho-game-message {
  margin: 0.5rem 0 1.5rem;
  padding: 1rem;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  border-radius: var(--radius-md);
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.dialog-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.dialog-box h3 { font-size: var(--font-size-lg); margin-bottom: 0.75rem; }
.dialog-box p { color: var(--color-text-muted); margin-bottom: 1.5rem; font-size: var(--font-size-sm); }
.dialog-actions { display: flex; gap: 0.75rem; }

.nacho-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-top: 2px solid #f59e0b;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: var(--font-size-sm);
  color: #92400e;
  z-index: 100;
}

.footer-left {
  display: flex;
  align-items: center;
}

.bored-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#boredDisplay {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
}

#boredEmoji {
  font-size: 2rem;
}

#boredWord {
  font-size: var(--font-size-xl);
}

.footer-nacho-count {
  font-weight: 800;
  font-size: var(--font-size-base);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .practice-main { padding: 1rem 0.75rem 2rem; }
  .panel { padding: 1.25rem 1rem; }
  .prompt-text { font-size: var(--font-size-xl); }
  .answer-actions { flex-direction: column; }
  .filter-footer { flex-direction: column; align-items: flex-start; }

@media (max-width: 480px) {
  .conversation-entry {
    flex-direction: column;
    text-align: center;
  }

  .conversation-entry-btn {
    width: 100%;
  }
}
   
  .nacho-keyboard {
    gap: 0.25rem;
  }

  .nacho-letter-btn {
    height: 48px;
    border-width: 1px;
    border-radius: var(--radius-sm);
  }

  .nacho-letter-btn strong {
    font-size: 0.9rem;
  }

  .nacho-letter-btn span {
    font-size: 0.45rem;
    margin-top: 0.1rem;
  }

  .nacho-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .footer-left {
    justify-content: center;
  }

  .bored-area {
    margin-left: 0;
    justify-content: center;
  }

  #boredEmoji {
    font-size: 1.75rem;
  }

  #boredWord {
    font-size: var(--font-size-lg);
  }
}

/* ============================================================
   TEACHER SETTINGS DIALOG
   ============================================================ */

.teacher-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.teacher-box {
  background: var(--color-surface);
  border-radius: var(--color-radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.teacher-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.toggle-on,
.toggle-off {
  min-width: 60px;
}

.toggle-on {
  background: var(--color-success);
  color: white;
}

.toggle-off {
  background: var(--color-border);
  color: var(--color-text-muted);
}

/* ============================================================
   CONVERSATION MODE
   ============================================================ */

.conversation-scene {
  text-align: center;
  margin-bottom: 25px;
}

.conversation-scene-image {
  display: block;
  max-width: 100%;
  max-height: 300px;
  margin: 0 auto 15px;
  border-radius: 12px;
}

.conversation-scene-text {
  font-size: 1.1rem;
  line-height: 1.6;
}

.conversation-teacher-area {
  text-align: center;
  margin: 25px auto;
  max-width: 700px;
}

.conversation-teacher-label {
  font-weight: bold;
  margin-bottom: 8px;
}

.conversation-prompt {
  font-size: 1.4rem;
  line-height: 1.5;
  margin: 10px 0 15px;
}

.conversation-answer-area,
.conversation-choices,
.conversation-writing,
.conversation-speaking {
  max-width: 700px;
  margin: 20px auto;
  text-align: center;
}

.conversation-answer-area {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.conversation-choices {
  display: grid;
  gap: 10px;
}

.conversation-writing textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  font: inherit;
  border-radius: 8px;
  margin-bottom: 10px;
}

.conversation-speaking audio {
  display: block;
  width: 100%;
  margin: 20px 0;
}

.conversation-record-controls,
.conversation-navigation {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.conversation-feedback {
  min-height: 30px;
  text-align: center;
  margin: 20px 0;
  font-weight: bold;
}

.conversation-feedback.correct {
  color: #16803c;
}

.conversation-feedback.incorrect {
  color: #b42318;
}

.conversation-feedback.error {
  color: #b42318;
}

.conversation-scaffold {
  max-width: 650px;
  margin: 20px auto;
  padding: 15px;
  border-radius: 10px;
  text-align: center;
  background: #fff8dc;
}

.conversation-recording-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}

/* ============================================================
   SHORT SPEAK RECORDING CONTROLS
   ============================================================ */

.short-speak-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.short-speak-container .conversation-button {
  width: fit-content;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing-panel {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 20px 45px;
}


/* ------------------------------------------------------------
   HERO
   ------------------------------------------------------------ */

.landing-hero {
  text-align: center;
  padding: 25px 20px 30px;
}

.landing-food-decor {
  font-size: 2.4rem;
  letter-spacing: 12px;
  margin-bottom: 18px;
}

.landing-hero h1 {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1.25;
}

.landing-welcome-english {
  margin: 10px 0 0;
  font-size: 1rem;
  opacity: 0.65;
}


/* ------------------------------------------------------------
   LEARNING OPTIONS
   ------------------------------------------------------------ */

.landing-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
  max-width: 760px;
}


.landing-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;

  padding: 22px 24px;

  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 16px;

  background: white;

  cursor: pointer;
  text-align: left;

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}


.landing-option:hover {
  transform: translateY(-2px);

  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.10);

  border-color: rgba(0, 0, 0, 0.18);
}


.landing-option:active {
  transform: translateY(0);
}


/* Icon */

.landing-option-icon {
  flex: 0 0 58px;

  width: 58px;
  height: 58px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 2rem;

  border-radius: 14px;
  background: #f7f3e8;
}


/* Text */

.landing-option-content {
  flex: 1;
}


.landing-option-content h2 {
  margin: 0 0 5px;

  font-size: 1.25rem;
}


.landing-option-content p {
  margin: 0;

  font-size: 0.95rem;
  opacity: 0.68;
}


/* Arrow */

.landing-option-arrow {
  flex: 0 0 auto;

  font-size: 1.6rem;
  opacity: 0.45;

  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
}


.landing-option:hover .landing-option-arrow {
  transform: translateX(4px);
  opacity: 0.8;
}


/* ------------------------------------------------------------
   FOOTER DECORATION
   ------------------------------------------------------------ */

.landing-food-footer {
  text-align: center;

  margin-top: 35px;

  font-size: 1.8rem;
  letter-spacing: 10px;

  opacity: 0.75;
}


/* ------------------------------------------------------------
   MOBILE
   ------------------------------------------------------------ */

@media (max-width: 600px) {

  .landing-panel {
    padding: 20px 12px 35px;
  }

  .landing-hero {
    padding: 15px 10px 25px;
  }

  .landing-food-decor {
    font-size: 2rem;
    letter-spacing: 7px;
  }

  .landing-hero h1 {
    font-size: 1.9rem;
  }

  .landing-option {
    padding: 18px;
    gap: 14px;
  }

  .landing-option-icon {
    flex-basis: 50px;
    width: 50px;
    height: 50px;
    font-size: 1.7rem;
  }

  .landing-option-content h2 {
    font-size: 1.1rem;
  }

  .landing-option-content p {
    font-size: 0.88rem;
  }

  .landing-option-arrow {
    font-size: 1.3rem;
  }

}

/* ============================================================
   LOADING SCREEN
   ============================================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: #fffaf0;
}


.loading-card {
  width: 100%;
  max-width: 500px;

  text-align: center;

  padding: 45px 35px;

  border-radius: 24px;

  background: white;

  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.10);
}


.loading-logo {
  font-size: 4rem;

  margin-bottom: 8px;

  animation: tacoBounce 1.2s ease-in-out infinite;
}


.loading-card h1 {
  margin: 0;

  font-size: 2rem;
}


.loading-message {
  min-height: 28px;

  margin: 12px 0 22px;

  font-size: 1rem;

  opacity: 0.7;
}


/* ------------------------------------------------------------
   TACOS
   ------------------------------------------------------------ */

.loading-tacos {
  min-height: 42px;

  margin-bottom: 18px;

  font-size: 1.8rem;

  letter-spacing: 4px;

  word-break: break-word;

  transition: all 0.2s ease;
}


/* ------------------------------------------------------------
   PROGRESS BAR
   ------------------------------------------------------------ */

.loading-progress-track {
  width: 100%;
  height: 18px;

  overflow: hidden;

  border-radius: 999px;

  background: #eee6d8;
}


.loading-progress-bar {
  height: 100%;

  border-radius: 999px;

  background: #d99a2b;

  transition: width 0.35s ease;
}


.loading-percent {
  margin-top: 10px;

  font-size: 0.9rem;

  font-weight: 600;

  opacity: 0.6;
}


/* ------------------------------------------------------------
   ANIMATION
   ------------------------------------------------------------ */

@keyframes tacoBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }

}


/* ------------------------------------------------------------
   MOBILE
   ------------------------------------------------------------ */

@media (max-width: 600px) {

  .loading-card {
    padding: 35px 22px;
  }

  .loading-logo {
    font-size: 3.2rem;
  }

  .loading-card h1 {
    font-size: 1.7rem;
  }

  .loading-message {
    font-size: 0.9rem;
  }

  .loading-tacos {
    font-size: 1.5rem;
    letter-spacing: 2px;
  }

}
