:root {
  --paper: #f6ead1;
  --paper-deep: #ead2a6;
  --paper-light: #fff8e8;
  --ink: #24160f;
  --ink-soft: #604b3a;
  --muted: #8b725c;
  --wine: #8c2f2b;
  --wine-dark: #5f1e1b;
  --gold: #d8aa46;
  --gold-soft: #efd28a;
  --forest: #385241;
  --shadow: 0 26px 70px rgba(47, 25, 14, .2);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: url('../images/фон.png') center/cover no-repeat fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .23;
  background-image:
    linear-gradient(90deg, rgba(87, 54, 24, .18) 1px, transparent 1px),
    linear-gradient(rgba(87, 54, 24, .16) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, #000, transparent 78%);
}

a { color: var(--wine); text-decoration-thickness: 1px; text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
button, input { font: inherit; }

.site-shell { position: relative; z-index: 1; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  width: min(1180px, calc(100% - 28px));
  margin: 14px auto 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(216, 170, 70, .45);
  border-radius: 999px;
  background: rgba(255, 248, 232, .82);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 45px rgba(47, 25, 14, .12);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  transition: opacity .2s ease;
}
.brand:hover { opacity: .85; }
.brand-mark {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: 'Playfair Display', serif;
  font-weight: 800;
  font-size: 1.65rem;
  color: #fff8e8;
  background: radial-gradient(circle at 32% 22%, #d4613f, var(--wine) 60%, var(--wine-dark));
  border: 2px solid var(--gold);
  box-shadow:
    0 0 0 4px rgba(216, 170, 70, .22),
    0 0 0 5px rgba(140, 47, 43, .12),
    0 8px 20px rgba(140, 47, 43, .35),
    inset 0 1px 0 rgba(255, 241, 197, .28);
  text-shadow: 0 1px 4px rgba(80, 20, 10, .4);
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.brand strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
}
.brand small {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.brand small::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--gold);
}
.main-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.main-nav a, .main-nav button.link {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  transition: .2s ease;
}
.main-nav a:hover, .main-nav button.link:hover { color: var(--wine); background: rgba(140, 47, 43, .08); }
.main-nav form { margin: 0; }
.nav-pill { background: var(--wine) !important; color: #fff8e8 !important; box-shadow: 0 10px 25px rgba(140,47,43,.22); }

.page { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 34px 0 74px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--wine);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .75rem;
  font-weight: 800;
}
.eyebrow::before { content: ""; width: 34px; height: 1px; background: var(--gold); }

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .92fr);
  align-items: center;
  gap: 30px;
  min-height: 520px;
  padding: clamp(26px, 5vw, 58px);
  border: 1px solid rgba(216,170,70,.48);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(110deg, rgba(255,248,232,.96), rgba(255,248,232,.72)),
    url('../images/ornament-map.svg') center/cover no-repeat;
  box-shadow: var(--shadow);
}
.hero::after, .frame::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(216, 170, 70, .34);
  border-radius: calc(var(--radius-lg) - 10px);
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 1; }
.hero h1, .section-heading h1, .section-heading h2, .auth-art h1, .side-panel h2 {
  font-family: 'Playfair Display', Georgia, serif;
  line-height: .96;
  letter-spacing: -.04em;
  margin: 14px 0 18px;
}
.hero h1 { max-width: 650px; font-size: clamp(3rem, 8vw, 6.6rem); }
.hero p { max-width: 620px; color: var(--ink-soft); font-size: clamp(1rem, 1.7vw, 1.2rem); line-height: 1.75; }
.hero-actions, .action-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 26px; }
.hero-art { position: relative; z-index: 1; }
.hero-art img { width: 100%; border-radius: 24px; box-shadow: 0 26px 60px rgba(52,28,18,.28); transform: rotate(1.2deg); }

.primary, button.primary, a.primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: 999px;
  color: #fff8e8;
  background: linear-gradient(135deg, var(--wine), var(--wine-dark));
  box-shadow: 0 14px 30px rgba(140, 47, 43, .25);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.primary:hover { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(140,47,43,.32); }
.primary.small { min-height: 40px; padding: 9px 16px; }
.primary.full { width: 100%; }
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 248, 232, .65);
  border: 1px solid rgba(216,170,70,.65);
  text-decoration: none;
  font-weight: 800;
}

.section-heading { text-align: center; margin: 56px auto 24px; max-width: 720px; }
.section-heading .eyebrow { justify-content: center; }
.section-heading .eyebrow::after { content: ""; width: 34px; height: 1px; background: var(--gold); }
.section-heading h1, .section-heading h2 { font-size: clamp(2.2rem, 5vw, 4.2rem); }
.section-heading p { color: var(--ink-soft); line-height: 1.65; }
.section-heading.compact { margin-top: 18px; }

.frame {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(216, 170, 70, .5);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(255,248,232,.97), rgba(246,234,209,.94)),
    url('../images/ornament-map.svg') center/cover no-repeat;
  box-shadow: var(--shadow);
}
.frame > * { position: relative; z-index: 1; }
.page-title {
  margin: 8px 0 8px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -.03em;
  text-align: center;
}
.page-subtitle { margin: 0 auto 28px; max-width: 620px; text-align: center; color: var(--ink-soft); line-height: 1.65; }

.auth-layout, .quiz-shell {
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: start;
}
.auth-art, .side-panel {
  overflow: hidden;
  min-height: 520px;
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(216,170,70,.42);
  background: rgba(80, 37, 25, .88);
  color: #fff8e8;
  box-shadow: var(--shadow);
}
.auth-art img, .side-panel img { width: 100%; border-radius: 22px; margin-bottom: 26px; }
.auth-art h1, .side-panel h2 { font-size: clamp(2.3rem, 5vw, 4.6rem); }
.auth-art p, .side-panel p { color: rgba(255,248,232,.82); line-height: 1.75; }
.auth-card { max-width: 520px; width: 100%; justify-self: end; }
.auth-card .page-title { text-align: left; }
.auth-card .page-subtitle { text-align: left; margin-left: 0; }

.alert {
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(140,47,43,.28);
  background: rgba(140,47,43,.1);
  color: var(--wine-dark);
}
.alert ul { margin: 0; padding-left: 18px; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 8px; color: var(--ink); font-weight: 800; }
.field input[type="text"], .field input[type="email"], .field input[type="password"] {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid rgba(139, 91, 38, .32);
  border-radius: 16px;
  background: rgba(255, 252, 242, .8);
  color: var(--ink);
  outline: none;
  transition: .2s ease;
}
.field input:focus { border-color: var(--wine); box-shadow: 0 0 0 4px rgba(140,47,43,.12); background: #fffaf0; }
.form-actions { margin-top: 24px; text-align: center; }
.form-footer { margin: 18px 0 0; text-align: center; color: var(--ink-soft); }

.quiz-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.quiz-card {
  overflow: hidden;
  border: 1px solid rgba(216,170,70,.48);
  border-radius: 26px;
  background: rgba(255,248,232,.9);
  box-shadow: 0 20px 46px rgba(47, 25, 14, .14);
  transition: transform .22s ease, box-shadow .22s ease;
}
.quiz-card:hover { transform: translateY(-6px); box-shadow: 0 28px 58px rgba(47,25,14,.2); }
.quiz-card-image { width: 100%; height: 178px; object-fit: cover; }
.quiz-card-body { padding: 22px; }
.era { margin-bottom: 8px; color: var(--wine); font-weight: 800; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.quiz-card h3 { margin: 0 0 10px; font-family: 'Playfair Display', serif; font-size: 1.55rem; line-height: 1.12; }
.quiz-card p { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.6; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meta { color: var(--muted); font-weight: 800; }

.quiz-shell { grid-template-columns: 340px minmax(0, 1fr); }
.side-panel { position: sticky; top: 104px; min-height: auto; }
.quiz-frame { overflow: visible; }
.question-block {
  margin: 0 0 22px;
  padding: 22px;
  border: 1px solid rgba(216, 170, 70, .42);
  border-radius: 22px;
  background: rgba(255, 252, 244, .72);
}
.question-number { margin-bottom: 8px; color: var(--wine); text-transform: uppercase; letter-spacing: .16em; font-size: .74rem; font-weight: 900; }
.question-text { margin-bottom: 14px; font-family: 'Playfair Display', serif; font-size: 1.28rem; line-height: 1.35; }
.option-label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 10px 0;
  padding: 14px 16px;
  border: 1px solid rgba(139,91,38,.25);
  border-radius: 16px;
  background: rgba(255, 248, 232, .72);
  color: var(--ink-soft);
  cursor: pointer;
  transition: .18s ease;
}
.option-label:hover { transform: translateX(3px); border-color: rgba(140,47,43,.55); color: var(--ink); background: rgba(255, 250, 239, .96); }
.option-label input { margin-top: 3px; accent-color: var(--wine); }
.sticky-actions { position: sticky; bottom: 12px; padding: 14px; border-radius: 999px; background: rgba(255,248,232,.82); backdrop-filter: blur(12px); box-shadow: 0 12px 30px rgba(47,25,14,.12); }

.result-layout { display: grid; place-items: center; min-height: 64vh; }
.result-layout-full { display: flex; flex-direction: column; align-items: center; gap: 40px; }
.result-card { max-width: 560px; width: 100%; text-align: center; }
.result-card .eyebrow { justify-content: center; }
.result-card .eyebrow::after { content: ""; width: 34px; height: 1px; background: var(--gold); }

.result-breakdown { width: 100%; max-width: 760px; }
.rq-block { margin-bottom: 16px; }
.rq-block.rq-correct { border-color: rgba(56, 130, 65, .45); background: rgba(240, 255, 242, .92); }
.rq-block.rq-wrong   { border-color: rgba(180, 50, 40, .38); background: rgba(255, 243, 242, .92); }
.rq-options { display: flex; flex-direction: column; gap: 8px; }
.rq-opt { cursor: default; gap: 10px; }
.rq-opt:hover { transform: none; }
.rq-opt-icon { flex-shrink: 0; width: 22px; font-weight: 900; font-size: 1rem; text-align: center; }
.rq-opt-correct {
  background: rgba(220, 255, 224, .95) !important;
  border-color: rgba(56, 130, 65, .6) !important;
  color: #1a5c24 !important;
  font-weight: 700;
}
.rq-opt-wrong {
  background: rgba(255, 224, 222, .95) !important;
  border-color: rgba(180, 50, 40, .6) !important;
  color: #7a1f1a !important;
  font-weight: 700;
}
.rq-opt-missed {
  background: rgba(220, 255, 224, .6) !important;
  border-color: rgba(56, 130, 65, .4) !important;
  color: #2a6b34 !important;
}
.seal {
  width: 150px;
  height: 150px;
  margin: 8px auto 24px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff8e8;
  background: radial-gradient(circle at 35% 25%, #ce6a45, var(--wine) 62%, var(--wine-dark));
  border: 5px solid var(--gold);
  box-shadow: 0 18px 45px rgba(140,47,43,.35), inset 0 0 0 8px rgba(255,248,232,.08);
}
.seal .score { font-family: 'Playfair Display', serif; font-size: 3.4rem; font-weight: 800; line-height: .9; }
.seal .total { margin-top: 6px; color: rgba(255,248,232,.8); font-weight: 800; }
.verdict { margin: 0 0 8px; font-family: 'Playfair Display', serif; font-size: 1.65rem; font-weight: 800; }
.verdict-text { margin: 0 auto 20px; max-width: 430px; color: var(--ink-soft); line-height: 1.7; }
.result-card .action-row { justify-content: center; }

.table-wrap { overflow-x: auto; }
table.history { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
table.history th { padding: 0 16px 8px; color: var(--wine); text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; }
table.history td { padding: 16px; background: rgba(255,252,244,.78); border-top: 1px solid rgba(216,170,70,.34); border-bottom: 1px solid rgba(216,170,70,.34); color: var(--ink-soft); }
table.history td:first-child { border-left: 1px solid rgba(216,170,70,.34); border-radius: 16px 0 0 16px; color: var(--ink); font-weight: 800; }
table.history td:last-child { border-right: 1px solid rgba(216,170,70,.34); border-radius: 0 16px 16px 0; }
.empty-state { display: grid; justify-items: center; gap: 16px; text-align: center; color: var(--ink-soft); }
.empty-state img { max-width: 360px; border-radius: 24px; }

.profile-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.profile-card {
  text-align: center;
  position: sticky;
  top: 104px;
}
.profile-avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: 'Playfair Display', serif;
  font-weight: 800;
  font-size: 2.4rem;
  color: #fff8e8;
  background: radial-gradient(circle at 32% 22%, #c85a3c, var(--wine) 68%, var(--wine-dark));
  border: 3px solid var(--gold);
  box-shadow: 0 10px 28px rgba(140,47,43,.28), inset 0 0 0 3px rgba(255,241,197,.14);
}
.profile-name {
  margin: 0 0 6px;
  font-family: 'Playfair Display', serif;
  font-size: 1.9rem;
  line-height: 1.1;
  letter-spacing: -.03em;
}
.profile-email {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .9rem;
}
.profile-since {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: .82rem;
}
.profile-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.pstat {
  padding: 12px 16px;
  border: 1px solid rgba(216,170,70,.42);
  border-radius: 16px;
  background: rgba(255,252,244,.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pstat-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--wine);
  line-height: 1;
  white-space: nowrap;
}
.pstat-label {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  text-align: right;
}
.profile-recent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .hero, .auth-layout, .quiz-shell { grid-template-columns: 1fr; }
  .side-panel { position: static; }
  .auth-card { max-width: none; justify-self: stretch; }
  .quiz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-layout { grid-template-columns: 1fr; }
  .profile-card { position: static; }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; border-radius: 26px; flex-direction: column; }
  .main-nav { justify-content: flex-start; }
  .page { width: min(100% - 18px, 1180px); padding-top: 20px; }
  .hero { min-height: auto; padding: 24px; }
  .hero h1 { font-size: 3rem; }
  .quiz-grid { grid-template-columns: 1fr; }
  .auth-art, .side-panel { min-height: auto; }
  .card-bottom { align-items: stretch; flex-direction: column; }
  .primary.small { width: 100%; }
  table.history { min-width: 680px; }
}
