/* hud.css — the in-game interface. One look throughout: warm paper panels with a pressed-paper
   edge, teal for actions, gold for coins, and pixel-art icons (icons.js) that match the voxels. */
:root {
  --ink: #30281e;
  --muted: #6b5c47;
  --paper: #fff6e4;
  --paper-2: #f7e8cb;
  --linen: #f4e5cb;
  --edge: #c9ad80;
  --edge-dark: #a8895a;
  --rule: #e6d4b4;
  --river: #245e5a;
  --river-dark: #174541;
  --light-river: #dcebdf;
  --gold: #c07a1e;
  --red: #9a3b30;
  --shadow: 0 2px 0 #d6bf95, 0 10px 24px #4a32141f;
  --left: max(12px, env(safe-area-inset-left));
  --right: max(12px, env(safe-area-inset-right));
  --top: max(12px, env(safe-area-inset-top));
  --bottom: max(12px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e2c48e; }
body { font: 600 14px/1.35 "Trebuchet MS", "Avenir Next", sans-serif; color: var(--ink); user-select: none; }
[hidden] { display: none !important; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; flex: none; fill: currentColor; shape-rendering: crispEdges; }
button, summary { touch-action: manipulation; }
button:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #137e77; outline-offset: 2px; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }
#view.placing { cursor: crosshair; }
#view.panning { cursor: grabbing; }

.panel { background: var(--paper); border: 1px solid var(--edge); border-radius: 16px; box-shadow: var(--shadow); }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

/* Buttons: raised paper that presses down. Primary is teal, quiet has no frame. */
.ui-button {
  min-height: 44px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--edge); border-radius: 12px; background: var(--paper); color: var(--ink);
  box-shadow: 0 3px 0 var(--edge-dark); cursor: pointer; font: inherit;
  transition: transform .08s, box-shadow .08s, background .12s;
}
.ui-button:hover:not(:disabled) { background: #fffaf0; }
.ui-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge-dark); }
.ui-button.primary { background: var(--river); border-color: var(--river-dark); color: #fff8e8; box-shadow: 0 3px 0 var(--river-dark); }
.ui-button.primary:hover:not(:disabled) { background: #2b6d68; }
.ui-button.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--river-dark); }
.ui-button.quiet { background: transparent; border-color: transparent; box-shadow: none; }
.ui-button.quiet:hover:not(:disabled) { background: var(--paper-2); }
.ui-button.quiet:active:not(:disabled) { transform: none; box-shadow: none; background: var(--rule); }
.ui-button.icon-button { min-width: 44px; padding: 8px; }
.ui-button:disabled { opacity: .5; cursor: default; box-shadow: none; transform: translateY(2px); }
.ui-button.quiet:disabled { transform: none; }
.ui-button svg { width: 18px; height: 18px; }
.danger { color: var(--red); }

/* --- top: resources, goal, menu -------------------------------------------------------------- */
#hud {
  position: fixed; top: var(--top); left: var(--left); right: var(--right); z-index: 5;
  /* The stats never run under the goal: when they grow (cargo, a production bonus), the goal moves right. */
  display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(280px, 380px) minmax(0, 1fr);
  gap: 8px 16px; align-items: start; pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-identity { display: flex; align-items: flex-start; gap: 8px; min-width: 0; width: fit-content; }
#stats { display: flex; align-items: center; min-height: 48px; padding: 4px 6px; border-radius: 14px; font-variant-numeric: tabular-nums; }
.stat { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 9px; white-space: nowrap; font-size: 15px; }
.stat + .stat { border-inline-start: 1px solid var(--rule); }
.stat svg { width: 18px; height: 18px; color: var(--river); }
.stat:first-child { font-size: 17px; font-weight: 700; }
.stat:first-child svg { width: 20px; height: 20px; color: var(--gold); }
.stat.cargo svg { color: #9a8e7a; }
.stat.cargo .cedar-icon { color: #8a5a32; margin-inline-start: 2px; }
.day-clock { display: inline-grid; }
.day-clock svg { grid-area: 1 / 1; color: var(--gold); }
.day-icon { opacity: calc(1 - var(--night, 0)); }
.night-icon { opacity: var(--night, 0); color: #5a6f9a !important; }
#crewToggle { min-height: 38px; border: 0; border-inline-start: 1px solid var(--rule); border-radius: 0; background: transparent; color: inherit; font: inherit; font-size: 15px; cursor: pointer; }
#crewToggle:hover { background: var(--light-river); }

#goal { min-width: 0; display: grid; gap: 6px; }
#goalOpen { width: 100%; min-width: 0; padding: 8px 12px 9px; display: grid; gap: 6px; text-align: left; color: inherit; font: inherit; cursor: pointer; }
#goalOpen:hover { background: #fffaf0; }
.goal-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
#goalLabel { flex: none; }
#goalText { min-width: 0; flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#missionDot { flex: none; align-self: center; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px #f6e2bd; }
#goal .bar, .progress-card .bar { display: block; height: 6px; border-radius: 6px; background: var(--rule); overflow: hidden; }
#goal .fill, .progress-card .fill { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--river); transition: width .2s; }
#seasonStat { min-height: 38px; border: 0; border-inline-start: 1px solid var(--rule); border-radius: 0; background: transparent; color: inherit;
  font: inherit; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
#seasonStat:hover { background: var(--light-river); }
#seasonStat[data-season="shemu"] svg { color: var(--gold); }
#seasonStat[data-season="akhet"] svg { color: #2f6f92; }
#crewToggle { position: relative; }
.badge { position: absolute; top: -10px; right: -8px; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--gold); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--paper); }
#weather { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px;
  background: #f6e2bd; font-size: 12px; color: #78501e; }
#weather[data-severity="3"], #weather[data-severity="4"] { background: #f4d3c6; color: var(--red); }
#weather svg { width: 16px; height: 16px; }
#weatherImpact { display: block; font-size: 11px; font-weight: 600; }
#weatherTime { margin-inline-start: auto; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
#visitorNote { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px; width: 100%;
  background: #f6e2bd; font: inherit; font-size: 12px; color: #78501e; text-align: left; cursor: pointer; }
#visitorNote[data-kind="thief"], #visitorNote[data-kind="croc"] { background: #f4d3c6; color: var(--red); }
#visitorNote[data-kind="feast"] { background: #dcebc8; color: #3d6a2c; }
#visitorNote svg { width: 16px; height: 16px; flex: none; }
#visitorDetail { display: block; font-size: 11px; font-weight: 600; }
#visitorTime { margin-inline-start: auto; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }

#townMenu { position: relative; z-index: 1; }
#townMenu > summary { list-style: none; }
#townMenu > summary::-webkit-details-marker { display: none; }
#townMenu[open] > summary { background: var(--light-river); transform: translateY(2px); box-shadow: 0 1px 0 var(--edge-dark); }
.menu-panel { position: absolute; bottom: calc(100% + 8px); right: 0; width: max-content; min-width: 190px; padding: 6px; display: grid; gap: 2px; }
.menu-panel .ui-button { justify-content: flex-start; }
.menu-panel .ui-button svg { color: var(--river); }
.menu-panel .danger svg { color: var(--red); }

/* --- bottom: tools, details card, camera ---------------------------------------------------- */
#controls {
  position: fixed; left: var(--left); right: var(--right); bottom: var(--bottom); z-index: 6;
  display: flex; justify-content: space-between; align-items: end; gap: 8px; pointer-events: none;
}
#townInfo { width: min(100%, 360px); min-width: 0; display: grid; justify-items: start; gap: 8px; }
#townInfo > *, #corner > * { pointer-events: auto; }
#corner { display: grid; justify-items: end; gap: 8px; }
#dock { display: flex; gap: 8px; }
#dock .ui-button { min-height: 50px; padding-inline: 18px; font-size: 15px; }
#dock .ui-button svg { width: 20px; height: 20px; }
#dock button[aria-expanded="true"], #dock button[aria-pressed="true"] { transform: translateY(2px); box-shadow: 0 1px 0 var(--river-dark); }
#clearTool[aria-pressed="true"] { background: #f6e2bd; border-color: var(--gold); box-shadow: 0 1px 0 #8a5414 !important; }
#cameraControls { display: flex; flex-direction: column; padding: 4px; gap: 2px;
  background: var(--paper); border: 1px solid var(--edge); border-radius: 14px; box-shadow: var(--shadow); }
#cameraControls .ui-button { background: transparent; border-color: transparent; box-shadow: none; border-radius: 10px; }
#cameraControls .ui-button:hover { background: var(--paper-2); }
#cameraControls .ui-button:active { transform: none; background: var(--rule); }
#cameraControls .ui-button svg { color: var(--river); }

#work, #placement { width: 100%; }
#work { padding: 12px 14px; max-height: min(54dvh, 300px); overflow: auto; animation: card-in 0.18s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } }
#work header, #buildPanel header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#work header { align-items: flex-start; }
#workTitle { display: block; margin-top: 2px; font: 700 20px/1.15 Georgia, serif; color: var(--river-dark); }
#workClose { margin: -6px -8px 0 0; }
#work p:not(.eyebrow) { margin: 6px 0; color: var(--muted); font-size: 13px; }
#workStatus { color: var(--ink) !important; }
#work progress { width: 100%; height: 8px; accent-color: var(--river); }
.work-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.work-actions:has(button:not([hidden])) { margin-top: 10px; }
.work-actions .ui-button { flex: 1 1 auto; font-size: 13px; }
#workUpgrade .cost::before { content: ' · '; }
#hint { padding: 7px 11px; border-radius: 12px; font-size: 12px; pointer-events: none; }
#placement { padding: 6px 6px 6px 14px; display: flex; align-items: center; gap: 6px; }
#placement > div { flex: 1; min-width: 0; }
#placementTitle, #placementHint { display: block; }
#placementTitle { color: var(--river-dark); }
#placementHint { font-size: 12px; color: var(--muted); }
#placementZone { display: block; color: var(--river); font-size: 11px; }
#placementZone::before { content: ''; display: inline-block; width: 12px; margin-right: 4px; vertical-align: middle; border-top: 2px dashed currentColor; }
#placement .ui-button { font-size: 13px; }

/* --- build tray: voxel art cards, available plans first ------------------------------------- */
#buildPanel {
  position: fixed; z-index: 8; left: var(--left); bottom: calc(var(--bottom) + 62px);
  width: min(640px, calc(100vw - var(--left) - var(--right))); max-height: min(66dvh, 520px);
  display: flex; flex-direction: column; padding: 12px 14px 14px;
}
#buildPanel header { justify-content: flex-start; gap: 10px; margin-bottom: 8px; }
#buildClose { margin: -4px -6px -4px auto; }
#buildPanel header .eyebrow { flex: 1; letter-spacing: .06em; text-transform: none; font-size: 12px; font-weight: 600; }
#buildPanel h2, #away h2, .sheet h2, #buildingPicker h2, #caravanPanel h2 { margin: 0; font: 700 24px/1.15 Georgia, serif; color: var(--river-dark); }
#build { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; overflow: auto; padding: 2px 2px 6px; }
#build .build-card {
  position: relative; min-width: 0; min-height: 0; display: grid; grid-template-rows: 70px auto auto;
  justify-items: center; align-items: end; gap: 3px; padding: 8px 4px 9px;
  background: var(--paper-2); border-color: #e2cba4; border-radius: 14px; box-shadow: 0 3px 0 #d9bf92;
}
#build .build-card:hover:not(:disabled) { background: #fbefd6; border-color: var(--river); }
#build .build-card[aria-pressed="true"] { border-color: var(--river); background: var(--light-river); }
#build .build-card:disabled { order: 1; opacity: 1; background: #efe3cc; box-shadow: none; transform: none; }
#build .build-art { width: 70px; height: 70px; object-fit: contain; filter: drop-shadow(0 3px 2px #6b4a2033); transition: transform .15s; pointer-events: none; }
#build .build-card:hover:not(:disabled) .build-art { transform: translateY(-2px) scale(1.04); }
#build .build-card:disabled .build-art { filter: grayscale(1) opacity(.45); }
#build .name { text-align: center; line-height: 1.15; font-size: 13px; }
#build .build-card:disabled .name { color: var(--muted); }
#build .key { position: absolute; top: 6px; left: 8px; min-width: 18px; padding: 1px 4px; border-radius: 6px; background: #fff8e8;
  border: 1px solid var(--rule); color: var(--muted); font-size: 10px; line-height: 14px; }
#build .cost { display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: #fff8e8;
  color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; }
#build .cost svg { width: 13px; height: 13px; color: var(--gold); }
#build .poor .cost { color: var(--red); }
#build .build-card:disabled .cost { background: transparent; color: var(--muted); font-size: 11px; }
#build .build-card:disabled .cost svg { color: var(--muted); width: 11px; height: 11px; }
#build .locked { display: inline-flex; align-items: center; gap: 4px; }
#build .build-card:disabled .price { display: none; }
#build .build-card:not(:disabled) .locked, #build .build-card:disabled .coin-mark { display: none; }

/* --- messages -------------------------------------------------------------------------------- */
#toasts { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 24px); width: max-content; display: grid; justify-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 8px 14px; border-radius: 99px; text-align: center; animation: toast 3.6s forwards; }
.toast.big { font-weight: 700; border-color: var(--gold); background: #fff1d2; }
.toast.storm { border-color: var(--red); color: var(--red); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-5px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.float { position: fixed; pointer-events: none; color: #fff6d0; text-shadow: 0 2px 0 #8a5a14, 0 0 6px #8a5a14;
  animation: rise 1.1s ease-out forwards; transform: translate(-50%, -50%); font-size: 18px; }
.float.bonus { font-size: 22px; color: #fff2a8; }
.float.dig { color: #fff; }
.float.thief { color: #ffd9cc; text-shadow: 0 2px 0 #8a2a14, 0 0 6px #8a2a14; }
.decor-label { position: fixed; z-index: 3; pointer-events: none; transform: translate(-50%, -50%); padding: 1px 7px;
  border-radius: 9px; font-size: 13px; font-weight: 700; color: #fff; background: #3f8a4c; box-shadow: 0 1px 3px #0005; white-space: nowrap; }
.decor-label.full { background: #8a7a62; font-weight: 500; font-size: 11px; }
.decor-label.shelter { background: #2f6f92; }
.decor-label.noise { background: #b0452f; }
@keyframes rise { to { opacity: 0; margin-top: -46px; } }

/* --- panels: while you were away, picker, and the sheets (settings, projects) ---------------------- */
#away { position: fixed; width: min(400px, calc(100vw - var(--left) - var(--right)));
  max-height: calc(100dvh - var(--top) - var(--bottom) - 54px); overflow: auto; z-index: 13; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 20px; text-align: center; }
#away .ui-button { margin-top: 10px; width: 100%; min-height: 50px; font-size: 15px; }
#away p { margin: 6px 0; }
#awayProject { padding-top: 8px; border-top: 1px solid var(--rule); color: var(--river-dark); }

/* Sheets: modal dialogs with a title bar, grouped sections and cards. Bottom sheets on phones. */
.sheet {
  color: var(--ink); width: min(440px, calc(100vw - var(--left) - var(--right)));
  max-height: calc(100dvh - var(--top) - var(--bottom)); padding: 16px 16px 18px; overflow: auto; overscroll-behavior: contain;
}
.sheet::backdrop { background: #30281e66; }
.sheet > header { display: flex; align-items: center; justify-content: space-between; gap: 6px; position: sticky; top: -16px; z-index: 1; margin: -16px -16px 0; padding: 14px 12px 10px 16px; background: var(--paper);
  border-bottom: 1px solid var(--rule); }
.sheet h2:focus { outline: none; }
.sheet-group { margin-top: 16px; }
.sheet-group > h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--muted); font-size: 11px;
  font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sheet-group > h3 .count { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--rule); color: var(--ink);
  text-align: center; letter-spacing: 0; font-size: 11px; line-height: 18px; }
.sheet-group > h3 .count:empty { display: none; }
.sheet .empty { margin: 0; padding: 12px; border: 1px dashed var(--rule); border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.sheet-footer { display: flex; justify-content: center; margin-top: 14px; }
.sheet-footer a, #cloudSettings a { color: var(--river); display: inline-flex; align-items: center; min-height: 44px; }

.settings-row, .settings-card { border: 1px solid var(--rule); border-radius: 14px; background: #fffaf0; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; }
.settings-row + .settings-row { margin-top: 8px; }
.settings-row > span { display: grid; min-width: 0; }
.settings-row small { color: var(--muted); font-size: 12px; font-weight: 500; }
.settings-row .ui-button { flex: none; }
.settings-card { padding: 12px 14px; margin-top: 8px; font-weight: 500; user-select: text; }
.settings-card > strong { display: block; font-weight: 700; }
.settings-card .note { margin: 4px 0 8px; color: var(--muted); font-size: 12px; }
.switch { position: relative; flex: none; width: 52px; height: 32px; margin: 6px; padding: 0; border: 1px solid var(--edge-dark);
  border-radius: 99px; background: var(--rule); cursor: pointer; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px #0004; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--river); border-color: var(--river-dark); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

#cloudSettings .status { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 12px; font-weight: 500; }
#cloudSettings .dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #b4a27f; }
#cloudSettings .status[data-state="ok"] .dot { background: #3f8a4c; }
#cloudSettings .status[data-state="bad"] .dot { background: var(--red); }
#cloudSettings .code, #cloudSettings form { display: flex; flex-wrap: wrap; gap: 8px; }
#cloudSettings code, #cloudSettings input { min-width: 0; flex: 1 1 150px; padding: 9px; border: 1px solid var(--edge); border-radius: 10px; background: #fff; }
#cloudSettings input { font: inherit; font-size: 16px; text-transform: uppercase; }
#cloudSettings code { font: 700 15px/1.4 monospace; overflow-wrap: anywhere; }
#cloudSettings .link { min-height: 40px; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--river);
  font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
#cloudSettings .error { margin: 8px 0 0; color: var(--red); }
#cloudSettings .choice { margin-top: 8px; padding: 12px; border-radius: 12px; background: var(--light-river); }
#cloudSettings .choice p { margin: 0 0 8px; }
#cloudSettings .choice > div { display: flex; flex-wrap: wrap; gap: 8px; }
#cloudSettings .passkey .ui-button, #cloudSettings .recovery > .ui-button { width: 100%; margin-top: 8px; }
#cloudSettings details summary { min-height: 28px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
#cloudSettings details[open] summary { margin-bottom: 8px; }
#cloudSettings details summary::-webkit-details-marker { display: none; }
#cloudSettings details summary { list-style: none; }
#cloudSettings details summary::after { content: ''; width: 7px; height: 7px; margin: 0 4px 3px auto; border: solid var(--muted);
  border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
#cloudSettings details[open] summary::after { transform: rotate(-135deg); margin-bottom: -3px; }
#cloudSettings .verification > div { margin-bottom: 8px; }

#buildingPicker header, #caravanPanel header { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#buildingPicker, #caravanPanel {
  position: fixed; inset: auto auto var(--bottom) var(--left); margin: 0; color: var(--ink);
  width: min(340px, calc(100vw - var(--left) - var(--right))); max-height: min(54dvh, 340px); padding: 12px; overflow: auto;
}
#buildingPicker::backdrop, #caravanPanel::backdrop { background: #30281e33; }
#buildingChoices, #caravanOffers { list-style: none; margin: 8px 0 0; padding: 2px 2px 4px; display: grid; gap: 8px; }
#buildingChoices .ui-button, #caravanOffers .ui-button { width: 100%; justify-content: space-between; text-align: left; }
#buildingChoices small, #caravanOffers small { flex: none; color: var(--muted); }
#confirmPanel { margin: auto; width: min(340px, calc(100vw - 32px)); padding: 16px; color: var(--ink); }
#confirmPanel::backdrop { background: #30281e55; }
#confirmPanel h2 { margin: 0; font: 700 22px/1.15 Georgia, serif; color: var(--river-dark); }
#confirmPanel p { margin: 8px 0 16px; }
#confirmPanel form { display: flex; justify-content: flex-end; gap: 10px; }
/* Projects & Crew: how the villagers are split, then projects and stopped workplaces. */
.crew { margin-top: 14px; }
.crew-bar { display: flex; height: 10px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.crew-bar span { transition: width .3s; }
.crew-bar .building, #crewSummary .building dt::before { background: var(--river); }
.crew-bar .working, #crewSummary .working dt::before { background: var(--gold); }
.crew-bar .free, #crewSummary .free dt::before { background: #9fc7ab; }
#crewSummary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 0; }
#crewSummary dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#crewSummary dt::before { content: ''; width: 8px; height: 8px; border-radius: 2px; }
#crewSummary dd { margin: 0; font: 700 22px/1.15 Georgia, serif; color: var(--river-dark); }
/* Upgrades: ready rows look ready; ones you're saving for are quieter. */
.job[data-reason="saving"] .job-art { filter: grayscale(.6) opacity(.75); }
.perk .job-find { cursor: default; padding-left: 14px; }
.upgrade-action { gap: 4px; min-width: 76px; font-variant-numeric: tabular-nums; }
.upgrade-action svg { width: 14px; height: 14px; color: #ffd27a; }
.upgrade-action:disabled svg { color: var(--gold); }
.upgrade-action:disabled { background: var(--paper-2); border-color: var(--edge); color: var(--muted); opacity: 1; }
.sheet-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* The Papyrus */
.progress-card { display: grid; gap: 8px; }
.progress-card .note { margin: 0; }
.mission-card { border-color: #ecd09a; background: #fff6e2; }
.mission-card .fill { background: var(--gold); }
.season-list, .done-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.season-list li { display: grid; gap: 3px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: 14px; background: #fffaf0; }
.season-list li.now { border-color: var(--river); background: var(--light-river); }
.season-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.season-when { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.season-list li.now .season-when { color: var(--river-dark); font-weight: 700; }
.season-note { color: var(--muted); font-size: 12px; font-weight: 500; }
.done-list li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.done-list li::before { content: '✓'; width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--light-river); color: var(--river); font-size: 12px; font-weight: 700; }
#projectsNote { margin: 12px 0 0; padding: 8px 10px; border-radius: 10px; background: #f6e2bd; color: #78501e; font-size: 12px; }
.job-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.job { display: flex; align-items: center; gap: 8px; padding-right: 8px; border: 1px solid var(--rule); border-radius: 14px; background: #fffaf0; }
.job[data-reason="buried"], .job[data-reason="short"] { border-color: #e4b9a2; background: #fff3ea; }
.job-find { flex: 1; min-width: 0; min-height: 60px; display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 8px;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 14px; }
.job-art { width: 46px; height: 46px; flex: none; object-fit: contain; filter: drop-shadow(0 2px 1px #6b4a2033); }
.job-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.job-text strong { font-size: 14px; }
.job-detail { color: var(--muted); font-size: 12px; font-weight: 500; }
.job[data-reason="buried"] .job-detail, .job[data-reason="short"] .job-detail { color: var(--red); }
.job-action { flex: none; min-height: 40px; padding: 6px 12px; font-size: 13px; }
.project-progress { display: block; height: 6px; border-radius: 6px; background: var(--rule); overflow: hidden; }
.project-progress span { display: block; height: 100%; background: var(--river); transition: width .3s; }

/* --- smaller screens ------------------------------------------------------------------------- */
@media (max-width: 900px) {
  #hud { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  #goal { grid-row: 2; }
  /* The stats fill the row like the goal below, spread evenly. */
  .hud-identity { width: auto; }
  #stats { flex: 1; }
  #stats .stat { flex: 1 1 auto; }
}
@media (max-width: 700px) {
  /* Stone sits over cedar, so the stats still fit one row. */
  .stat { padding-inline: 6px; }
  .stat.cargo:not([hidden]) { display: inline-grid; grid-template-columns: auto auto; gap: 0 3px; font-size: 12px; line-height: 1.2; }
  .stat.cargo svg { width: 12px; height: 12px; }
  .stat.cargo .cedar-icon { margin: 0; }
  /* The goal chip drops its label; the Papyrus has the rest. Weather stays. */
  #goalOpen { padding: 7px 10px 8px; gap: 5px; }
  #goalLabel { display: none; }
  .day-clock { display: none; }
  #townMenu summary span { display: none; }
  #townMenu summary { min-width: 48px; min-height: 48px; padding: 8px; }
  /* The build tray scrolls sideways along the bottom, so the map stays in view. */
  #buildPanel { left: var(--left); width: calc(100vw - var(--left) - var(--right)); padding: 10px 10px 12px; }
  #buildPanel header .eyebrow { display: none; }
  #build { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 96px; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x proximity; overscroll-behavior-x: contain; padding-bottom: 8px; }
  #build .build-card { scroll-snap-align: start; grid-template-rows: 58px auto auto; padding: 6px 4px 8px; }
  #build .build-art { width: 58px; height: 58px; }
  #dock .ui-button { min-height: 50px; }
  /* A slim details card, so the selected building stays in view above it. */
  #work { padding: 8px 10px 10px 12px; max-height: min(42dvh, 260px); }
  #work header .eyebrow { display: none; }
  #workTitle { margin-top: 0; font-size: 17px; }
  #work header { align-items: center; }
  #workClose { margin: -6px -6px -6px 0; }
  #work p:not(.eyebrow) { margin: 3px 0; font-size: 12px; }
  .work-actions { flex-wrap: nowrap; }
  .work-actions:has(button:not([hidden])) { margin-top: 8px; }
  .work-actions .ui-button { flex: 1 1 0; min-width: 0; min-height: 44px; padding-inline: 8px; }
  #workUpgrade { flex-direction: column; gap: 0; line-height: 1.2; }
  #workUpgrade .cost { font-size: 12px; opacity: 0.85; }
  #workUpgrade .cost::before { content: none; }
}
@media (max-width: 700px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 88dvh; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: sheet-up .22s ease-out; }
  .sheet > header::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 99px; background: var(--rule); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 360px) {
  :root { --left: max(8px, env(safe-area-inset-left)); --right: max(8px, env(safe-area-inset-right)); }
  #dock .ui-button { padding-inline: 12px; }
  .stat, #crewToggle { padding-inline: 4px; gap: 4px; font-size: 14px; }
  .stat:first-child { font-size: 15px; }
  .stat svg { width: 16px; height: 16px; }
  .stat:first-child svg { width: 18px; height: 18px; }
}
@media (pointer: coarse) {
  #build .key { display: none; }
  #cameraControls { display: none; } /* pinch to zoom */
}
@media (max-height: 530px) and (orientation: landscape) {
  #cameraControls { flex-direction: row; }
  .day-clock, #townMenu summary span { display: none; }
  #buildPanel { max-height: calc(100dvh - var(--top) - var(--bottom) - 70px); }
}
@media (min-width: 650px) and (max-height: 530px) and (orientation: landscape) {
  #hud { grid-template-columns: minmax(max-content, 1fr) minmax(220px, 320px); }
  #goal { grid-column: 2; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #goal .fill, .progress-card .fill, .ui-button, #build .build-art { transition: none; }
  .toast, .float, #work, .sheet { animation: none; }
}
