:root {
  --bg: #07070b; --panel: rgba(14, 14, 20, 0.92); --line: #23232f; --ink: #ecebf2; --dim: #a3a1b3;
  --lime: #c3ff5c; --lav: #b9a3ff; --coral: #ff7a6b;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; overscroll-behavior: none; }
canvas#world { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; cursor: grab; image-rendering: pixelated; }
canvas#world.dragging { cursor: grabbing; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--lime); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* ---- top bar ---- */
.top { position: fixed; top: 0; left: 0; right: 0; padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) 6px calc(10px + var(--safe-l));
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand tools" "clock clock"; align-items: center; gap: 2px 8px; pointer-events: none;
  background: linear-gradient(rgba(7,7,11,.9), rgba(7,7,11,.55) 70%, transparent); }
.top > * { pointer-events: auto; }
.brand { grid-area: brand; font-weight: 800; letter-spacing: .06em; font-size: 15px; white-space: nowrap; }
.brand .word { color: var(--lime); }
.brand .sub { color: var(--ink); font-weight: 600; letter-spacing: .02em; }
.brand .tag { font: 600 12px var(--mono); color: var(--lav); border: 1px solid #3b3452; border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px; letter-spacing: 0; }
.clock { grid-area: clock; display: flex; flex-wrap: wrap; gap: 4px 10px; font: 12px var(--mono); color: var(--dim); }
.clock .phase { color: var(--ink); }
.clock .tide { color: var(--lav); }
.clock .round { color: var(--dim); }
.tools { grid-area: tools; display: flex; gap: 2px; }
.icon { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
.icon svg { width: 22px; height: 22px; }
.icon:hover { background: rgba(255,255,255,.06); }
.icon[aria-pressed="true"] { color: var(--bg); background: var(--lime); }
.icon.small svg { width: 20px; height: 20px; }

/* ---- ticker ---- */
.ticker { position: fixed; left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); bottom: calc(var(--sheet-h, 120px) + 16px + var(--safe-b)); font: 12px var(--mono); color: var(--dim);
  pointer-events: none; text-shadow: 0 1px 2px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .4s; }

/* ---- the followed daemon ---- */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px calc(12px + var(--safe-r)) calc(30px + var(--safe-b)) calc(12px + var(--safe-l));
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; max-height: 48dvh; display: flex; flex-direction: column; backdrop-filter: blur(6px); }
.sheet.expanded { max-height: 78dvh; }
.hint { margin: 0 0 8px; color: var(--dim); font-size: 13px; }
.pickrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #101017; cursor: pointer; text-align: left; }
.pick:hover { border-color: #3a3a4c; }
.pick .ph { display: flex; align-items: center; gap: 6px; font: 600 12px var(--mono); }
.pick canvas { width: 28px; height: 28px; image-rendering: pixelated; }
.pick .pi { font-size: 12px; color: var(--dim); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pick .pk { font: 12px var(--mono); color: var(--lav); }
.cardhead { display: flex; align-items: center; gap: 10px; }
.face { width: 48px; height: 48px; image-rendering: pixelated; background: #000; border-radius: 8px; flex: none; }
.who { flex: 1; min-width: 0; }
.name { font: 700 15px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.house { font: 600 12px var(--mono); padding: 1px 6px; border-radius: 6px; background: #1b1b26; margin-left: 2px; }
.meta { font: 12px var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.intent { margin: 8px 0 6px; font-size: 15px; line-height: 1.35; }
.intent .label { display: inline-block; font: 600 12px var(--mono); color: var(--bg); background: var(--lime); padding: 1px 6px; border-radius: 6px; margin-right: 4px; vertical-align: 1px; }
.bars { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.bar { height: 6px; border-radius: 3px; background: #22222e; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; transition: width .5s; }
.bar.hp i { background: var(--coral); }
.bar.vg i { background: var(--lav); }
.purse { font: 600 12px var(--mono); color: var(--lime); white-space: nowrap; }
.more { overflow-y: auto; margin-top: 8px; padding-right: 2px; overscroll-behavior: contain; min-height: 0; }
.card:not([hidden]) { display: flex; flex-direction: column; min-height: 0; }
.more h3 { font: 700 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--lav); margin: 14px 0 6px; }
.plan { margin: 0; color: var(--ink); font-size: 13px; }
.tally { margin: 6px 0 0; font: 12px var(--mono); color: var(--dim); }
.decisions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.decisions li { border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 13px; }
.decisions .chose { font-weight: 700; }
.decisions .p { font: 600 12px var(--mono); color: var(--lime); }
.decisions .why { color: var(--dim); margin-top: 2px; }
.decisions .alt { font: 12px var(--mono); color: var(--dim); margin-top: 4px; }
.decisions .when { font: 12px var(--mono); color: #77758a; float: right; }
.persona { margin: 0; font-size: 13px; color: var(--dim); }
.lessons, .story { margin: 0; padding-left: 18px; font-size: 13px; color: var(--dim); }
.story li { margin: 2px 0; }
.rec { font-size: 13px; }

/* ---- panels ---- */
.panel { width: min(520px, calc(100vw - 24px)); max-height: min(80dvh, 720px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: #0d0d13; color: var(--ink); overflow: hidden; }
.panel[open] { display: flex; flex-direction: column; }
.panel::backdrop { background: rgba(0,0,0,.6); }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.phead h2 { margin: 0; font: 700 16px var(--mono); color: var(--lime); }
.note { margin: 10px 16px 0; font-size: 12px; color: var(--dim); }
.standings, .chron { list-style: none; margin: 0; padding: 8px 8px 16px; overflow-y: auto; overscroll-behavior: contain; }
.standings li button { width: 100%; display: grid; grid-template-columns: 30px 28px 1fr auto; gap: 8px; align-items: center; min-height: 44px; padding: 4px 8px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; }
.standings li button:hover { background: #16161f; }
.standings .rk { font: 600 12px var(--mono); color: var(--dim); }
.standings canvas { width: 28px; height: 28px; image-rendering: pixelated; }
.standings .nm { font: 600 13px var(--mono); }
.standings .nm small { display: block; font-weight: 400; color: var(--dim); font-size: 12px; }
.standings .em { font: 700 13px var(--mono); color: var(--lime); }
.standings li.cut { border-top: 1px dashed #3b3452; margin-top: 4px; padding-top: 4px; }
.chron li { padding: 8px; border-bottom: 1px solid #16161f; font-size: 13px; }
.chron time { display: block; font: 12px var(--mono); color: #77758a; }
.about { padding: 4px 16px 16px; overflow-y: auto; font-size: 14px; }
.about h3 { font: 700 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--lav); margin: 16px 0 6px; }
.about ul { padding-left: 18px; }
.about li { margin: 4px 0; }
.about .dev { font: 12px var(--mono); color: var(--dim); }

.foot { position: fixed; right: calc(10px + var(--safe-r)); bottom: calc(6px + var(--safe-b)); font: 12px var(--mono); color: var(--dim); }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; }

/* ---- phone landscape and short screens: the sheet moves to the side ---- */
@media (orientation: landscape) and (max-height: 520px) {
  .top { grid-template-columns: auto 1fr auto; grid-template-areas: "brand clock tools"; }
  .clock { justify-content: center; }
  .sheet { left: auto; top: calc(56px + var(--safe-t)); width: min(340px, 46vw); max-height: none; border-radius: 16px 0 0 0; border-left: 1px solid var(--line); padding-bottom: calc(28px + var(--safe-b)); }
  .sheet.expanded { max-height: none; }
  .ticker { right: calc(min(340px, 46vw) + 12px); bottom: calc(8px + var(--safe-b)); }
  .pickrow { grid-template-columns: 1fr; }
  .pick .pi { -webkit-line-clamp: 2; }
}
/* ---- desktop: a floating card ---- */
@media (min-width: 900px) and (min-height: 560px) {
  .top { grid-template-columns: auto 1fr auto; grid-template-areas: "brand clock tools"; padding-left: 18px; padding-right: 14px; }
  .clock { justify-content: center; font-size: 13px; }
  .sheet { left: 16px; right: auto; bottom: 16px; width: 400px; border: 1px solid var(--line); border-radius: 16px; max-height: 46vh; padding-bottom: 12px; }
  .sheet.expanded { max-height: calc(100dvh - 100px); }
  .ticker { left: 432px; bottom: 22px; right: 160px; }
}
/* ---- narrow phones: a stacked brand so every control fits ---- */
@media (max-width: 520px) {
  .brand { display: flex; flex-direction: column; line-height: 1.05; font-size: 15px; }
  .brand .word { font-size: 12px; letter-spacing: .18em; }
  .brand .tag { display: none; }
  .clock::after { content: "prototype"; color: var(--lav); }
  .tools { gap: 0; }
  .icon { width: 44px; }
}
@media (max-width: 360px) { .clock .round { flex-basis: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar i, .ticker { transition: none; } }
body:has(.sheet.expanded) .ticker { display: none; }
