:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #1769e0;
  --primary-dark: #0d4dac;
  --ok: #0d8a53;
  --bad: #c0392b;
  --soft-ok: #e9f8ef;
  --soft-bad: #fdeceb;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  background: radial-gradient(circle at top right, #dbeafe 0, transparent 34%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 4vw, 42px);
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.hero-card,
.question-card,
.session-card,
.result-card,
.review-card {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(217,225,236,0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: clamp(22px, 4vw, 40px);
}

.hero-card h2,
.result-card h2,
.review-card h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 3vw, 32px);
}

.hero-card p { color: var(--muted); margin: 0 0 24px; }

.welcome-brand {
  text-align: center;
  margin-bottom: 28px;
}

.welcome-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(280px, 62vw);
  aspect-ratio: 1 / 1;
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,255,0.96));
  border: 1px solid rgba(217,225,236,0.95);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
  margin-bottom: 14px;
  animation: logoPop 0.55s ease;
}

.welcome-logo {
  width: 100%;
  height: auto;
  display: block;
}

.welcome-brand .brand-note {
  color: var(--muted);
  margin: 0;
}

@keyframes logoPop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.topic-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-radius: 18px;
  padding: 20px;
  text-align: right;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(23, 105, 224, 0.13);
  border-color: #9ec3ff;
}

.topic-card strong {
  display: block;
  font-size: 21px;
  margin-bottom: 8px;
}

.topic-card span { color: var(--muted); }

.quiz-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.session-card,
.question-card,
.result-card,
.review-card {
  padding: clamp(18px, 3vw, 30px);
}

.session-card {
  position: sticky;
  top: 18px;
}

.pill {
  display: inline-block;
  background: #e8f1ff;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  margin-bottom: 18px;
}

.progress-text {
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 10px;
}

.progress-bar {
  height: 12px;
  background: #e5eaf2;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

#progressFill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: inherit;
  transition: width 0.2s ease;
}

.score-live { color: var(--muted); margin-bottom: 22px; }

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.badge {
  background: #f2f4f7;
  color: #344054;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
}

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

#questionText {
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1.35;
  margin: 0 0 22px;
}

.options-box {
  display: grid;
  gap: 12px;
}

.option-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  text-align: right;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  min-height: 64px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: #98bfff;
  transform: translateY(-1px);
}

.option-letter {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef2f7;
  font-weight: 800;
}

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

.option-btn.correct .option-letter {
  background: var(--ok);
  color: #fff;
}

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

.option-btn.wrong .option-letter {
  background: var(--bad);
  color: #fff;
}

.feedback {
  margin-top: 18px;
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f8fafc;
  line-height: 1.6;
}

.feedback.good { background: var(--soft-ok); border-color: #96dbb8; }
.feedback.bad { background: var(--soft-bad); border-color: #f0a39d; }

.actions-row,
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.primary,
.secondary,
.ghost {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
}

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

.secondary {
  background: #172033;
  color: #fff;
}

.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.full { width: 100%; }

.result-card {
  text-align: center;
  max-width: 760px;
  margin: 0 auto;
}

.result-kicker {
  color: var(--primary-dark);
  font-weight: 900;
  margin-bottom: 8px;
}

.score-circle {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  margin: 24px auto 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #e8f1ff, #ffffff);
  border: 10px solid #cfe2ff;
}

.score-circle span {
  font-size: 38px;
  font-weight: 900;
}

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

.review-card { max-width: 980px; margin: 0 auto; }
.review-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.review-list { display: grid; gap: 12px; }

.review-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}

.review-item.ok { border-color: #96dbb8; background: #fbfffd; }
.review-item.no { border-color: #f0a39d; background: #fffafa; }

.review-item h3 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.4;
}

.review-meta {
  display: grid;
  gap: 6px;
  color: #344054;
}

.mark-ok { color: var(--ok); font-weight: 900; }
.mark-no { color: var(--bad); font-weight: 900; }

.bottom-actions { margin-top: 24px; }

@media (max-width: 820px) {
  .topbar { align-items: flex-start; }
  .quiz-layout { grid-template-columns: 1fr; }
  .session-card { position: static; }
  .progress-text { font-size: 30px; }
  .review-head { display: block; }
  .review-head .ghost { margin-top: 12px; }
}


.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.18), transparent 28%),
    linear-gradient(145deg, rgba(7, 15, 30, 0.96), rgba(18, 42, 84, 0.94));
  overflow: hidden;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.intro-overlay::before,
.intro-overlay::after {
  content: "";
  position: absolute;
  inset: auto;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(16px);
  opacity: 0.18;
}

.intro-overlay::before {
  background: rgba(255, 70, 70, 0.55);
  top: -18vmax;
  left: -12vmax;
}

.intro-overlay::after {
  background: rgba(30, 180, 90, 0.5);
  bottom: -18vmax;
  right: -12vmax;
}

.intro-overlay.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-inner {
  position: relative;
  text-align: center;
  color: #fff;
  padding: 24px;
}

.intro-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(60vw, 360px);
  height: min(60vw, 360px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 0 18px rgba(255,255,255,0.04), 0 0 70px rgba(255,255,255,0.08);
  animation: introPulse 2.4s ease-in-out infinite;
}

.intro-logo-card {
  position: relative;
  width: min(50vw, 300px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 18px;
  border-radius: 30px;
  padding: 20px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  animation: introDrop 0.9s cubic-bezier(.2,.7,.2,1), introFloat 3s ease-in-out 0.9s infinite;
}

.intro-logo-card::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 36px;
  border: 2px solid rgba(255,255,255,0.22);
  opacity: 0.9;
  animation: introHalo 2.2s ease-in-out infinite;
}

.intro-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.intro-title {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 900;
  letter-spacing: 0.04em;
  animation: introTextIn 0.9s ease 0.2s both;
}

.intro-subtitle {
  margin: 8px 0 0;
  font-size: clamp(16px, 2vw, 22px);
  color: rgba(255,255,255,0.82);
  animation: introTextIn 0.9s ease 0.35s both;
}

.welcome-logo-wrap {
  animation: logoPop 0.55s ease, homeFloat 3.2s ease-in-out 0.55s infinite;
}

@keyframes introDrop {
  from {
    opacity: 0;
    transform: translateY(38px) scale(0.78) rotate(-6deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
  }
}

@keyframes introFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.02); }
}

@keyframes introPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.55; }
  50% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

@keyframes introHalo {
  0%, 100% { transform: scale(0.98); opacity: 0.45; }
  50% { transform: scale(1.04); opacity: 0.95; }
}

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

@keyframes homeFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}


/* Mobile logo fit fixes */
.intro-logo-card {
  width: clamp(220px, 82vw, 360px);
  aspect-ratio: 539 / 372;
  height: auto;
  padding: clamp(10px, 3.8vw, 18px);
  border-radius: clamp(18px, 5vw, 30px);
}

.intro-logo-card::after {
  border-radius: clamp(24px, 6vw, 36px);
}

.intro-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.intro-ring {
  width: clamp(250px, 94vw, 430px);
  height: clamp(250px, 94vw, 430px);
}

.welcome-logo-wrap {
  width: clamp(210px, 78vw, 380px);
  aspect-ratio: 539 / 372;
  padding: clamp(10px, 3.8vw, 18px);
}

.welcome-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .topbar h1 {
    font-size: 24px;
    line-height: 1.18;
  }

  .topbar p {
    font-size: 14px;
  }

  .hero-card {
    padding: 16px;
    border-radius: 18px;
  }

  .welcome-brand {
    margin-bottom: 18px;
  }

  .welcome-logo-wrap {
    width: min(86vw, 330px);
    margin-bottom: 10px;
  }

  .intro-logo-card {
    width: min(88vw, 340px);
    max-height: 58vh;
  }

  .intro-title {
    font-size: 32px;
  }

  .intro-subtitle {
    font-size: 16px;
  }
}

@media (max-width: 360px) {
  .intro-logo-card,
  .welcome-logo-wrap {
    width: 90vw;
    padding: 8px;
  }
}
