/* Shared glass theme for the participant and staff interfaces. */
:root {
  --bg: #eef2f9;
  --card: #f9fbff;
  --text: #14213a;
  --ink: #14213a;
  --muted: #53627b;
  --accent: #2854c7;
  --accent-ink: #fff;
  --accent-soft: #e1eafe;
  --success: #17724c;
  --danger: #bd2948;
  --line: #d5dfee;
  --radius: 16px;
  --glass: rgba(251, 253, 255, .79);
  --glass-edge: rgba(255, 255, 255, .85);
  --shadow-sm: 0 4px 14px rgba(27, 48, 91, .10);
  --shadow: 0 10px 30px rgba(27, 48, 91, .11);
  --shadow-lg: 0 24px 65px rgba(27, 48, 91, .17);
  --maxw: 860px;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(ellipse at 84% 0%, #ebe7fc, transparent 49%),
                    radial-gradient(ellipse at 11% 100%, #e2ebf8, transparent 55%);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
button, input, textarea, select { font-family: inherit; }
button:focus-visible { outline: 2px solid #2854c7; outline-offset: 3px; }
input:not([type="checkbox"]), textarea, select {
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  scroll-margin-block: 16px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #557de1;
  box-shadow: 0 0 0 3px rgba(74, 117, 219, .20);
}

.auth-screen { background: transparent; min-height: 100svh; padding: 64px 18px 28px; }
.auth-card, .login-card {
  max-width: 460px;
  padding: clamp(24px, 5vw, 38px);
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 30px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.brand { margin-bottom: 23px; }
.brand h1, .login-card h1 { font-size: clamp(27px, 5vw, 37px); line-height: 1.07; letter-spacing: -.045em; font-weight: 750; }
.brand p { margin-top: 9px; font-size: 15px; line-height: 1.55; }
.brand .glass-mark, .login-card .glass-mark { margin-bottom: 16px; }
.glass-mark {
  position: relative;
  display: block;
  width: 49px;
  height: 49px;
  border: 1px solid rgba(255, 255, 255, .65);
  border-radius: 16px;
  background: linear-gradient(145deg, #829fff 0%, #4268dc 44%, #2c3e98 100%);
  box-shadow: inset 0 1px 3px #dce5ff, 0 8px 17px rgba(49, 78, 173, .25);
}
.glass-mark::before, .glass-mark::after {
  content: "";
  position: absolute;
  inset: 26% 21%;
  border: 1.5px solid #fff;
  border-radius: 50%;
  transform: rotate(-37deg) scaleY(.61);
}
.glass-mark::after { transform: rotate(37deg) scaleY(.61); }
.choice-card { max-width: 520px; padding: clamp(25px, 6vw, 48px); }
.choice-card .brand { margin-bottom: 26px; }
.choice-card .brand h1 { font-size: clamp(31px, 7vw, 45px); }
.choice-card .btn-outline { width: 100%; margin-top: 9px; }
.recovery-action { width: 100%; margin-top: 10px; }
#login-reset-success { margin: 0 0 12px; color: #205847; }
#p-password-reset-link { width: 100%; margin: 8px 0; }
#p-password-reset-result { text-align: left; }
.language-switch {
  right: max(16px, calc((100vw - 960px) / 2));
  padding: 4px;
  background: rgba(250, 253, 255, .85);
  border: 1px solid #fff;
  border-radius: 999px;
}
.language-btn { min-height: 34px; border-radius: 999px; }
.language-btn[aria-pressed="true"], .btn-primary {
  background: linear-gradient(145deg, #385fce, #2446aa);
  color: #fff;
  box-shadow: inset 0 1px rgba(255,255,255,.26), var(--shadow-sm);
}
.btn-outline { border: 1px solid #ccd9ee; background: rgba(255,255,255,.55); color: #264ba7; }
.consent { background: #e7eefc; }

.app-body { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.panel { padding: 72px clamp(14px, 4vw, 32px) 26px; }
.panel-title { font-size: clamp(32px, 5.5vw, 47px); font-weight: 750; line-height: 1.08; letter-spacing: -.05em; }
.panel-title + .muted { font-size: 15px; margin-top: 6px; }
.profile-header, .qr-card, .history-item, .leaderboard-row {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 23px;
  box-shadow: var(--shadow-sm), inset 0 1px rgba(255,255,255,.7);
}
.profile-header { padding: 15px; }
.profile-meta { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.profile-meta h2 { font-size: clamp(17px, 3vw, 23px); letter-spacing: -.026em; }
.avatar { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 17px; background: linear-gradient(150deg,#6b8ff1,#364aa8); }
.balance-card {
  background: radial-gradient(ellipse at 88% 12%, #687cdb, transparent 57%), linear-gradient(135deg, #152758, #314bb0);
  border: 1px solid #516ab9;
  border-radius: 25px;
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.28);
}
.balance-value { font-size: clamp(52px, 9vw, 77px); line-height: 1.05; letter-spacing: -.055em; margin: 7px 0; }
.qr-card { padding: 20px; }
.qr-box { width: fit-content; max-width: 100%; padding: 10px; background: #fff; border: 1px solid #e1e7f0; border-radius: 13px; }
.qr-box img, .qr-box canvas { max-width: 100%; height: auto; }
@media (min-width: 700px) {
  #panel-profile { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; gap: 16px; }
  #panel-profile .profile-header { grid-column: 1/-1; }
  #panel-profile .balance-card, #panel-profile .qr-card { margin: 0; display: grid; align-content: center; }
}
.stage-switch, .tab-bar {
  border: 1px solid rgba(255, 255, 255, .95);
  background: rgba(246, 248, 253, .78);
  box-shadow: 0 12px 32px rgba(32, 37, 66, .12), inset 0 1px 1px #fff;
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
}
#panel-stages { padding-top: clamp(72px, 9vw, 112px); }
#panel-stages .panel-title { margin-bottom: 18px; }
#panel-stages .panel-title:has(+ .stage-contest-total) { margin-bottom: 4px; }
.stage-contest-total { margin: 0 0 18px; }
.stage-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: min(100%, 380px);
  margin-bottom: clamp(18px, 4vw, 30px);
  padding: 4px;
  border-radius: 999px;
}
.stage-switch button {
  min-height: 44px;
  padding: 8px 4px;
  border-radius: 999px;
  background: transparent;
  color: #49536a;
  box-shadow: none;
  font-size: 14px;
  font-weight: 650;
}
.stage-switch button[aria-pressed="true"] {
  color: #25265c;
  background: #fff;
  box-shadow: 0 3px 10px rgba(39, 38, 82, .13);
}
.stage-card {
  padding: clamp(20px, 5vw, 40px);
  border: 1px solid #e5e7ef;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 14px 42px rgba(30, 34, 63, .06);
}
.stage-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e7e9f0;
}
.stage-card h3 {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.06;
  letter-spacing: -.047em;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.stage-heading > :first-child { flex: 1 1 285px; min-width: 0; }
.stage-heading .muted, .stage-card > h3 + .muted { margin: 9px 0 0; }
.stage-card h4 { margin: 24px 0 6px; font-size: 15px; font-weight: 650; }
.stage-progress { display: grid; gap: 9px; flex: 0 1 156px; min-width: 134px; }
.stage-progress-label { color: #454a65; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stage-progress-meter {
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: #ececf5;
  accent-color: #5552ad;
}
.stage-progress-meter::-webkit-progress-bar { background: #ececf5; border-radius: 999px; }
.stage-progress-meter::-webkit-progress-value { background: #5552ad; border-radius: 999px; }
.stage-progress-meter::-moz-progress-bar { background: #5552ad; border-radius: 999px; }
.stage-check-list { list-style: none; margin: 0; padding: 0; }
.stage-check-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 20px;
  min-height: 58px;
  padding: 14px 0;
  border-bottom: 1px solid #e7e9f0;
}
.stage-check-list strong { font-weight: 700; }
.stage-check-list p { margin: 4px 0 0; color: #536078; font-size: 14px; line-height: 1.5; }
.stage-check-list .stage-deadline { font-size: 13px; font-weight: 650; }
.stage-task-details { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.stage-task-points { padding: 3px 8px; border-radius: 999px; background: #eeedf9; color: #45438b; font-size: 13px; font-weight: 650; white-space: nowrap; }
.stage-check-status { display: inline-flex; align-items: center; gap: 6px; color: #5a6479; font-size: 13px; font-weight: 600; }
.stage-check-status::before { content: ""; width: 16px; height: 16px; flex: 0 0 16px; border: 1px solid #929bb0; border-radius: 50%; }
.is-checked .stage-check-status { color: #176548; }
.is-checked .stage-check-status::before {
  content: "✓";
  display: grid;
  place-items: center;
  border-color: #176548;
  background: #176548;
  color: #fff;
  font-size: 11px;
}
.stage-note {
  margin-top: 24px;
  padding: 2px 0 2px 14px;
  border-inline-start: 2px solid #a49fda;
  border-radius: 0;
  background: transparent;
  color: #4f5973;
  font-size: 14px;
  line-height: 1.55;
}
.quiz-result { border-color: #d4e0f7; background: linear-gradient(135deg, #f8faff, #e4edff); border-radius: 19px; }
.quiz-clock {
  position: sticky; top: max(10px, env(safe-area-inset-top)); z-index: 2;
  display: flex; gap: 8px; align-items: center; width: fit-content; margin: 0 0 12px;
  padding: 8px 14px; border: 1px solid #fff; border-radius: 999px;
  background: rgba(243, 242, 251, .95); color: #383788; box-shadow: var(--shadow-sm);
  font-size: 14px;
}
.quiz-clock strong { font-variant-numeric: tabular-nums; }
.quiz-clock.is-urgent { background: #fff1f2; color: #9a253a; }
.history-item { padding: 13px 15px; }
.leaderboard-row { border-radius: 17px; }
.leaderboard-row.is-podium { background: linear-gradient(120deg, #fff5db, #fbfcff); }
.tab-bar {
  inset: auto 0 max(12px, env(safe-area-inset-bottom));
  width: calc(100% - 24px);
  max-width: 448px;
  margin-inline: auto;
  height: 66px;
  padding: 5px;
  gap: 3px;
  z-index: 10;
  border-radius: 999px;
}
.tab-btn { min-width: 0; border-radius: 999px; color: #4f5a70; }
.tab-btn.is-active { background: rgba(98, 94, 167, .13); color: #383788; box-shadow: inset 0 1px 1px #fff; }
.tab-btn.is-active::before { content: none; }
.tab-btn.is-active .tab-icon { transform: none; }
.tab-label { font-size: 11px; }
.tab-icon, .staff-ui .admin-tab-icon, .staff-ui .scan-icon { font-size: 0; }
.tab-icon { position: relative; display: block; width: 21px; height: 21px; }
.tab-icon::before, .tab-icon::after { content: ""; position: absolute; }
[data-panel="profile"] .tab-icon::before { inset: 1px 7px auto; height: 7px; border: 1.5px solid; border-radius: 50%; }
[data-panel="profile"] .tab-icon::after { inset: 10px 3px 1px; border: 1.5px solid; border-radius: 10px 10px 5px 5px; }
[data-panel="stages"] .tab-icon::before { inset: 2px 3px; border: 1.5px solid; border-radius: 4px; }
[data-panel="stages"] .tab-icon::after { inset: 7px 7px auto; height: 1.5px; background: currentColor; box-shadow: 0 5px currentColor; }
[data-panel="leaderboard"] .tab-icon::before { inset: 3px 8px 2px; border-radius: 2px; background: currentColor; }
[data-panel="leaderboard"] .tab-icon::after { inset: 9px auto 2px 1px; width: 5px; border-radius: 2px; background: currentColor; box-shadow: 14px 0 currentColor; }
[data-panel="history"] .tab-icon::before { inset: 2px; border: 1.5px solid; border-radius: 50%; }
[data-panel="history"] .tab-icon::after { inset: 6px auto auto 10px; width: 5px; height: 5px; border-inline-start: 1.5px solid; border-bottom: 1.5px solid; }
.staff-ui .admin-tab-icon::before, .staff-ui .scan-icon::before { font-size: 22px; line-height: 1; }
#participants-tab-btn .admin-tab-icon::before { content: "◉"; }
#quiz-tab-btn .admin-tab-icon::before { content: "▤"; }
#team-tab-btn .admin-tab-icon::before { content: "◇"; }
#points-tab-btn .admin-tab-icon::before { content: "＋"; }
.staff-ui .scan-icon::before { content: "⌗"; font-size: 28px; }

/* Staff console keeps camera controls and actions distinct on the darker canvas. */
.staff-ui {
  --bg: #0b1328;
  --shadow: 0 12px 30px rgba(0,0,0,.26);
  --shadow-lg: 0 22px 65px rgba(0,0,0,.35);
  background-color: var(--bg);
  background-image: radial-gradient(ellipse at 7% 12%, #203b66, transparent 49%),
                    radial-gradient(ellipse at 96% 12%, #303258, transparent 46%),
                    radial-gradient(ellipse at 65% 100%, #172a4b, transparent 52%);
  font-size: 16px;
}
.staff-ui #login-screen { display: grid; place-items: center; padding: 24px 16px; min-height: 100svh; }
.staff-ui .login-card { width: 100%; margin: 0; }
.staff-ui .login-card .field { text-align: start; }
.staff-ui .login-card p { margin: 9px 0 20px; }
.staff-ui .topbar {
  min-height: 64px;
  padding: 8px max(14px, calc((100vw - 900px) / 2));
  border-bottom: 1px solid rgba(255,255,255,.13);
  background: rgba(11, 19, 40, .88);
  -webkit-backdrop-filter: blur(17px) saturate(140%);
  backdrop-filter: blur(17px) saturate(140%);
}
.staff-ui .topbar-title { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.staff-ui .topbar-title .glass-mark { flex: 0 0 34px; height: 34px; border-radius: 11px; }
.staff-ui .topbar .btn-ghost, .staff-ui .refresh-btn { border: 1px solid #8593b5; background: rgba(255,255,255,.09); color: #edf2ff; }
.staff-ui .admin-tabs {
  top: 64px;
  max-width: 800px;
  margin: 13px auto 0;
  padding: 5px;
  border: 1px solid rgba(226,235,255,.25);
  border-radius: 18px;
  background: rgba(24, 39, 72, .91);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}
.staff-ui .admin-tab {
  min-height: 45px;
  background: transparent;
  color: #dae5fc;
}
.staff-ui .admin-tab.is-active { background: #e1eaff; color: #173477; box-shadow: inset 0 1px #fff; }
.staff-ui .scan-wrap { max-width: 800px; padding-inline: 16px; }
.staff-ui .scan-btn, .staff-ui .btn-primary, .staff-ui .search-btn {
  background: linear-gradient(150deg,#426ad8,#2a4db7);
  color: #fff;
  border: 1px solid #6d8de7;
  box-shadow: inset 0 1px rgba(255,255,255,.35), var(--shadow-sm);
}
.staff-ui .scan-btn { border-radius: 20px; font-size: clamp(18px, 4vw, 24px); }
.staff-ui .participant-search { padding: clamp(16px, 4vw, 24px); border-color: rgba(230,238,255,.26); border-radius: 22px; background: rgba(45,62,101,.66); }
.staff-ui .participant-search h2 { letter-spacing: -.02em; }
.staff-ui .reader-box { border: 1px solid #647395; background: #101b33; border-radius: 19px; overflow: hidden; }
.staff-ui .team-page, .staff-ui .points-page { max-width: 800px; padding-inline: 16px; }
.staff-ui .team-page-heading h1, .staff-ui .points-page-heading h1 { font-size: clamp(27px, 5vw, 38px); letter-spacing: -.045em; line-height: 1.13; }
.staff-ui .team-section, .staff-ui .points-section, .staff-ui .participant-result {
  background: #f4f7ff;
  border: 1px solid #e4ebfb;
  border-radius: 19px;
  box-shadow: var(--shadow-sm);
}
.staff-ui #quiz-list-status { color: #d2def3; }
.staff-ui .quiz-list-review.is-pending { color: #84551b; }
.staff-ui .modal-overlay { background: rgba(6, 13, 32, .72); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); }
.staff-ui .modal-card { background: #f7faff; border: 1px solid #dfe8fb; border-radius: 25px; max-height: 86dvh; }
.staff-ui .scrolling-modal-header { background: #edf3ff; }
.staff-ui .participant-avatar { background: #dfe9ff; color: #254ba9; }
.staff-ui .btn-secondary { border: 1px solid #b7c8ed; color: #2144a3; background: #eef3ff; }
.staff-ui .participant-stages button[aria-expanded="true"] { color: #fff; background: #2d52ad; border-color: #2d52ad; }
.staff-ui .btn-danger-outline { border: 1px solid #e0afbd; background: #fff4f7; }
.staff-ui .btn-ghost { border-width: 1px; }
.staff-ui .modal-card button:focus-visible, .staff-ui .login-card button:focus-visible { outline-color: #2854c7; }
.staff-ui .toast.ok { background: #2454bb; }

@media (max-width: 640px) {
  #panel-stages .panel-title { margin-bottom: 14px; }
  .stage-switch { width: 100%; }
  .stage-heading { padding-bottom: 18px; }
  .stage-check-list li { grid-template-columns: 1fr; gap: 6px; padding-block: 12px; }
  .stage-check-status { justify-self: start; }
  .staff-ui .admin-tabs {
    top: auto;
    bottom: max(9px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    margin: 0 auto;
    max-width: 480px;
    padding: 5px;
  }
  .staff-ui .admin-tab { gap: 4px; }
  .staff-ui .topbar-title { font-size: 14px; }
  .staff-ui .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-transparency: reduce) {
  .stage-switch, .tab-bar { background: #f5f6fb; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
