:root {
  --bg: #f8f4ea;
  --surface: #fffdf8;
  --ink: #132238;
  --muted: #6d7480;
  --line: #e5d9c2;
  --primary: #12345b;
  --primary-2: #1e5f8a;
  --gold: #c9952f;
  --good: #198754;
  --bad: #c0392b;
  --shadow: 0 20px 60px rgba(19, 34, 56, 0.14);
}

body.dark {
  --bg: #101923;
  --surface: #182638;
  --ink: #f8f4ea;
  --muted: #b9c1cc;
  --line: #2d4057;
  --primary: #d5a547;
  --primary-2: #7db8df;
  --gold: #e2b85c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(201, 149, 47, 0.16), transparent 26rem),
    linear-gradient(180deg, var(--bg), #ffffff 70%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  background: rgba(255, 253, 248, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

body.dark .topbar {
  background: rgba(16, 25, 35, 0.9);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  letter-spacing: 0;
}

.nav {
  display: flex;
  flex: 1;
  gap: 0.35rem;
  justify-content: center;
  overflow-x: auto;
}

.nav button,
.theme-toggle {
  border: 0;
  background: transparent;
  color: var(--ink);
  min-height: 2.4rem;
  border-radius: 8px;
  padding: 0 0.7rem;
}

.nav button:hover,
.nav button.active,
.theme-toggle:hover {
  background: rgba(18, 52, 91, 0.1);
}

main {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  min-height: calc(100vh - 4.1rem);
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 28rem);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  padding: clamp(2rem, 7vw, 6rem) clamp(1rem, 6vw, 5rem);
}

.hero.active {
  display: grid;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 3rem);
  letter-spacing: 0;
}

h3 {
  margin: 0 0 0.8rem;
}

.lead {
  max-width: 40rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.6;
}

.hero-actions,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary,
.secondary {
  min-height: 2.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 1rem;
  font-weight: 800;
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: var(--shadow);
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.full {
  width: 100%;
}

.hero-panel,
.question-card,
.feedback,
.results,
.editor,
.table-wrap,
.admin-list,
.admin-login {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 1rem;
}

.scripture-card {
  min-height: 18rem;
  display: grid;
  align-content: center;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: 8px;
  background: linear-gradient(145deg, #12345b, #1f5d89);
  color: #fff;
}

.scripture-card .icon {
  width: 3.4rem;
  height: 3.4rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #f3c969;
  font-size: 1.5rem;
}

.scripture-card strong {
  font-size: 2rem;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.stats-strip span {
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(201, 149, 47, 0.12);
  color: var(--muted);
  text-align: center;
}

.stats-strip b {
  display: block;
  color: var(--ink);
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 4rem) 0;
}

.section-head {
  margin-bottom: 1.25rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 1rem;
}

.competition-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 26rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.competition-main {
  display: grid;
  gap: 1rem;
}

.join-bar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.room-panel {
  display: grid;
  gap: 1rem;
}

.room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.room-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.competition-stats {
  margin-top: 0;
}

.stepper {
  display: grid;
  grid-template-columns: 2.8rem minmax(0, 1fr) 2.8rem;
  gap: 0.35rem;
}

.stepper button {
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 900;
}

.advanced-options {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(201, 149, 47, 0.08);
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.game-board {
  display: grid;
  gap: 1rem;
}

.game-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  font-weight: 800;
}

.progress {
  height: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(18, 52, 91, 0.12);
}

.progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--primary-2));
  transition: width 0.2s linear;
}

.question-card {
  padding: clamp(1rem, 4vw, 2rem);
}

.pill {
  display: inline-flex;
  margin: 0 0 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(201, 149, 47, 0.15);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.answers {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.3rem;
}

.answer {
  min-height: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0.8rem 1rem;
  text-align: left;
  font-weight: 800;
}

.answer.correct {
  border-color: var(--good);
  background: rgba(25, 135, 84, 0.14);
}

.answer.wrong {
  border-color: var(--bad);
  background: rgba(192, 57, 43, 0.13);
}

.feedback,
.results {
  padding: 1rem;
}

.reference {
  color: var(--gold);
  font-weight: 800;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.challenge-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.challenge-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.mini-progress {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(18, 52, 91, 0.12);
  overflow: hidden;
}

.mini-progress span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 42rem;
}

th,
td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.admin-login {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.admin-panel {
  display: grid;
  gap: 1rem;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 25rem) minmax(0, 1fr);
  gap: 1rem;
}

.editor,
.admin-list {
  padding: 1rem;
}

.editor {
  display: grid;
  gap: 0.75rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check input {
  width: auto;
  min-height: auto;
}

.admin-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.admin-item p {
  margin: 0;
  color: var(--muted);
}

.admin-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .hero,
  .hero.active {
    display: block;
  }

  .hero-panel {
    margin-top: 1.5rem;
  }

  .setup-grid,
  .admin-login,
  .admin-layout,
  .competition-layout,
  .join-bar {
    grid-template-columns: 1fr;
  }

  .room-head {
    display: grid;
  }

  .room-actions {
    justify-content: stretch;
  }
}

@media (max-width: 520px) {
  .stats-strip {
    grid-template-columns: 1fr;
  }

  .game-meta {
    flex-direction: column;
  }

  .primary,
  .secondary {
    width: 100%;
  }
}
