:root {
  --navy: #0b3d6d;
  --navy-deep: #062445;
  --gold: #f4b942;
  --ink: #1b2838;
  --sky: #4fc3f7;
  --mint: #66bb6a;
  --coral: #ff7043;
  --lilac: #ab47bc;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, #ffe082 0, transparent 28%),
    radial-gradient(circle at 90% 0%, #81d4fa 0, transparent 30%),
    radial-gradient(circle at 80% 80%, #c5e1a5 0, transparent 25%),
    #f3f7ff;
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(21, 101, 192, .15);
}
.urdu, [dir="rtl"] {
  font-family: "Noto Nastaliq Urdu", "Segoe UI", serif;
  line-height: 2;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.app-header {
  background: linear-gradient(120deg, #1565c0, #7b1fa2 55%, #ef6c00);
  color: #fff;
  padding: 14px 0;
  box-shadow: 0 10px 28px rgba(21, 101, 192, .28);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.header-brand { min-width: 0; }
.brand-kicker {
  letter-spacing: .16em;
  font-size: .72rem;
  font-weight: 800;
  color: #ffe082;
  text-transform: uppercase;
}
.brand-title { font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}
.header-name {
  font-weight: 700;
  font-size: .95rem;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.header-actions .btn {
  min-height: 36px;
  padding-left: 12px;
  padding-right: 12px;
}
.page-main { max-width: 1100px; }
.app-footer {
  margin-top: 32px;
  padding: 16px 0 calc(28px + var(--safe-bottom));
  color: #5c6b7a;
  font-size: .9rem;
}
.card-soft, .kid-card {
  background: #fff;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 16px 36px rgba(21, 101, 192, .12);
}
.kid-card { position: relative; overflow: hidden; }
.kid-card-blue { border-top: 8px solid #42a5f5; }
.kid-card-orange { border-top: 8px solid #ff9800; }
.kid-card-green { border-top: 8px solid #66bb6a; }
.kid-card-title { color: #1565c0; font-weight: 800; margin-bottom: .5rem; }

.start-hero {
  text-align: center;
  background: linear-gradient(135deg, #fff59d, #80deea);
  border-radius: 24px;
  padding: 24px 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,.08);
}
.start-emoji { font-size: 2.2rem; }
.start-hero h2 { color: #0d47a1; font-weight: 800; font-size: clamp(1.25rem, 4vw, 1.75rem); }

.kid-radio-list label {
  display: block;
  background: #f5f9ff;
  border: 2px solid #d6e4ff;
  border-radius: 14px;
  padding: 14px 14px;
  margin: 8px 0;
  cursor: pointer;
  font-weight: 600;
  min-height: 48px;
  transition: .15s ease;
  word-wrap: break-word;
}
.kid-radio-list input { margin-right: 8px; margin-top: 4px; vertical-align: top; }
.kid-radio-list label:hover { border-color: #42a5f5; background: #e3f2fd; }
.kid-select { border-radius: 14px; border-width: 2px; min-height: 48px; }

.btn-kid-start {
  background: linear-gradient(135deg, #ff9800, #f44336);
  border: 0;
  color: #fff !important;
  font-weight: 800;
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(244, 67, 54, .35);
  min-height: 52px;
  width: min(100%, 360px);
}
.btn-kid-start:hover { filter: brightness(1.05); color: #fff; }

.subject-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 16px;
  height: 100%;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(11,61,109,.08);
  border-bottom: 6px solid #90caf9;
  transition: transform .15s ease, box-shadow .15s ease;
}
.subject-tile:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(11,61,109,.14); color: inherit; }
.subject-tile h3 { margin: 0 0 6px; color: var(--navy); font-size: 1.1rem; font-weight: 800; }
.subject-tile p { font-size: .9rem; color: #546e7a; }
.subject-en { border-bottom-color: #42a5f5; }
.subject-sci { border-bottom-color: #66bb6a; }
.subject-math { border-bottom-color: #ff9800; }
.subject-iq { border-bottom-color: #ab47bc; }
.subject-ur { border-bottom-color: #ef5350; }

.login-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0;
}
.login-brand {
  background:
    radial-gradient(900px 480px at 10% 10%, rgba(255,224,130,.35), transparent 55%),
    linear-gradient(165deg, #1565c0 0%, #7b1fa2 55%, #ef6c00 100%);
  color: #fff;
  padding: 48px 40px;
  border-radius: 20px 0 0 20px;
}
.login-brand h1 {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 800;
  line-height: 1.2;
}
.login-panel {
  background: #fff;
  padding: 40px 32px;
  border-radius: 0 20px 20px 0;
}
.login-panel .form-control,
.login-panel .btn {
  min-height: 48px;
}

/* Quiz UI */
.quiz-page { padding-bottom: calc(88px + var(--safe-bottom)); }
.quiz-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
  justify-content: space-between;
  margin-bottom: 14px;
}
.quiz-heading { min-width: 0; flex: 1 1 180px; }
.quiz-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  justify-content: flex-end;
  flex: 1 1 220px;
}
.quiz-title { font-size: clamp(1.15rem, 3.5vw, 1.4rem); font-weight: 800; color: #0d47a1; }
.quiz-progress { color: #546e7a; font-weight: 600; font-size: .95rem; }
.quiz-timer {
  background: #fff3e0;
  border: 3px solid #ffb74d;
  border-radius: 16px;
  padding: 10px 14px;
  font-weight: 800;
  color: #e65100;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.live-score {
  min-width: 150px;
  flex: 1 1 150px;
  border-radius: 18px;
  padding: 10px 14px;
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 22px rgba(0,0,0,.12);
}
.live-pass { background: linear-gradient(135deg, #43a047, #1b5e20); }
.live-warn { background: linear-gradient(135deg, #fb8c00, #e65100); }
.live-label { font-size: .75rem; opacity: .95; font-weight: 700; }
.live-marks { font-size: 1.25rem; font-weight: 800; }
.live-pct { font-size: 1rem; font-weight: 800; }
.live-hint { font-size: .78rem; margin-top: 4px; }

.quiz-stage {
  padding: 18px;
  border: 3px solid #bbdefb;
  background: linear-gradient(180deg, #ffffff, #f3f9ff);
}
.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: .85rem;
}
.pill-subject { background: #e1bee7; color: #6a1b9a; }
.pill-marks { background: #c8e6c9; color: #1b5e20; }
.btn-help {
  border: 0;
  background: #fff59d;
  color: #f57f17;
  font-weight: 800;
  border-radius: 999px;
  padding: 10px 14px;
  margin-left: auto;
  min-height: 42px;
  box-shadow: 0 4px 10px rgba(245, 127, 23, .25);
}
.help-box {
  background: #fffde7;
  border: 2px dashed #fbc02d;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  color: #5d4037;
  font-weight: 600;
}
.q-english {
  font-size: clamp(1.1rem, 3.8vw, 1.3rem);
  font-weight: 700;
  color: #0d47a1;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.q-urdu {
  font-size: clamp(1.05rem, 3.6vw, 1.2rem);
  color: #4a148c;
  background: #f3e5f5;
  border-radius: 14px;
  padding: 10px 14px;
}

.option-grid { width: 100%; }
.kid-options {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
}
.kid-options input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.kid-options label {
  position: relative;
  display: block !important;
  width: 100%;
  background: #fff;
  border: 3px solid #90caf9;
  border-radius: 16px;
  padding: 14px 16px 14px 52px;
  margin: 0;
  cursor: pointer;
  font-size: clamp(1rem, 3.5vw, 1.1rem);
  font-weight: 700;
  min-height: 56px;
  line-height: 1.4;
  transition: .12s ease;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  -webkit-user-select: none;
  user-select: none;
}
.kid-options label::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 3px solid #64b5f6;
  border-radius: 50%;
  background: #fff;
}
.kid-options label::after {
  content: "";
  position: absolute;
  left: 21px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transform: translateY(-50%);
}
.kid-options label:active { transform: scale(.99); }
.kid-options label:hover {
  border-color: #1976d2;
  background: #e3f2fd;
}
.kid-options input:checked + label {
  border-color: #43a047;
  background: #e8f5e9;
  box-shadow: 0 0 0 3px rgba(67,160,71,.2);
}
.kid-options input:checked + label::before {
  border-color: #43a047;
}
.kid-options input:checked + label::after {
  background: #43a047;
}
.kid-input {
  border-radius: 14px;
  border: 3px solid #90caf9;
  font-size: 1.05rem !important;
  min-height: 96px;
}
.practice-note {
  margin-top: 12px;
  background: #fce4ec;
  color: #880e4f;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}

.quiz-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 24px;
  align-items: center;
}
.btn-kid-nav, .btn-kid-next, .btn-kid-finish {
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  padding: 12px 18px;
  min-height: 48px;
}
.btn-kid-nav { background: #eceff1; color: #37474f; }
.btn-kid-next { background: linear-gradient(135deg, #42a5f5, #5c6bc0); color: #fff !important; }
.btn-kid-finish { background: linear-gradient(135deg, #66bb6a, #2e7d32); color: #fff !important; margin-left: auto; }

.pass-badge { background: #198754; }
.fail-badge { background: #dc3545; }
.review-correct { background: #e8f7ee; }
.review-wrong { background: #fdecee; }
.q-card { border-left: 5px solid var(--gold); margin-bottom: 16px; }
.q-meta { font-size: .85rem; color: #5c6b7a; }
.timer-box {
  position: sticky; top: 12px; z-index: 20;
  background: #fff8e8; border: 1px solid #f0d48a; border-radius: 12px;
  padding: 10px 14px; font-weight: 700; color: #7a5a10;
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* Phones / small tablets */
@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .login-brand {
    border-radius: 20px 20px 0 0;
    padding: 28px 22px;
  }
  .login-panel {
    border-radius: 0 0 20px 20px;
    padding: 28px 22px;
  }
}

@media (max-width: 767.98px) {
  .app-header { padding: 10px 0; }
  .brand-kicker { font-size: .62rem; letter-spacing: .12em; }
  .brand-title { font-size: 1.05rem; }
  .header-user {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }
  .header-name { max-width: 55%; font-size: .85rem; }
  .page-main { padding-left: 12px; padding-right: 12px; }
  .kid-card, .card-soft, .start-hero { border-radius: 18px; }
  .kid-card.p-4, .card-soft.p-4 { padding: 1rem !important; }
  .subject-tile { padding: 14px 12px; }
  .subject-tile h3 { font-size: 1rem; }
  .subject-tile p { font-size: .8rem; line-height: 1.3; }

  .quiz-status { width: 100%; }
  .quiz-timer, .live-score { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .live-score { padding: 8px 10px; }
  .live-marks { font-size: 1.1rem; }
  .quiz-stage { padding: 14px; border-width: 2px; }
  .btn-help { margin-left: 0; width: 100%; }

  /* Sticky MCQ controls for thumb reach */
  .quiz-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    margin: 0;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border-top: 1px solid #dbe7f5;
    box-shadow: 0 -8px 24px rgba(11, 61, 109, .12);
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 8px;
  }
  .btn-kid-nav,
  .btn-kid-next,
  .btn-kid-finish {
    width: 100%;
    margin: 0 !important;
    padding: 12px 8px;
    font-size: .92rem;
    white-space: nowrap;
  }
  .btn-kid-finish { order: 0; }

  .app-footer { font-size: .8rem; padding-bottom: calc(18px + var(--safe-bottom)); }
}

@media (max-width: 420px) {
  .quiz-timer { font-size: .95rem; padding: 8px 10px; }
  .btn-kid-nav,
  .btn-kid-next,
  .btn-kid-finish { font-size: .84rem; padding: 12px 4px; }
  .header-actions .btn { font-size: .8rem; padding-left: 8px; padding-right: 8px; }
}

/* Larger phones in landscape still keep sticky nav */
@media (max-width: 900px) and (orientation: landscape) {
  .quiz-page { padding-bottom: calc(76px + var(--safe-bottom)); }
}

.demo-purchase-banner {
  border: 2px solid #f0ad4e;
  background: #fff8e6;
  color: #5c4400;
  font-size: .98rem;
  line-height: 1.55;
}
