:root {
  --bg: #f4f1ea;
  --bg-accent: #efe9dc;
  --surface: #ffffff;
  --ink: #1f2430;
  --ink-soft: #55606f;
  --muted: #8a93a0;
  --brand: #b8433a;      /* ciepła czerwień */
  --brand-strong: #98332b;
  --brand-soft: #f7e4e1;
  --accent: #2e6f6a;     /* stonowana zieleń */
  --accent-soft: #dcece9;
  --gold: #c99a3f;
  --line: #e7e1d5;
  --ok: #2e7d5b;
  --shadow: 0 10px 30px rgba(31, 36, 48, 0.10);
  --shadow-sm: 0 4px 14px rgba(31, 36, 48, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --bg-accent: #1b1e24;
    --surface: #22262e;
    --ink: #eef1f5;
    --ink-soft: #b6bdc8;
    --muted: #8791a0;
    --brand: #e0655b;
    --brand-strong: #ef8078;
    --brand-soft: #3a2622;
    --accent: #6bb8ad;
    --accent-soft: #21322f;
    --gold: #d9b463;
    --line: #333944;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-accent), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, var(--accent-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 28px) 60px;
}

/* Ekrany */
.screen { display: none; animation: fade .35s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero { text-align: center; margin-bottom: 26px; }
.kicker {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 8px;
}
h1 {
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  line-height: 1.1;
  font-weight: 800;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.lead { color: var(--ink-soft); font-size: 1.03rem; margin: 0 auto; max-width: 56ch; }

/* Karty */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

/* Formularz startowy */
.start-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: .95rem;
}
input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.field-error { color: var(--brand-strong); font-size: .88rem; margin: 8px 0 0; }

/* Przyciski */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  cursor: pointer;
  transition: transform .08s ease, background .15s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 18px rgba(184, 67, 58, .35);
}
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.start-card .muted { text-align: center; margin: 12px 0 0; }

/* Quiz */
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.progress { flex: 1; min-width: 180px; }
.progress-bar {
  height: 10px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--gold));
  border-radius: 99px;
  transition: width .3s ease;
}
.progress-label { font-size: .82rem; color: var(--muted); margin: 6px 2px 0; font-weight: 600; }
.player-tag { font-size: .9rem; color: var(--ink-soft); margin: 0; }

.question-card { text-align: left; }
.q-category {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 5px 12px;
  border-radius: 99px;
  margin: 0 0 14px;
}
.q-prompt { font-size: 1.15rem; margin: 0 0 20px; font-weight: 700; }

.options { display: grid; gap: 12px; }
.option {
  text-align: left;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: border-color .15s, background .15s, transform .08s;
}
.option:hover { border-color: var(--brand); background: var(--brand-soft); }
.option:active { transform: translateY(1px); }
.option .badge {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
  font-weight: 700; font-size: .9rem;
  color: var(--brand);
}

/* Wynik */
.result-card { text-align: center; }
.score-ring {
  --pct: 0;
  width: 150px; height: 150px;
  margin: 6px auto 18px;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--pct) * 1%), var(--line) 0);
  display: grid; place-items: center;
  transition: background .8s ease;
}
.score-inner {
  width: 118px; height: 118px;
  background: var(--surface);
  border-radius: 50%;
  display: grid; place-items: center;
  line-height: 1;
}
.score-num { font-size: 2.7rem; font-weight: 800; color: var(--brand); }
.score-den { font-size: .95rem; color: var(--muted); font-weight: 600; }
#result-headline { margin: 4px 0 10px; font-size: 1.5rem; font-weight: 800; }

.note {
  text-align: left;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 22px 0;
  font-size: .92rem;
  color: var(--ink-soft);
}
.note strong { color: var(--ink); }

.save-status { font-size: .9rem; min-height: 1.2em; margin-bottom: 10px; font-weight: 600; }
.save-status.ok { color: var(--ok); }
.save-status.warn { color: var(--gold); }
.save-status.err { color: var(--brand-strong); }

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Tablica wyników */
.board-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.board-head h2 { margin: 0; font-size: 1.25rem; }
.board-preview h2 { font-size: 1.15rem; }

.board { margin-top: 12px; }
.board table { width: 100%; border-collapse: collapse; }
.board th {
  text-align: left;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.board td { padding: 11px 8px; border-bottom: 1px solid var(--line); font-size: .96rem; }
.board tr:last-child td { border-bottom: none; }
.board .rank { width: 44px; font-weight: 800; color: var(--muted); }
.board .rank.top1 { color: var(--gold); }
.board .rank.top2 { color: #a9adb5; }
.board .rank.top3 { color: #c98a5a; }
.board .name { font-weight: 600; word-break: break-word; }
.board .pts { text-align: right; white-space: nowrap; font-weight: 700; }
.board .pts b { color: var(--brand); }
.board tr.me { background: var(--brand-soft); }
.board tr.me td:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.board tr.me td:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

.board .empty, .board .info { color: var(--muted); font-size: .9rem; padding: 8px 0; }

.site-foot { text-align: center; margin-top: 26px; }

@media (max-width: 480px) {
  .quiz-top { align-items: flex-start; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { width: 100%; }
}
