/* The layout comes from hadithguessr, recoloured white and pine green. */
:root {
  --black: #f6faf8;
  --panel: #ffffff;
  --deep: #cfe4dd;
  --accent: #1f5a4f;
  --paper: #1f5a4f;
  --on-paper: #ffffff;
  --text: #12302a;
  --mute: #55695f;
  --rule: rgba(31, 90, 79, .14);
  --wash: rgba(31, 90, 79, .06);
  --line: rgba(31, 90, 79, .32);
  --right: #2e7d4f;
  --wrong: #b83a55;
  --sans: "Montserrat", system-ui, sans-serif;
  --glow: 0 0 28px rgba(31, 90, 79, .5);
  --glow-soft: inset 0 0 32px rgba(31, 90, 79, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font: 400 14.5px/1.5 var(--sans);
  background: var(--black);
  -webkit-tap-highlight-color: transparent;
}

/* A separate fixed layer, because fixed page backgrounds are unreliable on phones. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(70vmax 50vmax at 10% 35%, var(--deep) 0%, transparent 72%),
    radial-gradient(60vmax 40vmax at 100% 105%, #e0eeea 0%, transparent 70%);
}

#app { min-height: 100vh; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: start; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }

.eyebrow { margin: 0; color: var(--mute); font: 600 11px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; }

/* Top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; max-width: 620px; margin: 0 auto; padding: 24px 16px 16px; }
.wordmark { font: 700 17px/1 var(--sans); letter-spacing: -.02em; white-space: nowrap; }
.wordmark span { color: var(--accent); }
.tabs { display: flex; }
.tab { min-height: 40px; padding: 8px 16px; border: 1px solid var(--line); text-align: center; font-size: 13px; font-weight: 500; text-decoration: none; transition: box-shadow .2s, background .2s; }
.tab + .tab { border-inline-start: 0; }
.tab.on { color: var(--on-paper); font-weight: 600; background: var(--paper); border-color: var(--paper); }
.tab:hover:not(.on) { position: relative; z-index: 1; background: var(--wash); box-shadow: var(--glow); }

/* Page */
.setup { width: 100%; max-width: 620px; margin: 0 auto; padding: 16px 16px 64px; }
.page-title { margin: 8px 0 0; font: 700 clamp(30px, 8vw, 44px)/1.08 var(--sans); letter-spacing: -.035em; overflow-wrap: anywhere; }
.lede { margin: 12px 0 24px; color: var(--mute); font-size: 16px; }
.section-title { margin: 32px 0 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); font: 600 16px/1.3 var(--sans); letter-spacing: -.01em; }
.final { margin: 8px 0 0; color: var(--accent); font: 700 80px/1 var(--sans); letter-spacing: -.03em; }
.form-error { margin: 12px 0 0; color: var(--wrong); font-size: 13.5px; }
.saved { margin: 12px 0 0; color: var(--right); font-size: 13.5px; }

/* Inputs and buttons */
.field { width: 100%; min-height: 48px; padding: 8px 16px; color: var(--text); background: none; border: 1px solid var(--line); border-radius: 0; font: 500 16px var(--sans); transition: box-shadow .2s, border-color .2s; }
.field::placeholder { color: var(--mute); opacity: .7; }
.field:focus { outline: 0; border-color: var(--accent); box-shadow: var(--glow-soft); }
textarea.field { display: block; min-height: 96px; padding: 12px 16px; resize: vertical; font-weight: 400; }
.join-row { display: flex; }
.join-row .field { flex: 1; min-width: 0; }
.pill { flex: none; min-height: 48px; padding: 12px 24px; border: 1px solid var(--line); border-inline-start: 0; text-align: center; transition: box-shadow .2s, background .2s; }
.pill:hover { background: var(--wash); box-shadow: var(--glow); }
.begin { display: block; width: 100%; min-height: 48px; margin-top: 24px; padding: 12px 24px; text-align: center; font-weight: 500; color: var(--on-paper); background: var(--paper); transition: box-shadow .2s; }
.begin:hover:not(:disabled) { box-shadow: var(--glow); }
.begin:disabled { cursor: default; color: var(--mute); background: var(--wash); }
.quit { min-height: 32px; color: var(--mute); font-size: 13px; }
.quit:hover { color: var(--accent); text-shadow: 0 0 12px rgba(31, 90, 79, .9); }

/* Exam */
.progress { position: sticky; top: 8px; z-index: 2; margin-top: 16px; padding: 12px 16px 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 8px 28px rgba(31, 90, 79, .15); }
.progress-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--mute); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.progress-top b { color: var(--accent); font-weight: 600; }
.segments { display: flex; gap: 2px; }
.segments span { flex: 1; min-width: 0; height: 6px; background: var(--rule); }
.segments span.now { background: var(--line); box-shadow: 0 0 10px rgba(31, 90, 79, .7); }
.segments i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.page-section { margin: 16px 0 0; font: 700 26px/1.15 var(--sans); letter-spacing: -.03em; color: var(--accent); }
.page-nav { display: flex; align-items: stretch; gap: 8px; margin-top: 32px; }
.page-nav .begin { flex: 1; margin-top: 0; }
.page-nav .pill { border-inline-start: 1px solid var(--line); }
.question { margin-top: 32px; }
.question h3 { margin: 4px 0 12px; font: 600 19px/1.3 var(--sans); letter-spacing: -.01em; overflow-wrap: anywhere; }
.options { display: grid; gap: 8px; }
.option { display: flex; gap: 12px; align-items: center; width: 100%; min-height: 48px; padding: 12px 16px; border: 1px solid var(--rule); overflow-wrap: anywhere; transition: box-shadow .2s, background .2s; }
.option:hover { border-color: var(--line); color: var(--accent); }
.option:not(.picked) { background: #fff; }
.options.names { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.options.names .skip { grid-column: 5; grid-row: 1 / span 2; }
.option.skip { justify-content: center; color: var(--mute); border-style: dashed; border-color: var(--line); text-align: center; }
.option.skip:disabled { cursor: default; opacity: .45; }
.text-skip { margin-top: 8px; }
.options.names .option { justify-content: center; gap: 8px; min-height: 44px; padding: 8px; text-align: center; }
.option .tick { flex: none; }
.option.picked .tick.on { border-color: var(--on-paper); background: var(--on-paper); box-shadow: inset 0 0 0 3px var(--paper); }
.option.picked, .option.picked:hover { color: var(--on-paper); font-weight: 600; border-color: var(--paper); background: var(--paper); }

/* Results */
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.row.me .name { color: var(--accent); }
.name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.place { width: 20px; color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.tally { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.tally-top { display: flex; gap: 12px; justify-content: space-between; overflow-wrap: anywhere; }
.tally.right .tally-top { color: var(--right); font-weight: 500; }
.meter { height: 8px; margin-top: 8px; background: var(--rule); }
.meter i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); }
.tally.right .meter i { background: var(--right); }
.who { margin: 6px 0 0; color: var(--mute); font-size: 12.5px; overflow-wrap: anywhere; }
.said { padding: 10px 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; white-space: pre-wrap; }
.said.right b { color: var(--right); }
.said b { font-weight: 600; }
.chart-all { margin-top: 8px; }
.chart-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
.chart-pick .level { min-height: 32px; padding: 4px; font-size: 12px; }
.columns { display: flex; align-items: stretch; gap: 8px; margin-top: 16px; }
.column { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.column b { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.column-track { display: flex; align-items: flex-end; justify-content: center; width: 100%; height: 140px; border-bottom: 1px solid var(--line); }
.column-track i { display: block; width: min(100%, 32px); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--accent); }
.column.right .column-track i { background: var(--right); }
.column span { width: 100%; font-size: 11.5px; line-height: 1.2; overflow-wrap: anywhere; }
.columns + .who { margin-top: 12px; }
.who b { font-weight: 600; color: var(--text); }
.pie { display: flex; align-items: center; gap: 24px; margin-top: 16px; }
.pie svg { flex: none; width: 180px; height: 180px; }
.pie ul { flex: 1; min-width: 0; display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pie li { display: flex; gap: 8px; font-size: 13.5px; overflow-wrap: anywhere; }
.pie li i { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 2px; }
.pie li b { font-weight: 600; }
.pie li small { display: block; color: var(--mute); font-size: 12px; }
.said small { display: block; color: var(--mute); font-size: 12.5px; }

/* Editor */
.q-edit { margin-top: 24px; padding: 16px; border: 1px solid var(--rule); background: var(--panel); }
.q-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.q-head .eyebrow { flex: 1; }
.q-head .quit { min-width: 28px; text-align: center; }
.q-head .quit:disabled { cursor: default; opacity: .3; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 12px; }
.section-field { min-height: 40px; margin-top: 8px; font-size: 13px; font-weight: 400; }
.member-list { margin-top: 12px; min-height: 160px; }
.level { min-height: 40px; padding: 8px 4px; border: 1px solid var(--line); text-align: center; font-size: 13px; font-weight: 500; }
.level.on { color: var(--on-paper); font-weight: 600; background: var(--paper); border-color: var(--paper); }
.opt-edit { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.opt-edit .field { flex: 1; min-width: 0; min-height: 44px; font-weight: 400; font-size: 15px; }
.opt-edit .quit { flex: none; min-width: 24px; min-height: 44px; text-align: center; }
.tick-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; }
.tick { width: 18px; height: 18px; border: 1px solid var(--mute); transition: border-color .2s, box-shadow .2s; }
.tick.on { border-color: var(--right); background: var(--right); box-shadow: inset 0 0 0 3px var(--panel); }
.tick-btn:hover .tick:not(.on) { border-color: var(--accent); box-shadow: 0 0 12px rgba(31, 90, 79, .7); }
.hint { margin: 12px 0 0; color: var(--mute); font-size: 13px; }
.add { width: 100%; margin-top: 16px; border-inline-start: 1px solid var(--line); }
.danger { margin-bottom: 16px; color: var(--wrong); }
.danger:disabled { cursor: default; color: var(--mute); }
.sec-toggle { flex: none; min-width: 64px; min-height: 32px; padding: 4px 8px; border: 1px dashed var(--line); color: var(--mute); font-size: 12.5px; font-weight: 500; text-align: center; }
.sec-toggle.on { color: var(--on-paper); border: 1px solid var(--paper); background: var(--paper); }
.sec-actions { display: flex; flex-wrap: wrap; gap: 16px; }
.page-section + .question { margin-top: 16px; }
.sec-count { flex: none; min-width: 20px; color: var(--mute); font-size: 12.5px; text-align: center; font-variant-numeric: tabular-nums; }
.section-divider { margin: 32px 0 0; color: var(--accent); font: 700 20px/1.2 var(--sans); letter-spacing: -.02em; }
.opt-edit .quit:disabled { cursor: default; opacity: .3; }
.add-opt { margin-top: 8px; color: var(--accent); }
.save-bar { position: sticky; bottom: 0; z-index: 2; padding: 8px 0 16px; background: linear-gradient(transparent, var(--black) 30%); }
.save-bar .begin { margin-top: 16px; }

@media (max-width: 520px) {
  .bar { padding: 16px; }
  .wordmark { white-space: normal; line-height: 1.15; }
  .pie { flex-direction: column; align-items: stretch; }
  .pie svg { align-self: center; }
  .columns { gap: 4px; }
  .options.names { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options.names .skip { grid-column: 2; grid-row: var(--skip-row) / span 2; }
  .tab { padding: 8px 10px; font-size: 12.5px; }
  .setup { padding: 8px 16px 40px; }
  .final { font-size: 64px; }
  .q-edit { padding: 12px; }
}

@media (hover: none) {
  .tab:hover:not(.on), .pill:hover { background: none; box-shadow: none; }
  .begin:hover:not(:disabled) { box-shadow: none; }
  .option:hover:not(.picked) { color: inherit; border-color: var(--rule); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
