/* Dark, high-contrast, thumb-first. The whole document is RTL (Hebrew UI);
   English is the embedded direction and is isolated wherever it appears. */

:root {
  --bg: #0d1117;
  --bg-raise: #161b26;
  --bg-card: #1c2333;
  --line: #2a3346;
  --text: #eef2f8;
  --text-dim: #97a3b8;

  --accent: #5eead4;         /* teal: primary action */
  --accent-ink: #04231f;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --good: #4ade80;
  --good-bg: #0f3323;
  --bad: #f87171;
  --bad-bg: #3a1620;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --pad: 16px;
  --tap: 52px;

  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --font: "Heebo", "Assistant", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  /* Kills the 300ms tap delay and the double-tap-to-zoom gesture, which
     otherwise makes rapid answering feel laggy. */
  touch-action: manipulation;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; cursor: pointer; border: none; }
button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* English inside an RTL document. Without isolation, a trailing period or a
   phrase like "as...as" reorders visually and reads as a rendering bug. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  gap: var(--pad);
  animation: rise .22s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ------------------------------------------------------------------ header */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px var(--pad) 0;
}

.topbar .spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.streak { color: var(--amber); }
.chip.level  { color: var(--accent); }

.iconbtn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
}
.iconbtn:active { transform: scale(.94); }

/* XP bar */
.xpbar {
  height: 8px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 var(--pad);
}
.xpbar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}

/* ------------------------------------------------------------- home / cards */

h1.brand {
  margin: 4px 0 0;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -.5px;
}
.brand small {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 2px;
}

.menu { display: flex; flex-direction: column; gap: 12px; }

.bigcard {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 84px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: start;
  transition: transform .12s ease, border-color .12s ease;
}
.bigcard:active { transform: scale(.985); }
.bigcard .emoji { font-size: 30px; line-height: 1; }
.bigcard .t { flex: 1; }
.bigcard .t b { display: block; font-size: 19px; font-weight: 800; }
.bigcard .t span { font-size: 14px; color: var(--text-dim); }
.bigcard .go { color: var(--text-dim); font-size: 22px; }

.bigcard.primary {
  background: linear-gradient(135deg, #123c3a, #16233a);
  border-color: #2c6c63;
}
.bigcard.primary .t b { color: var(--accent); }

.bigcard[disabled] { opacity: .45; }

/* ------------------------------------------------------------------- map */

.maplist { display: flex; flex-direction: column; gap: 10px; }

.stagerow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  width: 100%;
  text-align: start;
}
.stagerow[disabled] { opacity: .4; }
.stagerow .num {
  width: 42px; height: 42px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--bg-raise);
  font-weight: 900;
  font-size: 17px;
}
.stagerow.done .num { background: var(--accent); color: var(--accent-ink); }
.stagerow.current { border-color: var(--accent); }
.stagerow .t { flex: 1; }
.stagerow .t b { display: block; font-size: 16px; font-weight: 800; }
.stagerow .t span { font-size: 13px; color: var(--text-dim); }
.stars { letter-spacing: 2px; font-size: 15px; color: var(--amber); }
.stars .off { color: #384155; }

/* ------------------------------------------------------------------- play */

.playhead {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hearts { font-size: 16px; letter-spacing: 1px; }
.progress {
  flex: 1;
  height: 10px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

.timerbar {
  height: 4px;
  border-radius: 999px;
  background: var(--bg-card);
  overflow: hidden;
}
.timerbar > i {
  display: block; height: 100%;
  background: var(--amber);
  transform-origin: right center;   /* RTL: drains toward the left */
}
.timerbar.urgent > i { background: var(--bad); }

.qcard {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px 18px;
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--line);
  text-align: center;
  min-height: 168px;
}

.qask { font-size: 14px; color: var(--text-dim); font-weight: 600; }

.qword {
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -.5px;
}
.qword.he { font-size: clamp(28px, 8vw, 42px); }

.qsentence {
  font-size: clamp(18px, 5vw, 23px);
  line-height: 1.6;
  font-weight: 600;
}
.qsentence .target { color: var(--accent); font-weight: 900; }
.qsentence .blank {
  display: inline-block;
  min-width: 84px;
  border-bottom: 3px solid var(--accent);
  vertical-align: baseline;
}

.speaker {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 40px;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.speaker:active { transform: scale(.94); }

/* Options sit at the bottom, inside thumb reach. */
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opt {
  min-height: var(--tap);
  padding: 14px 18px;
  border-radius: var(--r);
  background: var(--bg-raise);
  border: 2px solid var(--line);
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.opt:active { transform: scale(.985); }
.opt.correct {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}
.opt.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}
.opt.muted { opacity: .3; }
.opt[disabled] { cursor: default; }

/* Answer feedback strip */
.verdict {
  border-radius: var(--r);
  padding: 14px 16px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: rise .18s ease-out;
}
.verdict.ok  { background: var(--good-bg); color: var(--good); }
.verdict.no  { background: var(--bad-bg);  color: var(--bad); }
.verdict .sub {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  opacity: .9;
}

.combo {
  position: fixed;
  inset-inline-start: 50%;
  top: 22%;
  transform: translateX(50%);
  font-size: 40px;
  font-weight: 900;
  color: var(--amber);
  pointer-events: none;
  animation: pop .7s ease-out forwards;
  text-shadow: 0 4px 18px rgba(0, 0, 0, .6);
}
@keyframes pop {
  0%   { opacity: 0; transform: translateX(50%) scale(.6); }
  25%  { opacity: 1; transform: translateX(50%) scale(1.15); }
  70%  { opacity: 1; transform: translateX(50%) scale(1); }
  100% { opacity: 0; transform: translateX(50%) translateY(-30px) scale(1); }
}

/* ------------------------------------------------------------------ meet */

.meetcard {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 26px 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(150deg, #1b2740, var(--bg-card));
  border: 1px solid var(--line);
  text-align: center;
}
.meetcard .en { font-size: clamp(32px, 10vw, 50px); font-weight: 900; }
.meetcard .he { font-size: clamp(24px, 7vw, 34px); font-weight: 800; color: var(--accent); }
.meetcard .ex { font-size: 16px; color: var(--text-dim); line-height: 1.6; }

/* --------------------------------------------------------------- results */

.result-hero { text-align: center; padding: 8px 0; }
.result-hero .big { font-size: 30px; font-weight: 900; }
.result-hero .stars { font-size: 40px; letter-spacing: 6px; }

.statgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 8px;
  text-align: center;
}
.stat b { display: block; font-size: 24px; font-weight: 900; }
.stat span { font-size: 12px; color: var(--text-dim); }

.misslist { display: flex; flex-direction: column; gap: 8px; }
.missrow {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}
.missrow .pair {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 17px; font-weight: 800;
}
.missrow .pair .he { color: var(--accent); }
.missrow .ex { font-size: 14px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }

/* --------------------------------------------------------------- controls */

.btn {
  min-height: var(--tap);
  padding: 15px 22px;
  border-radius: var(--r);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  font-weight: 800;
  width: 100%;
}
.btn:active { transform: scale(.985); }
.btn.ghost {
  background: transparent;
  border: 2px solid var(--line);
  color: var(--text);
}

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-dim);
  margin: 4px 0 -4px;
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 11px 15px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 2px solid var(--line);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.pill[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.optionlist { display: flex; flex-direction: column; gap: 8px; }
.optionrow {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--bg-card);
  border: 2px solid var(--line);
  color: var(--text);
  width: 100%; text-align: start;
  font-size: 16px; font-weight: 700;
}
.optionrow[aria-pressed="true"] { border-color: var(--accent); }
.optionrow .sub { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.optionrow .t { flex: 1; }

.switchrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r); font-weight: 700;
}
.switch {
  width: 52px; height: 30px; border-radius: 999px;
  background: var(--line); position: relative; flex: none;
  transition: background .2s ease;
}
.switch[aria-pressed="true"] { background: var(--accent); }
.switch i {
  position: absolute; top: 3px; inset-inline-start: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform .2s ease;
}
.switch[aria-pressed="true"] i { transform: translateX(-22px); }

.danger { color: var(--bad); border-color: #5b2330 !important; }

.note {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  text-align: center;
}

.empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-dim);
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}
