/* Judges panel — phone first, works on tablets and laptops too. */

body.judge { min-height: 100dvh; font-size: 16px; line-height: 1.55; background-attachment: fixed; }
a { color: var(--blue); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--blue); background: var(--white); color: var(--blue);
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
  transition: transform .08s, background-color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, .icon-btn:focus-visible, .tabbar button:focus-visible, .seg-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn .icon { font-size: 18px; }
.btn.primary { background: var(--blue); color: var(--white); }
.btn.primary:hover { background: var(--blue-dark); }
.btn.gold { background: var(--gold-deep); border-color: var(--gold-deep); color: var(--white); }
.btn.ghost { background: var(--white); }
.btn.ghost:hover { background: var(--sky-2); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 11px; }
.btn.block { display: flex; width: 100%; }
.btn.grow { flex: 1 1 0; min-width: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 0; background: rgba(255,255,255,.14); color: var(--white); font-size: 22px; cursor: pointer; }

input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--white); font-size: 16px;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,104,177,.18); }
label { font-weight: 700; font-size: 14px; color: var(--navy); }

.form { display: flex; flex-direction: column; gap: 8px; }
.form .btn { margin-top: 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row + .row, .row + .chips, .chips + .row, .big-timer + .row { margin-top: 10px; }
.hint { margin: 2px 0 12px; font-size: 14px; color: #4A5A78; }
.err { margin: 4px 0 0; color: var(--danger); font-weight: 700; font-size: 14px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--white); font-weight: 700; font-size: 14px; color: var(--navy); cursor: pointer; }
.chip:hover { border-color: var(--blue); }
.chip.on { background: var(--blue); border-color: var(--blue); color: var(--white); }

.switch { display: flex; align-items: center; gap: 12px; min-height: 46px; font-weight: 600; font-size: 15px; cursor: pointer; }
.switch input { width: 22px; height: 22px; min-height: 0; accent-color: var(--blue); flex: none; }
.switch + .btn { margin-top: 8px; }

.badge-soft { font-size: 13px; font-weight: 800; color: var(--gold-deep); background: var(--gold-soft); border-radius: 999px; padding: 2px 12px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); background: var(--white); border-radius: 26px; padding: 28px 22px 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 20px 60px rgba(27,42,74,.12); }
.login-logo { width: 96px; height: 96px; }
.login-title { font-size: 36px; }
.login-card .pill { font-size: 16px; }
.login-card form { width: 100%; margin-top: 6px; }
.muted-link { font-size: 14px; margin-top: 4px; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--blue); color: var(--white); }
.tb-logo { width: 40px; height: 40px; flex: none; border-radius: 10px; }
.tb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.tb-title b { font-size: 17px; }
.tb-title .who { font-size: 13px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-dot { width: 12px; height: 12px; border-radius: 50%; background: #FFE2A8; box-shadow: 0 0 0 3px rgba(255,255,255,.2); flex: none; }
.conn-dot.live { background: #FFFFFF; }

.now { position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 19; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--white); border-bottom: 1px solid var(--line); box-shadow: 0 6px 18px rgba(27,42,74,.06); }
.now-seg { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.now-k { font-size: 12px; color: #4A5A78; font-weight: 700; }
.now-seg b { font-size: 17px; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-timer { display: flex; align-items: center; gap: 10px; flex: none; }
.now-timer .d { direction: ltr; font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; color: var(--navy); }
.now-timer[data-state="warn"] .d, .now-timer[data-state="done"] .d { color: var(--gold-deep); }
.now-timer[data-state="paused"] .d { opacity: .6; }

.panes { max-width: 760px; margin: 0 auto; padding: 14px 12px 24px; }
.pane { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--white); border-radius: 20px; padding: 16px; box-shadow: 0 1px 0 rgba(45,104,177,.08), 0 8px 24px rgba(27,42,74,.05); }
.card h2 { margin: 0 0 4px; font-size: 18px; color: var(--blue); font-weight: 800; }
.card h3 { margin: 0; font-size: 16px; color: var(--navy); }

.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--white); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 20px rgba(27,42,74,.06); }
.tabbar button { min-height: 64px; min-width: 0; padding: 0 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: #4A5A78; font-weight: 700; font-size: 12px; white-space: nowrap; cursor: pointer; }
.tabbar button .icon { font-size: 22px; }
.tabbar button[aria-selected="true"] { color: var(--blue); box-shadow: inset 0 3px 0 var(--gold); }

/* ---------- control tab ---------- */
.seg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seg-btn { position: relative; min-height: 60px; padding: 8px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--white); text-align: start; cursor: pointer; display: flex; flex-direction: column; justify-content: center; gap: 0; }
.seg-btn b { font-size: 15px; color: var(--navy); line-height: 1.35; }
.seg-btn small { font-size: 12px; color: #4A5A78; font-weight: 600; }
.seg-btn .h { position: absolute; top: 6px; inset-inline-end: 8px; font-size: 11px; font-weight: 800; color: var(--gold-deep); }
.seg-btn.on { border-color: var(--blue); background: var(--blue); }
.seg-btn.on b, .seg-btn.on small, .seg-btn.on .h { color: var(--white); }

.big-timer { display: flex; flex-direction: column; align-items: center; padding: 10px 0 6px; border-radius: 16px; background: var(--sky-2); }
.big-timer .d { direction: ltr; font-weight: 800; font-size: 64px; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--navy); }
.big-timer .l { font-weight: 700; font-size: 15px; color: var(--blue); }
.big-timer[data-state="warn"] .d, .big-timer[data-state="done"] .d, .big-timer[data-state="done"] .l { color: var(--gold-deep); }
.big-timer[data-state="paused"] .l { color: var(--gold-deep); }
#customTimer input { flex: 1; }

.ctx-fact { background: var(--sky-2); border-radius: 14px; padding: 12px 14px; margin: 8px 0 10px; }
.ctx-fact .t { font-weight: 800; font-size: 17px; }
.ctx-fact .o { font-size: 14px; color: var(--gold-deep); font-weight: 700; margin-top: 4px; }
.ctx-sub { font-weight: 800; font-size: 14px; color: var(--navy); margin: 12px 0 6px; }
.q-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.q-list button { width: 100%; text-align: start; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); font-size: 15px; cursor: pointer; }
.q-list button.on { border-color: var(--blue); background: var(--sky-2); font-weight: 800; color: var(--blue); }

/* ---------- scores tab ---------- */
.sticky-tools { position: sticky; top: calc(128px + env(safe-area-inset-top)); z-index: 10; }
.seg-ctl { display: inline-flex; border: 1.5px solid var(--blue); border-radius: 12px; overflow: hidden; }
.seg-ctl button { min-width: 52px; min-height: 40px; border: 0; background: var(--white); color: var(--blue); font-weight: 800; font-size: 16px; cursor: pointer; }
.seg-ctl button + button { border-inline-start: 1.5px solid var(--blue); }
.seg-ctl button[aria-checked="true"] { background: var(--blue); color: var(--white); }

.score-cards { display: grid; gap: 12px; }
@media (min-width: 700px) { .score-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sc { background: var(--white); border-radius: 20px; padding: 14px; box-shadow: 0 1px 0 rgba(45,104,177,.08), 0 8px 24px rgba(27,42,74,.05); }
.sc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sc-rank { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; border: 2px solid var(--line); color: var(--blue); flex: none; }
.sc-rank.r1 { background: var(--gold); border-color: var(--gold); color: var(--white); }
.sc-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.sc-name b { font-size: 17px; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-name button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; color: #4A5A78; border-radius: 10px; cursor: pointer; flex: none; }
.sc-total { font-weight: 800; font-size: 26px; color: var(--navy); font-variant-numeric: tabular-nums; }
.sc-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px 64px 48px; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--sky); }
.sc-row .cn { font-size: 14px; font-weight: 700; line-height: 1.35; }
.sc-row .cn small { display: block; font-size: 11px; font-weight: 600; color: #4A5A78; }
.pm { width: 48px; height: 48px; border-radius: 14px; border: 1.5px solid var(--blue); background: var(--white); color: var(--blue); font-size: 22px; display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pm.plus { background: var(--blue); color: var(--white); }
.pm:active { transform: scale(.94); }
.val { height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--sky-2); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; cursor: pointer; }

/* ---------- stories tab ---------- */
.fact-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fact-item { border: 1.5px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.fact-item.cur { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,104,177,.12); }
.fact-top { display: flex; gap: 10px; align-items: flex-start; }
.fact-top .n { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--white); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.fact-top .t { flex: 1; font-weight: 700; }
.st { font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.st.hidden { background: var(--sky); color: #4A5A78; }
.st.shown { background: var(--blue); color: var(--white); }
.st.revealed { background: var(--gold-soft); color: var(--gold-deep); }
.fact-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fact-actions select { width: auto; flex: 1 1 140px; min-height: 40px; font-size: 14px; padding: 6px 10px; }

/* ---------- Quran + camp tabs ---------- */
.val.ro { display: grid; place-items: center; cursor: default; color: #4A5A78; }
.rc-groups { display: flex; flex-direction: column; gap: 10px; }
.rc-group { border: 1.5px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.rc-head { display: flex; align-items: center; gap: 6px; }
.rc-head b { flex: 1; min-width: 0; font-size: 16px; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-count { font-weight: 800; font-size: 20px; color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-count small { font-size: 14px; color: #4A5A78; }
.rc-names { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rc-names li { display: inline-flex; align-items: center; gap: 2px; min-height: 36px; padding-inline-start: 12px; border-radius: 999px; background: var(--sky-2); border: 1.5px solid var(--line); font-weight: 700; font-size: 14px; }
.rc-names li button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: none; color: #4A5A78; border-radius: 50%; cursor: pointer; }
.rc-names .none { padding: 0; border: 0; background: none; color: #4A5A78; font-weight: 600; }

/* ---------- more tab ---------- */
#adminCard .row.wrap .btn { flex: 1 1 100%; }
.seg-btn .h { font-size: 10px; }
.plain-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plain-list li { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 4px 4px 4px 4px; border-bottom: 1px solid var(--sky); }
.plain-list li span { flex: 1; min-width: 0; font-weight: 700; }
.plain-list li small { color: #4A5A78; font-weight: 600; }
#groupCountRow { margin-bottom: 8px; }
#groupCountRow label { white-space: nowrap; }
#groupCountRow select { width: auto; }
.log-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 420px; overflow: auto; font-size: 14px; }
.log-list li { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--sky); }
.log-list time { direction: ltr; text-align: end; color: #4A5A78; font-variant-numeric: tabular-nums; }
.log-list .undone { text-decoration: line-through; opacity: .6; }
.log-list b { color: var(--blue); }

/* ---------- dialog & snackbar ---------- */
.dlg { border: 0; border-radius: 22px; padding: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(27,42,74,.25); }
.dlg::backdrop { background: rgba(27,42,74,.4); }
.dlg h3 { margin: 0 0 6px; color: var(--blue); font-size: 19px; }
.dlg input { margin: 4px 0 14px; }
.snack { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 20px); opacity: 0; z-index: 60; background: var(--navy); color: var(--white); padding: 10px 18px; border-radius: 14px; font-weight: 700; font-size: 15px; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; pointer-events: none; }
.snack.show { opacity: 1; transform: translate(-50%, 0); }
.snack.bad { background: var(--danger); }
