:root {
  color-scheme: light;
  --ink: #173f46;
  --deep-ink: #102f35;
  --sea: #1f6670;
  --sea-light: #66a7a5;
  --paper: #f6eedc;
  --paper-bright: #fffaf0;
  --paper-deep: #e7d7bb;
  --line: rgba(23, 63, 70, .18);
  --terracotta: #bd674d;
  --terracotta-deep: #934a3a;
  --sage: #758f70;
  --gold: #d4a34f;
  --shadow: 0 16px 40px rgba(14, 45, 50, .16), 0 2px 8px rgba(14, 45, 50, .08);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--ink); }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid #e6bb60; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: .75rem; left: .75rem; z-index: 50; padding: .65rem .9rem; background: var(--paper-bright); color: var(--ink); transform: translateY(-160%); transition: transform .2s; }
.skip-link:focus { transform: translateY(0); }

.app { height: 100vh; min-height: 620px; display: grid; grid-template-rows: 74px 1fr; background: #173f46; }
.topbar { z-index: 10; display: flex; align-items: center; gap: 1.4rem; padding: .65rem clamp(1rem, 3vw, 3.2rem); color: var(--paper); background: rgba(16, 47, 53, .96); border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-lockup { display: flex; align-items: center; gap: .75rem; min-width: 230px; }
.mark { width: 31px; height: 42px; color: #eac276; flex: none; }
.eyebrow { margin: 0 0 .22rem; color: var(--sea-light); font-size: .61rem; font-weight: 800; letter-spacing: .14em; line-height: 1.15; text-transform: uppercase; }
.topbar .eyebrow { color: #9cc6bc; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; color: var(--paper-bright); font: 500 1.48rem/1 var(--serif); letter-spacing: -.03em; }
.day-readout { display: flex; align-items: baseline; gap: .55rem; min-width: 155px; color: #a7c4be; font-size: .74rem; }
.day-readout strong { color: var(--paper); font: 600 1.05rem var(--serif); letter-spacing: .03em; }
.day-readout small { color: #79a39d; font-size: .72rem; }
.resources { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.resource { display: flex; align-items: center; gap: .34rem; color: var(--paper); font-size: .82rem; font-variant-numeric: tabular-nums; }
.resource-icon { display: grid; place-items: center; width: 21px; height: 21px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: #e9bd68; font-size: .78rem; }
.timber-icon { border-radius: 4px; color: #a9c58b; font-size: .65rem; transform: rotate(45deg); }
.rep-icon { border: 0; color: #e8b6a2; }
.resource-label { color: #8eb2ac; font-size: .61rem; text-transform: uppercase; letter-spacing: .08em; }
.top-actions { display: flex; gap: .35rem; margin-left: .5rem; }
.speed-button { height: 32px; padding: 0 .55rem; border: 1px solid rgba(255,255,255,.18); border-radius: 99px; background: transparent; color: #a9cbc3; font-size: .65rem; font-weight: 800; }
.speed-button:hover { background: rgba(255,255,255,.13); color: #f4d18a; }
.icon-button { width: 32px; height: 32px; padding: 0; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; background: transparent; color: #a9cbc3; transition: .2s ease; }
.icon-button:hover, .icon-button[aria-pressed=true] { background: rgba(255,255,255,.13); color: #f4d18a; }

.game-shell { position: relative; min-height: 0; overflow: hidden; background: #11505a; }
.scene-wrap { position: absolute; inset: 0; }
#harbour { display: block; width: 100%; height: 100%; }
.scene-compass { position: absolute; right: 2rem; bottom: 1.8rem; display: flex; align-items: center; gap: .55rem; color: rgba(255,250,240,.7); font-size: .58rem; font-weight: 800; letter-spacing: .15em; text-shadow: 0 1px 2px rgba(0,0,0,.15); }
.scene-compass i { display: block; width: 23px; height: 23px; border: 1px solid rgba(255,250,240,.7); border-radius: 50%; position: relative; }
.scene-compass i::after { content: ''; position: absolute; left: 10px; top: 3px; width: 1px; height: 15px; background: currentColor; }
.scene-hint { position: absolute; left: 50%; bottom: 1.55rem; transform: translateX(-50%); padding: .43rem .8rem; border: 1px solid rgba(255,250,240,.34); border-radius: 99px; background: rgba(16,47,53,.28); color: rgba(255,250,240,.82); font-size: .66rem; letter-spacing: .05em; pointer-events: none; }
.panel { background: var(--paper); box-shadow: var(--shadow); opacity: 1; }
.plans, .context { position: absolute; z-index: 4; top: 1.4rem; width: 264px; max-height: calc(100% - 8.6rem); overflow: auto; border: 1px solid rgba(255,255,255,.48); }
.plans { left: 1.4rem; }
.context { right: 1.4rem; width: min(326px, calc(100% - 2.8rem)); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; padding: 1.15rem 1.2rem .75rem; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0; color: var(--deep-ink); font: 500 1.22rem/1.04 var(--serif); letter-spacing: -.025em; }
.close-mobile { display: none; border: 0; background: transparent; color: var(--sea); font-size: 1.5rem; line-height: 1; }
.building-list { padding: .45rem .5rem .65rem; }
.place-button { display: grid; grid-template-columns: 27px 1fr auto; align-items: center; gap: .62rem; width: 100%; padding: .66rem .65rem; border: 0; border-bottom: 1px solid rgba(23,63,70,.1); background: transparent; text-align: left; }
.place-button:hover, .place-button[aria-current=true] { background: #efe0c8; }
.place-button[aria-current=true] { box-shadow: inset 3px 0 var(--terracotta); }
.place-mark { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--sea-light); border-radius: 50%; color: var(--sea); font: .72rem var(--serif); }
.place-name { display: block; color: var(--deep-ink); font-size: .74rem; font-weight: 750; }
.place-level { display: block; margin-top: .15rem; color: #70827e; font-size: .61rem; }
.place-status { color: var(--terracotta); font-size: .64rem; font-weight: 800; }
.paper-link { display: flex; justify-content: space-between; width: calc(100% - 2rem); margin: .1rem 1rem 1rem; padding: .7rem 0 0; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--terracotta-deep); font-size: .68rem; font-weight: 800; }
.paper-link:hover, .text-button:hover { color: var(--sea); }

.worker-dock { position: absolute; z-index: 4; bottom: 1.35rem; left: 50%; width: min(390px, calc(100% - 580px)); min-width: 260px; transform: translateX(-50%); padding: .72rem .85rem .8rem; border: 1px solid rgba(255,255,255,.4); }
.dock-heading { display: flex; justify-content: space-between; align-items: baseline; padding: 0 .2rem .38rem; }
.dock-heading h2 { font-size: .84rem; }
.resident-count { color: #72857d; font-size: .61rem; }
.worker-list { display: flex; gap: .5rem; }
.worker-card { flex: 1; min-width: 0; padding: .48rem .54rem; border: 1px solid rgba(23,63,70,.13); background: rgba(255,250,240,.55); }
.worker-card strong { display: block; font: 600 .86rem var(--serif); }
.worker-card small { display: block; overflow: hidden; color: #6f7d79; font-size: .61rem; text-overflow: ellipsis; white-space: nowrap; }
.worker-card .worker-habit { color: #8a7764; font-family: var(--serif); font-style: italic; }
.worker-task { margin-top: .42rem; color: var(--terracotta-deep); font-size: .61rem; }
.progress-track { height: 4px; margin-top: .35rem; overflow: hidden; background: #deceb3; }
.progress-fill { height: 100%; background: var(--terracotta); transition: width .25s ease; }
.idle-label { margin-top: .42rem; color: var(--sage); font-size: .61rem; }

.context #contextBody { padding: .9rem 1.2rem 1.2rem; }
.place-kicker { margin-bottom: .3rem; color: var(--terracotta-deep); font-size: .67rem; font-weight: 800; }
.context-copy { margin: .7rem 0 1rem; color: #516965; font-size: .74rem; line-height: 1.55; }
.benefit { margin: .72rem 0; padding: .62rem .7rem; border-left: 3px solid var(--sage); background: #e8e5cf; color: #415b54; font-size: .68rem; line-height: 1.4; }
.objective-card { display: flex; align-items: baseline; justify-content: space-between; gap: .7rem; margin: .25rem 0 .8rem; padding: .6rem .7rem; border: 1px solid rgba(23,63,70,.13); background: #eee4ce; }
.objective-card strong { color: var(--deep-ink); font: 600 .75rem var(--serif); }
.objective-card p { margin: 0; color: var(--terracotta-deep); font-size: .65rem; font-weight: 800; }
.cost-line { display: flex; justify-content: space-between; align-items: center; margin: .85rem 0 .55rem; color: #61756f; font-size: .67rem; }
.cost { color: var(--deep-ink); font-weight: 800; }
.primary-button, .secondary-button, .danger-button { border: 0; border-radius: 2px; padding: .68rem .85rem; font-size: .68rem; font-weight: 800; letter-spacing: .01em; transition: transform .15s, background .15s; }
.primary-button { background: var(--terracotta); color: #fff8eb; box-shadow: 0 3px 0 var(--terracotta-deep); }
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.primary-button:active { transform: translateY(1px); box-shadow: none; }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }
.button-icon { margin-right: .35rem; }
.secondary-button { border: 1px solid var(--line); background: var(--paper-bright); color: var(--ink); }
.danger-button { border: 1px solid rgba(147,74,58,.28); background: transparent; color: var(--terracotta-deep); }
.text-button { padding: 0; border: 0; background: transparent; color: var(--terracotta-deep); font-size: .68rem; font-weight: 800; }
.action-row { display: flex; gap: .45rem; align-items: center; }
.action-row .primary-button { flex: 1; }
.contract-list { display: grid; gap: .45rem; }
.contract-card { padding: .65rem .7rem; border: 1px solid var(--line); background: rgba(255,250,240,.5); }
.contract-card h3 { margin: 0 0 .2rem; color: var(--deep-ink); font: 600 .82rem var(--serif); }
.contract-card p { margin: 0 0 .48rem; color: #6a7b76; font-size: .64rem; line-height: 1.4; }
.contract-meta { display: flex; align-items: center; justify-content: space-between; color: var(--terracotta-deep); font-size: .61rem; }
.contract-meta button { padding: .34rem .5rem; border: 1px solid rgba(147,74,58,.35); background: transparent; color: var(--terracotta-deep); font-size: .61rem; font-weight: 800; }
.contract-meta button:disabled { color: #89948d; border-color: var(--line); cursor: not-allowed; }
.policy-picker { display: grid; gap: .4rem; margin: 1rem 0; padding-top: .85rem; border-top: 1px solid var(--line); }
.policy-picker legend { padding: 0; color: var(--deep-ink); font: 600 .78rem var(--serif); }
.policy-option { display: flex; gap: .5rem; align-items: flex-start; padding: .42rem; border: 1px solid transparent; color: #62736f; font-size: .64rem; cursor: pointer; }
.policy-option:has(input:checked) { border-color: var(--sea-light); background: #e5eee7; color: var(--ink); }
.policy-option input { accent-color: var(--sea); margin-top: .14rem; }
.policy-option strong { display: block; color: var(--deep-ink); font-size: .67rem; }
.policy-option small { display: block; margin-top: .15rem; line-height: 1.35; }
.locked-note { color: #8a746d; font-size: .65rem; line-height: 1.4; }

.newspaper { position: absolute; z-index: 4; left: 1.4rem; bottom: 1.35rem; width: 265px; padding: .95rem 1rem 1rem; border-top: 3px solid var(--terracotta); transform: rotate(-1deg); }
.newspaper h2 { margin: .15rem 0 .35rem; font-size: 1.12rem; }
.newspaper p:not(.eyebrow) { display: -webkit-box; margin-bottom: .55rem; overflow: hidden; color: #63756f; font: .72rem/1.4 var(--serif); -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.mobile-tabs { display: none; }
.welcome-card { position: absolute; z-index: 13; left: 50%; top: 50%; width: min(440px, calc(100% - 2rem)); padding: 2.1rem 2.2rem 1.8rem; transform: translate(-50%, -50%); text-align: center; box-shadow: 0 25px 60px rgba(12,39,44,.28); }
.welcome-card::before { content: ''; position: absolute; inset: 7px; border: 1px solid rgba(23,63,70,.16); pointer-events: none; }
.welcome-card h2 { position: relative; margin: .3rem auto .75rem; max-width: 350px; font-size: 1.85rem; line-height: 1.04; }
.welcome-card > p:not(.eyebrow):not(.fine-print) { position: relative; max-width: 320px; margin: 0 auto 1.25rem; color: #62756e; font: .82rem/1.55 var(--serif); }
.welcome-card .primary-button { position: relative; }
.fine-print { position: relative; margin: 1rem 0 0; color: #8a9485; font-size: .6rem; }
.recovery-banner { position: absolute; z-index: 12; left: 50%; bottom: 1.35rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(620px, calc(100% - 2rem)); padding: .85rem 1rem; border-left: 3px solid var(--terracotta); transform: translateX(-50%); }
.recovery-banner strong { display: block; color: var(--deep-ink); font: 600 .88rem var(--serif); }
.recovery-banner p:not(.eyebrow) { margin: .25rem 0 0; color: #697a73; font-size: .66rem; line-height: 1.35; }
.recovery-actions { display: flex; flex: none; gap: .4rem; }
.history-list { display: grid; gap: .55rem; margin: .7rem 0; }
.history-item { padding-left: .65rem; border-left: 2px solid var(--sea-light); }
.history-item strong { display: block; color: var(--deep-ink); font: 600 .72rem var(--serif); }
.history-item p { margin: .18rem 0 0; color: #6a7973; font-size: .62rem; line-height: 1.4; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 1.2rem; max-width: min(420px, calc(100% - 2rem)); padding: .62rem .9rem; border: 1px solid rgba(255,255,255,.25); background: var(--deep-ink); color: var(--paper); font-size: .71rem; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.save-status { position: fixed; z-index: 11; right: 1.35rem; bottom: .8rem; color: rgba(255,250,240,.72); font-size: .59rem; }
.journal-dialog { width: min(640px, calc(100% - 2rem)); max-height: min(760px, calc(100% - 2rem)); border: 0; padding: 0; color: var(--ink); background: var(--paper-bright); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.journal-dialog::backdrop { background: rgba(10,35,38,.65); backdrop-filter: blur(2px); }
.dialog-inner { position: relative; padding: 2rem clamp(1.4rem, 5vw, 3.2rem) 2.1rem; }
.dialog-close { position: absolute; top: 1rem; right: 1rem; border: 0; background: transparent; color: var(--sea); font-size: 1.5rem; }
.journal-dialog h2 { max-width: 520px; margin: .2rem 0 .7rem; font-size: 2rem; }
.journal-lede { max-width: 520px; color: #63756f; font: 1rem/1.55 var(--serif); }
.journal-rule { height: 1px; margin: 1.5rem 0 .7rem; background: var(--line); }
.journal-events { display: grid; gap: .7rem; }
.journal-entry { padding: .65rem 0 .7rem 1rem; border-left: 2px solid var(--sea-light); }
.journal-entry h3 { margin: 0 0 .2rem; color: var(--deep-ink); font: 600 .9rem var(--serif); }
.journal-entry p { margin: 0; color: #667871; font-size: .7rem; line-height: 1.45; }
.journal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.settings-popover { position: fixed; z-index: 25; top: 66px; right: 1rem; width: 220px; padding: .9rem; border: 1px solid var(--line); background: var(--paper-bright); box-shadow: var(--shadow); color: #5d716b; font-size: .68rem; }
.settings-popover label { display: flex; gap: .45rem; color: var(--ink); font-weight: 700; }
.settings-popover p { margin: .7rem 0 0; line-height: 1.4; }

@media (max-width: 980px) {
  .topbar { gap: .75rem; padding-inline: 1rem; }
  .brand-lockup { min-width: 0; }
  .day-readout { min-width: 0; }
  .resource-label { display: none; }
  .plans { left: .8rem; }
  .context { right: .8rem; }
  .newspaper { left: .8rem; }
  .worker-dock { width: min(360px, calc(100% - 570px)); }
}
@media (max-width: 700px) {
  body { overflow: hidden; }
  .app { min-height: 560px; grid-template-rows: 92px 1fr; }
  .topbar { gap: .55rem; padding: .5rem .75rem; }
  .mark { width: 24px; height: 34px; }
  .brand-lockup { flex: 0 1 auto; }
  .brand-lockup .eyebrow { display: none; }
  h1 { font-size: 1.2rem; }
  .day-readout { display: grid; gap: 0; font-size: .58rem; }
  .day-readout strong { font-size: .91rem; }
  .day-readout small { font-size: .6rem; }
  .resources { gap: .24rem; margin-left: auto; }
  .resource { gap: .12rem; font-size: .72rem; }
  .resource-icon { width: 17px; height: 17px; font-size: .64rem; }
  .resource-label { display: inline; font-size: .48rem; letter-spacing: .03em; }
  .topbar { position: relative; align-content: flex-start; }
  .top-actions { position: absolute; right: .75rem; bottom: .42rem; margin-left: 0; }
  .speed-button { height: 28px; padding-inline: .45rem; }
  .icon-button { width: 28px; height: 28px; }
  .scene-wrap { top: 0; right: 0; bottom: 0; left: 0; height: auto; transform: none; }
  .plans, .context { top: auto; right: .6rem; bottom: 3.75rem; left: .6rem; width: auto; max-height: min(70vh, 520px); visibility: hidden; opacity: 0; pointer-events: none; transform: translateY(14px); transition: opacity .2s ease, transform .2s ease, visibility .2s ease; }
  .plans.drawer-open, .context.drawer-open { visibility: visible; opacity: 1; pointer-events: auto; transform: translateY(0); }
  .close-mobile { display: block; }
  .newspaper { top: auto; right: .6rem; bottom: 3.75rem; left: .6rem; width: auto; visibility: hidden; opacity: 0; pointer-events: none; transform: translateY(14px) rotate(0); transition: opacity .2s ease, transform .2s ease, visibility .2s ease; }
  .newspaper.drawer-open { visibility: visible; opacity: 1; pointer-events: auto; transform: translateY(0); }
  .worker-dock { right: .6rem; bottom: 4.25rem; left: .6rem; width: auto; min-width: 0; transform: none; }
  .worker-card { padding: .4rem; }
  .worker-card small { font-size: .57rem; }
  .scene-hint { bottom: 7.3rem; font-size: .59rem; }
  .scene-compass { right: .8rem; bottom: 7.2rem; }
  .mobile-tabs { position: absolute; z-index: 8; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); height: 55px; border-top: 1px solid rgba(255,255,255,.15); background: rgba(16,47,53,.96); }
  .mobile-tabs button { display: grid; place-content: center; gap: .15rem; border: 0; background: transparent; color: #c0d4cb; font-size: .59rem; }
  .mobile-tabs button span { font-size: 1rem; }
  .mobile-tabs button:hover { background: rgba(255,255,255,.1); color: #f2cf87; }
  .save-status { right: .6rem; bottom: 57px; font-size: .53rem; }
  .welcome-card { padding: 1.6rem 1.2rem 1.35rem; }
  .welcome-card h2 { font-size: 1.55rem; }
  .recovery-banner { right: .6rem; bottom: 4.25rem; left: .6rem; display: block; width: auto; transform: none; }
  .recovery-actions { margin-top: .7rem; }
  .settings-popover { top: 86px; right: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
