/* Saints Live Quiz — Queen of All Saints Academy
   Navy + gold from the school's identity, on warm ivory "paper". */
:root {
	--navy: #1a3059;
	--navy-deep: #0f1f3d;
	--navy-soft: #2b4677;
	--cornflower: #678fb2;
	--cornflower-light: #a4bcd1;
	--sky: #e7eef6;
	--paper: #f5f2ea; /* warm ivory, after the school site's bisque */
	--surface: #ffffff;
	--subtle: #faf8f3;
	--gold: #e2a93a;
	--gold-soft: #fbf1db;
	--gold-deep: #9c6d12;
	--ink: #14213d;
	--muted: #5a6273;
	--line: #e4dfd3;
	--line-strong: #cbc3b1;
	--green: #1d7a46;
	--green-soft: #e4f2e9;
	--red: #b23a30;
	--red-soft: #f9e8e5;
	--radius: 14px;
	--white: #ffffff;
	--bisque: var(--paper);
	--shadow: 0 1px 2px rgb(20 33 61 / 0.05), 0 6px 20px -8px rgb(20 33 61 / 0.12);
	--shadow-lift: 0 2px 4px rgb(20 33 61 / 0.06), 0 16px 40px -12px rgb(20 33 61 / 0.22);
	--display: "Libre Baskerville", Baskerville, Georgia, serif;
	--ui: "Source Sans 3", system-ui, -apple-system, sans-serif;
	--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: var(--ui);
	color: var(--ink);
	background: var(--paper);
	font-size: 18px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation; /* no double-tap zoom on iPad */
	min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
a { color: var(--navy); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; color: var(--navy); line-height: 1.18; margin: 0 0 0.4em; letter-spacing: -0.015em; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }
.hidden { display: none !important; }

/* Small spaced capitals for section labels */
.label {
	display: block; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
	color: var(--gold-deep); margin-bottom: 8px;
}

/* ---------- top bar ---------- */
.topbar {
	background: var(--navy);
	color: #fff;
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 70px;
	padding: 10px 24px;
	padding-top: max(10px, env(safe-area-inset-top));
	position: sticky;
	top: 0;
	z-index: 20;
	box-shadow: inset 0 -3px 0 var(--gold);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; min-width: 0; }
/* Official Queen of All Saints crest (from qasonline.org) */
.brand .crest { height: 46px; width: auto; flex: none; display: block; }
.brand .title {
	font-family: var(--display); font-size: 21px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	padding-left: 14px; border-left: 1px solid rgb(255 255 255 / 0.3);
}
/* School wordmark, styled after the qasonline.org logo lockup */
.brand .wordmark {
	font-family: var(--display); font-weight: 400; font-size: 15px; line-height: 1.25;
	letter-spacing: 0.06em; white-space: nowrap;
	padding-left: 14px; border-left: 1px solid rgb(255 255 255 / 0.3);
}
.brand .wordmark i { font-style: italic; font-weight: 400; letter-spacing: 0; text-transform: none; }
.topbar .spacer { flex: 1; }
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: #d5e0ec; white-space: nowrap; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgb(226 169 58 / 0.2); }
.conn.ok::before { background: #5fd08f; box-shadow: 0 0 0 3px rgb(95 208 143 / 0.18); }
.conn.bad { color: #ffc2bc; }
.conn.bad::before { background: #ff7b6e; box-shadow: 0 0 0 3px rgb(255 123 110 / 0.2); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.topbar .link { color: #fff; text-decoration: none; font-weight: 600; font-size: 16px; padding: 10px 4px; white-space: nowrap; }
.topbar .link:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 52px; padding: 0 22px;
	border-radius: 10px; border: 1px solid var(--line-strong);
	font-weight: 600; font-size: 17px; text-decoration: none; white-space: nowrap;
	background: var(--surface); color: var(--navy);
	box-shadow: 0 1px 1px rgb(20 33 61 / 0.04);
	transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--subtle); border-color: #b6ad99; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 1px 2px rgb(15 31 61 / 0.25), inset 0 1px 0 rgb(255 255 255 / 0.08); }
.btn.primary:hover:not(:disabled) { background: var(--navy-soft); border-color: var(--navy-soft); }
.btn.gold { background: var(--gold); border-color: #d39a2a; color: var(--navy-deep); font-weight: 700; box-shadow: 0 1px 2px rgb(156 109 18 / 0.3), inset 0 1px 0 rgb(255 255 255 / 0.35); }
.btn.gold:hover:not(:disabled) { background: #eab44a; border-color: #d39a2a; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red:hover:not(:disabled) { background: #9c3128; border-color: #9c3128; }
.btn.ghost { background: transparent; border-color: rgb(255 255 255 / 0.35); color: #fff; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: rgb(255 255 255 / 0.1); border-color: rgb(255 255 255 / 0.55); }
.btn.small { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: 9px; }
.btn.big { min-height: 64px; font-size: 19px; padding: 0 30px; border-radius: 12px; }
.btn.block { width: 100%; }

/* ---------- surfaces ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding: 36px 24px 64px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.eyebrow { font-size: 15px; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

label.field { display: block; font-weight: 600; font-size: 15px; color: var(--ink); margin-bottom: 16px; }
label.field span.hint, .field span.hint { font-weight: 400; color: var(--muted); }
.input, select.input, textarea.input {
	display: block; width: 100%; margin-top: 6px;
	min-height: 54px; padding: 12px 16px;
	border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
	font-size: 18px;
	box-shadow: inset 0 1px 2px rgb(20 33 61 / 0.04);
	transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
textarea.input { min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 4px var(--sky); }

/* ---------- leaderboard ---------- */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board li {
	display: flex; align-items: center; gap: 12px;
	padding: 10px 12px; border-radius: 10px;
	font-weight: 600;
}
.board li:nth-child(even):not(.top):not(.me) { background: var(--subtle); }
.board li.top { background: var(--gold-soft); }
.board li.me { background: var(--sky); box-shadow: inset 3px 0 0 var(--navy); }
.board li.me .nm::after { content: "You"; margin-left: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy); }
.board li .medal { width: 28px; font-size: 22px; text-align: center; flex: none; }
.board li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .pts {
	font-family: var(--display); font-size: 18px; font-weight: 700; color: var(--navy);
	min-width: 40px; text-align: center; font-variant-numeric: tabular-nums;
	padding: 2px 10px; border-radius: 999px; background: rgb(255 255 255 / 0.7);
}
.board li.top .pts { background: #fff; color: var(--gold-deep); }
.board.nomedals .medal { display: none; }
.board .empty { color: var(--muted); font-weight: 400; }

/* ---------- dialogs (in-page only) ---------- */
.scrim {
	position: fixed; inset: 0; z-index: 100;
	background: rgb(15 31 61 / 0.45);
	-webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
	display: grid; place-items: center; padding: 20px;
	animation: fade 0.18s var(--ease);
}
.dialog {
	background: var(--surface); border-radius: 18px; padding: 30px;
	width: min(480px, 100%); max-height: 90dvh; overflow: auto;
	box-shadow: 0 30px 80px -20px rgb(15 31 61 / 0.45);
	border-top: 4px solid var(--gold);
	animation: rise 0.22s var(--ease);
}
.dialog h2 { font-size: 25px; }
.dialog .actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.dialog .actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px) scale(0.98); opacity: 0; } }

/* PIN pad */
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 10px 0 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--navy); transition: background 0.12s var(--ease), transform 0.12s var(--ease); }
.pin-dots i.on { background: var(--navy); transform: scale(1.1); }
.pin-dots.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button {
	min-height: 72px; border-radius: 14px; border: 1px solid var(--line);
	background: var(--subtle); color: var(--navy);
	font-family: var(--display); font-size: 28px; font-weight: 700;
	transition: background 0.1s var(--ease), transform 0.1s var(--ease);
}
.pinpad button:active { background: var(--sky); transform: scale(0.96); }
.pinpad button.fn { font-family: var(--ui); font-size: 16px; font-weight: 600; color: var(--muted); background: transparent; border-color: transparent; }
.pin-error { text-align: center; color: var(--red); font-weight: 600; min-height: 1.5em; }

/* toast */
.toast {
	position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
	background: var(--navy-deep); color: #fff; padding: 14px 22px; border-radius: 12px;
	font-weight: 600; z-index: 200; max-width: calc(100% - 32px);
	box-shadow: var(--shadow-lift);
	animation: toastIn 0.24s var(--ease);
}
.toast.error { background: var(--red); }
@keyframes toastIn { from { transform: translate(-50%, 12px); opacity: 0; } }

/* confetti canvas */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; }

/* join code */
.code-chip {
	display: inline-flex; align-items: center;
	border: 1px solid currentColor; border-radius: 8px;
	font-weight: 700; letter-spacing: 0.14em; font-variant-numeric: tabular-nums;
	padding: 3px 10px 3px 12px; font-size: 17px;
}
.topbar .code-chip { color: var(--gold); border-color: rgb(226 169 58 / 0.6); background: rgb(226 169 58 / 0.08); }

/* Status dots (students online / offline) */
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); display: inline-block; flex: none; }
.dot.on { background: #2fa866; box-shadow: 0 0 0 3px rgb(47 168 102 / 0.18); }
.dot.away { background: var(--gold); }

/* Initials avatar */
.avatar {
	width: 44px; height: 44px; border-radius: 50%; flex: none;
	display: grid; place-items: center;
	background: var(--sky); color: var(--navy);
	font-weight: 700; font-size: 16px; letter-spacing: 0.02em;
}

input::placeholder, textarea::placeholder { color: #7a8292; opacity: 1; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Respect "reduce motion": no slide/scale animations, no confetti (handled in app.js). */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 640px) {
	body { font-size: 17px; }
	.topbar { padding-left: 16px; padding-right: 16px; }
	.brand .title { font-size: 18px; }
	.brand .wordmark { font-size: 14px; }
	.wrap { padding: 22px 16px 44px; }
	.card { padding: 20px; }
}
