/* The live view. The island is the picture; everything here floats lightly over
   it, can be minimised, and can be hidden altogether. */
:root {
  --ink: #f5f0e6;
  --dim: #c2bbad;
  --faint: #8f897d;
  --glass: rgba(13, 18, 26, 0.56);
  --glass-strong: rgba(13, 18, 26, 0.8);
  --line: rgba(255, 255, 255, 0.1);
  --gold: #ffd27a;
  --warn: #ff8f6b;
  --ok: #8fd6a0;
  --gap: 14px;
  --r: 16px;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1026; color: var(--ink); font-size: 13.5px; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#stage, #labels, #shade { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
#labels { pointer-events: none; overflow: hidden; }
/* A soft darkening at top and bottom so the controls read against a bright sky or sand. */
#shade { pointer-events: none; background: linear-gradient(180deg, rgba(8, 12, 20, 0.32) 0, rgba(8, 12, 20, 0) 13%, rgba(8, 12, 20, 0) 72%, rgba(8, 12, 20, 0.42) 100%); transition: opacity 0.5s; }

.panel, .card, .chip {
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.35); -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.26);
}
.panel { position: fixed; border-radius: var(--r); }
.card, .panel, .chip, #dock button { transition: opacity 0.35s, transform 0.35s, background 0.2s, border-color 0.2s; }

/* ------------------------------------------------------------ status pill */
#clock { top: var(--gap); left: var(--gap); display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 11px; border-radius: 999px; white-space: nowrap; }
#live { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
#live .dot { width: 8px; height: 8px; border-radius: 50%; background: #777; }
#live.on { color: var(--ink); }
#live.on .dot { background: #ff5a4f; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 90, 79, 0.7); } 100% { box-shadow: 0 0 0 8px rgba(255, 90, 79, 0); } }
#home { color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: 0.01em; }
#home:hover { color: var(--gold); }
.sepdot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
#clock-day, #clock-weather { color: var(--dim); }
#clock-time { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ the people, as chips */
#roster { position: fixed; top: var(--gap); right: var(--gap); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: min(62vw, 640px); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 8px; border-radius: 999px; font-weight: 650; }
.chip:hover { border-color: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }
.chip.on { border-color: var(--gold); background: rgba(40, 32, 12, 0.66); }
.chip.dead { opacity: 0.4; text-decoration: line-through; }
.swatch { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14); }
/* Four small ticks: food, water, rest, health. Tall and green is well; short and red is trouble. */
.vitals { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; margin-left: 2px; }
.vitals i { width: 3px; border-radius: 1.5px; background: var(--ok); min-height: 2px; transition: height 1s, background 1s; }
.vitals i.low { background: var(--warn); }
.chip small { font-weight: 400; color: var(--dim); max-width: 0; overflow: hidden; white-space: nowrap; transition: max-width 0.4s; }
.chip:hover small, .chip.on small { max-width: 220px; }

/* ------------------------------------------------------------ cards: person in view, and the feed */
.card { position: fixed; border-radius: var(--r); overflow: hidden; }
.card-top { display: flex; align-items: center; gap: 9px; padding: 10px 10px 10px 13px; }
.card-top.slim { padding: 6px 8px 6px 13px; }
.card-title { flex: 1; min-width: 0; }
.card-label { flex: 1; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.mini { background: transparent; border: 0; border-radius: 8px; padding: 3px 8px; font-size: 11px; color: var(--faint); letter-spacing: 0.04em; }
.mini:hover { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.card.min .card-body { display: none; }
.card.min { opacity: 0.86; }

#focus { left: var(--gap); bottom: calc(var(--gap) + 58px); width: min(340px, calc(100vw - 2 * var(--gap))); max-height: 52vh; display: flex; flex-direction: column; }
#focus .card-body { overflow: auto; padding: 0 14px 12px; }
#focus .swatch { width: 14px; height: 14px; }
#focus-name { font-weight: 700; font-size: 15.5px; }
#focus-doing { color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#focus-thought { margin: 0; padding: 2px 0 2px 11px; border-left: 2px solid var(--gold); font-size: 13.5px; line-height: 1.45; font-style: italic; }
#focus-more { margin: 10px 0 0; font-size: 12.5px; line-height: 1.45; display: none; }
#focus.more #focus-more { display: block; }
#focus dt { color: var(--faint); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 8px; }
#focus dd { margin: 2px 0 0; color: var(--dim); }

#feedbox { right: var(--gap); bottom: calc(var(--gap) + 58px); width: min(360px, calc(100vw - 2 * var(--gap))); background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
#feedbox .card-top { justify-content: flex-end; padding: 0 0 4px; opacity: 0; transition: opacity 0.25s; }
#feedbox:hover .card-top, #feedbox.min .card-top { opacity: 1; }
#feedbox.min .card-top { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 13px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
#feed { display: flex; flex-direction: column; gap: 5px; pointer-events: none; }
.line {
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 7px 11px; line-height: 1.4;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: rise 0.4s ease-out; transition: opacity 1.2s;
}
.line b { font-weight: 650; }
.line time { color: var(--faint); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.line.old { opacity: 0.5; }
.line.speech { font-style: italic; }
.line.milestone { border-color: var(--gold); color: var(--gold); }
.line.death, .line.fight, .line.quarrel { border-color: var(--warn); color: #ffc2b0; }
.line.omen { border-color: #9fc6ff; color: #cfe2ff; }
.line.bond { border-color: #f2a7c6; color: #ffd6e6; }
.line.build, .line.insight { border-color: rgba(255, 210, 122, 0.4); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* ------------------------------------------------------------ the dock */
#dock { left: 50%; bottom: var(--gap); transform: translateX(-50%); display: flex; align-items: center; gap: 3px; padding: 5px; border-radius: 999px; max-width: calc(100vw - 2 * var(--gap)); }
#dock button { background: transparent; border: 0; border-radius: 999px; padding: 8px 13px; color: var(--dim); white-space: nowrap; }
#dock button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.09); }
#modes { display: flex; gap: 2px; background: rgba(0, 0, 0, 0.26); border-radius: 999px; padding: 2px; }
#modes button.on { color: #1a1408; background: var(--gold); font-weight: 650; }
#dock .sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--line); }
#dock button.accent { color: var(--gold); box-shadow: inset 0 0 0 1px rgba(255, 210, 122, 0.45); }
#dock button.accent:hover { background: rgba(255, 210, 122, 0.16); }
#dock #sound-toggle.on { color: var(--ok); }
#uncinema { right: var(--gap); bottom: var(--gap); border-radius: 999px; padding: 8px 14px; color: var(--dim); opacity: 0.55; }
#uncinema:hover { opacity: 1; color: var(--ink); }

/* Just the island: every panel slides away. */
body.cinema #roster, body.cinema #focus, body.cinema #feedbox, body.cinema #dock { opacity: 0; pointer-events: none; transform: translateY(8px); }
body.cinema #dock { transform: translate(-50%, 8px); }
body.cinema #shade { opacity: 0.35; }
body.cinema .tag small { display: none; }

/* ------------------------------------------------------------ labels in the world */
.tag {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 11.5px; font-weight: 650;
  padding: 2px 8px; border-radius: 9px; background: rgba(13, 18, 26, 0.5); border: 1px solid var(--line);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); will-change: transform; transition: opacity 0.4s;
}
/* Only the person in view carries a note of what they are doing, so a crowd stays readable. */
.tag small { display: none; font-weight: 400; color: var(--dim); margin-left: 5px; }
.tag.mine { border-color: rgba(255, 210, 122, 0.55); }
.tag.mine small { display: inline; }
.bubble {
  position: absolute; transform: translate(-50%, -100%); max-width: 260px; font-size: 13px; line-height: 1.35;
  padding: 8px 11px; border-radius: 13px; background: #fbf7ef; color: #23201a; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.32);
  animation: rise 0.3s ease-out;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-top-color: #fbf7ef; border-bottom: 0; }

#banner {
  position: fixed; left: 50%; top: 20%; transform: translateX(-50%); padding: 14px 28px; border-radius: 18px; text-align: center;
  background: rgba(22, 17, 6, 0.74); border: 1px solid var(--gold); color: var(--gold); font-size: 20px; font-weight: 650;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); max-width: min(560px, calc(100vw - 32px)); animation: rise 0.6s ease-out; z-index: 4;
}
#banner small { display: block; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.8; margin-bottom: 4px; }

/* ------------------------------------------------------------ dialogs */
dialog { background: #131a22; color: var(--ink); border: 1px solid var(--line); border-radius: 20px; padding: 26px 30px; width: min(640px, calc(100vw - 32px)); max-height: 84vh; overflow: auto; line-height: 1.58; font-size: 14.5px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
dialog::backdrop { background: rgba(4, 7, 12, 0.6); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 12px; font-size: 21px; letter-spacing: -0.01em; }
dialog h3, #shape h3 { margin: 22px 0 6px; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
dialog p { margin: 0 0 10px; color: var(--dim); }
dialog ul { margin: 0 0 6px; padding-left: 18px; color: var(--dim); }
dialog li { padding: 3px 0; }
dialog b { color: var(--ink); }
dialog ol { margin: 0; padding: 0; list-style: none; }
dialog ol li { border-bottom: 1px solid var(--line); padding: 7px 0; color: var(--dim); }
dialog li time { color: var(--gold); margin-right: 8px; font-variant-numeric: tabular-nums; }
dialog .close { float: right; margin: -8px -12px 0 0; }
dialog button, #shape-close, #back button { background: rgba(255, 255, 255, 0.09); border: 0; border-radius: 9px; padding: 6px 12px; font-size: 12px; color: var(--ink); }
dialog button:hover, #shape-close:hover, #back button:hover { background: rgba(255, 255, 255, 0.18); }
button.link { background: none !important; padding: 0 !important; color: var(--gold) !important; font-size: inherit !important; text-decoration: underline; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0; }
.stat { background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 11px 8px; text-align: center; }
.stat b { display: block; font-size: 25px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.site { margin: 8px 0; }
.site-top { display: flex; justify-content: space-between; gap: 10px; }
.site-top small { color: var(--dim); }
.meter { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.11); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.6s; }
.who { display: grid; grid-template-columns: 78px 1fr; gap: 4px 10px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.who b { display: flex; align-items: center; gap: 6px; }
.who small { color: var(--dim); }
#island-chronicle p b { color: var(--gold); }
.hint { color: var(--faint); font-size: 12.5px; margin: 0 0 8px; }

/* ------------------------------------------------------------ shape the story, and the welcome-back note */
#shape { top: calc(var(--gap) + 46px); right: var(--gap); bottom: calc(var(--gap) + 58px); width: min(380px, calc(100vw - 2 * var(--gap))); padding: 18px 18px 16px; overflow: auto; z-index: 5; line-height: 1.45; background: var(--glass-strong); }
.shape-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shape-head h2 { margin: 0; font-size: 18px; }
#shape h3 small { color: var(--dim); letter-spacing: 0; text-transform: none; font-weight: 400; margin-left: 6px; }
.note { background: rgba(255, 210, 122, 0.1); border: 1px solid rgba(255, 210, 122, 0.38); color: var(--gold); border-radius: 11px; padding: 8px 11px; font-size: 12.5px; margin: 10px 0 0; }
#shape-coming { margin-top: 10px; font-size: 12.5px; color: var(--dim); }
#shape-coming b { color: var(--ink); }
.choice { position: relative; display: block; width: 100%; text-align: left; background: rgba(255, 255, 255, 0.055); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin-bottom: 7px; overflow: hidden; }
.choice:hover:not(:disabled) { border-color: var(--gold); background: rgba(255, 210, 122, 0.07); }
.choice:disabled { cursor: default; }
.choice .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255, 210, 122, 0.15); transition: width 0.6s; }
.choice > * { position: relative; }
.choice b { display: flex; justify-content: space-between; gap: 8px; font-weight: 650; }
.choice b span + span { font-weight: 400; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.choice small { display: block; color: var(--dim); margin-top: 2px; }
.choice.mine { border-color: var(--gold); }
.tone { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--ok); }
.tone.harsh { background: var(--warn); }
.tone.mixed { background: #e6cf7a; }
.field { display: block; color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.field input { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 14px; color: var(--ink); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.field input:focus { outline: 0; border-color: var(--gold); }
#support-row { display: flex; align-items: center; gap: 7px; }
#support-row button { background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-radius: 999px; padding: 7px 15px; }
#support-row button:hover { border-color: var(--gold); }
#support-total { margin-left: auto; color: var(--dim); font-size: 12.5px; }
#shape:not([hidden]) ~ #feedbox { opacity: 0; pointer-events: none; }
#back { left: 50%; top: calc(var(--gap) + 50px); transform: translateX(-50%); width: min(540px, calc(100vw - 32px)); padding: 16px 18px; z-index: 6; line-height: 1.5; max-height: 56vh; overflow: auto; background: var(--glass-strong); }
#back p { margin: 10px 0 0; color: var(--dim); }
#back p b { color: var(--gold); }

/* ------------------------------------------------------------ small screens */
@media (max-width: 760px) {
  :root { --gap: 10px; }
  #clock { padding: 6px 11px 6px 9px; gap: 7px; font-size: 12.5px; }
  #clock-weather, #clock .sepdot { display: none; }
  #roster { top: calc(var(--gap) + 40px); left: var(--gap); right: var(--gap); max-width: none; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { padding: 5px 9px 5px 7px; }
  .chip small { display: none; }
  #dock { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; border-radius: 18px; }
  #dock button { padding: 8px 11px; }
  #focus { right: var(--gap); width: auto; max-height: 40vh; }
  #feedbox { left: var(--gap); width: auto; }
  #focus:not([hidden]):not(.min) ~ #feedbox { display: none; }
  #feed .line:nth-last-child(n + 3) { display: none; }
  #shape { top: var(--gap); left: var(--gap); width: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  dialog { padding: 20px 20px; }
}

/* Children and expectant mothers in the row of people */
.chip.child { font-weight: 500; padding: 5px 9px 5px 7px; }
.chip small.age { max-width: none; color: var(--faint); font-size: 11px; margin-left: -2px; }

/* Embedded on the front page: nothing but the island and the people's names. */
body.embed #clock, body.embed #roster, body.embed #focus, body.embed #feedbox, body.embed #dock, body.embed #uncinema, body.embed #banner, body.embed #shape, body.embed #back, body.embed #shade { display: none !important; }
body.embed .tag small { display: none; }
