:root {
  --paper: #f3ead7;
  --paper-2: #ebdfc4;
  --card: #fbf6ea;
  --ink: #2b2118;
  --ink-soft: #6b5a45;
  --line: #d8c7a3;
  --accent: #9c4a2f;
  --sea: #2d6f8e;
  --warn: #a2461f;
  --good: #5b7a3a;
  --top: #2b2118;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 6px 20px rgba(60, 40, 20, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 "Alegreya", Georgia, serif;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  background: var(--top);
  color: var(--paper);
  font-family: "Alegreya Sans", system-ui, sans-serif;
  position: sticky;
  top: 0;
  z-index: 3;
}
.brand { font: 700 20px/1 "Alegreya", Georgia, serif; letter-spacing: .02em; white-space: nowrap; }
.brand #season { display: block; font: 500 12px "Alegreya Sans", system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #d9c6a3; }
.brand span { color: #e0a36b; }
.dial { width: 120px; height: 40px; flex: none; }
.dial .arc { fill: none; stroke: rgba(243, 234, 215, .25); stroke-width: 2; }
.dial .tick { stroke: rgba(243, 234, 215, .55); stroke-width: 1.5; }
.dial .sun { fill: #f0c24a; filter: drop-shadow(0 0 3px rgba(240, 194, 74, .8)); }
.dial .moon { fill: #dfe6f2; }
.clock { flex: 1; min-width: 0; line-height: 1.25; }
.clock #time { font-size: 15px; }
.weather { font-size: 13px; opacity: .75; }
.purse { display: flex; gap: 10px; align-items: center; white-space: nowrap; font-weight: 700; }
.coin { display: inline-flex; align-items: center; gap: 5px; }
.coin i {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .18), inset 2px 2px 0 rgba(255, 255, 255, .35);
}
.coin.silver i { background: #cfd3d6; }
.coin.copper i { background: #c27a45; }
.tools { display: flex; gap: 6px; }
.tool {
  background: rgba(243, 234, 215, .08);
  border: 1px solid rgba(243, 234, 215, .25);
  color: var(--paper);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 14px;
  cursor: pointer;
}
.tool:hover, .tool[aria-pressed="true"] { background: rgba(243, 234, 215, .2); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  align-items: start;
}

/* ---------- scene: a camera over the quarter painting ---------- */
.scene {
  position: relative;
  margin: 0 0 16px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #8a7a5c;
  aspect-ratio: 5 / 3;
}
.painting {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  max-width: none;
  user-select: none;
  pointer-events: none;
}
.backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; pointer-events: none; }
.backdrop[hidden] { display: none; }
.crowd { position: absolute; inset: 0; pointer-events: none; }
.stander { position: absolute; width: auto; translate: -50% 0; /* not transform: the glide animation owns that */  filter: drop-shadow(0 6px 12px rgba(20, 12, 5, .45)); animation: show .6s ease-out; }
@keyframes show { from { opacity: 0; } }
.tint { position: absolute; inset: 0; pointer-events: none; transition: background 1.2s, opacity 1.2s; }
/* a painted scene breathes: the picture slowly drifts and swells (individual scale/translate, so the dive animation's transform is untouched) */
.backdrop { animation: breathe 22s ease-in-out infinite alternate; }
@keyframes breathe { from { scale: 1.02; translate: -.8% .4%; } to { scale: 1.06; translate: .8% -.5%; } }
/* light shaft from the upper right, swaying; its strength follows the hour (--beam) */
.sunbeam, .motes { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; }
.sunbeam {
  background: linear-gradient(112deg, transparent 38%, rgba(255, 232, 180, .22) 50%, transparent 62%),
              linear-gradient(112deg, transparent 56%, rgba(255, 232, 180, .14) 66%, transparent 76%);
  opacity: calc(var(--beam, 0) * .9);
  animation: sway 14s ease-in-out infinite alternate;
  transition: opacity 1.2s;
}
@keyframes sway { from { translate: -3% 0; } to { translate: 3% 0; } }
.scene:has(.backdrop[hidden]) :is(.sunbeam, .motes) { display: none; } /* only on a painted place, not over the map */
.scene:has(.weather-fx.rain) .sunbeam { opacity: 0; }
.motes i {
  position: absolute; width: var(--s); height: var(--s); border-radius: 50%;
  background: rgba(255, 240, 200, .6); box-shadow: 0 0 3px rgba(255, 235, 180, .3);
  opacity: 0; animation: mote var(--d) ease-in-out infinite;
}
.scene.night .motes i { background: rgba(190, 215, 255, .5); box-shadow: 0 0 3px rgba(150, 190, 255, .3); }
.scene:has(.weather-fx.rain) .motes { display: none; }
@keyframes mote { 0%, 100% { opacity: 0; translate: 0 0; } 25%, 70% { opacity: var(--o, .5); } 50% { translate: calc(var(--dx) * .6) calc(var(--dy) * .5); } 100% { translate: var(--dx) var(--dy); } }
@media (prefers-reduced-motion: reduce) { .backdrop, .sunbeam, .motes i { animation: none; } }
.weather-fx { position: absolute; inset: 0; pointer-events: none; }
.weather-fx.rain {
  /* Two layers of short streaks: small far drops fall slower than big near ones; each tile loops seamlessly. */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><g stroke='%23e6eef6' stroke-opacity='0.55' stroke-width='1.6' stroke-linecap='round'><line x1='32' y1='114' x2='27' y2='132'/><line x1='139' y1='147' x2='134' y2='165'/><line x1='139' y1='-13' x2='134' y2='5'/><line x1='89' y1='112' x2='84' y2='130'/><line x1='123' y1='86' x2='118' y2='104'/><line x1='64' y1='106' x2='59' y2='124'/><line x1='64' y1='84' x2='60' y2='102'/><line x1='79' y1='156' x2='74' y2='174'/><line x1='79' y1='-4' x2='74' y2='14'/><line x1='31' y1='147' x2='26' y2='165'/><line x1='31' y1='-13' x2='26' y2='5'/><line x1='146' y1='55' x2='141' y2='73'/><line x1='-14' y1='55' x2='-19' y2='73'/></g></svg>"), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><g stroke='%23e6eef6' stroke-opacity='0.45' stroke-width='1' stroke-linecap='round'><line x1='86' y1='55' x2='83' y2='64'/><line x1='-4' y1='55' x2='-7' y2='64'/><line x1='52' y1='22' x2='49' y2='31'/><line x1='28' y1='26' x2='25' y2='35'/><line x1='35' y1='81' x2='32' y2='90'/><line x1='35' y1='-9' x2='32' y2='0'/><line x1='35' y1='72' x2='33' y2='81'/><line x1='38' y1='76' x2='36' y2='85'/><line x1='35' y1='53' x2='33' y2='62'/><line x1='79' y1='19' x2='77' y2='28'/><line x1='20' y1='62' x2='18' y2='71'/><line x1='26' y1='47' x2='23' y2='56'/><line x1='61' y1='86' x2='58' y2='95'/><line x1='61' y1='-4' x2='58' y2='5'/><line x1='41' y1='64' x2='39' y2='73'/><line x1='9' y1='67' x2='7' y2='76'/><line x1='14' y1='22' x2='11' y2='31'/></g></svg>");
  background-size: 160px 160px, 90px 90px;
  animation: rain .55s linear infinite;
}
@keyframes rain { to { background-position: -43px 160px, -24px 90px; } }
.weather-fx.fog { background: linear-gradient(180deg, rgba(235, 238, 240, .55), rgba(235, 238, 240, .25)); animation: fog 12s ease-in-out infinite alternate; }
@keyframes fog { to { opacity: .6; } }
.weather-fx.cloudy { background: rgba(110, 115, 125, .18); }
.weather-fx.fog { display: none; } /* the haze washed out the painting */
.scene:has(.backdrop:not([hidden])) .weather-fx:is(.cloudy, .windy) { display: none; } /* a painted scene has its own sky */
.weather-fx.windy {
  background: repeating-linear-gradient(170deg, transparent 0 40px, rgba(255, 255, 255, .07) 40px 42px);
  background-size: 300% 300%;
  animation: wind 3s linear infinite;
}
@keyframes wind { to { background-position: 300px 40px; } }
.scene figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 36px 18px 12px;
  background: linear-gradient(transparent, rgba(30, 20, 12, .78));
  color: #fff8ee;
  font: 700 24px/1.2 "Alegreya", Georgia, serif;
}

/* conversation: portrait and the last line over the scene */
.scene.talking figcaption { opacity: 0; }
/* the two speakers stand on the scene behind the talk panel */
.cast { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(transparent 35%, rgba(30, 20, 12, .35)); }
.cast[hidden], .figure[hidden] { display: none; }
.figure { position: absolute; bottom: -14%; height: 112%; width: auto; filter: drop-shadow(0 6px 12px rgba(20, 12, 5, .5)); animation: rise .25s ease-out; }
.figure.hero { left: 8%; }
.figure.npc { right: 8%; }
.talk-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 14px;
  align-items: flex-end;
  padding: 44px 18px 14px;
  background: linear-gradient(transparent, rgba(24, 15, 8, .82) 55%);
  color: #fff8ee;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.portrait {
  width: 96px; height: 120px; flex: none;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #7d6a4e, #4a3b28);
  border: 2px solid #c9b58e;
}
.portrait img, .portrait svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.talk-body { min-width: 0; }
.talk-name { font: 700 16px "Alegreya Sans", system-ui, sans-serif; color: #f3d9a4; }
.talk-att { font-weight: 400; font-size: 14px; color: #e3d3b4; }
.scene:has(.cast:not([hidden])) .portrait { display: none; } /* the speaker stands on the scene instead */
.att-pop { font-weight: 700; font-size: 14px; animation: pop 2.4s ease-out forwards; }
.att-pop.up { color: var(--good); }
.att-pop.down { color: var(--warn); }
@keyframes pop { 0% { opacity: 0; } 10% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.talk-line { font-size: 17px; line-height: 1.45; max-height: 7.3em; overflow-y: auto; }

/* ---------- log ---------- */
.log-toggle { display: none; } /* phones only, see the max-width block */
.log {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 20px;
  max-height: 46vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.turn { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.turn:last-child { border-bottom: 0; }
.turn p { margin: 0 0 6px; }
.turn .you { font: 500 14px/1.4 "Alegreya Sans", system-ui, sans-serif; color: var(--accent); margin-bottom: 6px; }
.turn .you::before { content: "› "; }
.turn h3 { font-size: 18px; margin: 4px 0 2px; color: var(--ink); }
.turn .info { color: var(--ink-soft); font: 15px/1.45 "Alegreya Sans", system-ui, sans-serif; }
.turn .need {
  display: inline-block;
  margin: 2px 6px 2px 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: #f6dccb;
  color: var(--warn);
  font: 600 13px/1.5 "Alegreya Sans", system-ui, sans-serif;
}
.turn .speaker { font-weight: 700; color: var(--sea); }
.turn .end { color: var(--ink-soft); font-style: italic; }

/* several days: one card per day */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 6px 0 8px; }
.day-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: 13px/1.4 "Alegreya Sans", system-ui, sans-serif;
}
.day-card b { display: block; font-size: 14px; }
.day-card .pay { font-size: 18px; font-weight: 700; color: var(--good); }
.day-card.idle .pay { color: var(--ink-soft); }
.day-card .muted { color: var(--ink-soft); }
.days-total { font: 600 15px "Alegreya Sans", system-ui, sans-serif; }
.days-total .plus { color: var(--good); }
.days-total .minus { color: var(--warn); }
.days-people { font: 15px/1.5 "Alegreya Sans", system-ui, sans-serif; }

.typed { margin-top: 10px; }
.typed input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: 15px "Alegreya Sans", system-ui, sans-serif;
}
.typed input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- side: needs and choices ---------- */
.side { position: sticky; top: 64px; }
.needs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.need-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px 9px;
  font-family: "Alegreya Sans", system-ui, sans-serif;
}
.need-card small { display: block; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.need-card b { font-size: 14px; }
.bar { height: 6px; border-radius: 3px; background: var(--paper-2); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--good); transition: width .6s ease, background .6s; }
.need-card.mid .bar i { background: #c9922e; }
.need-card.bad .bar i { background: var(--warn); }
.need-card.bad b { color: var(--warn); }

.side-title {
  font: 700 13px/1 "Alegreya Sans", system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.choices { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 220px); overflow-y: auto; padding-right: 2px; }
.choice {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: 15px/1.35 "Alegreya Sans", system-ui, sans-serif;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.choice:hover, .choice:focus-visible { background: #fff; border-color: var(--accent); outline: none; transform: translateX(2px); }
.choice .n { color: var(--ink-soft); font-size: 12px; min-width: 16px; }
.choice.talk { border-left: 3px solid var(--sea); }
.choice .wants { margin-left: auto; align-self: center; flex: none; width: 10px; min-width: 10px; height: 10px; aspect-ratio: 1; padding: 0; border-radius: 50%; background: #d62b1f; box-shadow: 0 0 6px 2px rgba(214, 43, 31, .55); animation: wants 1s ease-in-out infinite; }
@keyframes wants { 50% { opacity: .25; box-shadow: none; } }
.choice .who { color: var(--ink-soft); }
.choice.work { border-left: 3px solid var(--accent); }
.choice.section { font-weight: 500; }
.choice.back { color: var(--ink-soft); background: transparent; }
.choice.ask { border-left: 3px solid #b5651d; background: #fbf0dc; font-weight: 500; }
.choice.ask.later { font-weight: 400; color: var(--ink-soft); background: transparent; }
.choice .check { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.choice .warn { display: block; margin-top: 2px; font-size: 13px; color: var(--warn); }
.choice:disabled { opacity: .5; cursor: wait; }

/* ---------- modals: map and journal ---------- */
.modal {
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(20, 12, 5, .45);
  max-width: min(1200px, 94vw);
  width: 100%;
}
.modal::backdrop { background: rgba(30, 20, 12, .55); }
.modal-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; }
.close { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-family: "Alegreya Sans", system-ui, sans-serif; }
.map-wrap { padding: 12px 18px 0; }
.map-view { position: relative; overflow: hidden; border-radius: 8px; touch-action: none; user-select: none; }
.map-inner { position: relative; transform-origin: 0 0; --z: 1; --ms: 1; }
.map-inner img { width: 100%; display: block; }
.map-zoom { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map-zoom button { width: 36px; height: 36px; font: 600 20px/1 "Alegreya Sans", system-ui, sans-serif; color: var(--ink); background: rgba(251, 246, 234, .92); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); cursor: pointer; padding: 0; }
.pin {
  position: absolute;
  transform-origin: 0 0; /* markers keep their screen size while the map zooms under them */
  transform: scale(calc(var(--ms, 1) / var(--z))) translate(-50%, -50%);
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fbf6ea;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  cursor: pointer;
  padding: 0;
}
.pin.kinds { border-color: #fff; }
.pin.gate { width: 10px; height: 10px; border-radius: 2px; border-width: 2px; border-color: #2b2b33; background: #fbf6ea; }
.pin.shut { background: #7d7468; border-style: dashed; }
.pin[hidden], .pin-label.off { display: none; }
.map-filter { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 8px; font: 14px "Alegreya Sans", system-ui, sans-serif; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 3px 12px 3px 8px; cursor: pointer; font: inherit; }
.chip i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff8ee; }
.chip-note { color: var(--ink-soft); font-size: 13px; }
.pin:hover, .pin:focus-visible { box-shadow: 0 0 0 4px rgba(156, 74, 47, .35); outline: none; }
.pin.here { width: 24px; height: 24px; background: var(--accent); border-color: #fff; cursor: default; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(156, 74, 47, .25); } }
.pin-label {
  position: absolute;
  transform-origin: 0 0;
  transform: scale(calc(1 / var(--z))) translate(-50%, -150%);
  background: rgba(30, 20, 12, .85);
  color: #fff8ee;
  font: 13px/1.3 "Alegreya Sans", system-ui, sans-serif;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
}
.dot {
  position: absolute;
  transform-origin: 0 0;
  transform: scale(calc(var(--ms, 1) / var(--z))) translate(-50%, -50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--sea);
  color: #fff;
  font: 700 11px/20px "Alegreya Sans", system-ui, sans-serif;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  pointer-events: auto;
  padding: 0;
  cursor: pointer;
}
.dot:hover, .dot:focus-visible { box-shadow: 0 0 0 3px rgba(255, 255, 255, .6); outline: none; }
.names .dot { width: auto; padding: 0 8px; border-radius: 10px; font-size: 0; white-space: nowrap; }
.names .dot::after { content: attr(data-name); font: 700 12px/16px "Alegreya Sans", system-ui, sans-serif; }
.map-hint { margin: 8px 18px 14px; color: var(--ink-soft); font: 14px "Alegreya Sans", system-ui, sans-serif; }
.journal { padding: 12px 22px 20px; max-height: 70vh; overflow-y: auto; }
.journal h3 { font: 700 13px "Alegreya Sans", system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 14px 0 4px; }
.journal p { margin: 0 0 8px; }
.journal .empty { color: var(--ink-soft); font-style: italic; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.tab { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px; cursor: pointer; font: 15px "Alegreya Sans", system-ui, sans-serif; color: var(--ink-soft); }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff8ee; }
.faction { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.faction:last-child { border-bottom: 0; }
.faction .rep { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 8px; color: var(--accent); }
.person { display: flex; gap: 14px; align-items: flex-start; scroll-margin-top: 8px; transition: background .4s; border-radius: 6px; }
.person.flash { background: rgba(156, 74, 47, .14); }
.person .face { width: 64px; height: 80px; object-fit: cover; border-radius: 6px; margin-top: 14px; flex: none; background: linear-gradient(180deg, #7d6a4e, #4a3b28); }
.person .who { font: 15px/1.45 "Alegreya Sans", system-ui, sans-serif; color: var(--ink-soft); }
.wants { margin-left: 8px; padding: 1px 8px; border-radius: 10px; background: var(--accent); color: #fff8ee; font: 700 11px/18px "Alegreya Sans", system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; animation: pulse 1.6s ease-in-out infinite; }
.person .now { font: 600 15px/1.5 "Alegreya Sans", system-ui, sans-serif; }
.person .now.away { font-weight: 400; color: var(--ink-soft); font-style: italic; }
.go-to { margin-left: 8px; padding: 1px 12px; border: 1px solid var(--accent); border-radius: 6px; background: transparent; color: var(--accent); cursor: pointer; font: 600 14px "Alegreya Sans", system-ui, sans-serif; }
.go-to:hover { background: var(--accent); color: #fff8ee; }
.restart { margin-top: 28px; padding-top: 14px; border-top: 1px dashed var(--line, #c9b48f); text-align: center; }
.restart p { margin: 0 0 10px; }
.go-to.danger { border-color: #9b2c1f; color: #9b2c1f; }
.go-to.danger:hover { background: #9b2c1f; color: #fff8ee; }
.person-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.person-link:hover { text-decoration: underline; }
.quest p { margin: 2px 0 8px; }
.quest.done { opacity: .7; }
.quest.failed h3 .rep { color: var(--warn); }
.quest .where { font: 15px/1.5 "Alegreya Sans", system-ui, sans-serif; }
.go-quest { margin: 2px 0 8px; padding: 5px 14px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff8ee; cursor: pointer; font: 600 15px "Alegreya Sans", system-ui, sans-serif; }
.go-quest:hover { filter: brightness(1.1); }
.quests-done { margin-top: 18px; }
.stat-table { border-collapse: collapse; margin: 4px 0 10px; font: 16px/1.5 "Alegreya Sans", system-ui, sans-serif; }
.stat-table td { padding: 2px 18px 2px 0; vertical-align: top; }
.stat-table td:first-child { color: var(--ink-soft); }
.members { margin: 4px 0 8px; padding-left: 18px; font: 15px/1.45 "Alegreya Sans", system-ui, sans-serif; }

.offline {
  position: fixed;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  background: var(--warn);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font: 15px "Alegreya Sans", system-ui, sans-serif;
  box-shadow: var(--shadow);
  z-index: 5;
}

/* Desktop: the page fits the screen; the story log scrolls by itself so the newest text is always in view. */
@media (min-width: 861px) {
  body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  .layout { flex: 1; min-height: 0; width: 100%; padding-bottom: 20px; }
  .story, .side { height: 100%; min-height: 0; }
  .story { display: flex; flex-direction: column; }
  .scene { aspect-ratio: auto; height: 56vh; flex: none; }
  .log { flex: 1; min-height: 0; max-height: none; }
  .side { position: static; display: flex; flex-direction: column; }
  .choices { flex: 1; min-height: 0; max-height: none; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px 24px; gap: 16px; }
  .side { position: static; }
  .choices { max-height: none; }
  .log { display: none; max-height: 45vh; } /* folded behind the "Лента событий" button */
  .story.log-open .log { display: block; }
  .log-toggle { display: block; width: 100%; margin: 12px 0 0; padding: 10px 12px; font: 700 13px/1 "Alegreya Sans", system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; }
  .story.log-open .log-toggle { margin-bottom: 8px; }
  /* two rows: [name | date & weather | purse], then the tool buttons */
  /* dialogs: title left, "Закрыть" always top right, tabs (journal) on their own row below */
  .modal-head h2 { order: 1; flex: 1; }
  .modal-head .close { order: 2; }
  .modal-head .tabs { order: 3; flex-basis: 100%; }
  .top { display: grid; grid-template-columns: auto 1fr auto; padding: 8px 12px; gap: 6px 10px; }
  .clock { grid-column: 2; grid-row: 1; }
  .clock #time { font-size: 13px; }
  .weather { font-size: 12px; }
  .purse { grid-column: 3; grid-row: 1; }
  .tools { grid-column: 1 / -1; grid-row: 2; }
  .dial { display: none; }
  .portrait { width: 64px; height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- intro ---------- */
.intro { position: fixed; inset: 0; z-index: 50; background: #14100b; color: #f3ead7; font-family: "Alegreya", Georgia, serif; overflow: hidden; animation: introIn .6s ease both; }
.intro.out { opacity: 0; transition: opacity .5s ease; pointer-events: none; }
.intro-art { position: absolute; inset: -4%; background-size: cover; background-position: center; transform-origin: center; }
.intro-art.run.pan-0 { animation: pan0 22s ease-out both; }
.intro-art.run.pan-1 { animation: pan1 22s ease-out both; }
.intro-art.run.pan-2 { animation: pan2 22s ease-out both; }
.intro-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(14, 10, 6, .92) 0%, rgba(14, 10, 6, .55) 38%, rgba(14, 10, 6, .1) 70%, rgba(14, 10, 6, .35) 100%); }
.intro-skip { position: absolute; top: 14px; right: 16px; background: rgba(20, 16, 11, .55); border: 1px solid rgba(243, 234, 215, .35); border-radius: 999px; padding: 6px 14px; cursor: pointer; font: 500 14px "Alegreya Sans", system-ui, sans-serif; }
.intro-text { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(720px, calc(100% - 32px)); cursor: pointer; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
.intro-kicker { font: 500 14px "Alegreya Sans", system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: #e0a36b; margin-bottom: 6px; animation: introLine 1s ease both; }
.intro-title { margin: 0 0 10px; font: 700 clamp(40px, 9vw, 76px)/1 "Alegreya", Georgia, serif; letter-spacing: .04em; animation: introLine 1.4s ease both; }
.intro-line { margin: 0 0 12px; font-size: clamp(18px, 2.6vw, 23px); line-height: 1.5; animation: introLine 1s ease both; }
.intro-nav { position: absolute; left: 0; right: 0; bottom: 20px; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 0 16px; }
.intro-dots { display: flex; gap: 8px; }
.intro-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(243, 234, 215, .3); }
.intro-dots i.on { background: #e0a36b; }
.intro-back, .intro-next { background: rgba(20, 16, 11, .55); border: 1px solid rgba(243, 234, 215, .45); border-radius: 999px; padding: 8px 20px; cursor: pointer; font: 600 16px "Alegreya Sans", system-ui, sans-serif; min-height: 40px; }
.intro-next { background: var(--accent); border-color: var(--accent); }
.intro-back:focus-visible, .intro-next:focus-visible, .intro-skip:focus-visible { outline: 2px solid #e0a36b; outline-offset: 2px; }
@keyframes introIn { from { opacity: 0; } }
@keyframes introLine { from { opacity: 0; transform: translateY(10px); } }
@keyframes pan0 { from { transform: scale(1.02) translate(1.5%, 0); } to { transform: scale(1.12) translate(-1.5%, -1%); } }
@keyframes pan1 { from { transform: scale(1.12) translate(-1.5%, 0); } to { transform: scale(1.02) translate(1.5%, 1%); } }
@keyframes pan2 { from { transform: scale(1.02) translate(0, 1.5%); } to { transform: scale(1.12) translate(0, -1.5%); } }
@media (max-width: 600px) { .intro-text { bottom: 88px; } }
