    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --orange: #F47920; --blue: #003087; --bm: #1A5DAA;
      --green: #1a7a30; --red: #b02020;
    }

      /* ── Exercise Tab (new Level 1-6 flow) ── */
    .exn-level-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin: 14px 0;
    }
    .exn-level-btn {
      padding: 14px 6px 12px;
      border-radius: 14px;
      border: 2px solid var(--blue);
      background: white;
      color: var(--blue);
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
      text-align: center;
      transition: transform .15s, background .15s;
      line-height: 1.3;
    }
    .exn-level-btn:active { transform: scale(.96); }
    .exn-level-btn.locked {
      border-color: #d0d0d0;
      color: #bbb;
      background: #f7f7f7;
      cursor: not-allowed;
    }
    .exn-level-btn .exn-lock-icon { font-size: 18px; display: block; margin-bottom: 3px; }
    .exn-level-btn .exn-sub       { font-size: 10px; font-weight: 600; opacity: .7;
                                     display: block; margin-top: 3px; line-height: 1.2; }
    .exn-level-btn .exn-pct       { font-size: 10px; color: var(--green); font-weight: 700;
                                     display: block; margin-top: 2px; }
    .exn-timer-notice {
      background: #fff8e1; border: 1.5px solid #f9a825;
      border-radius: 12px; padding: 14px 16px;
      font-size: 13px; color: #5d4037; text-align: center; margin: 10px 0;
    }
    /* ── Question screen ── */
    .exn-level-title {
      font-size: 15px; font-weight: 800; color: var(--blue);
      text-align: center; margin-bottom: 2px;
    }
    .exn-meta {
      font-size: 11px; color: #999; text-align: center; margin-bottom: 4px;
    }
    .exn-cat-badge {
      display: inline-block; background: var(--blue); color: white;
      border-radius: 8px; padding: 2px 11px; font-size: 11px; font-weight: 700;
    }
    .exn-numbers-wrap {
      background: #f0f4ff; border-radius: 16px;
      padding: 20px 12px; margin: 8px 0; text-align: center;
    }
    .exn-num-row {
      display: flex; justify-content: center;
      align-items: center; gap: 6px; flex-wrap: wrap;
    }
    .exn-num { font-size: 30px; font-weight: 900; color: #1a1a2e; min-width: 40px; text-align: center; }
    .exn-num.neg { color: #c0392b; }
    .exn-op  { font-size: 22px; color: #999; font-weight: 700; }
    /* Timer bar */
    .exn-timer-wrap {
      display: flex; align-items: center; gap: 10px; margin: 2px 0;
    }
    .exn-timer-track {
      flex: 1; height: 8px; background: #e0e0e0;
      border-radius: 99px; overflow: hidden;
    }
    .exn-timer-fill {
      height: 100%; background: var(--green);
      border-radius: 99px; transition: width .95s linear, background .3s;
    }
    .exn-timer-fill.warn   { background: #f39c12; }
    .exn-timer-fill.danger { background: #e74c3c; }
    .exn-timer-num { font-size: 13px; font-weight: 800; color: #666; min-width: 32px; text-align: right; }
    /* Stats bar */
    .exn-stats-bar {
      display: flex; justify-content: space-around;
      background: #f8f9ff; border-radius: 12px; padding: 10px 6px; margin: 4px 0;
    }
    .exn-stat-val { font-size: 20px; font-weight: 900; color: var(--blue); text-align: center; }
    .exn-stat-lbl { font-size: 10px; color: #999; font-weight: 600; text-align: center; }
    /* Answer */
    .exn-ans-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
    .exn-ans-input {
      flex: 1; font-size: 28px; font-weight: 800; text-align: center;
      border: 2px solid var(--blue); border-radius: 12px; padding: 10px; outline: none;
    }
    .exn-ans-input:disabled { background: #f0f0f0; }
    .exn-submit-btn {
      background: var(--green); color: white; border: none;
      border-radius: 12px; padding: 12px 22px; font-size: 16px;
      font-weight: 800; cursor: pointer;
    }
    .exn-submit-btn:disabled { background: #ccc; cursor: not-allowed; }
    /* Feedback */
    .exn-feedback {
      text-align: center; font-size: 20px; font-weight: 900;
      padding: 8px; border-radius: 12px;
      display: none;
    }
    .exn-feedback.ok  { display: block; color: #27ae60; background: #eafaf1; }
    .exn-feedback.bad { display: block; color: #c0392b; background: #fdecea; }
    /* Unlock banner */
    .exn-unlock-banner {
      display: none; background: linear-gradient(135deg,#27ae60,#2ecc71);
      color: white; border-radius: 14px; padding: 14px;
      text-align: center; font-weight: 800; font-size: 14px;
      animation: exnPop .35s ease;
    }
    @keyframes exnPop {
      from { transform: scale(.8); opacity: 0; }
      to   { transform: scale(1);  opacity: 1; }
    }
    .exn-quit {
      text-align: center; font-size: 11px; color: #bbb;
      cursor: pointer; text-decoration: underline; margin-top: 6px;
    }

    body { font-family: sans-serif; background: #003087; color: white; min-height: 100vh; padding: 16px; }
    .screen { display: none; min-height: 100vh; flex-direction: column; align-items: center; justify-content: flex-start; padding: 16px; }
    .screen.active { display: flex; }
    .screen#sc-home { justify-content: center; }
    .wizard { font-size: 64px; margin-bottom: 12px; }
    .app-name { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
    .app-sub { font-size: 13px; opacity: .7; margin-bottom: 28px; }
    .menu { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; }
    .btn { padding: 13px; border-radius: 12px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; width: 100%; }
    .btn:active { transform: scale(.97); }
    .btn-orange { background: var(--orange); color: white; }
    .btn-ghost { background: rgba(255,255,255,.12); color: white; border: 1.5px solid rgba(255,255,255,.25); }
    .btn-ghost2 { background: rgba(255,255,255,.06); color: white; border: 1.5px solid rgba(255,255,255,.12); }
    .btn-solid { background: white; color: var(--blue); }
    .version { font-size: 10px; opacity: .35; margin-top: 24px; }
    .login-box { background: white; border-radius: 20px; padding: 28px 24px; width: 100%; max-width: 340px; color: #222; }
    .login-av { font-size: 48px; text-align: center; margin-bottom: 8px; }
    .login-title { font-size: 18px; font-weight: 700; color: var(--blue); text-align: center; margin-bottom: 4px; }
    .login-sub { font-size: 12px; color: #888; text-align: center; margin-bottom: 18px; }
    .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
    .field label { font-size: 11px; color: #666; font-weight: 600; }
    .field input { padding: 10px 12px; border-radius: 8px; border: 1.5px solid #ddd; font-size: 14px; outline: none; font-family: inherit; }
    .field input:focus { border-color: var(--orange); }
    .ef-feature-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
    .ef-feature-toggle { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: #333; cursor: pointer; background: #f8f9ff; border: 1.5px solid #e0e6ff; border-radius: 10px; padding: 8px 14px; }
    .ef-feature-toggle input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
    .pin-dots { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
    .pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue); background: white; transition: background .1s; }
    .pin-dot.filled { background: var(--blue); }
    .pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 220px; margin: 0 auto 12px; }
    .pkey { padding: 11px; border-radius: 10px; border: 1.5px solid #eee; background: white; font-size: 17px; font-weight: 600; cursor: pointer; color: #222; transition: all .12s; }
    .pkey:hover { background: #f0f4ff; border-color: var(--blue); }
    .pkey.del { font-size: 13px; color: var(--red); }
    .err-msg { color: var(--red); font-size: 11px; min-height: 16px; text-align: center; margin-bottom: 6px; }
    .back-lnk { font-size: 12px; color: rgba(255,255,255,.6); cursor: pointer; text-decoration: underline; margin-top: 14px; }
    .dash { background: #f4f6fa; min-height: auto; color: #222; width: 100%; max-width: 500px; border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
    .dash.wide { max-width: 560px; }
    .dash-header { background: var(--blue); color: white; padding: 16px; display: flex; align-items: center; gap: 12px; }
    .dash-av { width: 44px; height: 44px; border-radius: 50%; background: var(--orange); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; }
    .dash-name { font-size: 15px; font-weight: 700; }
    .dash-meta { font-size: 11px; opacity: .75; }
    .signout { margin-left: auto; font-size: 11px; opacity: .7; cursor: pointer; text-decoration: underline; }
    .dash-tabs { display: flex; background: white; border-bottom: 1px solid #eee; overflow-x: auto; }
    .dtab { padding: 10px 14px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; color: #888; border-bottom: 2px solid transparent; }
    .dtab.active { color: var(--blue); border-color: var(--blue); }
    .dash-body { padding: 14px; }
    .section { font-size: 12px; font-weight: 700; color: var(--blue); margin: 12px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
    .stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 14px; }
    .stat { background: white; border-radius: 10px; padding: 10px; text-align: center; border: 1px solid #eee; }
    .stat-val { font-size: 20px; font-weight: 700; color: var(--blue); }
    .stat-val.or { color: var(--orange); }
    .stat-val.gr { color: var(--green); }
    .stat-lbl { font-size: 10px; color: #888; margin-top: 2px; }
    .card { background: white; border-radius: 10px; padding: 14px; margin-bottom: 10px; border: 1px solid #eee; }
    .practice-btn { background: var(--orange); color: white; border: none; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; width: 100%; margin-bottom: 10px; }
    .htable { width: 100%; border-collapse: collapse; font-size: 12px; }
    .htable th { background: var(--blue); color: white; padding: 6px 8px; text-align: left; }
    .htable td { padding: 5px 8px; border-bottom: 1px solid #eee; }
    .htable tr:nth-child(even) td { background: #f9f9f9; }
    .badge { display: inline-block; padding: 2px 7px; border-radius: 8px; font-size: 10px; font-weight: 600; }
    .bg { background: #e8f5ec; color: #1a7a30; }
    .bo { background: #fde8d0; color: #c85e0a; }
    .br { background: #fceaea; color: #b02020; }
    .weak-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #eee; font-size: 12px; }
    .wbar { flex: 1; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
    .wfill { height: 100%; border-radius: 3px; }
    .pdetail { font-size: 13px; line-height: 2.2; }
    .pdetail b { color: var(--blue); }
    .empty { text-align: center; padding: 30px; color: #aaa; font-size: 13px; }
    .srow { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; border: 1px solid #eee; background: white; margin-bottom: 6px; cursor: pointer; }
    .srow:hover { border-color: var(--orange); background: #fff8f0; }

    /* ── Abacus ── */
    .abacus-wrap { background: #F5EFE6; border-radius: 12px; padding: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; display: flex; justify-content: center; }
    .abacus-frame { background: #7B4A1E; border-radius: 10px; padding: 6px 4px; display: inline-flex; flex-direction: column; width: auto; }
    .abacus-frame .frame-bar { height: 7px; background: #5A3010; border-radius: 4px; margin: 2px 0; }
    .frame-inner { display: flex; flex-direction: row; align-items: stretch; }
    .end-post { width: 10px; background: #5A3010; border-radius: 2px; flex-shrink: 0; }
    .rods-row { display: flex; justify-content: center; }
    .acol { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; width: 28px; }
    .acol-lbl { font-size: 6px; color: #C8956A; text-align: center; margin-bottom: 1px; font-weight: 600; height: 10px; line-height: 10px; white-space: nowrap; }
    .acol-lbl.home-lbl { color: #FF3300; font-size: 7px; }
    .acol-lbl.dec-lbl { color: #FFAA44; }
    .heaven-zone { height: 52px; position: relative; width: 28px; }
    .earth-zone { height: 120px; position: relative; width: 28px; }
    .rod-stick { position: absolute; left: 50%; transform: translateX(-50%); width: 3px; background: #C8956A; border-radius: 2px; top: 0; bottom: 0; z-index: 1; }
    .divider-bar { height: 6px; background: #5A3010; border-radius: 3px; width: 100%; margin: 0; z-index: 3; position: relative; }
    .home-rod .divider-bar { background: #CC0000; height: 8px; box-shadow: 0 0 6px rgba(220,0,0,.7); }
    .home-rod .rod-stick { background: #C8906A; }
    .abead { width: 24px; height: 18px; border-radius: 9px; position: absolute; left: 50%; transform: translateX(-50%); z-index: 2; cursor: pointer; transition: top .15s cubic-bezier(.4,0,.2,1); touch-action: none; -webkit-tap-highlight-color: transparent; }
    .abead-h { background: radial-gradient(circle at 33% 30%, #D4926A, #8B4A1A 55%, #5A2E08); border: 1px solid #3A1800; }
    .abead-h.on { background: radial-gradient(circle at 33% 30%, #EEC080, #A8641E 55%, #6B3A10); border-color: #2A1000; box-shadow: 0 0 4px rgba(140,70,10,.5); }
    .abead-e { background: radial-gradient(circle at 33% 30%, #7B4A1E, #3D1A08 55%, #220D00); border: 1px solid #180800; }
    .abead-e.on { background: radial-gradient(circle at 33% 30%, #9B5A28, #5A2A0A 55%, #341200); border-color: #0E0400; box-shadow: 0 0 4px rgba(60,20,0,.4); }

    /* ── Practice mode ── */
    .practice-modes { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
    .mode-btn { padding: 5px 10px; border-radius: 16px; border: 1.5px solid var(--orange); background: white; color: var(--orange); font-size: 11px; font-weight: 600; cursor: pointer; }
    .mode-btn.active { background: var(--orange); color: white; }
    .problem-banner { background: var(--blue); color: white; border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
    .problem-txt { font-size: 18px; font-weight: 700; }
    .problem-hint { font-size: 10px; opacity: .7; }
    .timer-badge { background: var(--orange); border-radius: 8px; padding: 3px 10px; font-size: 14px; font-weight: 700; min-width: 44px; text-align: center; }
    .timer-badge.urgent { background: #cc0000; animation: tpulse .5s infinite alternate; }
    @keyframes tpulse { from{opacity:1} to{opacity:.5} }
    .abacus-readout { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
    .ab-chip { background: white; border: 1px solid #ddd; border-radius: 8px; padding: 4px 10px; text-align: center; min-width: 70px; }
    .ab-chip-lbl { font-size: 9px; color: #999; }
    .ab-chip-val { font-size: 17px; font-weight: 600; color: var(--blue); }
    .ab-chip-val.or { color: var(--orange); }
    .ab-controls { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
    .ab-btn { padding: 5px 12px; border-radius: 7px; border: 1.5px solid var(--orange); background: var(--orange); color: white; font-size: 11px; font-weight: 600; cursor: pointer; }
    .ab-btn:hover { background: #C85E0A; }
    .ab-btn.outline { background: white; color: var(--orange); }
    .ab-btn.gray { background: white; border-color: #ccc; color: #666; }
    .ab-feedback { margin-top: 6px; font-size: 12px; min-height: 16px; }
    .ab-feedback.ok { color: #1a7a30; font-weight: 600; }
    .ab-feedback.err { color: #b02020; font-weight: 600; }
    .ab-feedback.info { color: var(--blue); }
    .ab-scores { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
    .ab-sc { background: #D0E4F7; border-radius: 7px; padding: 2px 8px; font-size: 10px; color: #003087; font-weight: 500; }
    .session-saving { font-size: 11px; color: #888; margin-top: 4px; text-align: center; }
    .sav { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: white; flex-shrink: 0; }
    .sname { font-size: 13px; font-weight: 600; color: var(--blue); }
    .smeta { font-size: 10px; color: #888; }

    /* ── Kid Feedback ── */
    .kid-feedback-overlay { position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center; pointer-events: none; }
    .kid-feedback-bubble { background: white; border-radius: 20px; padding: 18px 28px; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.18); animation: kfPop .35s cubic-bezier(.34,1.56,.64,1); max-width: 240px; }
    .kid-feedback-bubble.wrong { border: 3px solid #F47920; }
    .kid-feedback-bubble.correct { border: 3px solid #1a7a30; }
    .kid-feedback-bubble.angry { border: 3px solid #b02020; }
    .kf-emoji { font-size: 52px; display: block; margin-bottom: 6px; }
    .kf-msg { font-size: 16px; font-weight: 700; color: #222; }
    .kf-sub { font-size: 12px; color: #888; margin-top: 4px; }
    @keyframes kfPop { 0%{transform:scale(0.2);opacity:0} 70%{transform:scale(1.1)} 100%{transform:scale(1);opacity:1} }
    @keyframes kfShake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-10px)} 40%,80%{transform:translateX(10px)} }

    /* ── Exercise Tab ── */
    .ex-level-row { display: flex; gap: 8px; margin-bottom: 14px; }
    .ex-level-btn { flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid var(--orange); background: white; color: var(--orange); font-size: 13px; font-weight: 700; cursor: pointer; text-align: center; }
    .ex-level-btn.active { background: var(--orange); color: white; }
    .ex-chapter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
    .ex-chapter-btn { padding: 7px 14px; border-radius: 10px; border: 1.5px solid var(--blue); background: white; color: var(--blue); font-size: 12px; font-weight: 700; cursor: pointer; }
    .ex-chapter-btn.active { background: var(--blue); color: white; }
    .ex-set-row { display: flex; gap: 6px; margin-bottom: 14px; }
    .ex-set-btn { flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid #888; background: white; color: #555; font-size: 14px; font-weight: 700; cursor: pointer; text-align: center; transition: all .15s; }
    .ex-set-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
    .ex-set-btn.done { background: #e8f5ec; color: #1a7a30; border-color: #1a7a30; }
    .ex-set-btn.disabled { opacity: .4; cursor: not-allowed; }

    /* ── Exercise Question Screen ── */
    .ex-q-wrap { width: 100%; }
    .ex-progress-bar { width: 100%; height: 6px; background: #ddd; border-radius: 3px; margin-bottom: 10px; overflow: hidden; }
    .ex-progress-fill { height: 100%; background: var(--orange); border-radius: 3px; transition: width .3s; }
    .ex-q-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
    .ex-q-label { font-size: 13px; font-weight: 700; color: var(--blue); }
    .ex-timer-ring { width: 48px; height: 48px; position: relative; }
    .ex-timer-ring svg { transform: rotate(-90deg); }
    .ex-timer-ring .ring-bg { fill: none; stroke: #eee; stroke-width: 4; }
    .ex-timer-ring .ring-fill { fill: none; stroke: var(--orange); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 126; transition: stroke-dashoffset .9s linear, stroke .3s; }
    .ex-timer-ring .ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--blue); }
    .ex-numbers-card { background: var(--blue); color: white; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
    .ex-numbers-title { font-size: 10px; opacity: .7; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
    .ex-numbers-grid { display: flex; flex-direction: column; gap: 4px; }
    .ex-number-row { font-size: 26px; font-weight: 700; text-align: center; letter-spacing: 2px; }
    .ex-number-row.negative { color: #FFB347; }
    .ex-answer-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
    .ex-answer-input { flex: 1; font-size: 24px; font-weight: 700; text-align: center; padding: 10px; border-radius: 10px; border: 2px solid #ddd; outline: none; font-family: inherit; color: #222; }
    .ex-answer-input:focus { border-color: var(--orange); }
    .ex-answer-input.correct-border { border-color: var(--green); background: #e8f5ec; }
    .ex-answer-input.wrong-border { border-color: var(--red); background: #fceaea; }
    .ex-check-btn { padding: 10px 20px; border-radius: 10px; border: none; background: var(--orange); color: white; font-size: 15px; font-weight: 700; cursor: pointer; }
    .ex-check-btn:active { transform: scale(.97); }
    .ex-check-btn:disabled { opacity: .5; cursor: not-allowed; }
    .ex-next-btn { width: 100%; padding: 12px; border-radius: 10px; border: none; background: var(--blue); color: white; font-size: 15px; font-weight: 700; cursor: pointer; display: none; margin-top: 6px; }
    .ex-next-btn:active { transform: scale(.97); }

    /* ── Exercise Summary ── */
    .ex-summary { text-align: center; padding: 10px 0; }
    .ex-summary-emoji { font-size: 56px; margin-bottom: 8px; }
    .ex-summary-title { font-size: 20px; font-weight: 700; color: var(--blue); margin-bottom: 4px; }
    .ex-summary-sub { font-size: 13px; color: #888; margin-bottom: 16px; }
    .ex-summary-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 16px; }
    .ex-summary-stat { background: #f4f6fa; border-radius: 10px; padding: 10px; text-align: center; }
    .ex-summary-stat-val { font-size: 22px; font-weight: 700; color: var(--blue); }
    .ex-summary-stat-lbl { font-size: 10px; color: #888; margin-top: 2px; }
    .ex-replay-btn { width: 100%; padding: 12px; border-radius: 10px; border: none; background: var(--orange); color: white; font-size: 15px; font-weight: 700; cursor: pointer; margin-bottom: 8px; }
    .ex-back-btn { width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid #ccc; background: white; color: #666; font-size: 13px; font-weight: 600; cursor: pointer; }
