/* The Dreamer: Saltmarsh seen from under the water, at night. The town is a
   street of windows: lit amber where someone is awake, dark where someone
   sleeps, and ringed with the god's own light by how open that sleeper is to
   a dream. Dawn is the one pale page: the chronicle, in daylight.
   No inline styles anywhere (strict CSP). */

@font-face { font-family: 'Fell'; src: url('../fonts/fell-roman.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fell'; font-style: italic; src: url('../fonts/fell-italic.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fell SC'; src: url('../fonts/fell-sc.woff2') format('woff2'); font-display: swap; }

:root {
  --sea: #12313a;
  --sea-2: #183c46;
  --sea-3: #22505b;
  --foam: #dde9e2;
  --foam-2: #9fb8b2;
  --glow: #cfe08a;
  --lamp: #f0c36d;
  --heat: #e58a6a;
  --line: rgba(221, 233, 226, .14);
  --day: #e9ece4;
  --day-2: #dde2d6;
  --day-ink: #23302f;
  --day-ink-2: #5d6a64;
  --shadow: rgba(0, 0, 0, .45);
  --gutter: 16px;
  --nav-h: 62px;
  --bar-h: 64px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--sea);
  background-image: radial-gradient(ellipse at 50% -10%, rgba(207, 224, 138, .07), transparent 60%);
  color: var(--foam);
  font: 18px/1.5 'Fell', Georgia, 'Times New Roman', serif;
  -webkit-tap-highlight-color: transparent;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { font-weight: 400; margin: 0; }
p { margin: 0 0 .7em; }
.ic { width: 24px; height: 24px; flex: none; }
.num { font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-variant-numeric: lining-nums; font-size: .92em; }
.quiet { color: var(--foam-2); }
.help { font-size: 14px; color: var(--foam-2); font-style: italic; }

/* ---------- shell ---------- */

.shell { min-height: 100dvh; }
.head { position: sticky; top: 0; z-index: 20; background: var(--sea); padding: calc(env(safe-area-inset-top) + 8px) var(--gutter) 8px; border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.head-night { font-family: 'Fell SC', 'Fell', serif; font-size: 19px; }
.head-stars { font-style: italic; font-size: 15px; color: var(--foam-2); }
.gauges { display: flex; gap: 16px; align-items: center; font-size: 14px; color: var(--foam-2); margin-top: 2px; flex-wrap: wrap; }
.essence { color: var(--glow); }
.heat { display: flex; align-items: center; gap: 6px; }
.heat-bar { width: 64px; height: 3px; background: var(--sea-3); position: relative; }
.heat-fill { position: absolute; inset: 0 auto 0 0; background: var(--heat); }
.pips { display: flex; gap: 10px; margin-left: auto; }
.pip { font-size: 13px; font-style: italic; color: var(--foam-2); display: flex; align-items: center; gap: 4px; }
.pip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--foam-2); }
.pip.is-done { color: var(--glow); }
.pip.is-done::before { background: var(--glow); border-color: var(--glow); box-shadow: 0 0 6px var(--glow); }

.view { max-width: 680px; margin: 0 auto; padding: 16px var(--gutter) calc(var(--nav-h) + var(--bar-h) + env(safe-area-inset-bottom) + 28px); }
.view-title { font-size: 26px; line-height: 1.2; margin-bottom: 4px; }
.view-sub { color: var(--foam-2); font-style: italic; font-size: 16px; margin-bottom: 14px; }

/* ---------- the town: a street of windows ---------- */

.house { padding: 10px 0; border-bottom: 1px solid var(--line); }
.house-top { display: flex; align-items: center; gap: 12px; }
.house-name { flex: 1; font-size: 17px; }
.windows { display: flex; gap: 6px; }
.win {
  position: relative; width: 22px; height: 30px; padding: 0;
  border: 1px solid rgba(221, 233, 226, .35); border-radius: 2px 2px 0 0;
  background: #0b1f25;
}
.win::after { content: ''; position: absolute; left: 50%; top: 2px; bottom: 2px; border-left: 1px solid rgba(221, 233, 226, .2); }
.win.is-lit { background: var(--lamp); border-color: var(--lamp); box-shadow: 0 0 10px rgba(240, 195, 109, .35); cursor: default; }
.win.is-lit::after { border-color: rgba(80, 50, 10, .35); }
.win.is-gone { opacity: .2; cursor: default; }
/* How open a sleeper is: the god's own light around the dark window. */
.win.is-open { box-shadow: 0 0 calc(var(--o, 0) * 14px) calc(var(--o, 0) * 3px) rgba(207, 224, 138, .7); border-color: rgba(207, 224, 138, .7); }
.win.is-dreamt { background: var(--glow); border-color: var(--glow); box-shadow: 0 0 14px 3px rgba(207, 224, 138, .8); }
.win.is-watcher { border-color: var(--heat); }
.win.is-watcher.is-lit { box-shadow: 0 0 0 2px var(--heat), 0 0 10px rgba(240, 195, 109, .35); }
.mind { font-style: italic; color: var(--heat); }
.win.is-believer::before { content: ''; position: absolute; left: -3px; right: -3px; bottom: -5px; height: 2px; background: var(--glow); border-radius: 1px; }
.sleepers-line { font-size: 14px; color: var(--foam-2); margin: 4px 0 0; }
.sleepers-line b { font-weight: 400; color: var(--foam); }
.filter { display: flex; gap: 6px; margin: 0 0 6px -8px; }

/* ---------- the map (M3): Saltmarsh from above, at night ---------- */

.mapbox { margin: 4px calc(-1 * var(--gutter)) 6px; }
.map { display: block; width: 100%; height: auto; max-height: 80vh; margin: 0 auto; }
.m-land { fill: #0f2a31; }
.m-sea { fill: #0a1d24; }
.m-surf { fill: none; stroke: var(--foam-2); stroke-width: .4; stroke-opacity: .5; }
.m-rock { fill: var(--sea-3); }
.m-deep { fill: var(--glow); fill-opacity: .08; }
.m-street { fill: none; stroke: #2a5560; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.m-tree { fill: #16382f; }
.m-building { fill: #1d4650; }
.m-church, .m-spire { fill: #2b5d68; }
.m-pier { stroke: #3a6d78; stroke-width: .8; fill: none; }
.m-grave { stroke: #6b8b86; stroke-width: .35; fill: none; }
.m-beam { fill: var(--lamp); fill-opacity: .12; }
.m-tower { fill: var(--foam-2); }
.m-lamp { fill: var(--sea-3); }
.m-lamp.is-lit { fill: var(--lamp); }
.m-seat { fill: none; stroke: var(--glow); stroke-opacity: .4; stroke-dasharray: .8 .8; stroke-width: .4; }
.m-mark { fill: var(--glow); }
.m-hit { fill: transparent; }
.m-home { cursor: pointer; outline: none; }
.m-home.is-empty { opacity: .35; }
.m-house { fill: #081a20; stroke: #2a5560; stroke-width: .25; }
.m-home:hover .m-house, .m-home:focus-visible .m-house { stroke: var(--glow); stroke-width: .5; }
.m-win { fill: #0b1f25; stroke: var(--glow); stroke-width: .45; }
.m-win.is-lit { fill: var(--lamp); }
.m-win.is-gone { fill-opacity: .3; }
.m-win.is-dreamt { fill: var(--glow); }
.m-win.is-watcher { stroke: var(--heat); stroke-opacity: 1; }
.m-faith { fill: var(--glow); }
.m-label { font: italic 2.6px 'Fell', Georgia, serif; fill: var(--foam-2); pointer-events: none; }
.m-label.is-sea { fill: var(--glow); fill-opacity: .75; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 14px; color: var(--foam-2); margin: 0 0 14px; }
.key { display: inline-block; width: 9px; height: 13px; border: 1px solid rgba(221, 233, 226, .35); background: #0b1f25; margin-left: 6px; }
.key:first-child { margin-left: 0; }
.key-lit { background: var(--lamp); border-color: var(--lamp); }
.key-open { border-color: var(--glow); box-shadow: 0 0 6px rgba(207, 224, 138, .7); }
.key-faith { height: 3px; border: 0; background: var(--glow); }
.key-watch { border-color: var(--heat); }
.list-head { font-family: 'Fell SC', 'Fell', serif; font-size: 17px; color: var(--foam-2); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 6px 0 4px; }
.members { list-style: none; padding: 0; margin: 8px 0 0; }
.members li { border-bottom: 1px solid var(--line); }
.member { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 0; background: none; border: 0; text-align: left; }
.member:disabled { opacity: .45; cursor: default; }
.member .win { flex: none; pointer-events: none; }
.member-name { display: flex; flex-direction: column; font-size: 17px; line-height: 1.3; }
.member-name small { font-size: 14px; color: var(--foam-2); font-style: italic; }

/* ---------- choosing a god ---------- */

.god { padding: 14px 0; border-bottom: 1px solid var(--line); }
.god:last-child { border-bottom: 0; }
.god h3 { font-size: 22px; font-style: italic; margin-bottom: 4px; color: var(--glow); }
.score { font-family: 'Fell SC', 'Fell', serif; font-size: 24px; color: var(--glow); margin: 0 0 6px; }

/* ---------- the word: choices, circled in light ---------- */

.w {
  position: relative; display: inline-flex; align-items: center; height: 34px; padding: 0 9px; margin: 0 1px;
  background: none; border: 0; color: var(--foam); font-size: 17px; line-height: 1; white-space: nowrap;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.w-text { position: relative; z-index: 1; }
.w .mk { position: absolute; pointer-events: none; overflow: visible; }
.w .mk-circle { inset: 2px -1px 1px -1px; width: calc(100% + 2px); height: calc(100% - 3px); color: var(--glow); filter: drop-shadow(0 0 3px rgba(207, 224, 138, .6)); }
.w.is-circled .w-text { color: var(--glow); }
.w:disabled { opacity: .35; cursor: default; }
.words { display: flex; flex-wrap: wrap; align-items: center; margin-left: -9px; }
.pick { margin-top: 12px; }
.pick-label { font-size: 14px; color: var(--foam-2); font-style: italic; }
.w small { font-size: 12px; font-style: italic; color: var(--foam-2); margin-left: 4px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 18px;
  background: transparent; color: var(--foam); border: 1px solid rgba(221, 233, 226, .55); border-radius: 3px; font-size: 17px; line-height: 1.2;
}
.btn-primary { background: var(--glow); color: #14302a; border-color: var(--glow); }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }
.btn small { font-style: italic; font-size: 15px; opacity: .85; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1 1 140px; }
.link { background: none; border: 0; padding: 0; color: var(--glow); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }

/* ---------- tonight's bar and the tabs ---------- */

.tonight {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 8px var(--gutter);
  background: var(--sea-2); border-top: 1px solid var(--line);
}
.tonight-text { flex: 1; font-size: 15px; color: var(--foam-2); line-height: 1.3; }
.tonight-text b { font-weight: 400; color: var(--glow); }
.tonight .btn { min-height: 44px; }
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: space-around;
  background: var(--sea); border-top: 1px solid var(--line); padding: 4px 4px calc(env(safe-area-inset-bottom) + 4px);
}
.tab { flex: 1; max-width: 140px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: none; border: 0; color: var(--foam-2); font-size: 14px; }
.tab .ic { width: 23px; height: 23px; }
.tab.is-on { color: var(--glow); }

/* ---------- sheets ---------- */

.scrim { position: fixed; inset: 0; background: var(--shadow); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.is-open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--sea-2); border-top: 1px solid var(--line); box-shadow: 0 -10px 34px var(--shadow);
  padding: 14px var(--gutter) calc(env(safe-area-inset-bottom) + 20px);
  transform: translateY(102%); transition: transform .22s ease-out;
}
.sheet.is-open { transform: none; }
.sheet-full { top: 0; max-height: none; border-top: 0; padding-top: calc(env(safe-area-inset-top) + 10px); }
.sheet-inner { max-width: 640px; margin: 0 auto; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.sheet-head h2 { flex: 1; font-size: 22px; line-height: 1.25; padding-top: 6px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: inherit; flex: none; margin: -4px -8px 0 0; }
@media (min-width: 700px) {
  .sheet:not(.sheet-full) { left: 50%; right: auto; width: 640px; margin-left: -320px; bottom: 24px; border: 1px solid var(--line); max-height: 80dvh; }
}
@media (prefers-reduced-motion: reduce) { .sheet, .scrim { transition: none; } }

/* Dawn: the one page in daylight. */
.sheet.is-day { background: var(--day); color: var(--day-ink); }
.is-day .quiet, .is-day .help { color: var(--day-ink-2); }
.is-day .btn { color: var(--day-ink); border-color: var(--day-ink); }
.is-day .btn-primary { background: var(--day-ink); color: var(--day); }
.dawn-head { font-family: 'Fell SC', 'Fell', serif; font-size: 16px; color: var(--day-ink-2); border-bottom: 1px solid var(--day-2); margin: 18px 0 8px; }
.dawn-list { list-style: none; padding: 0; margin: 0; }
.dawn-list li { padding: 6px 0; border-bottom: 1px dotted var(--day-2); }
.dawn-list li.mine { font-style: italic; }

/* ---------- people ---------- */

.bars { margin: 10px 0; }
.bar-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; font-size: 15px; padding: 2px 0; }
.bar { height: 4px; background: var(--sea-3); position: relative; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--foam-2); }
.bar-row.is-god .bar-fill { background: var(--glow); box-shadow: 0 0 6px rgba(207, 224, 138, .6); }
.why { font-size: 15px; color: var(--foam-2); }
.why li { margin-bottom: 4px; }
.prediction { border-left: 2px solid var(--glow); padding-left: 12px; font-style: italic; margin: 14px 0; }

/* ---------- gate and chronicle ---------- */

.part { padding: 12px 0; border-bottom: 1px solid var(--line); }
.part h3 { font-size: 20px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.part.is-done h3 { color: var(--glow); }
.day-head { font-family: 'Fell SC', 'Fell', serif; font-size: 16px; color: var(--foam-2); border-bottom: 1px solid var(--line); margin: 20px 0 6px; }
.day-line { margin: 0 0 6px; }
.day-line.mine { font-style: italic; color: var(--glow); }

/* ---------- start ---------- */

.start { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) var(--gutter) calc(env(safe-area-inset-bottom) + 40px); }
.wordmark { font-size: 56px; line-height: 1; font-style: italic; color: var(--foam); text-shadow: 0 0 22px rgba(207, 224, 138, .25); }
.start-lede { font-size: 20px; line-height: 1.45; font-style: italic; color: var(--foam-2); margin: 18px 0 28px; }
.start .btn { margin-bottom: 10px; }
.start-windows { display: flex; gap: 6px; margin: 0 0 22px; }
.seed-row { display: flex; gap: 8px; margin-top: 8px; }
.seed-row input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 10px; background: transparent; border: 0; border-bottom: 1px solid var(--line); font-size: 17px; }
.start-foot { margin-top: 24px; font-size: 14px; color: var(--foam-2); }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--bar-h) + env(safe-area-inset-bottom) + 12px); z-index: 60; display: grid; justify-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--foam); color: var(--sea); padding: 8px 14px; border-radius: 3px; font-size: 16px; max-width: calc(100% - 32px); box-shadow: 0 4px 16px var(--shadow); animation: toast 2.6s ease both; }
@keyframes toast { 0% { opacity: 0; transform: translateY(6px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
