/* Sarvoday Youth Club theme, taken from the ExamAite logo: purple #5E4289 + gold #D4A629. */
:root {
  --brand: #5e4289;
  --brand-dark: #462f6b;
  --brand-light: #a67fb7;
  --accent: #d4a629;      /* gold fills, stripes, active chips */
  --accent-text: #8a6500; /* gold for text on white (the logo gold is too light to read) */
  --bg: #f6f3fa;
  --card: #fff;
  --text: #241c33;
  --muted: #645a73;
  --border: #e6dfee;
  --green: #15803d;
  --green-bg: #e8f7ee;
  --red: #dc2626;
  --red-bg: #fdecec;
  --grey: #94a0b2;
  --grey-bg: #f1edf6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { overflow-x: clip; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* Header: white so the logo's purple lettering stays readable */
.topbar { background: #fff; border-bottom: 3px solid var(--accent); box-shadow: 0 1px 4px #5e42891a; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { min-width: 0; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: .2px; line-height: 1.15; color: var(--brand); }
.brand-name span { color: var(--accent-text); }
.brand-tag { font-size: 12px; color: var(--muted); font-weight: 600; }
.partner-logo { height: 44px; width: auto; flex: none; display: block; }

/* Layout */
.container { max-width: 960px; margin: 16px auto; padding: 0 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
#results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: 0 1px 3px #0000000d; }
h1 { font-size: 21px; line-height: 1.25; color: var(--brand); }
h2 { font-size: 17px; margin-bottom: 12px; color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 12px; margin-top: 10px; }

/* Volunteer registration banner */
.join-card { background: linear-gradient(135deg, #fff 0%, #f3edf8 100%); border-left: 4px solid var(--accent); }
.join-card h2 { margin-bottom: 6px; }
.join-card p { color: var(--text); margin-bottom: 4px; line-height: 1.6; }
.join-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.btn-join { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #2a1f05; font-weight: 700; text-decoration: none; padding: 10px 16px; border-radius: 10px; }
.btn-join:hover { background: #c4961f; }
.btn-join:focus-visible { outline: 3px solid #5e428966; outline-offset: 2px; }
.join-tagline { font-weight: 700; color: var(--brand); font-size: 14px; }

/* Form */
form { display: grid; gap: 6px; margin-top: 12px; }
label { font-weight: 600; font-size: 13px; margin-top: 6px; }
.req { color: var(--red); }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; min-width: 0; }
input[type=url], select { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-size: 16px; /* 16px stops iOS zoom */ }
input:focus, select:focus { outline: 2px solid #5e428933; border-color: var(--brand); }
.btn-light { background: var(--grey-bg); border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 13px; font-weight: 700; cursor: pointer; margin-top: 10px; font-size: 16px; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.error { color: var(--red); background: var(--red-bg); padding: 9px 11px; border-radius: 10px; font-size: 14px; }

label.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 10px; cursor: pointer; }
label.consent input { width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--brand); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.two-col > div { display: grid; gap: 6px; min-width: 0; }

/* Rank */
.rank-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rank-tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px 10px; text-align: center; min-width: 0; }
.rank-tile.primary { background: linear-gradient(120deg, var(--brand-dark), var(--brand)); border-color: transparent; color: #fff; }
.rank-tile .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rank-tile .grp { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; min-height: 1.5em; }
.rank-tile .val { font-size: 26px; font-weight: 800; line-height: 1.15; margin-top: 2px; color: var(--brand); }
.rank-tile .val small { font-size: 14px; font-weight: 600; color: var(--muted); }
.rank-tile .avg { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rank-tile.primary .lbl, .rank-tile.primary .grp, .rank-tile.primary .avg, .rank-tile.primary .val small { color: #ffffffc4; }
.rank-tile.primary .val { color: #fff; }
.rank-unavailable { background: #fff8e6; border: 1px solid #fde4a8; color: #8a5a00; border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* Candidate details */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; }
.details div { min-width: 0; }
.details dt { color: var(--muted); font-size: 12px; }
.details dd { font-weight: 600; overflow-wrap: anywhere; }

/* Score */
.marks-hero { background: linear-gradient(120deg, var(--brand-dark), var(--brand)); border-bottom: 3px solid var(--accent); color: #fff; border-radius: 12px; padding: 14px 16px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.marks-hero .lbl { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: .05em; }
.marks-hero .val { font-size: 32px; font-weight: 800; line-height: 1; }
.marks-hero .val small { font-size: 16px; opacity: .75; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px; text-align: center; }
.tile .val { font-size: 22px; font-weight: 800; line-height: 1.2; }
.tile .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.tile.correct .val { color: var(--green); }
.tile.wrong .val { color: var(--red); }

/* Subject table */
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { padding: 9px 6px; border-bottom: 1px solid var(--border); text-align: center; }
.grid th:first-child, .grid td:first-child { text-align: left; padding-left: 8px; }
.grid thead th { background: var(--grey-bg); font-size: 12px; color: var(--muted); }
.grid tfoot td { font-weight: 800; background: #faf8fc; }
.grid .r { color: var(--green); font-weight: 600; }
.grid .w { color: var(--red); font-weight: 600; }
.grid .short { display: none; }

/* Compare with toppers */
.compare td:not(:first-child), .compare th:not(:first-child) { width: 22%; }
.compare .grp-row td { background: var(--grey-bg); font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 6px 8px; }
.compare .you { font-weight: 700; }
.compare .up { color: var(--green); font-weight: 700; }
.compare .down { color: var(--red); font-weight: 700; }
.compare .flat { color: var(--muted); font-weight: 600; }
.cohort-note { background: #fff8e6; border: 1px solid #fde4a8; color: #8a5a00; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-bottom: 10px; }

/* Answer details: subject tabs */
/* Tabs wrap instead of scrolling sideways, so nothing on the page pans horizontally. */
.subject-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.subject-tab { max-width: 100%; text-align: left; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 14px; }
.subject-tab small { color: var(--muted); font-weight: 600; margin-left: 4px; white-space: nowrap; }
.subject-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.subject-tab.active small { color: #ffffffb3; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #2a1f05; }

/* Question palette */
.palette-wrap { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.palette-wrap summary { padding: 9px 12px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--brand); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; padding: 0 12px 10px; max-height: 240px; overflow-y: auto; }
.pal { height: 36px; border-radius: 8px; border: 0; font-size: 13px; font-weight: 700; cursor: pointer; color: #fff; }
.pal.correct { background: var(--green); }
.pal.wrong { background: var(--red); }
.pal.unanswered, .pal.nokey { background: #cfc7da; color: #241c33; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 12px 10px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dot.correct { background: var(--green); }
.dot.wrong { background: var(--red); }
.dot.unanswered { background: #cfc7da; }

/* Question cards */
.q { border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; padding: 12px; margin-bottom: 10px; scroll-margin-top: 12px; }
.q.correct { border-left-color: var(--green); }
.q.wrong { border-left-color: var(--red); }
.q.unanswered, .q.nokey { border-left-color: var(--grey); }
.q.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #fff4d6; } to { background: #fff; } }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.q-no { font-weight: 800; }
.q-sec { color: var(--muted); font-size: 12px; font-weight: 600; margin-left: 6px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.correct { background: var(--green-bg); color: var(--green); }
.badge.wrong { background: var(--red-bg); color: var(--red); }
.badge.unanswered, .badge.nokey { background: var(--grey-bg); color: var(--muted); }
.q-text { margin-bottom: 8px; overflow-wrap: anywhere; }
.q-text img, .opt img { max-width: 100%; height: auto; vertical-align: middle; }
/* Question tables (e.g. 15-column coding tables) must fit the card instead of overflowing it. */
.q-text table, .opt table { border-collapse: collapse; width: 100%; max-width: 100%; }
.q-text td, .q-text th, .opt td, .opt th { border: 1px solid var(--border); padding: 3px 5px; text-align: center; }
.opts { list-style: none; display: grid; gap: 5px; }
.opt { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.opt > span { min-width: 0; }
.opt .n { font-weight: 700; }
.opt .tag { grid-column: 2; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.opt.is-correct { background: var(--green-bg); border-color: #b7e4c7; }
.opt.is-correct .tag { color: var(--green); }
.opt.is-chosen-wrong { background: var(--red-bg); border-color: #f5c2c2; }
.opt.is-chosen-wrong .tag { color: var(--red); }
.q-meta { margin-top: 7px; font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pager button { min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid var(--border); background: #fff; border-radius: 10px; cursor: pointer; font-weight: 600; }
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .gap { color: var(--muted); padding: 0 2px; }
.pager .info { width: 100%; text-align: center; font-size: 12px; color: var(--muted); margin-top: 2px; }

.site-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px 24px; }

@media (max-width: 600px) {
  .container { margin-top: 12px; gap: 12px; }
  .card { padding: 14px; border-radius: 12px; }
  .subject-tab { padding: 7px 10px; font-size: 13px; }
  .q-text table, .opt table { font-size: 13px; }
  .q-text td, .q-text th, .opt td, .opt th { padding: 3px 1px; }
  .grid .opt-col { display: none; }
  .grid .long { display: none; }
  .grid .short { display: inline; }
  .grid { font-size: 12.5px; }
  .grid th, .grid td { padding: 8px 2px; }
  .details { grid-template-columns: 1fr 1fr; }
  .details .wide { grid-column: 1 / -1; }
  .marks-hero .val { font-size: 28px; }
  .brand-name { font-size: 16px; }
  .brand-tag { font-size: 11px; }
  .partner-logo { height: 34px; }
  .btn-join { width: 100%; justify-content: center; }
  .tile .val { font-size: 19px; }
  .rank-tiles { grid-template-columns: 1fr 1fr; }
  .rank-tile .val { font-size: 22px; }
  .pager { gap: 4px; }
  .pager button { min-width: 36px; height: 38px; padding: 0 6px; }
}

@media (max-width: 360px) {
  .grid { font-size: 12px; }
  .grid th, .grid td { padding: 7px 1px; }
  .grid th:first-child, .grid td:first-child { padding-left: 4px; }
  .compare .grp-row td { padding-left: 4px; }
}
