:root {
  color-scheme: dark;
  --bg: #0e151a;
  --panel: #151f25;
  --edge: #2e4147;
  --text: #f3eadc;
  --muted: #aab9ba;
  --accent: #f3b86e;
  font: 16px/1.5 system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .25em; }
.top { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: 1.15rem max(1rem, calc((100% - 1040px) / 2)); border-bottom: 1px solid var(--edge); }
.top a { text-decoration: none; }
.brand { color: var(--text); font: bold clamp(1.05rem, 3vw, 1.35rem) monospace; letter-spacing: .07em; }
.brand span { color: var(--accent); }
nav { display: flex; flex-wrap: wrap; gap: clamp(.65rem, 3vw, 1.5rem); }
nav a { color: var(--text); }
nav a:hover, nav a[aria-current] { color: var(--accent); }
main { width: min(1040px, calc(100% - 2rem)); margin: clamp(1.75rem, 5vw, 4rem) auto; }
h1, h2, p { margin: 0 0 .85rem; }
h1 { font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1.12; letter-spacing: -.05em; }
h2 { font-size: 1.3rem; }
.muted, small { color: var(--muted); }
.section-label { font: .8rem monospace; color: var(--accent); letter-spacing: .1em; }
.panel { background: var(--panel); border: 1px solid var(--edge); padding: clamp(1rem, 4vw, 1.6rem); margin-block: 1.2rem; }
.scene { margin: 1.5rem 0; border: 1px solid var(--edge); background: #0f171c; }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.map-stage { position: relative; width: min(100%, 96vh); margin-inline: auto; }
form { display: grid; gap: .9rem; max-width: 34rem; }
label { display: grid; gap: .25rem; }
input, select, button { font: inherit; border: 1px solid var(--edge); padding: .55rem .8rem; color: var(--text); background: var(--bg); width: 100%; }
button { width: fit-content; cursor: pointer; color: #201910; background: var(--accent); font-weight: 650; }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: .55rem; }
li { margin-block: .35rem; overflow-wrap: anywhere; }
ul { padding-left: 1.2rem; }
[role=alert] { color: #ffb6a2; }
[hidden] { display: none !important; }
form > div > label { margin-bottom: .75rem; }
.map-stage { overflow: hidden; }
.map-draggable { cursor: grab; touch-action: none; user-select: none; }
.map-interior, .map-enterable { cursor: pointer; }
.map-dragging { cursor: grabbing; }
.welcome { cursor: pointer; display: grid; justify-items: center; align-content: center; min-height: min(36rem, 76dvh); text-align: center; }
.welcome-character { display: block; width: min(15rem, 58vw, 30dvh); height: auto; aspect-ratio: 3 / 4; object-fit: contain; margin: 0 0 .8rem 1rem; }
.welcome h1 { font-size: clamp(2rem, 5.5vw, 3.65rem); max-width: 20ch; }
.welcome p { max-width: 42ch; color: var(--muted); margin: .2rem 0 1.45rem; }
.map-viewport { position: relative; }
.map-arrival { animation: map-arrival .85s ease-out both; }
@keyframes map-arrival { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .map-arrival { animation: none; } }
body.world-only { overflow: hidden; }
.world-only .top, .world-only .world-overview > :not(.scene) { display: none; }
.world-only main { width: 100%; height: 100dvh; margin: 0; }
.world-only .welcome { background: radial-gradient(ellipse at 50% 41%, #273930 0%, #142023 30%, var(--bg) 67%); height: 100%; min-height: 0; padding: 1.25rem; overflow: auto; }
.world-only .world-overview, .world-only .scene { height: 100%; }
.world-only .scene {
  width: 100%;
  margin: 0;
  border: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}
.world-only .map-viewport {
  overflow: hidden;
  container-type: size;
}
.world-only .map-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, 133.333cqh);
  margin: 0;
  transform: translate(-50%, -50%);
}
.welcome .welcome-hint { color: var(--accent); margin: 0; font-size: .88rem; }
.scene { position: relative; }
.sky-clock {
  position: absolute;
  top: max(.8rem, env(safe-area-inset-top));
  left: max(.8rem, env(safe-area-inset-left));
  inline-size: 7rem;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: .5rem .65rem .42rem;
  color: #f6e5ca;
  background: #111a20e6;
  border: 1px solid #49534e;
  border-radius: .6rem;
  font: .85rem ui-monospace, monospace;
  pointer-events: none;
}
.sky-horizon {
  position: relative;
  grid-column: 1 / -1;
  height: 1.65rem;
  margin-bottom: .35rem;
  border-bottom: 1px solid #a48b65;
}
.sky-horizon::before {
  content: '';
  position: absolute;
  inset: .15rem 0 0;
  border: 1px dashed #8b785e;
  border-bottom: 0;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.sky-body {
  position: absolute;
  transform: translate(-50%, 50%);
  color: #ffd289;
  font: 1rem/1 system-ui, sans-serif;
  text-shadow: 0 0 .4rem #f3b86e88;
}
.sky-night .sky-body { color: #c6dbff; text-shadow: 0 0 .4rem #93b4f588; }
.sky-temperature { color: #aab9ba; justify-self: end; }
.sky-autumn:not(.sky-night) .sky-body { color: #dec39a; text-shadow: none; }
.character-profile {
  padding: 0;
  width: min(22rem, calc(100vw - 2rem));
  border: 1px solid var(--edge);
  background: #152027;
  color: var(--text);
  border-radius: .65rem;
}
.character-profile::backdrop { background: #080e13a8; }
.character-profile article { padding: 1.3rem; }
.character-profile h3 { margin: 1.1rem 0 .45rem; color: var(--accent); font-size: .95rem; }
.character-profile dl { display: grid; grid-template-columns: 1fr auto; gap: .45rem 1rem; margin: 0; }
.character-profile dt { color: var(--muted); }
.character-profile dd { margin: 0; font-variant-numeric: tabular-nums; }
.character-profile ul { margin-block: 0; }
.world-finances {
  width: auto;
  position: absolute;
  top: max(.8rem, env(safe-area-inset-top));
  right: max(.8rem, env(safe-area-inset-right));
  padding: .5rem .75rem;
  color: #f6e5ca;
  background: #111a20e6;
  border: 1px solid #49534e;
  border-radius: .6rem;
  text-decoration: none;
}
.world-finances:hover { color: var(--accent); }
.finance-book {
  width: min(33rem, calc(100vw - 1.3rem));
  max-height: 84dvh;
  padding: .55rem;
  border: 1px solid #735438;
  border-radius: .45rem .8rem .8rem .45rem;
  background: #35281e;
  color: #38281d;
  box-shadow: .2rem .35rem 0 #1e1713, 0 1.5rem 4rem #0009;
}
.finance-book::backdrop { background: #080e13a8; }
.finance-book-cover {
  max-height: calc(84dvh - 1.1rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #ebd5a9;
  border: 1px solid #a87e54;
  border-left: .4rem solid #b18b5f;
}
.finance-book header, .finance-book footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .55rem .85rem;
  background: #d7b888;
}
.finance-book header h2 { margin: 0; font: bold 1.2rem Georgia, serif; }
.finance-book button {
  min-width: 44px;
  min-height: 44px;
  padding: .25rem;
  background: #563926;
  color: #fff0d3;
  font-size: 1.25rem;
}
.finance-book button:disabled { cursor: default; }
.finance-sheet {
  min-height: 12rem;
  max-height: 52dvh;
  overflow: auto;
  padding: .85rem 1rem 1.05rem;
  touch-action: pan-y;
  background: linear-gradient(90deg, #c49a6455, transparent 10%), #efdbb4;
}
.finance-sheet h3 { margin: .2rem 0 .45rem; font: bold clamp(1.35rem, 5vw, 1.8rem) Georgia, serif; }
.finance-entry-category { margin: 0; color: #6b4c37; font: .8rem ui-monospace, monospace; }
.finance-sheet dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: .45rem .7rem; }
.finance-sheet dt { color: #614631; }
.finance-sheet dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.finance-sheet summary { color: #61371e; cursor: pointer; font-weight: 650; }
.finance-book-page { font: .85rem ui-monospace, monospace; }
.finance-book { border-radius: 0; border: 3px solid #735438; box-shadow: .24rem .3rem 0 #16110e, .46rem .53rem 0 #302116, 0 1.5rem 4rem #0009; }
.finance-book-cover { grid-template-rows: auto auto auto minmax(0, 1fr) auto; border-radius: 0; }
.finance-book-tabs, .finance-period {
  display: flex;
  gap: .3rem;
  padding: .3rem .6rem;
  background: #d7b888;
}
.finance-book-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.finance-book-tabs button {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: .2rem .12rem;
  font: bold clamp(.62rem, 2.7vw, .8rem) monospace;
  border: 2px solid #806142;
  background: #e7cb9e;
  color: #38281d;
}
.finance-book-tabs button[aria-current=page] { background: #563926; color: #fff0d3; }
.finance-period select, .finance-period input, .finance-sheet input, .finance-sheet select {
  min-width: 0;
  border: 1px solid #a87e54;
  background: #f3e1bd;
  color: #38281d;
  color-scheme: light;
}
.finance-period select, .finance-period input { padding: .3rem; font-size: .85rem; }
.finance-sheet { min-height: 0; }
.finance-sheet h4 { margin: .75rem 0 .4rem; }
.finance-total { font: bold clamp(1.3rem, 6vw, 2.15rem) monospace; }
.finance-conclusion { border-top: 1px solid #bd986e; padding-top: .6rem; }
.finance-obligation { border-top: 1px solid #bd986e; padding-block: .6rem; }
.finance-obligation > summary { padding-block: .2rem; }
.finance-obligation > p, .finance-obligation form { margin-top: .45rem; }
.finance-sheet .panel { background: #e6ca9d; border-color: #b28e63; margin-block: .55rem 0; }
.finance-sheet .panel h2 { display: none; }
.finance-sheet [role=alert] { color: #862f26; }
.world-finances {
  background: transparent;
  border: 0;
  padding: .25rem;
  color: #ebd5a9;
}
.world-book-object {
  display: grid;
  place-items: center;
  width: 4.4rem;
  height: 4.9rem;
  border: 3px solid #392819;
  border-left: 7px solid #563824;
  background: #815336;
  box-shadow: inset 0 0 0 2px #a67648, 3px 4px 0 #d9b786, 6px 7px 0 #302219;
  image-rendering: pixelated;
}
.world-book-object::before {
  content: '';
  width: 52%;
  height: 45%;
  border: 2px solid #b78b56;
  box-shadow: inset 0 0 0 2px #774b31;
  background: #956741;
}
.world-finances:hover .world-book-object { background: #9c6842; }
.character-description { color: #c3ccca; font-size: .92rem; }
.character-profile article > p:last-child { margin: .85rem 0 0; font-size: .85rem; }
.chinar-info h2 { color: #b6dfaf; }
.profile-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.profile-header h2:focus { outline: none; }
.profile-finance-book { padding: .18rem; border: 0; background: transparent; }
.profile-finance-book .world-book-object { width: 2rem; height: 2.35rem; border-width: 2px 2px 2px 4px; }
.profile-finance-book:hover .world-book-object { background: #9c6842; }
.profile-property { margin-top: .9rem; }
.profile-property summary { cursor: pointer; color: var(--accent); font-weight: 650; }
.profile-possessions { padding: 0; list-style: none; }
.profile-possessions li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: .25rem 0 0; padding: .25rem .4rem; border-bottom: 1px solid #35454a; }
.profile-possessions li strong { font-size: .88rem; font-weight: 600; }
.profile-possessions li small { display: block; font-size: .75rem; }
.profile-location {
  min-width: 36px;
  min-height: 36px;
  padding: .1rem;
  color: var(--accent);
  background: #1d2b31;
  border: 1px solid #3a4b50;
  text-decoration: none;
}
.profile-location:hover { background: #26363b; border-color: #947a53; }
.world-only .map-room-view .map-stage { width: min(100cqw, 133.333cqh); }
