/* BestQuizzes.com — shared styles (design: History Guesser.html) */

@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url('../fonts/cinzel-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/fredoka-latin.woff2') format('woff2');
}

:root {
  --wine: #4A1220;
  --wine-deep: #2A0A12;
  --wine-mid: #6E1F30;
  --gold: #E3B04B;
  --gold-dark: #C8922E;
  --parchment: #F4E6C8;
  --cream: #F7EBD3;
  --sand: #F0D9A8;
  --bronze: #B98B4E;
  --muted: #A8957A;
  --display: 'Cinzel', Georgia, serif;
  --body: 'Fredoka', system-ui, sans-serif;
  --gap: 28px;
}

* { box-sizing: border-box; }

html { background: var(--wine); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--wine);
  background-image: radial-gradient(rgba(240,217,168,0.07) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  color: var(--cream);
  font-family: var(--body);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.4;
}

a { color: var(--sand); }
a:hover { color: var(--gold); }
input::placeholder { color: var(--muted); letter-spacing: 0.02em; }
input:focus { outline: 4px solid var(--gold); outline-offset: 2px; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
button:active { transform: translateY(4px); }
[hidden] { display: none !important; }
.show-sm { display: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
  max-width: 1120px; width: 100%; margin: 0 auto; padding: 20px 24px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.brand:hover { color: inherit; }
.brand-badge {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--wine-deep);
  box-shadow: 0 4px 0 var(--wine-deep), inset 0 0 0 4px var(--gold-dark);
  display: flex; align-items: center; justify-content: center;
}
.brand-badge svg { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.brand-name {
  font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: 0.02em;
  color: var(--cream); white-space: nowrap;
}
.brand-name span { color: var(--gold); }
.brand-sub {
  font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--sand); white-space: nowrap; margin-top: 4px;
}

.nav { display: flex; gap: 8px; }
.nav-link {
  color: var(--cream); text-decoration: none; padding: 10px 16px; border-radius: 12px;
  font: 600 19px/1.4 var(--body); border: 2px solid rgba(240,217,168,0.35);
  background: transparent; cursor: pointer;
}
.nav-link:hover { color: var(--gold); border-color: var(--gold); }
.nav-icon {
  display: none; flex: 0 0 auto; width: 44px; height: 44px; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--wine-deep); border: 0; cursor: pointer; padding: 0;
}

/* ---------- Layout ---------- */
main {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 24px 64px;
  display: flex; flex-direction: column; gap: var(--gap);
}
.screen { display: flex; flex-direction: column; gap: var(--gap); }

/* ---------- Round bar ---------- */
.round-bar { display: flex; flex-direction: column; gap: 12px; }
.round-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.round-label {
  font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: 0.1em; color: var(--sand);
}
.score-pill {
  display: flex; align-items: center; gap: 10px; background: var(--wine-deep);
  border-radius: 999px; padding: 8px 20px 8px 10px;
}
.score-pill svg { width: 26px; height: 26px; }
.score-pill .score-value { font-size: 26px; font-weight: 700; color: var(--gold); }
.score-pill .score-unit { font-size: 16px; font-weight: 600; color: var(--sand); }

.pips { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.pip { flex: 1; height: 8px; border-radius: 999px; background: rgba(240,217,168,0.18); }
.pip.done { background: var(--gold); }
.pip.current { background: var(--sand); box-shadow: 0 0 0 2px var(--wine-deep), 0 0 0 4px var(--gold); }

/* ---------- Parchment card ---------- */
.card {
  background: var(--parchment); color: var(--wine-deep);
  border: 4px solid var(--wine-deep); border-radius: 20px; box-shadow: 0 8px 0 var(--wine-deep);
  padding: 10px;
}
.card-inner {
  border: 2px solid var(--bronze); outline: 1px solid var(--bronze); outline-offset: -7px;
  border-radius: 12px; padding: 40px 32px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.ornament { width: 120px; height: 14px; }
.question-text { margin: 0; font-size: 40px; line-height: 1.2; font-weight: 600; }
.question-text.long { font-size: 32px; }
.card-kicker {
  margin: 0; font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: 0.12em; color: var(--bronze);
}
.card-text { margin: 0; font-size: 21px; font-weight: 500; }

/* ---------- Guess form ---------- */
.guess-form { display: flex; flex-direction: column; gap: 16px; }
.guess-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.year-input {
  flex: 1 1 200px; min-width: 0; height: 76px; padding: 0 20px;
  border: 4px solid var(--wine-deep); border-radius: 18px; background: var(--parchment);
  box-shadow: inset 0 4px 0 rgba(42,10,18,0.12);
  font: 700 36px/1 var(--body); letter-spacing: 0.06em; text-align: center; color: var(--wine-deep);
}
.year-input.invalid { animation: shake 0.35s; border-color: #B3261E; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.era-toggle {
  flex: 0 0 auto; display: flex; padding: 6px; gap: 6px; background: var(--wine-deep); border-radius: 18px;
}
.era-toggle button {
  width: 88px; border: 0; border-radius: 13px; background: transparent; color: var(--sand);
  font: 700 22px/1 var(--body); cursor: pointer;
}
.era-toggle button[aria-pressed="true"] { background: var(--gold); color: var(--wine-deep); }
.form-hint { margin: 0; min-height: 1.4em; text-align: center; font-size: 16px; font-weight: 600; color: var(--sand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 76px; padding: 0 28px; width: 100%;
  border: 4px solid var(--wine-deep); border-radius: 18px; background: var(--gold);
  box-shadow: 0 6px 0 var(--wine-deep); color: var(--wine-deep);
  font: 700 30px/1 var(--body); letter-spacing: 0.08em; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #EBBE5E; color: var(--wine-deep); }
.btn-md { height: 68px; font-size: 24px; letter-spacing: 0.06em; }
.btn-sm { height: 52px; font-size: 18px; letter-spacing: 0.04em; border-width: 3px; box-shadow: 0 4px 0 var(--wine-deep); width: auto; }
.btn-ghost { background: transparent; color: var(--cream); border-color: rgba(240,217,168,0.55); box-shadow: 0 4px 0 var(--wine-deep); }
.btn-ghost:hover { background: rgba(240,217,168,0.08); color: var(--gold); border-color: var(--gold); }

/* ---------- Result panel ---------- */
.result {
  position: relative;
  background: var(--wine-mid); border: 4px solid var(--wine-deep); border-radius: 24px;
  box-shadow: 0 8px 0 var(--wine-deep); padding: 28px 32px;
  display: flex; flex-direction: column; gap: 20px; text-align: center;
}
.headline {
  margin: 0; font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: 0.04em; color: var(--gold);
}

/* Multiplier badge (how-to dialog) */
.mult-badge {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; height: 36px; padding: 0 10px; border-radius: 999px;
  background: var(--gold); color: var(--wine-deep); border: 3px solid var(--wine-deep);
  font: 700 20px/1 var(--body);
}
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--wine); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; }
.tile-label { font-size: 15px; font-weight: 600; color: var(--sand); }
.tile-value { font-size: 32px; font-weight: 700; }
.tile-value.gold { color: var(--gold); }
.tile-value small { font-size: 0.6em; color: var(--sand); }
.tiles.five { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.tiles.five .tile { padding: 14px 6px; }
.tiles.five .tile-label { hyphens: manual; }
.tiles.five .tile-value { font-size: 26px; line-height: 1.2; }
.tile-total { background: var(--wine-deep); box-shadow: inset 0 0 0 2px var(--gold); }
.verdict { margin: 0; font-size: 21px; font-weight: 600; }

/* ---------- Completion ---------- */
.final-score { margin: 0; font-family: var(--display); font-weight: 800; line-height: 1; font-size: 88px; color: var(--wine-deep); }
.final-score small { font-size: 32px; color: var(--bronze); }
.rank-title { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 800; letter-spacing: 0.06em; color: var(--wine-mid); }

.section-title {
  margin: 0; font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: 0.1em; color: var(--sand);
}
.breakdown { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.breakdown li {
  background: var(--wine); border-radius: 16px; padding: 14px 16px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
}
.bd-num {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--parchment); color: var(--wine-deep); border: 2px solid var(--wine-deep);
  box-shadow: inset 0 0 0 2px var(--bronze);
  font-family: var(--display); font-size: 18px; font-weight: 800;
}
.bd-q { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; }
.bd-meta { margin: 2px 0 0; font-size: 15px; color: var(--sand); }
.bd-meta strong { color: var(--gold); font-weight: 700; }
.bd-pts { text-align: right; font-size: 22px; font-weight: 700; white-space: nowrap; }
.bd-pts small { display: block; font-size: 13px; font-weight: 600; color: var(--sand); }

.share-feedback { margin: 0; min-height: 1.4em; text-align: center; font-size: 16px; font-weight: 600; color: var(--gold); }
.countdown { margin: 0; text-align: center; font-size: 18px; color: var(--sand); }
.countdown strong { font-family: var(--display); font-size: 26px; color: var(--cream); letter-spacing: 0.06em; display: block; }

/* ---------- Loading ---------- */
.spinner { width: 56px; height: 56px; animation: flip 2.4s ease-in-out infinite; }
@keyframes flip { 0%, 40% { transform: rotate(0); } 50%, 90% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .year-input.invalid { animation: none; }
  button:active { transform: none; }
}

/* ---------- Dialog ---------- */
dialog.modal {
  box-sizing: border-box;
  width: min(640px, calc(100vw - 24px)); max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 10px; margin: auto;
  background: var(--parchment); color: var(--wine-deep);
  border: 4px solid var(--wine-deep); border-radius: 20px; box-shadow: 0 8px 0 var(--wine-deep);
}
dialog.modal::backdrop { background: rgba(42,10,18,0.75); }
dialog.modal .card-inner { padding: 32px 28px; text-align: left; align-items: stretch; gap: 14px; min-width: 0; }
.modal-title { margin: 0; text-align: center; font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: 0.04em; }
.modal ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 18px; }
.modal-example { margin: 0; font-size: 16px; color: var(--wine-mid); }
.mult-list { display: flex; flex-direction: column; gap: 8px; }
.mult-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(185,139,78,0.16); border-radius: 12px; padding: 8px 12px;
}
.mult-row strong { display: block; font-size: 17px; }
.mult-row span:not(.mult-badge) { display: block; font-size: 15px; color: var(--wine-mid); }

/* ---------- Legal pages ---------- */
.legal .card-inner { text-align: left; align-items: stretch; gap: 0; padding: 40px 36px; }
.legal h1 { margin: 0 0 6px; font-family: var(--display); font-size: 36px; font-weight: 800; text-align: center; }
.legal .updated { margin: 0 0 24px; text-align: center; color: var(--bronze); font-size: 16px; font-weight: 600; }
.legal h2 { margin: 28px 0 8px; font-family: var(--display); font-size: 21px; font-weight: 800; letter-spacing: 0.03em; color: var(--wine-mid); }
.legal p, .legal li { font-size: 17px; line-height: 1.55; }
.legal p { margin: 0 0 12px; }
.legal ul { margin: 0 0 12px; padding-left: 22px; }
.legal a { color: var(--wine-mid); font-weight: 600; }
.legal a:hover { color: var(--gold-dark); }
.legal table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 15px; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid rgba(185,139,78,0.6); }
.legal th { font-family: var(--display); font-size: 13px; letter-spacing: 0.06em; color: var(--bronze); }
.legal code { font-size: 14px; background: rgba(185,139,78,0.18); padding: 1px 5px; border-radius: 4px; }
.table-wrap { overflow-x: auto; }
.placeholder { background: #FCE9A6; padding: 0 4px; border-radius: 4px; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1120px; width: 100%; margin: 0 auto; padding: 20px 24px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 24px; font-size: 16px;
}
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--sand); font: inherit; text-decoration: underline;
}
.link-btn:hover { color: var(--gold); }
.link-btn:active { transform: none; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50;
  max-width: 760px; margin: 0 auto;
  background: var(--wine-deep); color: var(--cream);
  border: 3px solid var(--gold); border-radius: 20px; box-shadow: 0 8px 0 rgba(0,0,0,0.35);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 12px;
}
.cookie-title { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 800; color: var(--gold); letter-spacing: 0.04em; }
.cookie-text { margin: 0; font-size: 16px; line-height: 1.45; }
.cookie-prefs { display: flex; flex-direction: column; gap: 10px; background: var(--wine); border-radius: 14px; padding: 14px; }
.cookie-pref { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; }
.cookie-pref input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--gold); flex: 0 0 auto; }
.cookie-pref strong { display: block; font-size: 16px; color: var(--cream); }
.cookie-pref span { color: var(--sand); }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.cookie-actions .btn { flex: 1 1 140px; }

/* ---------- Mobile (design: 390px board) ---------- */
@media (max-width: 640px) {
  :root { --gap: 18px; }
  body { font-size: 17px; }
  .site-header { padding: 14px 16px; gap: 10px; flex-wrap: nowrap; }
  .brand { gap: 10px; }
  .brand-badge { width: 42px; height: 42px; box-shadow: 0 3px 0 var(--wine-deep), inset 0 0 0 3px var(--gold-dark); }
  .brand-badge svg { width: 22px; height: 22px; }
  .brand-name { font-size: 20px; letter-spacing: 0.01em; }
  .brand-sub { font-size: 11px; letter-spacing: 0.18em; margin-top: 3px; }
  .nav .nav-link { display: none; }
  .nav-icon { display: flex; }
  main { padding: 8px 16px 32px; }
  .round-bar { gap: 10px; }
  .round-row { gap: 10px; flex-wrap: nowrap; }
  .round-label { font-size: 14px; letter-spacing: 0.08em; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .score-pill { gap: 6px; padding: 5px 14px 5px 8px; }
  .score-pill svg { width: 20px; height: 20px; }
  .score-pill .score-value { font-size: 20px; }
  .score-pill .score-unit { display: none; }
  .card { border-radius: 18px; box-shadow: 0 6px 0 var(--wine-deep); padding: 8px; }
  .card-inner { outline-offset: -6px; border-radius: 11px; padding: 24px 16px; gap: 12px; }
  .ornament { width: 96px; height: 12px; }
  .question-text { font-size: 27px; }
  .question-text.long { font-size: 23px; }
  .guess-form { gap: 14px; }
  .guess-row { flex-direction: column; gap: 14px; }
  .year-input { flex: 0 0 auto; width: 100%; height: 72px; padding: 0 16px; font-size: 32px; }
  .era-toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .era-toggle button { width: auto; height: 48px; font-size: 20px; }
  .btn { height: 68px; font-size: 26px; }
  .btn-md { height: 64px; font-size: 22px; }
  .result { border-radius: 22px; box-shadow: 0 6px 0 var(--wine-deep); padding: 20px 16px; gap: 16px; }
  .headline { font-size: 28px; }
  .mult-badge { min-width: 42px; height: 30px; font-size: 17px; border-width: 2px; }
  .result { padding: 20px 10px; }
  .tiles.five { gap: 5px; }
  .tiles.five .tile { padding: 8px 2px; border-radius: 12px; justify-content: space-between; }
  .tiles.five .tile-label { font-size: 11px; line-height: 1.2; }
  .tiles.five .tile-value { font-size: 18px; }
  .tiles.five .tile-value small { display: block; font-size: 12px; }
  .bd-num { width: 32px; height: 32px; font-size: 15px; }
  dialog.modal { padding: 6px; border-width: 3px; border-radius: 16px; box-shadow: 0 5px 0 var(--wine-deep); }
  dialog.modal .card-inner { padding: 20px 14px; gap: 10px; outline-offset: -5px; }
  .modal-title { font-size: 24px; }
  .modal ul { font-size: 15px; gap: 6px; padding-left: 18px; }
  .modal-example { font-size: 14px; }
  .mult-row { gap: 10px; padding: 6px 10px; }
  .mult-row strong { font-size: 15px; }
  .mult-row span:not(.mult-badge) { font-size: 13px; }
  .tiles { gap: 8px; }
  .tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { border-radius: 14px; padding: 10px 4px; }
  .tile-label { font-size: 13px; }
  .tile-value { font-size: 20px; }
  .verdict { font-size: 18px; }
  .final-score { font-size: 64px; }
  .final-score small { font-size: 24px; }
  .rank-title { font-size: 19px; }
  .breakdown li { gap: 10px; padding: 12px; }
  .bd-q { font-size: 16px; }
  .bd-meta { font-size: 14px; }
  .bd-pts { font-size: 18px; }
  .legal .card-inner { padding: 26px 18px; }
  .legal h1 { font-size: 27px; }
  .legal h2 { font-size: 18px; }
  .site-footer { padding: 16px; font-size: 15px; }
  .cookie-banner { left: 8px; right: 8px; bottom: 8px; padding: 16px; }
  .cookie-actions .btn { flex: 1 1 100%; }
}
