:root {
  color-scheme: dark;
  --ink: #f7f2ea;
  --muted: #bdb2a3;
  --faint: #8f8679;
  --gold: #f2bb5c;
  --clay: #ef7f50;
  --clay-hi: #ff9466;
  --teal: #5ccdb9;
  --red: #ff7465;
  --panel: rgba(21, 19, 17, 0.76);
  --panel-solid: #1f1b17;
  --raise: rgba(255, 255, 255, 0.045);
  --raise-hi: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 244, 228, 0.12);
  --line-hi: rgba(255, 244, 228, 0.3);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  --serif: Georgia, "Iowan Old Style", Palatino, serif;
  --panel-w: 330px;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #14120f;
  color: var(--ink);
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -4px;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, color 0.15s;
}

button:hover, .button:hover { border-color: var(--line-hi); background: var(--raise-hi); }
button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

button[aria-pressed="true"] {
  background: var(--ink);
  color: #1b1612;
  border-color: transparent;
}

button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.primary, #faucet {
  background: linear-gradient(180deg, var(--clay-hi), var(--clay));
  color: #1d110b;
  border-color: transparent;
  font-weight: 650;
}

.primary:hover, #faucet:hover { background: linear-gradient(180deg, #ffa57d, var(--clay-hi)); border-color: transparent; }

button.small { padding: 4px 10px; font-size: 12px; }

.icon-btn { padding: 7px; border-radius: 12px; }

#city {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: block;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}

#city:active { cursor: grabbing; }

.glass, .top, aside, #ticker, .controls > *, #mini, #panel-tab {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

/* Top bar ----------------------------------------------------------------- */

.top {
  position: fixed;
  z-index: 3;
  top: 12px;
  left: 12px;
  right: calc(var(--panel-w) + 26px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 20px;
  transition: right 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 12px 2px 6px;
}

.logo {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 34px;
  height: 34px;
  padding: 6px 6px 7px;
  border-radius: 11px;
  background: linear-gradient(160deg, #ff9a6a, #d9583a 60%, #8a3a2b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.logo i { flex: 1; background: #fff6ea; border-radius: 1.5px 1.5px 0 0; }
.logo i:nth-child(1) { height: 45%; }
.logo i:nth-child(2) { height: 100%; }
.logo i:nth-child(3) { height: 68%; }

.brand h1 { font-family: var(--serif); font-weight: 600; font-size: 21px; letter-spacing: -0.02em; line-height: 1; margin: 0; white-space: nowrap; }

.live {
  margin: 3px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(92, 205, 185, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(92, 205, 185, 0); }
  100% { box-shadow: 0 0 0 0 rgba(92, 205, 185, 0); }
}

.clock-block {
  padding: 2px 14px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

#clock { font-family: var(--serif); font-weight: 600; font-size: 17px; margin: 0; }
#place { font-size: 12px; margin: 1px 0 0; min-height: 15px; }

.chips {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  padding: 0 8px;
  border-left: 1px solid var(--line);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--raise);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}

.chip .i { width: 15px; height: 15px; color: var(--muted); vertical-align: 0; }
.chip.bad { background: rgba(255, 116, 101, 0.14); color: #ffb3a8; }
.chip.bad .i { color: var(--red); }
.chip.note { color: var(--muted); }

.nav { display: flex; gap: 2px; margin-left: auto; }

.nav button {
  position: relative;
  border: 0;
  background: transparent;
  border-radius: 13px;
  padding: 8px 11px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--ink);
}

.nav button:hover { background: var(--raise-hi); }
.nav button.open { background: var(--ink); color: #1b1612; }
.nav button .i { color: var(--gold); }
.nav button.open .i { color: var(--clay); }
.nav .badge { position: absolute; top: 2px; right: 2px; }

.wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 2px 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.wallet .coin { width: 22px; height: 22px; color: var(--gold); }
.coins { margin: 0; color: var(--gold); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 650; }
.wallet .tiny { margin: 0; font-size: 11px; }
#faucet { padding: 5px 11px; font-size: 12px; }

/* Side panel --------------------------------------------------------------- */

aside {
  position: fixed;
  z-index: 3;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: var(--panel-w);
  border-radius: 22px;
  padding: 12px 14px 14px;
  overflow: auto;
  scrollbar-width: thin;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

body.panel-closed aside { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
body.panel-closed .top { right: 12px; }
body.panel-closed #dock { right: 12px; }

#panel-tab {
  position: fixed;
  z-index: 3;
  top: 84px;
  right: 12px;
  border-radius: 14px;
  padding: 9px 12px;
  font-size: 13px;
}

#panel-tab .i { color: var(--gold); }

.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head .icon-btn { border: 0; background: transparent; color: var(--muted); }
.panel-head .icon-btn:hover { color: var(--ink); background: var(--raise-hi); }

.eyebrow, .muted, .api-note { color: var(--muted); margin: 0; }
.eyebrow { letter-spacing: 0.16em; text-transform: uppercase; font-size: 11px; }
.tiny { font-size: 12px; }

aside h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

aside h2 .i { color: var(--gold); }

.block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Nobody picked yet */
.meet {
  margin: 8px 0 12px;
  padding: 16px;
  border-radius: 18px;
  background: radial-gradient(120% 90% at 0% 0%, rgba(239, 127, 80, 0.22), transparent 60%), var(--raise);
  border: 1px solid var(--line);
}

.meet h3 { font-family: var(--serif); font-weight: 600; font-size: 19px; margin: 0 0 4px; }
.meet p { margin: 0 0 12px; color: var(--muted); line-height: 1.45; }
.meet .join-row { margin-top: 0; }

.picks { display: grid; gap: 6px; margin-top: 12px; }
.pick {
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  border-radius: 14px;
  padding: 7px 10px;
  text-align: left;
}
.pick > span:last-child { display: block; min-width: 0; }
.pick b { display: block; font-weight: 600; font-size: 13px; }
.pick small { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A picked resident */
.profile { display: flex; gap: 12px; align-items: center; margin: 6px 0 10px; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  font-weight: 700;
  font-size: 16px;
  color: #1b1612;
  background: var(--av, var(--gold));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.pick .avatar { width: 32px; height: 32px; font-size: 12px; }

.profile > div { flex: 1; min-width: 0; }
.let-go { border: 0; background: transparent; color: var(--muted); align-self: flex-start; }
.let-go:hover { color: var(--ink); }
.blurb { font-size: 13px; }

.who { font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.1; margin: 0; }
#citizen .role { display: block; color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }

.now {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 8px 0;
  padding: 9px 11px;
  border-radius: 14px;
  background: var(--raise);
  line-height: 1.4;
}

.now .i { color: var(--teal); margin-top: 1px; }

.quote {
  position: relative;
  margin: 10px 0;
  padding: 9px 12px;
  border-radius: 14px 14px 14px 4px;
  background: #f7f2ea;
  color: #2a211a;
  font-family: var(--serif);
  font-style: italic;
  line-height: 1.4;
}

.blurb { line-height: 1.5; margin: 8px 0; }
.trait { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }

/* Schooling and friends */
.people { margin: 10px 0 12px; padding: 10px 12px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line); }
.school-line { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 6px; font-size: 13px; line-height: 1.4; }
.school-line .i { color: var(--gold); flex: none; margin-top: 1px; }
.people-head { margin: 8px 0 6px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.friend-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.friend-chip { padding: 4px 10px; font-size: 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
button.friend-chip { cursor: pointer; }
.friend-chip.is-friend { color: var(--ink); border-color: rgba(92, 205, 185, 0.45); background: rgba(92, 205, 185, 0.1); }
.friend-chip.is-partner { border-color: rgba(255, 148, 102, 0.6); background: rgba(255, 148, 102, 0.14); }
.ask { align-items: center; gap: 8px; margin-top: 8px; }
.ask span { flex: 1; font-size: 13px; }

.needs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 12px 0; }
.need { font-size: 12px; color: var(--muted); }
.need span { display: flex; justify-content: space-between; }

.bar {
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 4px;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--clay), var(--gold));
  transition: width 0.6s ease;
}

.bar.low span { background: var(--red); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.actions button { flex: 1 1 auto; }

details.more { margin-top: 10px; border-radius: 14px; background: var(--raise); padding: 2px 12px; }
details.more summary { cursor: pointer; padding: 9px 0; font-size: 13px; color: var(--muted); list-style: none; display: flex; justify-content: space-between; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: "+"; color: var(--gold); font-weight: 700; }
details.more[open] summary::after { content: "–"; }

.ledger {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 2px 0 10px;
  font-size: 12px;
}
.ledger dt { color: var(--muted); }
.ledger dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.status-bad { color: var(--red); font-weight: 650; }
.status-pill { display: inline-block; margin: 6px 0; padding: 3px 10px; border-radius: 999px; background: rgba(255, 116, 101, 0.16); color: #ffb3a8; font-size: 12px; font-weight: 650; }

.search { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.search input, #results button, #chat-text, .fund-row input {
  width: 100%;
  border-radius: 12px;
  margin-top: 6px;
}

.search input, #chat-text, .fund-row input, #owner select, #owner textarea, #join select, #board-form select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  padding: 9px 11px;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}

.search input:focus, #chat-text:focus { border-color: var(--line-hi); background: rgba(255, 255, 255, 0.08); outline: none; }

#results { display: grid; gap: 4px; margin-top: 4px; }
#results button { justify-content: flex-start; text-align: left; border-radius: 12px; margin: 0; }

#shop { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
#shop .shop-group { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.swatches button[aria-pressed="true"] { border-color: var(--gold); }

.gift {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-height: 74px;
  padding: 10px;
  border-radius: 14px;
  text-align: left;
}

.gift:not(:disabled):hover { border-color: rgba(242, 187, 92, 0.5); background: rgba(242, 187, 92, 0.08); }
.gift-name { font-weight: 600; font-size: 13px; }
.gift small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.gift b { color: var(--gold); font-weight: 650; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.gift b .i { width: 13px; height: 13px; vertical-align: 0; }

.fund-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.fund-row input { width: 80px; margin: 0; }
.fund-row small { flex-basis: 100%; }

.player-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 650;
  font-style: normal;
  letter-spacing: 0.04em;
  background: var(--clay);
  color: #1b120e;
  vertical-align: middle;
}

#watchers { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; }
#watchers li { margin: 3px 0; display: flex; gap: 6px; align-items: center; }
#watchers li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex: none; }
#watchers li.muted::before { background: var(--faint); }
#watchers .me { color: var(--gold); }
#chat-log { max-height: 150px; overflow: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
#chat-log p { margin: 0; padding: 6px 10px; border-radius: 12px; background: var(--raise); line-height: 1.35; }
#chat-log b { color: var(--gold); }
#chat-form { display: flex; gap: 6px; margin-top: 8px; }
#chat-text { flex: 1; min-width: 0; margin: 0; }

.api-note { font-size: 12px; line-height: 1.5; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.api-note b { color: var(--ink); font-weight: 600; }

code { font-family: ui-monospace, monospace; font-size: 11px; color: var(--ink); }

/* Map, dock and hints ------------------------------------------------------ */

#mini {
  position: fixed;
  z-index: 2;
  left: 12px;
  bottom: 72px;
  width: 168px;
  height: 132px;
  border-radius: 16px;
  background: #1a1916;
  cursor: pointer;
  padding: 0;
}

#dock {
  position: fixed;
  z-index: 2;
  left: 12px;
  right: calc(var(--panel-w) + 26px);
  bottom: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
  transition: right 0.25s ease;
}

#ticker {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 50px;
  border-radius: 16px;
  padding: 7px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

#ticker p {
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: slide-in 0.4s ease;
}

#ticker p:not(:first-child) { color: var(--muted); font-size: 12px; }
#ticker p::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); margin-right: 8px; vertical-align: 2px; }
#ticker p.gift { color: var(--gold); background: none; border: 0; padding: 0; display: block; min-height: 0; }
#ticker p.gift::before, #ticker p.games::before { background: var(--gold); }
#ticker p.police::before, #ticker p.crime::before { background: var(--red); }
#ticker p.talk::before { background: #8cc4ec; }
#ticker p.clock { color: #f0d7a4; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.controls { display: flex; gap: 6px; pointer-events: auto; }

/* The on-screen controls are buttons, not text: a long press must not
   raise the copy and paste menu. */
#dock, #flypad, #mini, #panel-tab, #hint, .controls, .segmented {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.segmented {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 16px;
}

.segmented button { border: 0; background: transparent; border-radius: 12px; padding: 8px 11px; font-size: 13px; }
.segmented button:hover { background: var(--raise-hi); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #1b1612; }
.segmented .icon-btn { padding: 8px; }
.sound #volume { width: 76px; margin: 0 6px; accent-color: var(--gold); }
.sound #volume[hidden] { display: none; }

#hint {
  position: fixed;
  z-index: 2;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(640px, calc(100% - 420px));
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(14, 12, 10, 0.72);
  color: var(--ink);
  font-size: 12.5px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#hint:empty, #hint.faded { opacity: 0; }
body.panel-closed #hint { max-width: min(640px, calc(100% - 80px)); }

#stats {
  position: fixed;
  z-index: 2;
  left: 192px;
  bottom: 70px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Toasts */
#toasts {
  position: fixed;
  z-index: 9;
  left: 50%;
  top: 86px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: #f7f2ea;
  color: #231a13;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s ease;
  transition: opacity 0.4s, transform 0.4s;
}

.toast .i { color: var(--clay); }
.toast.bad { background: #3a1814; color: #ffd0c8; }
.toast.bad .i { color: var(--red); }
.toast.gone { opacity: 0; transform: translateY(-8px); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Welcome ------------------------------------------------------------------ */

#intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(80% 70% at 50% 40%, rgba(20, 16, 12, 0.35), rgba(10, 8, 6, 0.78));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 0.4s ease;
}

#intro.hidden { display: none; }

.intro-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 26px;
  padding: 0 28px 24px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.intro-art {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 110px;
  margin: 0 -28px 18px;
  padding: 0 28px;
  border-radius: 26px 26px 0 0;
  background:
    radial-gradient(circle at 78% 38%, #ffe3a3 0 16px, rgba(255, 227, 163, 0.35) 17px 30px, transparent 31px),
    linear-gradient(180deg, #ff9d6b 0%, #f0705a 45%, #6b3f6e 100%);
  overflow: hidden;
  position: relative;
}

.intro-art::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background: linear-gradient(180deg, #2f5f7d, #1d3c52);
}

.intro-art i { flex: 1; background: #3a2236; border-radius: 3px 3px 0 0; position: relative; z-index: 1; margin-bottom: 12px; box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.05); }
.intro-art i:nth-child(1) { height: 34%; }
.intro-art i:nth-child(2) { height: 58%; }
.intro-art i:nth-child(3) { height: 46%; }
.intro-art i:nth-child(4) { height: 82%; background: #2e1b2c; }
.intro-art i:nth-child(5) { height: 64%; }
.intro-art i:nth-child(6) { height: 92%; background: #2b1929; }
.intro-art i:nth-child(7) { height: 50%; }
.intro-art i:nth-child(8) { height: 70%; }
.intro-art i:nth-child(9) { height: 38%; }

.intro-card .eyebrow { color: var(--gold); }
.intro-card h2 { font-family: var(--serif); font-weight: 600; font-size: 34px; letter-spacing: -0.02em; margin: 2px 0 8px; }
.intro-card .lead { font-size: 15px; line-height: 1.55; color: #e6ddd0; margin: 0 0 18px; }

.choices { display: grid; gap: 8px; }

.choice {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 16px;
  text-align: left;
  background: var(--raise);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.choice:hover { transform: translateY(-1px); border-color: var(--line-hi); background: var(--raise-hi); }
.choice .i { width: 26px; height: 26px; color: var(--gold); }
.choice b { display: block; font-size: 15px; }
.choice small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.35; }
.choice.primary { background: linear-gradient(180deg, var(--clay-hi), var(--clay)); color: #1d110b; }
.choice.primary .i, .choice.primary small { color: #3a1c10; }
.choice.primary:hover { background: linear-gradient(180deg, #ffa57d, var(--clay-hi)); }

.intro-card .name { margin-top: 16px; }
.intro-card .fine { font-size: 12px; color: var(--faint); margin: 14px 0 0; text-align: center; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }

#boot {
  position: fixed;
  z-index: 11;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-family: var(--serif);
  font-size: 17px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Sheets: the panels that open from the menu ------------------------------ */

.sheet {
  position: fixed;
  z-index: 6;
  left: 12px;
  top: 86px;
  bottom: 12px;
  width: min(440px, calc(100% - 24px));
  overflow: auto;
  border-radius: 22px;
  padding: 16px 18px 18px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  scrollbar-width: thin;
  animation: sheet-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}

#owner, #paper { width: min(470px, calc(100% - 24px)); }

.boards-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.boards-head .icon-btn { border: 0; background: var(--raise); }

.sheet h2, .sheet h3, .sheet h4 { font-family: var(--serif); font-weight: 600; margin: 0; }
.sheet h2 { font-size: 23px; }
.sheet h3 { margin: 18px 0 6px; font-size: 16px; color: var(--gold); }
.sheet h4 { margin: 10px 0 2px; font-size: 14px; }
.sheet p { margin: 8px 0 4px; line-height: 1.5; font-size: 13.5px; }
.sheet .sub { color: var(--muted); margin: 6px 0 10px; }
.sheet .search { margin-top: 10px; }

#owner select, #owner textarea, #join select, #board-form select {
  width: 100%;
  margin-top: 6px;
  border-radius: 12px;
  font-size: 13px;
}

#owner select option, #join select option, #board-form select option { background: #241d18; }
#owner textarea { min-height: 70px; resize: vertical; }

#owner .join-row button, .card .join-row button { padding: 5px 12px; font-size: 12.5px; }
#owner-error:empty, #board-error:empty, #join-error:empty { display: none; }

.tabs { display: flex; gap: 4px; margin: 12px 0 6px; flex-wrap: wrap; padding: 4px; border-radius: 14px; background: var(--raise); width: fit-content; }
.tabs button { padding: 6px 13px; font-size: 13px; border: 0; background: transparent; border-radius: 10px; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #1b1612; }

.badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  background: var(--clay);
  color: #1b120e;
}

.card {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--raise);
  font-size: 13px;
}

.card b { font-size: 15px; }
.card small { display: block; color: var(--muted); line-height: 1.45; }

.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.meters span { font-size: 10.5px; color: var(--muted); }
.meters i { display: block; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 3px; }
.meters i::after { content: ""; display: block; height: 100%; width: var(--v); background: linear-gradient(90deg, var(--clay), var(--gold)); }

.feed { list-style: none; margin: 4px 0 0; padding: 0; font-size: 12.5px; }
.feed li { padding: 7px 0; border-top: 1px solid var(--line); line-height: 1.45; }
.feed li small { color: var(--muted); margin-right: 6px; }
.feed li.unread { color: var(--gold); }
.feed li.bad { color: #ff9b85; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; }

.join-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

#paper .headline { font-family: var(--serif); font-size: 22px; line-height: 1.25; margin: 10px 0 4px; }

/* Explore */
.places { display: grid; gap: 6px; }

.place {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px 9px 9px;
  border-radius: 16px;
  text-align: left;
  justify-content: stretch;
}

.place .tile {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--tile, #5b4b3c);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.place b { display: block; font-weight: 600; font-size: 14px; }
.place small { display: block; color: var(--muted); font-size: 12px; }
.place .state { font-size: 11.5px; text-align: right; color: var(--muted); white-space: nowrap; }
.place .state.open { color: var(--teal); }
.place .state em { display: block; font-style: normal; color: var(--ink); }

/* Help */
.keys { list-style: none; padding: 0; margin: 4px 0; display: grid; gap: 6px; }
.keys li { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: center; font-size: 13px; }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 7px;
  margin-right: 2px;
  border-radius: 7px;
  border: 1px solid var(--line-hi);
  border-bottom-width: 2px;
  background: var(--raise-hi);
  font-family: inherit;
  font-size: 11.5px;
  text-align: center;
}

/* Join (developer) dialog */
#join {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 40px);
  overflow: auto;
  border-radius: 22px;
  padding: 22px;
  z-index: 8;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

#join h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 8px; }
#join p { line-height: 1.45; }
#join .search { margin-top: 10px; }

#join .token {
  display: block;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  word-break: break-all;
  font-size: 13px;
  user-select: all;
}

#join pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.5;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  margin: 0;
}

/* Billboards */
#boards-list h3 { margin: 16px 0 2px; font-size: 16px; color: var(--gold); }

.board-row {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.board-row canvas, #board-preview {
  width: 100%;
  border-radius: 8px;
  background: #151b24;
  display: block;
}

.board-row canvas { aspect-ratio: 512 / 204; }
.board-row b { font-size: 14px; }
.board-row p { margin: 2px 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.board-row .live { color: var(--gold); letter-spacing: 0; text-transform: none; font-size: 12px; display: block; }
.board-row .join-row { margin-top: 6px; }
.board-row button { padding: 4px 11px; font-size: 12px; }

#board-preview { margin: 10px 0 2px; }
#board-form h3 { margin-top: 6px; }

.themes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.themes button { width: 34px; height: 24px; padding: 0; border-radius: 7px; border: 2px solid transparent; }
.themes button[aria-checked="true"] { border-color: var(--ink); }

/* Homes */
.estate-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.estate-row small { display: block; color: var(--muted); }
.estate-row button { padding: 4px 10px; font-size: 12px; align-self: center; }

/* Getting started */
.tour { border-color: rgba(242, 187, 92, 0.45); background: radial-gradient(120% 90% at 0% 0%, rgba(242, 187, 92, 0.12), transparent 60%), var(--raise); }
.tour-steps { margin: 8px 0 0; padding-left: 20px; font-size: 13px; }
.tour-steps li { margin: 6px 0; color: var(--muted); }
.tour-steps li.done { text-decoration: line-through; }
.tour-steps li.done::marker { color: var(--teal); }
.tour-steps li.next { color: inherit; }
.tour-steps li.next > span { font-weight: 650; }
.tour-steps li small { display: block; margin: 2px 0 6px; }
.tour-steps li button { padding: 5px 12px; font-size: 12px; }

.hidden { display: none !important; }

/* Narrower screens ---------------------------------------------------------- */

@media (max-width: 2040px) {
  .chip.extra { display: none; }
}

@media (max-width: 1420px) {
  .nav button span { display: none; }
  .nav button { padding: 9px; }
  .nav button .i { width: 20px; height: 20px; }
}

@media (max-width: 1180px) {
  .chips { display: none; }
  .wallet .tiny { display: none; }
  .segmented button span { display: none; }
  #hint { display: none; }
}

@media (max-width: 900px) {
  :root { --panel-w: 0px; }
  .top { right: 12px; flex-wrap: wrap; border-radius: 18px; }
  .brand h1 { font-size: 18px; }
  .live { display: none; }
  .clock-block { border: 0; padding: 2px 6px; }
  #place { display: none; }
  .nav { order: 5; width: 100%; justify-content: space-between; margin: 0; border-top: 1px solid var(--line); padding-top: 4px; }
  .nav button span { display: block; font-size: 10.5px; }
  .nav button { flex-direction: column; gap: 2px; padding: 6px 4px; flex: 1; }
  .wallet { margin-left: auto; border: 0; }
  .wallet .coin { display: none; }

  aside {
    top: auto;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 44vh;
  }

  body.panel-closed aside { transform: translateY(calc(100% + 24px)); }
  #panel-tab { top: auto; bottom: 12px; right: 12px; }
  #ticker, #mini, #hint, #stats { display: none; }
  #dock { left: auto; right: 12px; bottom: calc(44vh + 22px); }
  body.panel-closed #dock { bottom: 64px; }
  .sheet { top: 120px; left: 8px; right: 8px; bottom: 8px; width: auto; }
  #owner, #paper { width: auto; }
  .keys li { grid-template-columns: 130px 1fr; }
}

/* Phones, and phones turned sideways. The city stays on screen; everything
   else sits in a top strip and a thumb bar, and panels rise from the bottom. */
@media (max-width: 760px), (max-height: 500px) and (max-width: 980px) {
  .top {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    flex-wrap: nowrap;
    gap: 2px;
    padding: 4px;
    border-radius: 16px;
    /* The blur would trap the fixed menu inside this bar. A solid bar keeps
       the menu free to sit on the bottom edge. */
    background: rgba(21, 19, 17, 0.94);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .brand { gap: 0; padding: 2px 4px; }
  .brand h1, .live, #place, .chips, .wallet .tiny, .wallet .coin { display: none; }
  .logo { width: 30px; height: 30px; }
  .clock-block { border: 0; padding: 2px 6px; }
  #clock { font-size: 15px; }
  .wallet { margin-left: auto; border: 0; padding-left: 6px; gap: 6px; }
  .coins { font-size: 14px; }
  #faucet { min-height: 36px; padding: 6px 10px; }

  .nav {
    position: fixed;
    z-index: 7;
    left: 0;
    right: 0;
    bottom: 0;
    order: 0;
    width: auto;
    margin: 0;
    gap: 0;
    justify-content: space-around;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)) calc(100% / 7);
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: rgba(21, 19, 17, 0.94);
  }
  .nav button { flex: 1; flex-direction: row; min-width: 0; min-height: 44px; padding: 8px 0; }
  .nav button span { display: none; }
  .nav button .i { width: 22px; height: 22px; }

  #panel-tab {
    position: fixed;
    z-index: 8;
    top: auto;
    left: 0;
    right: auto;
    bottom: env(safe-area-inset-bottom, 0px);
    display: inline-flex;
    width: calc(100% / 7);
    height: 52px;
    margin: 0;
    padding: 8px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  #panel-tab span { display: none; }
  #panel-tab .i { width: 22px; height: 22px; }
  #panel-tab.open { background: var(--ink); color: #1b1612; }
  #panel-tab.open .i { color: var(--clay); }

  aside {
    top: auto;
    left: 0;
    right: 0;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: min(70dvh, 640px);
    border-radius: 22px 22px 0 0;
    padding-top: 8px;
  }
  aside::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: 2px auto 8px;
    border-radius: 4px;
    background: var(--line-hi);
  }
  body.panel-closed aside { transform: translateY(110%); opacity: 0; }
  .panel-head .icon-btn, .boards-head .icon-btn { width: 44px; height: 44px; }

  #dock {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  body.panel-closed #dock { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
  #ticker { display: flex; min-height: 0; max-height: 32px; padding: 5px 10px; }
  #ticker p:not(:first-child) { display: none; }
  .controls { flex-wrap: nowrap; justify-content: space-between; }
  .segmented button, .segmented .icon-btn { min-width: 36px; min-height: 40px; padding: 8px; }
  .sound #volume { width: 48px; }

  #mini {
    display: block;
    left: max(8px, env(safe-area-inset-left, 0px));
    bottom: calc(156px + env(safe-area-inset-bottom, 0px));
    width: 112px;
    height: 84px;
    -webkit-touch-callout: none;
  }

  #flypad {
    position: fixed;
    z-index: 4;
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: calc(248px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: 52px 52px;
    gap: 6px;
  }
  #flypad button { width: 52px; height: 46px; border-radius: 14px; font-size: 15px; touch-action: none; }
  #flypad[hidden] { display: none !important; }

  body:not(.panel-closed) #dock,
  body:not(.panel-closed) #mini,
  body:not(.panel-closed) #flypad,
  body:has(.sheet:not(.hidden)) #dock,
  body:has(.sheet:not(.hidden)) #mini,
  body:has(.sheet:not(.hidden)) #flypad { display: none; }

  #hint {
    display: block;
    left: 132px;
    bottom: calc(164px + env(safe-area-inset-bottom, 0px));
    transform: none;
    max-width: calc(100% - 148px);
    font-size: 12px;
    text-align: left;
  }

  .sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: min(76dvh, 720px);
    border-radius: 22px 22px 0 0;
    animation-name: sheet-up;
  }
  #owner, #paper { width: auto; }
  @keyframes sheet-up {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: none; }
  }

  #toasts { top: calc(64px + env(safe-area-inset-top, 0px)); width: calc(100% - 24px); }
  .toast { max-width: 100%; text-align: center; }

  #intro { padding: max(12px, env(safe-area-inset-top, 0px)) 12px 12px; align-items: end; }
  .intro-card { max-height: calc(100dvh - 24px); padding: 0 16px 16px; border-radius: 22px; }
  .intro-art { height: 72px; margin: 0 -16px 12px; padding: 0 16px; border-radius: 22px 22px 0 0; }
  .intro-card h2 { font-size: 28px; }
  .intro-card .lead { font-size: 14px; margin-bottom: 12px; }
  .choice { padding: 12px; }
  .choice small { font-size: 12px; }

  #join {
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    max-height: calc(100dvh - 88px);
  }

  input, select, textarea { font-size: 16px; }
  #chat-form button, .join-row button, #results button { min-height: 40px; }

  @media (max-height: 500px) {
    #ticker, #mini, .intro-art { display: none; }
    #hint { display: none; }
    .intro-card h2 { font-size: 24px; margin-top: 14px; }
    aside, .sheet { max-height: calc(100dvh - 108px); }
    #flypad { bottom: calc(118px + env(safe-area-inset-bottom, 0px)); grid-template-columns: repeat(3, 44px); }
    #flypad button { width: 44px; height: 36px; font-size: 13px; }
  }
}

/* Television home: the city is the picture, the apps sit on top of it. */
#tv-home { display: none; }

html.tv header.top,
html.tv aside,
html.tv #panel-tab,
html.tv #mini,
html.tv #dock,
html.tv #hint,
html.tv #stats,
html.tv #toasts,
html.tv #intro,
html.tv #join,
html.tv .sheet {
  display: none !important;
}

html.tv #city { cursor: default; }

html.tv #tv-home {
  display: flex;
  position: fixed;
  z-index: 6;
  inset: 0;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 36px 22px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.18), transparent 18%, transparent 34%, rgba(0, 0, 0, 0.28) 62%, rgba(0, 0, 0, 0.5));
  color: #fff;
}

html.tv #tv-home header {
  position: absolute;
  top: 22px;
  left: 40px;
  right: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 22px;
  letter-spacing: 0.18em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

html.tv #tv-apps {
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

html.tv #tv-apps button {
  min-height: 58px;
  padding: 8px 6px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(10, 14, 18, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 16px;
  letter-spacing: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

html.tv #tv-apps button:focus,
html.tv #tv-apps button:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: #fff;
  outline: none;
  transform: scale(1.04);
}

html.tv #tv-status {
  pointer-events: none;
  min-height: 22px;
  margin: 8px 0 0;
  text-align: center;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}
