:root {
  --paper: #f1ede4;
  --paper-deep: #e8e1d3;
  --ink: #172322;
  --muted: #68716e;
  --line: rgba(23, 35, 34, .16);
  --red: #d54f3f;
  --red-dark: #ad382d;
  --blue: #3c7381;
  --blue-dark: #254f59;
  --white: #fffdf8;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.paper-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 20; opacity: .23;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.site-header {
  height: 88px; padding: 0 clamp(22px, 5vw, 78px); display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--line); position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: var(--white);
  background: var(--red); font: 700 27px/1 Georgia, "Times New Roman", serif; transform: rotate(-7deg); box-shadow: 4px 4px 0 var(--ink);
}
.brand b { display: block; font: 700 20px/1 Georgia, "Times New Roman", serif; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.header-actions { display: flex; gap: 8px; }
.button { border: 0; border-radius: 4px; padding: 12px 17px; font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-dark { color: var(--white); background: var(--ink); box-shadow: 0 4px 0 rgba(23,35,34,.16); }
.button-red { color: var(--white); background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.button-ghost { color: var(--ink); background: transparent; border: 1px solid var(--line); }

main { padding: 0 clamp(18px, 4vw, 64px) 38px; }
.hero { max-width: 1180px; margin: 0 auto; padding: 48px 0 34px; position: relative; }
.hero::after { content: '✦'; position: absolute; right: 2%; top: 48%; color: var(--red); font-size: 46px; transform: rotate(14deg); }
.eyebrow, .panel-kicker { color: var(--red); font-size: 11px; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }
.eyebrow { display: flex; gap: 9px; align-items: center; }
.eyebrow span { width: 28px; height: 2px; background: var(--red); }
.hero h1 { margin: 15px 0 12px; font: 700 clamp(44px, 6vw, 78px)/.95 Georgia, "Times New Roman", serif; letter-spacing: -.04em; }
.hero h1 em { color: var(--blue); font-weight: 700; }
.hero > p { max-width: 560px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.65; }

.atlas-shell {
  max-width: 1280px; min-height: 650px; margin: 0 auto; display: grid; grid-template-columns: 350px 1fr;
  border: 1px solid var(--line); background: rgba(255,253,248,.56); box-shadow: 0 24px 65px rgba(42,42,31,.09);
}
.atlas-panel { padding: 34px 30px; border-right: 1px solid var(--line); background: rgba(255,253,248,.66); overflow: auto; }
.atlas-panel h2 { font: 700 31px/1.05 Georgia, "Times New Roman", serif; margin: 10px 0 14px; }
.muted, .map-hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.tab-list { display: flex; gap: 18px; margin: 28px 0 20px; border-bottom: 1px solid var(--line); }
.tab { padding: 0 0 10px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.tab.active { color: var(--ink); box-shadow: 0 2px 0 var(--red); }
.auth-form { display: grid; gap: 15px; }
.auth-form label, .search-label { display: grid; gap: 7px; color: var(--ink); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
input {
  width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 13px 12px; outline: none;
  color: var(--ink); background: var(--white); transition: .18s ease;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(60,115,129,.12); }
.form-error { min-height: 22px; color: var(--red-dark); font-size: 12px; }
.stats { display: flex; align-items: center; gap: 14px; margin: 26px 0 12px; }
.stats strong { color: var(--red); font: 700 60px/.8 Georgia, "Times New Roman", serif; }
.stats span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.progress-track { height: 5px; background: var(--paper-deep); overflow: hidden; margin-bottom: 28px; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--red); transition: width .5s ease; }
.search-box { position: relative; margin-top: 8px; }
.search-box span { position: absolute; right: 13px; top: 8px; color: var(--blue); font-size: 24px; }
.search-results { display: grid; gap: 2px; margin-top: 5px; }
.search-result { padding: 9px 10px; text-align: left; border: 0; background: var(--paper); border-radius: 2px; font-size: 12px; }
.search-result:hover { background: var(--paper-deep); }
.visited-heading { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.visited-heading b { background: var(--blue); color: white; min-width: 24px; padding: 4px 7px; border-radius: 20px; text-align: center; }
.visited-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; max-height: 150px; overflow: auto; }
.visited-chip { border: 1px solid rgba(60,115,129,.22); background: rgba(60,115,129,.08); color: var(--blue-dark); padding: 6px 8px; border-radius: 2px; font-size: 11px; }

.map-stage { min-width: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.map-toolbar { min-height: 55px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #5b9b69; margin-right: 6px; box-shadow: 0 0 0 4px rgba(91,155,105,.12); }
.zoom-controls { display: flex; }
.zoom-controls button { width: 34px; height: 32px; border: 1px solid var(--line); border-right: 0; background: var(--white); color: var(--ink); }
.zoom-controls button:last-child { border-right: 1px solid var(--line); }
#map { position: relative; flex: 1; min-height: 535px; overflow: hidden; background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.8), rgba(225,232,227,.43)); }
#map::before { content: ''; position: absolute; inset: 0; opacity: .25; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 44px 44px; }
#map svg { position: relative; width: 100%; height: 100%; display: block; }
.region { fill: #d7d6ca; stroke: var(--white); stroke-width: .65; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .18s ease, filter .18s ease; }
.region:hover, .region.focused { fill: #bdc8c3; filter: drop-shadow(0 2px 2px rgba(23,35,34,.2)); }
.region.visited { fill: var(--red); }
.region.visited:hover, .region.visited.focused { fill: var(--red-dark); }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.map-legend { display: flex; gap: 20px; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.map-legend span { display: flex; gap: 7px; align-items: center; }
.map-legend i { width: 13px; height: 13px; display: inline-block; }
.legend-visited { background: var(--red); }
.legend-next { background: #d7d6ca; }
.map-tooltip { position: fixed; z-index: 30; pointer-events: none; max-width: 220px; padding: 9px 11px; color: var(--white); background: var(--ink); border-radius: 3px; font-size: 11px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

footer { display: flex; justify-content: space-between; gap: 20px; max-width: 1280px; margin: 0 auto; padding: 8px clamp(18px,4vw,64px) 38px; color: var(--muted); font-size: 10px; }
.data-note { max-width: 540px; text-align: right; }

dialog { width: min(92vw, 470px); border: 0; border-radius: 5px; padding: 34px; color: var(--ink); background: var(--white); box-shadow: 0 30px 100px rgba(19,32,31,.3); }
dialog::backdrop { background: rgba(23,35,34,.7); backdrop-filter: blur(3px); }
dialog h2 { margin: 8px 0; font: 700 31px/1.1 Georgia, "Times New Roman", serif; }
dialog p { color: var(--muted); line-height: 1.55; }
.dialog-close { position: absolute; right: 13px; top: 10px; border: 0; background: transparent; font-size: 25px; color: var(--muted); }
.dialog-icon { color: var(--red); font-size: 30px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 25px; }
.secret-dialog { text-align: center; }
.secret-dialog .button { width: 100%; margin-top: 10px; }
.secret-words { margin: 24px 0 12px; padding: 18px; background: var(--paper); border: 1px dashed var(--blue); color: var(--blue-dark); font: 700 22px/1.5 Georgia, "Times New Roman", serif; }
.share-dialog { width: min(94vw, 620px); }
.share-dialog > p { margin-bottom: 18px; }
.share-preview-wrap {
  position: relative; display: grid; min-height: 280px; place-items: center; overflow: hidden;
  border: 1px solid var(--line); background: var(--paper); box-shadow: inset 0 0 0 7px rgba(255,255,255,.35);
}
.share-preview { display: block; width: 100%; max-height: 55vh; object-fit: contain; }
.share-loading { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.share-actions .button:last-child { grid-column: 1 / -1; }
.share-actions .button:disabled { opacity: .45; cursor: wait; transform: none; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px); padding: 11px 16px; color: white; background: var(--ink); border-radius: 3px; opacity: 0; pointer-events: none; transition: .25s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .site-header { height: 74px; }
  .brand small { display: none; }
  .hero { padding: 34px 0 28px; }
  .hero::after { display: none; }
  .atlas-shell { grid-template-columns: 1fr; }
  .atlas-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  #map { min-height: 480px; }
  footer { flex-direction: column; }
  .data-note { text-align: left; }
}

@media (max-width: 520px) {
  .site-header { padding: 0 16px; }
  .brand-mark { width: 39px; height: 39px; }
  .header-actions .button { padding: 10px 11px; font-size: 11px; }
  main { padding-inline: 10px; }
  .hero { padding-inline: 8px; }
  .hero h1 { font-size: 46px; }
  .atlas-panel { padding: 27px 20px; }
  #map { min-height: 390px; }
  .map-toolbar { padding-inline: 11px; }
  .map-legend { flex-wrap: wrap; }
  dialog { padding: 27px 20px; }
  .share-actions { grid-template-columns: 1fr; }
  .share-actions .button:last-child { grid-column: auto; }
}
