/* ============================================================
   STQ — Storage Room Quiz
   Branding: black top bar, white body, readable everywhere.
   ============================================================ */

:root {
  --black:   #0a0a0a;
  --bar-fg:  #ffffff;
  --bar-mut: #9ca3af;
  --bg:      #ffffff;
  --ink:     #1f2937;
  --ink-2:   #4b5563;
  --ink-3:   #6b7280;
  --line:    #e5e7eb;
  --line-2:  #f3f4f6;
  --accent:  #2563eb;
  --accent-soft: #dbeafe;
  --good:    #16a34a;
  --good-soft:#dcfce7;
  --bad:     #dc2626;
  --bad-soft:#fee2e2;
  --warn:    #d97706;
  --warn-soft:#fef3c7;
  --shadow:  0 4px 14px rgba(0,0,0,0.06);
  --radius:  14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
header.topbar {
  background: var(--black);
  color: var(--bar-fg);
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.topbar .brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: var(--bar-fg);
}
.topbar .wordmark {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 26px;
  color: var(--bar-fg);
}
.topbar .tag {
  color: var(--bar-mut);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar nav {
  display: flex;
  gap: 6px;
  align-items: center;
}
.topbar nav a {
  color: var(--bar-fg);
  opacity: 0.85;
  text-decoration: none;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 999px;
}
.topbar nav a:hover, .topbar nav a.active {
  background: rgba(255,255,255,0.12);
  opacity: 1;
}

/* ---------- Main / layout ---------- */
main {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
  flex: 1;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
h1 { font-size: 28px; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 20px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 16px; margin: 14px 0 6px; font-weight: 700; }
p  { margin: 0 0 12px; color: var(--ink-2); }
.sub { color: var(--ink-3); font-size: 14px; }

/* ---------- Form controls ---------- */
label { display: block; font-weight: 600; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: white;
  appearance: none;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field { margin-bottom: 14px; }
.row   { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.inline-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-weight: 600; color: var(--ink-2); }
.inline-check input[type="checkbox"] { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: white;
  min-height: 46px;
  text-decoration: none;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:hover:not(:disabled) { opacity: 0.94; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #1f2937; color: white; }
.btn.ghost     { background: transparent; color: var(--accent); padding: 6px 10px; min-height: 0; font-weight: 700; }
.btn.outline   { background: white; border: 1.5px solid var(--accent); color: var(--accent); }
.btn.danger    { background: var(--bad); }
.btn.success   { background: var(--good); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Pills / tags ---------- */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--line-2);
  color: var(--ink-2);
}
.pill.easy   { background: var(--good-soft); color: #166534; }
.pill.medium { background: var(--warn-soft); color: #92400e; }
.pill.hard   { background: var(--bad-soft);  color: #991b1b; }
.pill.bonus  { background: #fef9c3; color: #854d0e; }
.pill.quick  { background: var(--accent-soft); color: var(--accent); }

/* ---------- Status banners ---------- */
.banner {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.banner.good { background: var(--good-soft); color: #166534; }
.banner.bad  { background: var(--bad-soft);  color: #991b1b; }
.banner.warn { background: var(--warn-soft); color: #92400e; }

/* ---------- Choice cards (quiz) ---------- */
.choices { display: grid; gap: 10px; margin: 14px 0 8px; }
.choice {
  text-align: left;
  padding: 16px 18px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: white;
  font-size: 17px;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.4;
  font-weight: 500;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice:disabled { cursor: default; }

/* ---------- Quiz progress / timer ---------- */
.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.quiz-meta .meta-piece { color: var(--ink-3); font-size: 14px; font-weight: 600; }
.quiz-meta .meta-piece strong { color: var(--ink); font-size: 18px; }
.quiz-bar {
  height: 6px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.quiz-bar > div { height: 100%; background: var(--accent); transition: width 0.3s ease; }
.timer { font-variant-numeric: tabular-nums; }
.timer.urgent { color: var(--bad); }
.timer.warning { color: var(--warn); }

/* ---------- Question list (admin) ---------- */
.q-list { list-style: none; padding: 0; margin: 0; }
.q-list li {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  background: #fafbfc;
}
.q-list .q-prompt { font-weight: 700; margin: 4px 0; }
.q-list .q-answer { color: var(--good); font-size: 14px; }
.q-list .q-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.q-list .q-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Leaderboard ---------- */
.lb-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.lb-tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}
.lb-tabs button.active { background: var(--black); color: white; border-color: var(--black); }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); font-size: 15px; }
.lb-table th { color: var(--ink-3); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.lb-table td.rank { font-weight: 800; color: var(--ink); width: 50px; }
.lb-table td.score { font-weight: 700; }
.lb-table td.time  { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Results screen ---------- */
.results-big {
  text-align: center;
  padding: 20px 0 10px;
}
.results-pct {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin: 0;
}
.results-frac { color: var(--ink-3); font-size: 16px; }
.results-message { text-align: center; font-size: 18px; color: var(--ink-2); margin: 8px 0 18px; }
.detail {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  background: white;
}
.detail.right { border-left: 4px solid var(--good); }
.detail.wrong { border-left: 4px solid var(--bad); }
.detail .d-prompt { font-weight: 600; }
.detail .d-line { font-size: 14px; color: var(--ink-3); margin-top: 4px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 30px 20px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  color: var(--ink-3);
}

/* ---------- Misc ---------- */
.hidden { display: none !important; }
.muted  { color: var(--ink-3); }
.spacer { height: 8px; }
.center { text-align: center; }
.spinner {
  width: 22px; height: 22px;
  border: 3px solid #d1d5db;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--ink-3); }

footer.foot {
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  padding: 16px;
}

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar .wordmark { font-size: 22px; }
  .topbar .tag { display: none; }
  main { padding: 16px 14px 80px; }
  h1 { font-size: 22px; }
  .row { flex-direction: column; }
}
