:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e0e9ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(124, 58, 237, 0.12), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, rgba(37, 99, 235, 0.12), transparent 60%),
    var(--bg);
  min-height: 100vh;
  color: var(--text);
  font-family: Vazirmatn, Tahoma, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

h1,
h2,
h3,
h4 {
  line-height: 1.4;
  margin: 0.6em 0 0.4em;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.1rem;
  margin-top: 1.4em;
}

h4 {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 1.2em 0 0.4em;
}

p {
  margin: 0.4em 0;
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.empty,
.loading {
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0;
}

.hidden-input {
  display: none;
}

/* Layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 55%, #7c3aed 100%);
  color: #fff;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.25);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}

.brand {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-weight: 800;
  letter-spacing: 1px;
  direction: ltr;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.topbar p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(30, 41, 99, 0.08);
  padding: 18px;
  margin-bottom: 14px;
}

.bottom-nav {
  position: fixed;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  max-width: 740px;
  margin: 0 auto;
  padding-bottom: 6px;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.bottom-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3);
}

/* Buttons and chips */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--bad);
  border-color: #fca5a5;
}

.btn.small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.9rem;
}

.btn.wide {
  width: 100%;
}

.actions,
.toolbar-actions,
.q-actions,
.builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  align-items: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-toggle {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.chip-toggle.active {
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
  border-color: #818cf8;
  color: #3730a3;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.18);
}

.badges,
.q-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.8rem;
}

.badge.accent {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

/* Setup + play */

.setup .chips {
  margin-bottom: 4px;
}

.play-meta {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--muted);
}

.score {
  color: var(--primary-dark);
}

.timer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.timer-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.25s linear, background 0.3s;
}

.timer-fill.low {
  background: var(--bad);
}

.timer-text {
  min-width: 90px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.instruction {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

.question {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.8;
  margin: 10px 0 14px;
}

.answer-input {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: left;
  background: #fff;
}

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

.answer-input:disabled {
  background: #f8fafc;
  color: var(--text);
  opacity: 1;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row .answer-input {
  flex: 1;
  min-width: 0;
}

.mic {
  flex-shrink: 0;
  min-width: 96px;
  border-color: #c7d2fe;
  color: #3730a3;
}

.mic:disabled {
  opacity: 0.5;
}

.listening {
  background: var(--bad-soft) !important;
  border-color: var(--bad) !important;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 60px;
  padding: 10px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  background: #fafbff;
  margin-bottom: 10px;
}

.answer-row {
  border-color: var(--primary);
  background: #f5f8ff;
}

.bank-row.locked {
  opacity: 0.5;
  pointer-events: none;
}

.placeholder {
  color: var(--muted);
  align-self: center;
}

.chip {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #c7d2fe;
  background: #fff;
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
  min-height: 42px;
}

.answer-row .chip {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* Tappable key words inside a question */
.gloss-word {
  border-bottom: 2px dotted var(--primary);
  cursor: pointer;
  border-radius: 4px;
}

.gloss-word:hover,
.gloss-word:focus-visible {
  background: var(--primary-soft);
  outline: none;
}

.glossary {
  display: grid;
  gap: 6px;
  margin: 4px 0 12px;
}

.gloss-chip {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary-soft);
  border-color: var(--primary);
}

.gloss-tip {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fef9c3;
  border: 1px solid #facc15;
  font-size: 1.1rem;
}

.gloss-tip[hidden] {
  display: none;
}

/* Read-aloud buttons */
.speak-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-inline-start: 8px;
  vertical-align: middle;
}

.speak-buttons .speak {
  min-height: 34px;
  padding: 4px 12px;
}

.gloss-tip .speak-buttons {
  margin-inline-start: 0;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  font: inherit;
  font-size: 1.1rem;
  text-align: left;
  cursor: pointer;
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.option.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option:disabled {
  cursor: default;
  color: var(--text);
  opacity: 1;
}

.option.correct:disabled,
.option.wrong:disabled {
  font-weight: 600;
}

.feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
}

.feedback.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.feedback.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.feedback .answer-line {
  color: var(--text);
}

.answer-line span {
  color: var(--muted);
}

.explanation {
  color: var(--text);
  margin-top: 6px;
}

.hint {
  background: var(--warn-soft);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--warn);
}

.results .mistake {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}

/* Stats */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.stat {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  display: grid;
  gap: 2px;
}

.stat strong {
  font-size: 1.25rem;
  color: var(--primary-dark);
}

.stat span {
  color: var(--muted);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
}

td span[dir='auto'] {
  white-space: normal;
  display: inline-block;
  max-width: 260px;
}

/* Admin */

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filters input[type='search'] {
  grid-column: 1 / -1;
}

select,
input[type='text'],
input[type='search'],
input[type='number'],
textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.q-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}

.q-card.is-disabled {
  opacity: 0.6;
}

.q-id {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.85rem;
  direction: ltr;
}

.q-text {
  font-weight: 600;
  margin: 8px 0 2px;
}

.q-answer {
  color: var(--primary-dark);
  margin: 0;
}

.warn-text {
  color: var(--warn);
  font-size: 0.88rem;
  background: var(--warn-soft);
  border-radius: 8px;
  padding: 4px 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.switch input {
  width: 20px;
  height: 20px;
}

.import-report,
.error-box {
  background: var(--primary-soft);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
}

.error-list {
  color: var(--bad);
  padding-right: 20px;
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.field {
  display: grid;
  gap: 4px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field-label {
  font-weight: 600;
  font-size: 0.92rem;
}

.field small {
  font-size: 0.8rem;
}

.toasts {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.92rem;
}

.toast.error {
  background: var(--bad);
}

.toast.warn {
  background: var(--warn);
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .filters {
    grid-template-columns: repeat(3, 1fr);
  }

  .filters input[type='search'] {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .question {
    font-size: 1.15rem;
  }
}

/* ---------- Game look: player card, missions, streak, stars ---------- */

.setup.game {
  padding: 18px;
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px 16px;
  align-items: center;
  padding: 16px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #4f46e5 55%, #7c3aed);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.3);
}

.level-badge {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fde68a, #f59e0b 70%);
  color: #422006;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15), 0 0 0 4px rgba(255, 255, 255, 0.25);
  line-height: 1.1;
}

.level-badge span {
  font-size: 0.75rem;
  font-weight: 700;
}

.level-badge strong {
  font-size: 1.7rem;
}

.hero-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.hero-title {
  font-size: 1.1rem;
}

.hero .muted {
  color: rgba(255, 255, 255, 0.85);
}

.xp-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fde047, #facc15);
  transition: width 0.6s ease;
}

.hero-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-stat {
  display: grid;
  place-items: center;
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  text-align: center;
}

.mini-stat strong {
  font-size: 1.2rem;
}

.mini-stat span {
  font-size: 0.8rem;
  opacity: 0.9;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px;
}

.step-no {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
}

.card-options .chip-toggle {
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: 600;
  box-shadow: 0 2px 0 rgba(37, 99, 235, 0.12);
}

.card-options .chip-toggle.active {
  box-shadow: 0 3px 0 rgba(29, 78, 216, 0.5);
  transform: translateY(-1px);
}

.mission-options .chip-toggle {
  min-width: 132px;
  justify-content: center;
}

.info {
  margin-top: 14px;
  text-align: center;
}

.start-btn {
  width: 100%;
  margin-top: 8px;
  min-height: 60px;
  font-size: 1.25rem;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
  animation: pulse 2.4s ease-in-out infinite;
}

.start-btn:disabled {
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
  }
  50% {
    box-shadow: 0 8px 28px rgba(124, 58, 237, 0.55);
  }
}

.streak {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.results.game {
  text-align: center;
}

.result-hero {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 10px 0 16px;
}

.stars {
  display: flex;
  gap: 6px;
  font-size: 2.6rem;
  line-height: 1;
}

.star {
  color: #d1d5db;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.06);
}

.star.on {
  color: #f59e0b;
  animation: pop 0.5s ease both;
}

.star.on:nth-child(2) {
  animation-delay: 0.12s;
}

.star.on:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  70% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.xp-gain {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

.level-up {
  margin: 0;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 700;
}

.results-actions {
  justify-content: center;
}

.results-actions .btn {
  min-width: 130px;
}

.results .mistake {
  text-align: start;
}

@media (prefers-reduced-motion: reduce) {
  .start-btn,
  .star.on {
    animation: none;
  }
}

/* Keep the last controls of a screen clear of the floating bottom navigation. */
#app {
  padding-bottom: 120px;
}

/* ---------- Play screen zones: top bar, stage, answer zone ---------- */

.play.card {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.hud {
  display: grid;
  gap: 10px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-count {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}

.hud-chips {
  display: flex;
  gap: 6px;
}

.hud-chip {
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.hud-chip.streak {
  background: var(--warn-soft);
  color: var(--warn);
}

.hud-chip.streak.hot {
  animation: pop 0.4s ease;
}

.progress-track {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s ease, transform 0.3s ease;
}

.dot.ok {
  background: var(--ok);
}

.dot.bad {
  background: var(--bad);
}

.dot.current {
  background: var(--primary);
  transform: scale(1.25);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.timer {
  margin: 0;
}

.stage {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f5f7ff);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage .instruction {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.stage .question {
  margin: 4px 0 0;
  font-size: 1.35rem;
  line-height: 1.8;
}

.stage .question-block {
  display: grid;
  gap: 10px;
}

.glossary {
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.gloss-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.answer-zone {
  display: grid;
  gap: 10px;
}

.hint-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.play-actions {
  position: sticky;
  bottom: 96px;
  padding: 8px 0;
  background: linear-gradient(180deg, rgba(244, 246, 251, 0), var(--bg) 35%);
}

.play-actions .btn {
  flex: 1;
  min-height: 52px;
  font-size: 1.1rem;
  border-radius: 14px;
}

/* ---------- Feedback panel and glossary tip (clear hierarchy) ---------- */

.feedback {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid transparent;
  border-inline-start: 6px solid;
  box-shadow: var(--shadow);
}

.feedback.ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  border-inline-start-color: var(--ok);
  color: #14532d;
}

.feedback.bad {
  background: #fff7f7;
  border-color: #fecaca;
  border-inline-start-color: var(--bad);
  color: #7f1d1d;
}

.fb-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fb-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  flex: none;
}

.feedback.ok .fb-icon {
  background: var(--ok);
}

.feedback.bad .fb-icon {
  background: var(--bad);
}

.fb-title {
  font-size: 1.2rem;
}

.fb-box {
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
}

.fb-sentence {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.fb-sentence .speak-buttons {
  margin-inline-start: 0;
  margin-top: 4px;
}

.fb-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.fb-text {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.6;
}

.fb-text-sm {
  margin: 2px 0 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.fb-yours .fb-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--bad);
}

.fb-note {
  background: #fffbeb;
  border-color: #fde68a;
}

/* Glossary: a compact strip under the question, and a tip card for the tapped word */
.glossary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.glossary .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gloss-label {
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
}

.gloss-chip {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 1rem;
  background: #fff;
  border: 1px solid #c7d2fe;
  box-shadow: 0 2px 0 #c7d2fe;
}

.gloss-chip:active {
  transform: translateY(1px);
  box-shadow: none;
}

.gloss-tip {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #c7d2fe;
  border-inline-start: 5px solid #f59e0b;
  box-shadow: var(--shadow);
}

.gloss-tip[hidden] {
  display: none;
}

.tip-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.tip-word {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.tip-meaning {
  font-size: 1.15rem;
  color: var(--text);
}

.gloss-tip .speak-buttons {
  margin-inline-start: 0;
}

/* ---------- Compact play screen (less scrolling on phones) ---------- */

.play.card {
  padding: 12px;
  gap: 10px;
}

.hud {
  gap: 6px;
}

.hud-top {
  flex-wrap: nowrap;
}

.hud-count {
  font-size: 0.95rem;
}

.hud-chip {
  padding: 2px 10px;
  font-size: 0.9rem;
}

.dot {
  width: 10px;
  height: 10px;
}

.dot.current {
  transform: scale(1.2);
}

.hud .timer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud .timer-track {
  flex: 1;
  height: 8px;
}

.hud .timer-text {
  font-size: 0.85rem;
  min-width: 56px;
  text-align: end;
}

.stage {
  gap: 6px;
  padding: 12px;
  border-radius: 16px;
}

.stage .instruction {
  font-size: 0.88rem;
}

.stage .question {
  font-size: 1.2rem;
  line-height: 1.6;
  margin: 2px 0 0;
}

.stage-tags .badge {
  font-size: 0.78rem;
  padding: 2px 8px;
}

.glossary {
  padding-top: 6px;
  gap: 6px 8px;
}

.gloss-chip {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 0.95rem;
}

.answer-zone {
  gap: 8px;
}

.play-actions {
  bottom: 92px;
  padding: 6px 0;
}

.play-actions .btn {
  min-height: 46px;
  font-size: 1.02rem;
}

/* Feedback: one compact block, sentence and speak buttons on the same line */
.feedback {
  gap: 6px;
  padding: 10px 12px;
  border-radius: 14px;
}

.fb-icon {
  width: 28px;
  height: 28px;
  font-size: 0.95rem;
}

.fb-title {
  font-size: 1.05rem;
}

.fb-box {
  padding: 6px 10px;
  border-radius: 10px;
}

.fb-sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.fb-sentence .speak-buttons {
  margin-top: 0;
}

.fb-sentence .fb-label {
  flex-basis: 100%;
}

.fb-text {
  font-size: 1.12rem;
}

.fb-text-sm {
  font-size: 0.95rem;
}

.gloss-tip {
  padding: 8px 10px;
  gap: 6px;
}

.tip-word {
  font-size: 1.15rem;
}

.tip-meaning {
  font-size: 1.02rem;
}

/* Question prompt split into two lines: Persian instruction (RTL) and English sentence (LTR) */
.q-instruction {
  margin: 0;
  direction: rtl;
  text-align: start;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.q-english {
  direction: ltr;
  text-align: left;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.6;
}

/* Result modal: pops up after each answer. Correct = confetti, wrong or timed out = falling rain. */
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
  animation: result-fade 0.2s ease-out;
  overflow: hidden;
}

.result-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 16px 16px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: result-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.result-overlay.ok .result-card { border-top: 6px solid #43aa8b; }
.result-overlay.bad .result-card { border-top: 6px solid #e5484d; }

.result-mood {
  font-size: 3.2rem;
  line-height: 1;
  text-align: center;
  animation: result-bounce 0.6s ease-out;
}

.result-overlay.bad .result-mood {
  animation: result-sway 0.8s ease-in-out 2;
}

.result-card .feedback {
  margin: 8px 0 0;
}

.result-card .btn.primary {
  width: 100%;
  margin-top: 12px;
}

.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.rain-drop {
  position: absolute;
  top: -30px;
  width: 3px;
  height: 26px;
  border-radius: 3px;
  background: linear-gradient(#bfdbfe, #3b82f6);
  opacity: 0.6;
  animation-name: rain-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes result-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes result-bounce {
  0% { transform: scale(0.3); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes result-sway {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(720deg); opacity: 0.9; }
}

@keyframes rain-fall {
  from { transform: translateY(0); }
  to { transform: translateY(115vh); }
}

@media (prefers-reduced-motion: reduce) {
  .result-overlay,
  .result-card,
  .result-mood,
  .result-overlay.bad .result-mood,
  .confetti-piece,
  .rain-drop {
    animation: none !important;
  }
  .confetti-piece,
  .rain-drop {
    display: none;
  }
}
