/*
  VOICE: tajemný, ale čitelný – jako ilustrovaný hermetický rukopis
  IDEA: noční obloha nad pergamenovými listy; karta Mága jako brána
  PICTURE: mág se čtyřmi živly na úvodu, ke každé otázce vlastní kresba okruhu
  COLOUR: hluboká noční zeleň, pergamen, rumělka (elektrické) a lapis (magnetické), zlato jako akcent
  TYPE: Cinzel pro nadpisy, Alegreya pro text, Alegreya Sans pro ovládání
*/
:root {
  --night: #0e2422;
  --night-2: #13302d;
  --paper: #f3ead6;
  --paper-2: #e9dcc0;
  --ink: #2b1f17;
  --muted: #6b5a48;
  --gold: #c9a13b;
  --gold-2: #e7c76a;
  --red: #c2412d;
  --blue: #2d5c9e;
  --ok: #3f7a4a;
  --bad: #b03a2a;
  --radius: 14px;
}

* { box-sizing: border-box; min-width: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #1d4440 0%, transparent 60%),
    var(--night);
  color: var(--paper);
  font: 17px/1.6 "Alegreya", Georgia, serif;
  overflow-x: clip;
}

a { color: var(--gold-2); }

[hidden] { display: none !important; }

/* ---------- hlavička ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(5vw, 16px);
  border-bottom: 1px solid rgba(201, 161, 59, .25);
}
.brand {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .04em;
  color: var(--gold-2);
  text-decoration: none;
}
.top nav { display: flex; gap: 18px; flex-wrap: wrap; }
.top nav a {
  font-family: "Alegreya Sans", system-ui, sans-serif;
  color: var(--paper);
  text-decoration: none;
  padding: 8px 2px;
}
.top nav a:hover { color: var(--gold-2); }

/* ---------- úvod ---------- */
.view { padding: clamp(24px, 4vw, 56px) max(5vw, 16px); max-width: 1240px; margin: 0 auto; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(20px, 4vw, 56px);
  align-items: center;
  min-height: min(78vh, 720px);
}

h1, h2, .section-title {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  line-height: 1.1;
  text-wrap: balance;
}
h1 { font-size: clamp(38px, 6vw, 64px); margin: 0 0 16px; color: var(--gold-2); }
.lead { font-size: 19px; max-width: 34em; margin: 0 0 28px; color: #e6dcc6; }

.hero-art svg { width: 100%; height: auto; display: block; max-height: 640px; }
.hero-art .tw { animation: tw 3.2s ease-in-out infinite; }
.hero-art .tw:nth-child(2n) { animation-delay: -1.4s; }
@keyframes tw { 50% { opacity: .2; } }

.start {
  background: rgba(243, 234, 214, .06);
  border: 1px solid rgba(201, 161, 59, .35);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
}
.start label {
  display: block;
  font-family: "Alegreya Sans", system-ui, sans-serif;
  font-weight: 500;
  margin-bottom: 8px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row input { flex: 1 1 220px; }

input[type=text], input[type=password] {
  font: 16px "Alegreya Sans", system-ui, sans-serif;
  padding: 12px 14px;
  min-height: 48px;
  border-radius: 10px;
  border: 2px solid var(--paper-2);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.hint { font-family: "Alegreya Sans", system-ui, sans-serif; font-size: 14px; color: #cfc4ad; margin: 10px 0 0; }
.error { color: #ffb4a6; font-family: "Alegreya Sans", system-ui, sans-serif; font-size: 15px; margin: 8px 0 0; min-height: 1em; }

/* ---------- tlačítka ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  border-radius: 10px;
  font: 600 16px "Alegreya Sans", system-ui, sans-serif;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid transparent;
  transition: transform .12s ease, background .12s ease;
}
.btn:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 2px; }
.btn.primary { background: var(--gold); color: #1d150c; }
.btn.primary:hover { background: var(--gold-2); }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn:disabled { opacity: .55; cursor: wait; }

/* ---------- kvíz ---------- */
.quiz-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: "Alegreya Sans", system-ui, sans-serif; }
.quiz-head p { margin: 0; }
.count { color: var(--gold-2); font-weight: 700; }
.bar { height: 6px; background: rgba(243, 234, 214, .15); border-radius: 6px; margin: 12px 0 20px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--gold), var(--blue)); transition: width .3s ease; }

.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.qcard { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); overflow: hidden; }
.qart {
  margin: 0;
  background: var(--paper-2);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  border-right: 1px solid rgba(43, 31, 23, .12);
}
.qart svg.art { width: 100%; height: auto; display: block; }
.qart figcaption {
  font-family: "Cinzel", Georgia, serif;
  font-size: 15px;
  text-align: center;
  color: var(--muted);
}
.qbody { padding: clamp(20px, 3vw, 36px); }
.qbody h2 { font-family: "Alegreya", Georgia, serif; font-weight: 600; font-size: clamp(21px, 2.4vw, 27px); line-height: 1.3; margin: 0 0 20px; }

.options { display: grid; gap: 10px; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid #d8c8a6;
  background: #fffaf0;
  color: var(--ink);
  font: 17px/1.35 "Alegreya", Georgia, serif;
  cursor: pointer;
}
.opt:hover { border-color: var(--gold); }
.opt:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.opt .mark {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: 700 14px "Alegreya Sans", system-ui, sans-serif;
  background: var(--paper-2);
  color: var(--muted);
}
.opt[aria-checked=true] { border-color: var(--ink); background: #f6edd6; }
.opt[aria-checked=true] .mark { background: var(--ink); color: var(--paper); }

.qnav { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.qnav .btn.ghost { color: var(--ink); }
.qbody .error { color: var(--bad); }

.dots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }
.dots button {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(243, 234, 214, .4);
  background: transparent;
  color: var(--paper);
  font: 13px "Alegreya Sans", system-ui, sans-serif;
  cursor: pointer;
}
.dots button.done { background: rgba(201, 161, 59, .35); border-color: var(--gold); }
.dots button.current { outline: 2px solid var(--gold-2); outline-offset: 2px; }

/* ---------- výsledek ---------- */
.score-card {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 40px);
  align-items: center;
  padding: clamp(20px, 3vw, 40px);
}
.score-art svg { width: 100%; height: auto; display: block; }
.kicker { font-family: "Cinzel", Georgia, serif; font-size: 22px; margin: 0; color: var(--muted); }
.score { font-family: "Cinzel", Georgia, serif; font-size: clamp(56px, 9vw, 96px); line-height: 1; margin: 8px 0 16px; color: var(--ink); }
.score small { font-size: .4em; color: var(--muted); }
.facts { display: flex; gap: 28px; margin: 0 0 22px; flex-wrap: wrap; }
.facts dt { font: 14px "Alegreya Sans", system-ui, sans-serif; color: var(--muted); }
.facts dd { margin: 0; font: 700 24px "Alegreya Sans", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.actions .btn.ghost { color: var(--ink); }

.section-title { font-size: clamp(26px, 3.4vw, 36px); margin: 40px 0 14px; color: var(--gold-2); }

.review { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.review li {
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 16px 14px 56px;
  position: relative;
}
.review li::before {
  content: "";
  position: absolute;
  left: 16px; top: 16px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ok);
}
.review li.bad::before { background: var(--bad); }
.review li::after {
  content: "✓";
  position: absolute;
  left: 16px; top: 16px;
  width: 26px; line-height: 26px;
  text-align: center;
  color: #fff;
  font: 700 15px/26px "Alegreya Sans", system-ui, sans-serif;
}
.review li.bad::after { content: "✗"; }
.review .rq { font-weight: 600; margin: 0 0 4px; }
.review .ra { margin: 0; font-family: "Alegreya Sans", system-ui, sans-serif; font-size: 15px; color: var(--muted); }
.review .ra b { color: var(--ink); }

/* ---------- pořadí ---------- */
.board-band { background: var(--night-2); border-top: 1px solid rgba(201, 161, 59, .25); }
.board-inner { max-width: 1240px; margin: 0 auto; padding: clamp(28px, 4vw, 56px) max(5vw, 16px); }
.board-band .section-title { margin-top: 0; }
.hint.light { margin: 0 0 16px; }
.scroll { overflow-x: auto; }
.board { width: 100%; border-collapse: collapse; font-family: "Alegreya Sans", system-ui, sans-serif; background: var(--paper); color: var(--ink); border-radius: 12px; overflow: hidden; }
.board th, .board td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #e0d2b3; }
.board th { background: var(--paper-2); font-weight: 700; font-size: 14px; }
.board td.num, .board th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.board tr:last-child td { border-bottom: 0; }
.board td.rank { font-weight: 700; width: 3em; }
.board tr.top1 td.rank { color: #a07a14; }
.board tr.me td { background: #fbeec2; }
.board td.empty { text-align: center; color: var(--muted); padding: 24px; }

.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 20px max(5vw, 16px);
  font: 14px "Alegreya Sans", system-ui, sans-serif;
  color: #b9ae96;
}
.foot p { margin: 0; max-width: 60em; }

/* ---------- úzké obrazovky ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-art { order: -1; max-width: 360px; margin: 0 auto; width: 100%; }
  .qcard { grid-template-columns: 1fr; }
  .qart { border-right: 0; border-bottom: 1px solid rgba(43, 31, 23, .12); padding: 14px; }
  .qart svg.art { max-height: 170px; }
  .score-card { grid-template-columns: 1fr; }
  .score-art { max-width: 200px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .board th:nth-child(5), .board td:nth-child(5) { display: none; }
  .board th, .board td { padding: 10px 8px; }
  .qnav .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-art .tw { animation: none; }
  html { scroll-behavior: auto; }
  .bar span { transition: none; }
}
