:root {
  color-scheme: dark;
  --bg: #101c19;
  --ink: #f3ead4;
  --muted: #b6b9a2;
  --gold: #efc676;
  --edge: #364741;
  --fg: var(--ink);
  --card: var(--panel);
  --line: var(--edge);
  --code: #101b16;
  --accent: var(--gold);
  --warn: #ff9a8f;
  --sim-bg: #353221;
  --panel: #172722;
  --display: "Instrument Serif", Georgia, serif;
  --copy: "DM Sans", system-ui, sans-serif;
  --type: "DM Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; max-width: none; padding: 0; background: var(--bg); color: var(--ink); font: 1rem/1.55 var(--copy); }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--gold); }
button, .button { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.shell { width: min(1120px, calc(100% - 3.5rem)); margin: 0 auto; }
main.shell, footer.shell { max-width: 1120px; }
main.shell { padding: 0; }
.masthead { padding: 0; border-bottom: 1px solid var(--edge); }
.masthead-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark { font: 2rem/1 var(--display); white-space: nowrap; }
.star { color: var(--gold); font-size: .73em; vertical-align: .12em; }
.site-nav, .site-footer nav { display: flex; align-items: center; flex-wrap: wrap; gap: clamp(.85rem, 3vw, 2rem); color: var(--muted); font-size: .92rem; }
.connect { background: var(--panel); border: 1px solid #536353; border-radius: 6px; color: var(--ink); padding: .5rem .85rem; }
.connect:hover { color: var(--gold); border-color: var(--gold); }

.hero { position: relative; isolation: isolate; overflow: hidden; min-height: 452px; margin: 1.65rem 0 0; display: grid; align-items: center; background: #101f1c url("./outpost.webp") center 55% / cover; border: 1px solid var(--edge); border-radius: 15px; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, #0d1b19fa, #0d1b19d9 24%, #0d1b1970 52%, transparent 76%); }
.hero-copy { position: relative; padding: clamp(2rem, 5vw, 4.5rem); animation: arrive 680ms ease-out both; }
.eyebrow { color: var(--gold); font: 500 .78rem/1.4 var(--type); letter-spacing: .14em; margin: 0 0 .6rem; }
.eyebrow span { margin-right: .38rem; }
.hero h1 { margin: .05em 0; font: 400 clamp(6.7rem, 13vw, 10.2rem)/.87 var(--display); letter-spacing: -.05em; }
.hero h1 span { color: var(--gold); }
.tagline { margin: .5rem 0; font: 400 clamp(1.7rem, 3.7vw, 2.8rem)/1.12 var(--display); }
.intro { color: #dddcc3; margin: .75rem 0 1.65rem; }
.button { display: inline-flex; gap: .85rem; align-items: center; justify-content: center; min-height: 44px; padding: .55rem .95rem; border: 1px solid transparent; border-radius: 6px; font-weight: 700; }
.gold { background: var(--gold); color: #17241a; }
.gold:hover { color: #17241a; background: #fbdb98; }
.snow { pointer-events: none; position: absolute; inset: -65px 0 0; z-index: -1; opacity: .8; background-image: radial-gradient(circle at 20px 11px, #f8ebd9aa 0 1px, transparent 2px), radial-gradient(circle at 44px 55px, #e6effc77 0 1px, transparent 2px); background-size: 137px 131px, 171px 181px; mask-image: linear-gradient(90deg, transparent, black 62%); animation: snowfall 24s linear infinite; }
@keyframes snowfall { from { background-position: 0 0, 0 0; } to { background-position: 137px 262px, 171px 181px; } }
@keyframes arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.calendar-section, .leaderboard { scroll-margin-top: 1.5rem; }
.calendar-section { margin: 3.4rem 0 4rem; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 1.25rem; margin-bottom: 1.25rem; }
h2 { font: 400 clamp(2.4rem, 5vw, 4.1rem)/1.05 var(--display); margin: 0; color: var(--ink); }
.section-head p:not(.eyebrow), .leaderboard p:not(.eyebrow) { color: var(--muted); margin: .45rem 0 0; }
.counters { display: flex; min-width: max-content; }
.counters div { padding: 0 1.1rem; border-left: 1px solid var(--edge); display: grid; }
.counters div:last-child { padding-right: 0; }
.counters strong { font: 400 2.2rem/1 var(--display); }
.counters span { color: var(--muted); font-size: .8rem; }
.chain-status { margin: .25rem 0 1rem; color: var(--gold); }
.chain-status:empty { display: none; }

.door-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .7rem; }
.door { position: relative; isolation: isolate; display: flex; flex-direction: column; min-width: 0; min-height: 130px; gap: .15rem; align-items: flex-start; justify-content: end; padding: .8rem .9rem; text-align: left; background: #17251f; color: var(--ink); border: 1px solid var(--edge); border-radius: 8px; overflow: hidden; }
.door::after { content: ""; position: absolute; z-index: -1; inset: 5px; border: 1px solid #72857536; border-radius: 5px; pointer-events: none; }
.door .ornament { position: absolute; top: .7rem; right: .83rem; color: #a4af93; font-size: .96rem; }
.door .number { font: 400 3.3rem/.91 var(--display); }
.door .door-stat { color: var(--muted); font-size: .8rem; }
.door.locked { background: radial-gradient(ellipse at 74% 21%, #25352a, transparent 68%), #17241f; color: #c3c4ac; cursor: default; opacity: 1; }
.door.locked:nth-child(3n) { background: radial-gradient(ellipse at 82% 10%, #243538, transparent 73%), #162422; }
.door.locked:nth-child(5n) { background: radial-gradient(ellipse at 82% 10%, #33392e, transparent 73%), #192722; }
.door.open { cursor: pointer; border-color: #9c8151; background: radial-gradient(ellipse at top right, #5b4926, transparent 74%), #292e21; transition: transform 230ms ease, border-color 230ms ease, box-shadow 230ms ease; }
.door.open::after { border-color: #c4a87355; }
.door.open:hover { color: var(--ink); transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 9px 22px #080f0bc9; }
.door.open .ornament, .door.current .ornament { color: var(--gold); }
.door.current { border-color: var(--gold); }
.door.solved { border-color: #81a98a; }
.door.pending { opacity: 1; animation: none; }
.door.pending .ornament { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.lock-icon { width: .62rem; height: .53rem; border: 1px solid currentColor; border-radius: 2px; margin-top: .33rem; }
.lock-icon::before { content: ""; display: block; position: absolute; width: .38rem; height: .4rem; left: .06rem; bottom: .4rem; border: 1px solid currentColor; border-bottom: 0; border-radius: .4rem .4rem 0 0; }

.leaderboard { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.9rem; padding: clamp(1.4rem, 4vw, 2.75rem); margin: 0 0 3rem; background: #172620; border: 1px solid var(--edge); border-radius: 10px; }
.leader-rows { align-self: center; min-width: 0; }
.leader-row { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .55rem; padding: .45rem 0; border-bottom: 1px solid var(--edge); align-items: center; }
.leader-row strong { color: var(--gold); }
.leader-row code { background: transparent; padding: 0; overflow-wrap: anywhere; color: var(--ink); }
.leader-score { text-align: right; white-space: nowrap; }
.leader-score small { display: block; color: var(--muted); font-size: .73rem; }
#leader-status:empty { display: none; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1.2rem; border-top: 1px solid var(--edge); padding: 1.3rem 0 2rem; }
#network, .riddle-counts { font: 400 .8rem/1.5 var(--type); color: var(--gold); }

dialog { border: 1px solid #61715c; border-radius: 11px; color: var(--ink); background: #182920; }
dialog::backdrop { background: #090f0cce; backdrop-filter: blur(4px); }
.door-dialog { width: min(610px, calc(100% - 2rem)); max-height: min(90vh, 880px); padding: 0; }
.door-dialog[open] { animation: arrive 220ms ease-out both; }
.dialog-body { position: relative; padding: clamp(1.25rem, 5vw, 2.4rem); }
.close { position: absolute; top: .7rem; right: .7rem; border: 0; background: transparent; color: var(--muted); font-size: 1.6rem; }
#riddle-clue { margin-block: 1em; white-space: pre-wrap; overflow-wrap: anywhere; }
#riddle-clue pre { margin: .55rem 0; padding: .8rem 1rem; border: 1px solid var(--edge); border-radius: 6px; background: var(--code); overflow-x: auto; overflow-wrap: normal; white-space: pre; }
#riddle-clue pre:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
#guess-form { display: grid; justify-items: start; gap: .45rem; margin: 1.4rem 0; }
#guess-form[hidden] { display: none; }
#guess-form label { font-weight: 600; }
#guess { width: 100%; padding: .7rem; background: #101b16; border: 1px solid #61715b; color: var(--ink); border-radius: 6px; }
.form-help { color: var(--muted); font-size: .9rem; margin: 0 0 .35rem; }
#guess-status { color: var(--gold); overflow-wrap: anywhere; }
#guess-status:empty { display: none; }
#public-activity { border-top: 1px solid var(--edge); margin: 1.4rem 0 .7rem; padding-top: .75rem; }
#public-activity summary { cursor: pointer; }
#seal-list { padding-left: 0; list-style: none; overflow-wrap: anywhere; }
#riddle-clue a, #seal-list a, #door-realm, #guess-faucet { text-decoration: underline; text-underline-offset: .18rem; }
#door-realm { font-size: .9rem; color: var(--muted); }
.modal { z-index: 3; }
.modal .row { flex-wrap: wrap; }

@media (max-width: 780px) {
  .door-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero { min-height: 400px; background-position: 57% 47%; }
  .leaderboard { grid-template-columns: 1fr; gap: .8rem; }
}
@media (max-width: 500px) {
  .shell { width: calc(100% - 1.5rem); }
  .masthead-inner { min-height: 62px; }
  .site-nav { display: none; }
  .hero { margin-top: .85rem; min-height: 355px; background-position: 57% center; }
  .hero::before { background: linear-gradient(90deg, #0d1b19f2, #0d1b1980 68%, #0d1b1950); }
  .hero-copy { padding: 1.35rem; }
  .hero h1 { font-size: 6rem; }
  .intro { max-width: 24ch; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .calendar-section { margin: 2.45rem 0 2.85rem; }
  .door-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
  .door { min-height: 105px; padding: .65rem; }
  .door .number { font-size: 2.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}

[hidden] { display: none !important; }
.preview-tabs { display: flex; flex-wrap: wrap; gap: .5rem; border-bottom: 1px solid var(--edge); margin-top: 1.65rem; }
.preview-tabs a { padding: .65rem .85rem; color: var(--muted); border-bottom: 2px solid transparent; }
.preview-tabs a[aria-current="page"] { color: var(--gold); border-bottom-color: var(--gold); }
.preview-tabs:not([hidden]) ~ .calendar-section { margin-top: 1.55rem; }
.player-calendar { margin-bottom: 1rem; padding: 1rem; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; }
.player-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem 1rem; }
.player-summary h3 { font: 400 1.9rem/1.1 var(--display); margin: 0 0 .25rem; }
.player-summary p { color: var(--muted); margin: 0; }
#player-address { border-color: var(--edge); }
.door-filters { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.door-filters button { min-height: 36px; border-radius: 5px; background: transparent; padding: .3rem .6rem; color: var(--muted); font-size: .9rem; }
.door-filters button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.door-filters span { font-variant-numeric: tabular-nums; margin-left: .2rem; }
.door-state { color: var(--gold); font-size: .82rem; line-height: 1.15; font-weight: 600; }
.door.solved .door-state { color: #b7d7bb; }
.geek-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.2rem, 1fr)); gap: .6rem; margin: 0; }
.geek-stats div { padding: .8rem; border: 1px solid var(--edge); border-radius: 8px; background: var(--panel); }
.geek-stats dt { color: var(--muted); }
.geek-stats dd { font: 400 2.45rem/1.1 var(--display); margin: 0; }
.geek-table { overflow-x: auto; margin: .8rem 0 0; }
.geek-table table { width: 100%; min-width: 39rem; border-collapse: collapse; }
.geek-table th, .geek-table td { border-bottom: 1px solid var(--edge); padding: .5rem .65rem; text-align: left; }
.geek-table th a { text-decoration: underline; text-underline-offset: .2em; }
#geek-progress:empty { display: none; }
