:root {
  --legal-ink: #282113;
  --legal-muted: #6d6658;
  --legal-gold: #947500;
  --legal-gold-bright: #d7ad22;
  --legal-paper: #fffaf0;
  --legal-paper-deep: #f1e7c7;
  --legal-border: #827b69;
  --legal-green: #3f7d45;
  --legal-red: #b72b25;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #374e2f; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--legal-ink);
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.06), transparent 28rem),
    linear-gradient(145deg, #49653b, #263d2d);
  font-family: "Work Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legal-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(16px, 4vw, 56px);
  border-bottom: 4px solid var(--legal-gold-bright);
  background: linear-gradient(#fffdf4, #eee5c9);
  box-shadow: 0 4px 20px rgba(0,0,0,.24);
}

.legal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #6f5700;
  text-decoration: none;
}
.legal-brand strong {
  display: block;
  font: 700 clamp(24px, 3vw, 34px)/1 Georgia, serif;
}
.legal-brand small {
  display: block;
  margin-top: 5px;
  color: var(--legal-muted);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.legal-crest {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 2px solid var(--legal-border);
  border-radius: 12px;
  background: #fff9e5;
  box-shadow: inset 0 0 0 4px rgba(148,117,0,.11);
  font-size: 32px;
}

.legal-top-actions { display: flex; align-items: end; gap: 10px; }
.legal-top-actions label { display: grid; gap: 3px; color: var(--legal-muted); font-size: 12px; }
.legal-top-actions select,
.legal-back,
.legal-footer button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid #b19d64;
  border-radius: 10px;
  color: var(--legal-ink);
  background: #fff9e9;
  font: 700 14px/1 system-ui, sans-serif;
}
.legal-back { display: inline-flex; align-items: center; text-decoration: none; }

.legal-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}
.legal-nav,
.legal-document {
  border: 3px solid var(--legal-border);
  border-radius: 16px;
  background:
    radial-gradient(circle at 8px 8px, rgba(148,117,0,.04) 1px, transparent 1.5px) 0 0/18px 18px,
    var(--legal-paper);
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
}
.legal-nav {
  position: sticky;
  top: 110px;
  display: grid;
  gap: 8px;
  padding: 12px;
}
.legal-nav a {
  padding: 13px 14px;
  border-radius: 9px;
  color: #504a3f;
  text-decoration: none;
  font-weight: 700;
}
.legal-nav a:hover { background: #f3e8c3; }
.legal-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, #a98908, #6f5900);
  box-shadow: inset 0 -3px rgba(0,0,0,.18);
}

.legal-document { overflow: hidden; }
.legal-hero {
  padding: clamp(24px, 5vw, 52px);
  border-bottom: 4px solid var(--legal-gold-bright);
  background: linear-gradient(120deg, #fffdf5, #ecdfb8);
}
.legal-eyebrow {
  margin: 0 0 9px;
  color: var(--legal-gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.legal-hero h1 {
  margin: 0;
  font: 700 clamp(34px, 6vw, 58px)/1.05 Georgia, serif;
  color: #312814;
}
.legal-lead { max-width: 780px; margin: 18px 0 0; color: #554c3d; font-size: 18px; line-height: 1.55; }
.legal-meta { margin: 16px 0 0; color: var(--legal-muted); font-size: 13px; }

.legal-sections { padding: clamp(22px, 5vw, 52px); }
.legal-section { scroll-margin-top: 110px; padding: 0 0 30px; }
.legal-section + .legal-section { padding-top: 28px; border-top: 1px solid #d9cda9; }
.legal-section h2 { margin: 0 0 13px; color: #6f5700; font: 700 28px/1.2 Georgia, serif; }
.legal-section h3 { margin: 22px 0 8px; font: 700 20px/1.3 Georgia, serif; }
.legal-section p,
.legal-section li { line-height: 1.65; }
.legal-section ul { padding-left: 22px; }
.legal-section a { color: #6f5700; font-weight: 700; }
.legal-note {
  margin: 18px 0;
  padding: 15px 17px;
  border-left: 5px solid var(--legal-green);
  border-radius: 7px;
  background: #e9f3d5;
}
.legal-warning { border-left-color: var(--legal-red); background: #fbe3dd; }
.legal-table-wrap { overflow-x: auto; margin: 16px 0; }
.legal-table { width: 100%; min-width: 680px; border-collapse: collapse; }
.legal-table th,
.legal-table td { padding: 12px; border: 1px solid #d4c8a6; text-align: left; vertical-align: top; }
.legal-table th { background: var(--legal-paper-deep); }

.legal-footer {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #f7f1dc;
}
.legal-footer button { cursor: pointer; }

/* Shared consent UI, used on the game and legal pages. */
.privacy-consent {
  position: fixed;
  z-index: 100000;
  right: 20px;
  bottom: 20px;
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  padding: 22px;
  border: 3px solid #776f5e;
  border-radius: 16px;
  color: var(--legal-ink);
  background: linear-gradient(145deg, #fffdf5, #eee3bf);
  box-shadow: 0 18px 55px rgba(0,0,0,.4);
}
.privacy-consent[hidden] { display: none !important; }
.privacy-consent h2 { margin: 0 42px 10px 0; font: 700 27px/1.15 Georgia, serif; color: #604b00; }
.privacy-consent p { margin: 8px 0; line-height: 1.5; }
.privacy-consent a { color: #6f5700; font-weight: 700; }
.privacy-consent-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.privacy-consent button {
  min-height: 44px;
  padding: 10px 15px;
  border: 2px solid #715f28;
  border-radius: 9px;
  cursor: pointer;
  background: #fff9e7;
  color: var(--legal-ink);
  font: 700 14px/1.1 system-ui, sans-serif;
}
.privacy-consent button.primary { color: white; background: linear-gradient(#a48508, #705900); }
.privacy-consent-close { position: absolute; top: 12px; right: 12px; width: 38px; padding: 0 !important; font-size: 24px !important; }
.privacy-consent-options { display: grid; gap: 9px; margin-top: 15px; }
.privacy-consent-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid #c9bb91;
  border-radius: 9px;
  background: rgba(255,255,255,.42);
}
.privacy-consent-option strong { display: block; }
.privacy-consent-option small { grid-column: 1 / -1; color: var(--legal-muted); line-height: 1.4; }
.privacy-consent-option input { width: 20px; height: 20px; accent-color: #7b6500; }
.privacy-consent-status { color: var(--legal-green); font-weight: 700; }
.auth-legal {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(65,52,23,.18);
  color: #665d4e;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}
.auth-legal a,
.registration-consent a { color: #6f5700; font-weight: 700; }
.registration-consent {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 9px;
  margin: 10px 0 13px;
  color: #4e4639;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}
.registration-consent input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: #7b6500; }
.settings-legal-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.settings-legal-links a,
.settings-legal-links button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 2px solid var(--wood, #76552d);
  border-radius: 7px;
  color: var(--ink, #332714);
  background: #fffaf0;
  font: 700 13px/1 system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

@media (max-width: 760px) {
  .legal-topbar { position: relative; align-items: flex-start; padding: 12px 14px; }
  .legal-brand small,
  #legal-language-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .legal-top-actions { align-items: center; }
  .legal-back { width: 42px; overflow: hidden; padding: 9px 12px; }
  .legal-back::before { content: "←"; font-size: 20px; }
  .legal-shell { width: calc(100% - 18px); margin: 10px auto 18px; display: block; }
  .legal-nav {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 10px;
    padding: 6px;
  }
  .legal-nav a { display: grid; place-items: center; min-height: 54px; padding: 7px; font-size: 11px; text-align: center; }
  .legal-sections,
  .legal-hero { padding: 22px 18px; }
  .legal-lead { font-size: 16px; }
  .legal-footer { width: calc(100% - 24px); }
  .privacy-consent { inset: auto 8px 8px; width: auto; max-height: calc(100dvh - 16px); padding: 18px; }
  .privacy-consent-actions { display: grid; grid-template-columns: 1fr; }
  .privacy-consent-actions button { width: 100%; }
}
