/* ===== Shared theme: candlelit study ===== */
@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap");

:root {
  --ink: #0d0b12;
  --panel-top: #2a2332;
  --panel-bot: #1d1825;
  --gold: #d9b45a;
  --gold-bright: #f3d98f;
  --gold-dim: #8f7a45;
  --parchment: #efe3c4;
  --parchment-dim: #b7ab8e;
  --display: "Cinzel", "Trajan Pro", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --body: "EB Garamond", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--parchment);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.45;
  background:
    radial-gradient(ellipse 80% 45% at 50% -8%, rgba(217, 180, 90, .20), transparent 62%),
    radial-gradient(ellipse 55% 40% at 95% 100%, rgba(120, 60, 140, .14), transparent 60%),
    radial-gradient(ellipse 55% 40% at 0% 75%, rgba(40, 90, 120, .12), transparent 60%),
    var(--ink);
  background-attachment: fixed;
}

/* paper grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .22;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 18px 40px;
}

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

/* ----- top bar ----- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.backlink {
  font-family: var(--display);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--parchment-dim);
}
.backlink:hover { color: var(--gold-bright); }
.actions { display: flex; gap: 8px; }

/* ----- headings & ornaments ----- */
.kicker {
  font-family: var(--display);
  font-size: .72rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-align: center;
}

.title {
  margin: 6px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3.2rem);
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1.1;
  background: linear-gradient(180deg, #fbeab0 0%, var(--gold) 52%, #8d6d27 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 14px rgba(217, 180, 90, .28));
}

.rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px auto 14px;
  max-width: 420px;
  color: var(--gold-dim);
}
.rule::before,
.rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim));
}
.rule::after { transform: scaleX(-1); }

/* ----- buttons ----- */
.btn {
  display: inline-block;
  font-family: var(--display);
  font-size: .74rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--parchment);
  background: linear-gradient(180deg, #382e43, #241d2c);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 2px 0 rgba(0, 0, 0, .5);
  transition: border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn:hover:not(:disabled) {
  color: var(--gold-bright);
  border-color: var(--gold);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 2px 0 rgba(0, 0, 0, .5), 0 0 16px rgba(217, 180, 90, .25);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  color: #1c1404;
  font-weight: 700;
  background: linear-gradient(180deg, #e2bf67, #98741f);
  border-color: #f0d487;
}
.btn.primary:hover:not(:disabled) { color: #120c01; }

/* ----- panels ----- */
.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(42, 35, 50, .94), rgba(29, 24, 37, .94));
  border: 1px solid rgba(217, 180, 90, .38);
  border-radius: 6px;
  padding: 20px;
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, .28),
    inset 0 0 0 4px rgba(217, 180, 90, .12),
    0 16px 40px rgba(0, 0, 0, .55);
}

/* ----- dialogs ----- */
dialog {
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bot));
  color: var(--parchment);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  max-width: 560px;
  width: calc(100% - 32px);
  padding: 22px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .75);
}
dialog::backdrop { background: rgba(5, 3, 10, .74); }
dialog h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  letter-spacing: .08em;
  color: var(--gold-bright);
}
dialog p, dialog li { font-size: .98rem; }
dialog ul { padding-left: 18px; }
dialog li { margin-bottom: 6px; }
dialog form { margin: 14px 0 0; text-align: right; }

.sw {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 6px;
  border: 1px solid rgba(255, 255, 255, .25);
}
.sw.correct { background: #2f7a52; }
.sw.partial { background: #9a6a16; }
.sw.wrong { background: #3d3745; }
.sw.higher { background: #44559b; }

.statsGrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
  margin: 14px 0;
}
.statsGrid b {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  color: var(--gold-bright);
}
.statsGrid span {
  color: var(--parchment-dim);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ----- toast ----- */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--parchment);
  color: #1a140a;
  font-family: var(--display);
  font-size: .8rem;
  letter-spacing: .06em;
  padding: 10px 18px;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* ----- footer ----- */
footer {
  margin-top: 36px;
  text-align: center;
  color: var(--parchment-dim);
  font-size: .78rem;
  line-height: 1.55;
  opacity: .85;
}

@media (max-width: 460px) {
  body { font-size: 17px; }
  .wrap { padding: 12px 12px 32px; }
}

.support { margin-top: 6px; }