/* ============================================================
   Goftan Quiz — Friendly & Playful Design
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Core palette */
  --c-bg:           #F4FBF4;
  --c-surface:      #FFFFFF;
  --c-surface-alt:  #F0FAF0;
  --c-border:       #D9EDD9;
  --c-border-focus: #22C55E;

  /* Brand — warm green */
  --c-primary:      #22C55E;
  --c-primary-dark: #16A34A;
  --c-primary-dim:  #F0FDF4;

  /* Semantic */
  --c-success:      #059669;
  --c-success-bg:   #ECFDF5;
  --c-success-border:#A7F3D0;
  --c-error:        #DC2626;
  --c-error-bg:     #FEF2F2;
  --c-error-border: #FECACA;
  --c-warning:      #D97706;
  --c-warning-bg:   #FFFBEB;

  /* Text */
  --c-text:         #1A2E1A;
  --c-text-2:       #5A7060;
  --c-text-3:       #94A99A;
  --c-text-inv:     #FFFFFF;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10:40px;
  --sp-12:48px;

  /* Radii — slightly rounder for a friendlier feel */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  24px;
  --r-full:9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 8px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 20px -4px rgba(0,0,0,0.09), 0 4px 8px -2px rgba(0,0,0,0.04);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.22s ease;
}

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  background: #15803D;
  padding: var(--sp-5) var(--sp-8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  box-shadow: 0 2px 8px rgba(21,128,61,0.25);
  position: relative;
}

.header h2 {
  color: #FFFFFF;
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.4px;
}

.header p {
  color: rgba(255,255,255,0.55);
  font-size: 0.875rem;
  margin: 0;
  font-weight: 500;
}

/* ── Navbar ── */
#navbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 0 var(--sp-8);
  display: flex;
  justify-content: center;
  gap: var(--sp-1);
  box-shadow: var(--shadow-xs);
}

#navbar a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--c-text-2);
  text-decoration: none;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  font-size: 0.875rem;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}

#navbar a:hover {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary-dim);
}

#navbar a.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}

/* ── Page wrapper ── */
#wrapper {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-4);
}

.content  { padding: 16px; }
.sticky   { position: fixed; top: 0; width: 100%; }
.sticky + .content { padding-top: 60px; }

/* ── Cards (all quiz pages) ── */
#language_page,
#tasks_page,
#question_page,
#info_page,
#calculator_page,
#sign-hanging_page {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: var(--sp-10) var(--sp-10);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--sp-6);
}

/* Accent top bar */
#language_page::before,
#tasks_page::before,
#question_page::before,
#info_page::before,
#calculator_page::before,
#sign-hanging_page::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c-primary);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

/* ── Section titles ── */
#language_page h3,
#tasks_page h3,
#question_page h3,
#info_page h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-text);
  margin: 0 0 var(--sp-5) 0;
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  background: none;
  -webkit-text-fill-color: unset;
}

/* ── Checkboxes ── */
.container {
  display: flex;
  align-items: center;
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--c-text);
  background: var(--c-surface-alt);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  user-select: none;
}

.container:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-dim);
  box-shadow: var(--shadow-xs);
}

.container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0; width: 0;
}

.checkmark {
  position: absolute;
  top: 50%;
  right: var(--sp-4);
  transform: translateY(-50%);
  height: 18px;
  width: 18px;
  background: var(--c-surface);
  border-radius: var(--r-sm);
  border: 1.5px solid var(--c-border);
  transition: all var(--t-fast);
  flex-shrink: 0;
}

.container:hover input ~ .checkmark {
  border-color: var(--c-primary);
}

.container input:checked ~ .checkmark {
  background: var(--c-primary);
  border-color: var(--c-primary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.container input:checked ~ .checkmark:after { display: block; }

.container .checkmark:after {
  left: 5px; top: 2px;
  width: 5px; height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ── Select All / None link ── */
.select-all-link {
  display: inline-block;
  margin-bottom: var(--sp-2);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-primary);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color var(--t-fast);
}
.select-all-link:hover {
  color: var(--c-primary-dark);
  text-decoration: underline;
}

/* ── Beginner level special style ── */
.beginner-level {
  background: #F0FDF4;
  border-color: #86EFAC;
  color: #15803D;
  font-weight: 600;
}
.beginner-level:hover {
  background: #DCFCE7;
  border-color: var(--c-success);
}
.container.beginner-level input:checked ~ .checkmark {
  background: var(--c-success);
  border-color: var(--c-success);
}

/* ── Radio buttons (language selector) ── */
.radiocontainer {
  display: flex;
  align-items: center;
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--c-text);
  background: var(--c-surface-alt);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  user-select: none;
}

.radiocontainer:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-dim);
  box-shadow: var(--shadow-xs);
}

.radiocontainer input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.radiocheckmark {
  position: absolute;
  top: 50%;
  right: var(--sp-4);
  transform: translateY(-50%);
  height: 18px;
  width: 18px;
  background: var(--c-surface);
  border-radius: 50%;
  border: 1.5px solid var(--c-border);
  transition: all var(--t-fast);
}

.radiocontainer:hover input ~ .radiocheckmark {
  border-color: var(--c-primary);
}

.radiocontainer input:checked ~ .radiocheckmark {
  background: var(--c-primary);
  border-color: var(--c-primary);
}

.radiocheckmark:after {
  content: "";
  position: absolute;
  display: none;
}

.radiocontainer input:checked ~ .radiocheckmark:after { display: block; }

.radiocontainer .radiocheckmark:after {
  top: 4px; left: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: white;
}

/* Selected language */
.radiocontainer.language-selected {
  background: var(--c-primary-dim);
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
}

/* ── General buttons ── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  text-align: center;
}
.button:hover { background: var(--c-surface-alt); border-color: #C8CDD7; }

.button5 {
  display: block;
  width: 100%;
  padding: 11px 18px;
  margin: var(--sp-2) 0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.button5:hover {
  background: var(--c-primary-dim);
  border-color: var(--c-primary);
  color: var(--c-primary-dark);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Answer option tiles — all identical until feedback */
#opt1.button5, #opt2.button5, #opt3.button5, #opt4.button5 {
  background: var(--c-surface);
  border-color: var(--c-border);
  border-bottom: 3px solid var(--c-border);
  color: var(--c-text);
  font-weight: 500;
}
#opt1.button5:hover, #opt2.button5:hover,
#opt3.button5:hover, #opt4.button5:hover {
  background: var(--c-primary-dim);
  border-color: var(--c-primary);
  border-bottom-color: var(--c-primary-dark);
  color: var(--c-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
/* Disabled state: dim unchosen options so only the feedback stands out */
#opt1.button5:disabled, #opt2.button5:disabled,
#opt3.button5:disabled, #opt4.button5:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}
/* Keep full opacity on the option that has feedback coloring (correct/wrong) */
#opt1.button5:disabled[style*="background-color"],
#opt2.button5:disabled[style*="background-color"],
#opt3.button5:disabled[style*="background-color"],
#opt4.button5:disabled[style*="background-color"] {
  opacity: 1;
}

/* Primary CTA — Start Learning / Start Quiz */
#startLearning, #startQuizButton {
  display: block;
  width: fit-content;
  margin: var(--sp-8) auto 0;
  padding: 12px 36px;
  background: var(--c-primary);
  color: var(--c-text-inv);
  border: none;
  border-radius: var(--r-full);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(34,197,94,0.25), 0 4px 14px rgba(34,197,94,0.2);
  transition: all var(--t-fast);
  letter-spacing: 0.01em;
}
#startLearning:hover, #startQuizButton:hover {
  background: var(--c-primary-dark);
  box-shadow: 0 2px 4px rgba(22,163,74,0.35), 0 6px 18px rgba(22,163,74,0.28);
  transform: translateY(-2px);
}

/* Num of questions input */
#num_of_questions {
  width: 100%;
  max-width: 200px;
  padding: 9px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-xs);
  display: block;
  margin-bottom: var(--sp-4);
}
#num_of_questions:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
}

/* Beginner note */
#beginner_note {
  display: none;
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-2) 0 var(--sp-4);
  background: var(--c-success-bg);
  border: 1px solid var(--c-success-border);
  border-radius: var(--r-md);
  color: var(--c-success);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Question page */
#question_page {
  padding: var(--sp-8);
}

#extra {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-3);
  margin-bottom: var(--sp-2);
}

#question {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: var(--sp-6);
  line-height: 1.4;
}

/* ── Results page ── */
.results-header {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  background: linear-gradient(135deg, #15803D 0%, #16A34A 100%);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-8);
  margin-bottom: var(--sp-6);
  color: white;
  box-shadow: var(--shadow-md);
}

.results-score-ring {
  flex-shrink: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 3px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.results-meta { flex: 1; }

.results-language {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.results-grade {
  font-size: 0.875rem;
  opacity: 0.8;
  margin-bottom: var(--sp-3);
}

.results-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  font-size: 0.825rem;
  font-weight: 600;
}

.rs-correct   { color: #6EE7B7; }
.rs-incorrect { color: #FCA5A5; }
.rs-skipped   { color: rgba(255,255,255,0.5); }
.rs-total     { color: rgba(255,255,255,0.4); }

.results-chart {
  width: 100%;
  min-height: 220px;
  margin-bottom: var(--sp-6);
}

.results-history { margin-bottom: var(--sp-6); }

.results-history summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--c-primary);
  font-size: 0.875rem;
  margin-bottom: var(--sp-3);
  user-select: none;
}
.results-history summary:hover { color: var(--c-primary-dark); }

.result_table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  border-radius: var(--r-md);
  overflow: hidden;
}
.result_table th {
  padding: 10px 14px;
  text-align: left;
  background: var(--c-primary);
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}
.result_table th:first-child { border-radius: var(--r-sm) 0 0 0; }
.result_table th:last-child  { border-radius: 0 var(--r-sm) 0 0; }
.result_table td {
  border: 1px solid var(--c-border);
  padding: 9px 14px;
  color: var(--c-text);
}
.result_table tr:nth-child(even) td { background: var(--c-surface-alt); }
.result_table tr:hover td { background: var(--c-primary-dim); }

.results-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  margin-top: var(--sp-8);
  flex-wrap: wrap;
}

.results-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 24px;
  background: var(--c-primary);
  color: white;
  border: none;
  border-radius: var(--r-full);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(34,197,94,0.25), 0 4px 12px rgba(34,197,94,0.18);
  transition: all var(--t-fast);
}
.results-btn-primary:hover {
  background: var(--c-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(22,163,74,0.35);
}

.results-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 20px;
  background: var(--c-surface);
  color: var(--c-text-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full) !important;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.results-btn-secondary:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: var(--c-primary-dim);
}

/* Wrong answers review */
#wrong_answers_review { margin-top: var(--sp-6); }
#wrong_answers_review h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--sp-3);
  color: var(--c-text);
}
.wrong-answer-card {
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-error);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.wa-extra   { font-size: 0.75rem; color: var(--c-text-3); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.wa-question{ font-weight: 700; font-size: 0.95rem; margin-bottom: var(--sp-2); color: var(--c-text); }
.wa-your    { font-size: 0.85rem; color: var(--c-error);   margin-bottom: 2px; }
.wa-correct { font-size: 0.85rem; color: var(--c-success); }
.wa-your span, .wa-correct span { font-weight: 700; }

/* Stats grid */
.game-stats {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  margin: var(--sp-5) 0;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.stat-item {
  text-align: center;
  padding: var(--sp-4);
  background: var(--c-surface-alt);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.stat-item:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-xs);
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-primary);
  margin-bottom: 3px;
  letter-spacing: -0.5px;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Progress bar */
.progress-indicator { margin: var(--sp-4) 0; text-align: center; }
.progress-bar {
  width: 100%; max-width: 400px;
  height: 10px;
  background: var(--c-border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 0 auto var(--sp-2);
}
.progress-fill {
  height: 100%;
  background: var(--c-primary);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: var(--r-full);
}
#progress_text { font-size: 0.8rem; color: var(--c-text-2); font-weight: 600; }

/* Difficulty selector */
.difficulty-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.difficulty-selector label { font-size: 0.875rem; font-weight: 600; color: var(--c-text-2); }
.difficulty-selector select {
  padding: 6px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--c-text);
  cursor: pointer;
  outline: none;
  transition: border-color var(--t-fast);
}
.difficulty-selector select:focus { border-color: var(--c-primary); }

/* ── Crossword ── */
#puzzle-piece_page {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  margin: var(--sp-4) auto;
  max-width: 1300px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  position: relative;
  overflow: hidden;
}
#puzzle-piece_page::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c-primary);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

#crossword_question {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  padding: 12px 18px;
  background: var(--c-primary-dim);
  color: var(--c-primary-dark);
  border-radius: var(--r-md);
  border: 1px solid rgba(99,102,241,0.2);
  margin-bottom: var(--sp-4);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Controls toolbar */
.crossword-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface-alt);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
}
.control-group {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.control-group + .control-group {
  border-left: 1px solid var(--c-border);
  padding-left: var(--sp-2);
  margin-left: var(--sp-1);
}

/* All crossword buttons share a base */
.hint-button,
.super-hint-button,
.reveal-word-button,
.solve-button,
.timer-button,
.pause-button,
.reset-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.hint-button:hover,
.super-hint-button:hover,
.reveal-word-button:hover,
.solve-button:hover,
.timer-button:hover,
.pause-button:hover,
.reset-button:hover {
  background: var(--c-primary-dim);
  border-color: var(--c-primary);
  color: var(--c-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Crossword grid */
#crossword {
  border-collapse: separate;
  border-spacing: 2px;
  background: var(--c-surface-alt);
  padding: 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  margin: var(--sp-5) auto;
  box-shadow: var(--shadow-sm);
}
#crossword td {
  width: 36px; height: 36px;
  position: relative;
  background: var(--c-text);
  border-radius: var(--r-sm);
}
.crossword_cells {
  text-align: center;
  width: 100%; height: 100%;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--r-sm);
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  text-transform: uppercase;
  outline: none;
}
.crossword_cells:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(34,197,94,0.25);
}
.crossword_cells:hover { border-color: #C8CDD7; }
.crossword_cells[disabled] {
  background: var(--c-success-bg) !important;
  border-color: var(--c-success-border) !important;
  color: var(--c-success);
  cursor: not-allowed;
}
.crossword_cells.correct {
  background: var(--c-success-bg) !important;
  border-color: var(--c-success) !important;
  color: var(--c-success);
}
.crossword_cells.incorrect {
  background: var(--c-error-bg) !important;
  border-color: var(--c-error) !important;
  color: var(--c-error);
  animation: shake 0.4s ease;
}
.crossword_cells.hint-used {
  background: var(--c-warning-bg) !important;
  border-color: #FDE68A !important;
  color: var(--c-warning);
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.crossword_numerics {
  position: absolute;
  top: 2px; left: 2px;
  font-size: 9px;
  font-weight: 700;
  color: var(--c-text-2);
  line-height: 1;
  z-index: 10;
  pointer-events: none;
}

/* Crossword layout: grid on top, clues below in two columns */
.crossword-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
  margin: var(--sp-5) auto;
  max-width: 1400px;
}
.crossword-container {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  overflow-x: auto;          /* allow horizontal scroll if grid is very wide */
  max-width: 100%;
}
.clues-container {
  width: 100%;
  max-width: 900px;
}
.clues-wrapper {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;        /* Across and Down side by side */
  gap: var(--sp-6);
}
.clues-section {
  flex: 1;
  min-width: 0;
}
.clues-section:last-child { margin-bottom: 0; }
.clues-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-text-2);
  margin: 0 0 var(--sp-3) 0;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: none;
  -webkit-text-fill-color: unset;
}
.clues-title i { color: var(--c-primary); font-size: 0.75rem; }
.clues-list {
  max-height: 220px;
  overflow-y: auto;
  padding-right: var(--sp-2);
}
.clues-list::-webkit-scrollbar { width: 4px; }
.clues-list::-webkit-scrollbar-track { background: var(--c-border); border-radius: 2px; }
.clues-list::-webkit-scrollbar-thumb { background: var(--c-primary); border-radius: 2px; }

.crossword_questions_css {
  display: block;
  padding: 6px 10px;
  margin: 3px 0;
  font-size: 0.82rem;
  background: var(--c-surface-alt);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  border-left: 2px solid transparent;
  color: var(--c-text-2);
}
.crossword_questions_css:hover {
  background: var(--c-primary-dim);
  border-left-color: var(--c-primary);
  color: var(--c-primary-dark);
}
.crossword_questions_css[style*="color: red"] {
  background: var(--c-error-bg) !important;
  color: var(--c-error) !important;
  border-left-color: var(--c-error) !important;
}

.question_table {
  margin: var(--sp-5);
  border-collapse: collapse;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
}
.question_table th {
  background: var(--c-primary);
  color: white;
  font-weight: 700;
  padding: 12px 16px;
  font-size: 0.85rem;
}
.question_table td {
  word-wrap: break-word;
  max-width: 250px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.875rem;
  color: var(--c-text);
}
.question_table tr:last-child td { border-bottom: none; }
.question_table tr:nth-child(even) td { background: var(--c-surface-alt); }

/* Pause overlay */
.pause-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.pause-message {
  background: var(--c-surface);
  padding: var(--sp-10);
  border-radius: var(--r-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border);
}
.pause-message h2 { margin: 0 0 var(--sp-3); font-size: 1.25rem; color: var(--c-text); }
.pause-message p  { margin: 0; color: var(--c-text-2); font-size: 0.875rem; }

/* Word completion animation */
@keyframes completedWord {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.word-completed { animation: completedWord 0.5s ease; }

/* Colors square */
.square { height: 40px; width: 80px; display: inline-block; border-radius: var(--r-sm); border: 1px solid var(--c-border); }

/* Login (legacy) */
.logininput[type=text], .logininput[type=password], .logininput[type=email] {
  width: 100%; padding: 10px 14px; margin: 6px 0;
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: inherit; font-size: 0.9rem; box-sizing: border-box;
}
.loginbutton {
  background: var(--c-primary); color: white;
  padding: 12px 18px; margin: 6px 0; border: none;
  cursor: pointer; width: 100%; font-family: inherit; border-radius: var(--r-md);
}
.loginbutton:hover { background: var(--c-primary-dark); }
.cancelbtn { width: auto; padding: 10px 16px; background: var(--c-error); color: white; border: none; border-radius: var(--r-md); cursor: pointer; }
.imgcontainer { text-align: center; margin: 20px 0 10px; }
img.avatar { width: 40%; border-radius: 50%; }
.logincontainer { padding: 14px; }
span.psw { float: right; padding-top: 14px; font-size: 0.85rem; }

/* ── Hangman ── */
#hangman_hint {
  text-align: center;
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-primary-dim);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.hm-extra {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-3);
  margin-right: var(--sp-2);
}
.hm-clue {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
}

#hangman_answer {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.55em;   /* space between blanks — no space chars in the string */
  color: var(--c-text);
  margin-bottom: var(--sp-6);
}

.hm-alphabet-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}

.hm-letter-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1.5px solid var(--c-border);
  border-bottom: 3px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hm-letter-btn:hover:not([disabled]) {
  background: var(--c-primary-dim);
  border-color: var(--c-primary);
  border-bottom-color: var(--c-primary-dark);
  color: var(--c-primary-dark);
  transform: translateY(-1px);
}
.hm-letter-btn.hm-used,
.hm-letter-btn[disabled] {
  background: var(--c-surface-alt);
  color: var(--c-text-3);
  border-color: var(--c-border);
  border-bottom-color: var(--c-border);
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

/* ── Quiz progress bar (question completion) ── */
#quiz_progress_wrap {
  height: 4px;
  background: var(--c-border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 0 5px var(--sp-4);
}
#quiz_progress_fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: var(--r-full);
  width: 0%;
  transition: width 0.4s ease;
}

/* ── Personal best in results header ── */
.results-best {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
}
.results-best-new {
  color: #FDE68A;
}

/* ── Difficulty nudge card ── */
#difficulty_nudge { margin-bottom: var(--sp-4); }
.nudge-card {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border: 1px solid #BFDBFE;
  border-left: 4px solid #3B82F6;
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.nudge-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: #1E40AF;
  flex: 1;
}
.nudge-text strong { font-weight: 700; }

/* ── Question timer bar ── */
.question-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  margin-bottom: var(--sp-2);
}
.question-meta-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.sound-toggle {
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 5px 9px;
  cursor: pointer;
  color: var(--c-text-2);
  font-size: 0.85rem;
  line-height: 1;
  transition: all var(--t-fast);
}
.sound-toggle:hover { border-color: var(--c-primary); color: var(--c-primary); }
.sound-toggle.muted { color: var(--c-text-3); }

#question_timer_wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 5px var(--sp-3);
}
#question_timer_fill {
  flex: 1;
  height: 6px;
  background: var(--c-primary);
  border-radius: var(--r-full);
  transition: width 0.9s linear, background 0.3s ease;
  width: 100%;
}
#question_timer_label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text-2);
  min-width: 22px;
  text-align: right;
}

/* ── Engagement row (streak + XP) ── */
.engagement-row {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.streak-badge, .xp-badge {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  flex: 1;
  min-width: 150px;
}
.streak-icon, .xp-icon { font-size: 1.4rem; line-height: 1; }
.streak-count, .xp-earned {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--c-text);
}
.streak-sub, .xp-total { font-size: 0.72rem; color: var(--c-text-3); }

/* ── Recommendation card ── */
#weak_topic_rec { margin: var(--sp-5) 0; }
.recommendation-card {
  background: var(--c-primary-dim);
  border: 1px solid rgba(34,197,94,0.3);
  border-left: 4px solid var(--c-primary);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.rec-text { flex: 1; }
.rec-title { font-weight: 700; font-size: 0.9rem; color: var(--c-text); margin-bottom: 2px; }
.rec-sub   { font-size: 0.8rem; color: var(--c-text-2); }
.rec-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 18px;
  background: var(--c-primary);
  color: white;
  border: none;
  border-radius: var(--r-full);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.rec-btn:hover { background: var(--c-primary-dark); transform: translateY(-1px); }

/* ── Hangman scaffold + lives ── */
.hm-scaffold-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: var(--sp-2);
}
#hangman_svg { display: block; }
#hm-person circle, #hm-person line { stroke: #DC2626; }

#hangman_status {
  text-align: center;
  min-height: 28px;
  margin-bottom: var(--sp-3);
  font-size: 1rem;
  font-weight: 700;
}
.hm-gameover { color: var(--c-error); }
.hm-win      { color: var(--c-success); }
.hm-reveal   { color: var(--c-error); text-decoration: underline; }

.hm-lives {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: var(--sp-1) 0 var(--sp-2);
}
.hm-life      { font-size: 1.1rem; color: var(--c-error); transition: color 0.2s; }
.hm-life-lost { color: var(--c-border); }

/* ── Responsive ── */
@media (max-width: 768px) {
  #wrapper { padding: var(--sp-4) var(--sp-3); }
  #language_page, #tasks_page, #question_page,
  #info_page, #calculator_page, #sign-hanging_page { padding: var(--sp-6); }
  #puzzle-piece_page { padding: var(--sp-4); }
  .crossword-layout  { padding: 0; }
  .clues-wrapper     { flex-direction: column; gap: var(--sp-4); } /* stack Across/Down */
  .clues-list        { max-height: 160px; }
  #crossword td      { width: 30px; height: 30px; }
  .crossword_cells   { font-size: 14px; }
  .header            { padding: var(--sp-4) var(--sp-5); }
  .header h2         { font-size: 1.25rem; }
  #navbar            { padding: 0 var(--sp-4); }
  #navbar a          { padding: var(--sp-2) var(--sp-3); font-size: 0.8rem; }
  .results-header    { flex-direction: column; align-items: flex-start; gap: var(--sp-4); }
  .results-actions   { flex-direction: column-reverse; }
  .results-actions .results-btn-primary,
  .results-actions .results-btn-secondary { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  #crossword td    { width: 26px; height: 26px; }
  .crossword_cells { font-size: 12px; }
  @media screen and (max-width: 300px) {
    span.psw { display: block; float: none; }
    .cancelbtn { width: 100%; }
  }
}
