/* School ERP — student portal & test player (mobile first) */
:root {
  --ink: #14213d; --ink-2: #334155; --muted: #5b6475; --line: #e4e7f0; --bg: #f5f6fb; --card: #fff;
  --primary: #2b3a9f; --primary-2: #4553d6; --primary-soft: #eceefe;
  --accent: #f59e0b; --accent-2: #ea580c; --accent-soft: #fff4dc;
  --ok: #059669; --ok-soft: #d1fae5; --bad: #e11d48; --bad-soft: #ffe4e6; --flag: #7c3aed; --flag-soft: #ede9fe;
  --radius: 16px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 10px 28px -14px rgba(20,33,61,.25);
  --font-head: "Baloo 2", "Mukta", system-ui, sans-serif; --font-body: "Mukta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .4em; text-wrap: balance; }
img { max-width: 100%; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex-shrink: 0; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.p-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--primary); color: #fff; }
.p-brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.p-brand img, .p-brand svg { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; background: #fff; object-fit: contain; }
.p-brand strong { display: block; font-family: var(--font-head); font-size: 1.02rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.p-brand small { color: #c7d2fe; font-size: .78rem; }
.p-nav { display: flex; align-items: center; gap: 8px; }
.p-lang { display: flex; background: rgba(255,255,255,.12); border-radius: 999px; padding: 2px; }
.p-lang a { color: #e0e7ff; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.p-lang a.on { background: var(--accent); color: var(--ink); }
.p-out { background: rgba(255,255,255,.14); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.p-main { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }
.p-alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.p-alert-error { background: var(--bad-soft); color: #9f1239; }
.p-alert-success { background: var(--ok-soft); color: #065f46; }
.p-alert-info, .p-alert-warning { background: var(--accent-soft); color: #92400e; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 12px; border: 0; background: var(--primary); color: #fff; font: 700 1rem/1.2 var(--font-body); cursor: pointer; text-align: center; }
.btn:hover { background: var(--primary-2); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ok { background: var(--ok); }
.btn-light { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.btn-light:hover { background: var(--bg); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .9rem; border-radius: 10px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; color: var(--ink-2); }
.field input, .field textarea { width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font: inherit; background: #fff; color: var(--ink); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary-2); }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.field-error { color: var(--bad); font-size: .85rem; font-weight: 600; margin-top: 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.b-open { background: var(--ok-soft); color: #065f46; } .b-upcoming { background: var(--accent-soft); color: #92400e; }
.b-done { background: var(--primary-soft); color: var(--primary); } .b-closed { background: #f1f5f9; color: var(--muted); }
.b-in_progress { background: var(--flag-soft); color: var(--flag); }

/* Login */
.login-wrap { max-width: 420px; margin: 4vh auto 0; }
.login-art { text-align: center; margin-bottom: 10px; }
.login-art svg { width: 120px; height: auto; }

/* Dashboard */
.hello { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.hello .ph { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font: 800 1.6rem var(--font-head); flex-shrink: 0; }
.hello h1 { font-size: 1.4rem; margin: 0; }
.test-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.test-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px; border-top: 4px solid var(--primary); color: var(--ink); }
.test-card.st-open, .test-card.st-in_progress { border-top-color: var(--ok); }
.test-card.st-upcoming { border-top-color: var(--accent); }
.test-card.st-closed { border-top-color: #cbd5e1; }
.test-card h3 { font-size: 1.12rem; margin: 0; }
.test-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; color: var(--muted); }
.test-card .grow { flex: 1; }
.section-title { font-size: 1.15rem; margin: 22px 0 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.hist { width: 100%; border-collapse: collapse; font-size: .93rem; }
.hist td, .hist th { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.hist th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

/* Intro */
.rules { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.fact { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.fact b { display: block; font: 800 1.35rem var(--font-head); color: var(--primary); font-variant-numeric: tabular-nums; }
.fact span { font-size: .82rem; color: var(--muted); }

/* Player */
body.playing { background: #eef0f8; }
.player { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.p-bar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 58px); z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 12px; }
.p-bar .tt { font-weight: 700; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font: 800 1.3rem var(--font-head); font-variant-numeric: tabular-nums; color: var(--primary); background: var(--primary-soft); padding: 2px 12px; border-radius: 10px; white-space: nowrap; }
.timer.low { color: #fff; background: var(--bad); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .7; } }
.save-state { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.q-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .88rem; color: var(--muted); }
.q-text { font-size: 1.12rem; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 14px; }
.q-img { display: block; max-height: 320px; border-radius: 10px; margin: 0 0 14px; border: 1px solid var(--line); }
.opts { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; transition: border-color .15s, background .15s; }
.opt:hover { border-color: #c7cdf5; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .letter { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #c7cdf5; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; color: var(--primary); }
.opt .ot { padding-top: 3px; overflow-wrap: anywhere; }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.sel .letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; }
.q-input { width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font: inherit; font-size: 1.05rem; }
textarea.q-input { min-height: 160px; resize: vertical; }
.q-nav { display: flex; gap: 8px; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; }
.q-nav .mid { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-flag.on { background: var(--flag); color: #fff; border-color: var(--flag); }
.palette { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 124px); }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin: 10px 0; }
.pal-grid button { height: 40px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pal-grid button.ans { background: var(--ok); border-color: var(--ok); color: #fff; }
.pal-grid button.flag { border-color: var(--flag); box-shadow: inset 0 0 0 2px var(--flag-soft); }
.pal-grid button.ans.flag { background: var(--flag); border-color: var(--flag); }
.pal-grid button.cur { outline: 3px solid var(--accent); outline-offset: 1px; }
.legend { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--line); }
.legend .l-ans { background: var(--ok); border-color: var(--ok); } .legend .l-flag { border-color: var(--flag); }
.warn-overlay { position: fixed; inset: 0; background: rgba(20,33,61,.7); display: grid; place-items: center; z-index: 100; padding: 16px; }
.warn-overlay[hidden] { display: none; }
.warn-box { background: #fff; border-radius: 18px; padding: 22px; max-width: 420px; text-align: center; }
.warn-box h2 { color: var(--bad); }
dialog.sheet { border: 0; border-radius: 18px; padding: 0; width: min(440px, 94vw); box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); }
dialog.sheet::backdrop { background: rgba(20,33,61,.55); }
.sheet-body { padding: 20px; }
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; text-align: center; }
.sum-grid div { background: var(--bg); border-radius: 12px; padding: 8px; }
.sum-grid b { display: block; font: 800 1.4rem var(--font-head); }

/* Result */
.score-hero { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; background: conic-gradient(var(--ring, var(--primary)) calc(var(--p) * 1%), var(--primary-soft) 0); display: grid; place-items: center; }
.ring > div { width: 104px; height: 104px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.ring b { font: 800 1.6rem/1 var(--font-head); font-variant-numeric: tabular-nums; }
.ring small { color: var(--muted); font-size: .78rem; }
.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.stats4 div { background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.stats4 b { display: block; font: 800 1.25rem var(--font-head); font-variant-numeric: tabular-nums; }
.stats4 span { font-size: .78rem; color: var(--muted); }
.c-ok { color: var(--ok); } .c-bad { color: var(--bad); } .c-flag { color: var(--flag); }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 44px; gap: 10px; align-items: center; font-size: .9rem; }
.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.rv { border-left: 4px solid var(--line); padding: 10px 0 10px 14px; margin-bottom: 14px; }
.rv.right { border-color: var(--ok); } .rv.wrong { border-color: var(--bad); } .rv.pending { border-color: var(--accent); }
.rv .q-text { font-size: 1rem; margin-bottom: 6px; }
.rv-row { font-size: .92rem; } .rv-row b { font-weight: 700; }
.expl { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin-top: 6px; font-size: .92rem; color: #78350f; }
.lb td:first-child { width: 44px; font-weight: 800; }
.lb tr.me td { background: var(--accent-soft); }

@media (max-width: 860px) {
  .player { grid-template-columns: minmax(0, 1fr); }
  .palette { position: static; }
  .score-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .stats4 { grid-template-columns: repeat(2, minmax(0,1fr)); width: 100%; }
}
@media (max-width: 480px) {
  .p-lang { display: none; }
  .q-nav .btn { flex: 1; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 80px 40px; }
  .p-bar .tt { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- App home (Play Store / installed app start page) ---------- */
.app-hero { padding: 6px 2px 14px; }
.app-hero h1 { font-size: 1.6rem; margin: 0 0 2px; }
.app-hero p { margin: 0; color: var(--muted); }
.app-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.app-tile { display: flex; flex-direction: column; gap: 4px; padding: 16px 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); color: var(--ink); min-height: 128px; position: relative; overflow: hidden; transition: transform .15s; }
.app-tile:active { transform: scale(.98); }
.app-tile .ai { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; margin-bottom: 6px; background: var(--primary); }
.app-tile .ai .icon { width: 22px; height: 22px; }
.app-tile strong { font-family: var(--font-head); font-size: 1.05rem; line-height: 1.2; }
.app-tile small { color: var(--muted); font-size: .82rem; line-height: 1.3; }
.app-tile.t2 .ai { background: var(--ink); } .app-tile.t3 .ai { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent, #14213d); }
.app-tile.t4 .ai { background: #0e7490; } .app-tile.t5 .ai { background: #b45309; } .app-tile.t6 .ai { background: #059669; }
.app-contact { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.app-contact a { flex: 1; min-width: 100px; display: inline-flex; gap: 6px; align-items: center; justify-content: center; padding: 11px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.app-notices h2 { font-size: 1.05rem; display: flex; gap: 8px; align-items: center; }
.app-notices ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.app-notices a { display: block; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.app-notices .nd { display: block; font-size: .78rem; color: var(--muted); }
.app-foot { text-align: center; font-size: .8rem; color: var(--muted); margin: 18px 0 8px; }
.app-foot a { color: var(--muted); text-decoration: underline; }
@media (min-width: 720px) { .app-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
