:root {
  --ink: #f4efe4; --muted: #c9c1b0; --panel: rgba(18, 20, 26, 0.72); --line: rgba(255, 255, 255, 0.14);
  --gold: #e3b74a; --bg: #101318;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body.viewer { overflow: hidden; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }

.hud { position: fixed; z-index: 3; }
.top { top: 12px; left: 12px; right: 12px; display: flex; gap: 12px; align-items: flex-start; pointer-events: none; }
.top > * { pointer-events: auto; }
.top > div { background: var(--panel); border: 1px solid var(--line); padding: 6px 10px; border-radius: 10px; }
.top h1 { margin: 0; font-size: 17px; letter-spacing: 0.02em; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.top p { margin: 2px 0 0; font-size: 13px; color: var(--ink); max-width: 560px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.back { background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none; padding: 7px 11px; border-radius: 10px; font-size: 13px; white-space: nowrap; }

.tools { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; max-width: 52vw; }
.tools button { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; font-size: 13px; min-height: 32px; white-space: nowrap; }
.tools button:active { background: rgba(227, 183, 74, 0.35); }
#load { display: none; background: rgba(18, 20, 26, 0.86); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
#load.show { display: inline-block; }
#load.warn { color: #ffcf7a; border-color: rgba(255, 190, 90, 0.5); }
#perf { display: none; top: 64px; right: 12px; margin: 0; padding: 6px 10px; font: 12px/1.45 ui-monospace, Consolas, monospace; color: #cfe8c8; white-space: pre; z-index: 4; }
#perf.show { display: block; }
#bench { display: none; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 120px); overflow: auto; padding: 16px; z-index: 6; }
#bench.show { display: block; }
#bench h3 { margin: 0 0 8px; color: var(--gold); font-size: 16px; }
#bench .bad { color: #ffcf7a; }
#bench table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
#bench td { padding: 5px 6px; border-top: 1px solid var(--line); }
#bench td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#bench .note { font-size: 11px; color: var(--muted); word-break: break-word; }

#status { bottom: 62px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#watch { bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid #c9a24a; padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#watch[hidden] { display: none; }

.pad { right: 12px; top: 50%; transform: translateY(-50%); display: grid; grid-template-columns: repeat(1, 44px); gap: 6px; }
.pad button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; }
.pad button:active { background: rgba(227, 183, 74, 0.35); }
.pad button.off { opacity: 0.5; }

#chips { left: 12px; right: 12px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--panel); border: 1px solid var(--line); padding: 8px 12px; border-radius: 999px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.chip.working i { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px currentColor; animation: workpulse 1.6s ease-in-out infinite; color: var(--gold); }
@keyframes workpulse { 50% { box-shadow: 0 0 0 2px var(--panel), 0 0 0 5px currentColor; } }
@media (prefers-reduced-motion: reduce) { .chip.working i { animation: none; } }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; will-change: transform; }
.tag span { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: rgba(12, 14, 18, 0.7); border: 1px solid var(--c); color: #fff; }
.tag .task { display: none; font-style: italic; font-size: 10px; line-height: 1.2; color: #f4ecd8; padding: 1px 7px; border-radius: 999px; background: rgba(12, 14, 18, 0.8); border-bottom: 1px solid var(--c); white-space: nowrap; }
.tag .task.show { display: block; }
.bubble { display: none; max-width: 190px; font-size: 12px; line-height: 1.3; background: #fffdf7; color: #1d1a16; padding: 6px 9px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.35); text-align: center; position: relative; }
.bubble.show { display: block; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 0; border-top-color: #fffdf7; }

#help { display: none; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow: auto; padding: 16px; z-index: 5; }
#help.show { display: block; }
#help h3 { margin: 0 0 8px; font-size: 16px; color: var(--gold); }
#help .note { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
#help table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
#help th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; }
#help td { padding: 6px; border-top: 1px solid var(--line); vertical-align: top; }
#help td:first-child { color: var(--gold); white-space: nowrap; }

#follow { top: 92px; left: 12px; display: none; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border: 1px solid var(--c, var(--line)); max-width: min(360px, calc(100vw - 24px)); }
#follow.show { display: flex; }
#follow img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--c); }
#follow b { display: block; font-size: 16px; }
#follow small { display: block; color: var(--c); color: color-mix(in srgb, var(--c) 70%, #fff); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
#follow .goal { display: block; font-size: 13px; color: var(--ink); margin-top: 2px; }

@media (max-width: 640px) {
  .top p { display: none; }
  .tools { max-width: 60vw; }
  .tools button { padding: 5px 9px; font-size: 12px; min-height: 30px; }
  #perf { top: 96px; right: 12px; font-size: 11px; }
  #status { bottom: 104px; font-size: 12px; }
  #watch { bottom: 142px; font-size: 12px; }
  .pad { top: auto; bottom: 180px; transform: none; grid-template-columns: repeat(3, 44px); }   /* clear of the status and watch pills (R9 F16) */
  #follow { top: 104px; }   /* below the wrapped title and tool buttons */
  #follow img { width: 48px; height: 48px; }
  #help td:first-child { white-space: normal; }
}

/* index page */
body.index { min-height: 100%; background: radial-gradient(1200px 600px at 50% -10%, #2a3346 0%, var(--bg) 60%); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 32px 16px 48px; }
.wrap h1 { margin: 0 0 6px; font-size: 28px; }
.wrap > p { margin: 0 0 24px; color: var(--muted); max-width: 760px; line-height: 1.5; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 19px; }
.card .tagline { margin: 0; color: var(--gold); font-size: 13px; font-weight: 600; }
.card p, .card li { color: var(--muted); font-size: 14px; line-height: 1.45; }
.card ul { margin: 0; padding-left: 18px; }
.card .rec { align-self: flex-start; background: var(--gold); color: #1a1408; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.card a.open { margin-top: auto; text-align: center; background: var(--gold); color: #1a1408; text-decoration: none; font-weight: 700; padding: 11px; border-radius: 10px; }
.controls { margin-top: 28px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 16px; padding: 18px; overflow-x: auto; }
.controls h2 { margin: 0 0 10px; font-size: 18px; }
.controls table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.controls th { text-align: left; color: var(--muted); padding: 6px; }
.controls td { padding: 7px 6px; border-top: 1px solid var(--line); }
.controls td:first-child { color: var(--gold); }
/* live/economy: market board */
#market { position: fixed; left: 12px; bottom: 76px; width: min(300px, calc(100vw - 32px)); max-height: calc(100vh - 200px); overflow: auto; padding: 12px 14px; z-index: 4; font-size: 13px; }
#market[hidden] { display: none; }
#market header { display: flex; justify-content: space-between; align-items: center; }
#market h3 { margin: 0; font-size: 15px; color: var(--gold); }
#market h4 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#market .note { margin: 4px 0 8px; color: var(--muted); font-size: 12px; }
#market .close { background: none; border: 0; color: var(--ink); font-size: 20px; min-width: 32px; min-height: 32px; }
#market table { width: 100%; border-collapse: collapse; }
#market th { text-align: left; color: var(--muted); font-weight: 600; padding: 2px 4px; }
#market td { padding: 3px 4px; border-top: 1px solid var(--line); }
#market td:nth-child(n+2), #market th:nth-child(n+2) { text-align: right; }
#market .trend.up { color: #e07a5f; } #market .trend.down { color: #81b29a; }
#market ul, #market ol { margin: 0; padding-left: 18px; } #market .purses { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; padding: 0; }
@media (max-width: 700px) { #market { bottom: 240px; max-height: 40vh; } }

/* live/sim: vitals */
/* Bars: health, food, water, energy; full is good. Below WANT a bar turns amber (.warn); past CRITICAL red and pulsing (.crit). */
.vs, .vb { --v1: #b8324a; --v2: #ff6f7d; }
.vs.food, .vb.food { --v1: #7fa83a; --v2: #d7c25a; }
.vs.water, .vb.water { --v1: #2f78c8; --v2: #7cc8ff; }
.vs.energy, .vb.energy { --v1: #b8862a; --v2: #f6d76c; }
.vs.warn, .vb.warn { --v1: #c9701e; --v2: #ffb347; }
.vs.crit, .vb.crit { --v1: #b0201e; --v2: #ff5a46; }
@keyframes vpulse { 50% { opacity: 0.45; } }
.chip.has-vitals { position: relative; padding-top: 6px; padding-bottom: 10px; }
.vstrip { position: absolute; left: 11px; right: 11px; bottom: 5px; height: 3px; display: flex; gap: 2px; pointer-events: none; }
.vs { flex: 1; overflow: hidden; border-radius: 2px; background: rgba(255, 255, 255, 0.12); }
.vs i { display: block; height: 100%; background: linear-gradient(90deg, var(--v1), var(--v2)); transform-origin: left; }
.vs.crit i, .vb.crit .vt i { animation: vpulse 1s ease-in-out infinite; }

#follow.has-vitals { flex-wrap: wrap; width: min(340px, calc(100vw - 24px)); }
#follow.has-vitals > div:not(.vit) { flex: 1 1 0; min-width: 0; }
.vit { flex: 1 0 100%; border-top: 1px solid rgba(227, 183, 74, 0.28); padding-top: 8px; font-size: 12px; }
.vit-bars { display: grid; gap: 5px; }
.vb { display: grid; grid-template-columns: 14px 46px 1fr 24px; align-items: center; gap: 6px; }
.vb svg { width: 14px; height: 14px; fill: var(--v2); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.vl { color: var(--muted); }
.vt { position: relative; height: 8px; overflow: hidden; border-radius: 999px; background: rgba(0, 0, 0, 0.45); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(227, 183, 74, 0.18); }
.vt i { position: absolute; inset: 0; border-radius: 999px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 55%), linear-gradient(90deg, var(--v1), var(--v2)); transform: translateX(-100%); }
.vn { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.vb.warn .vn { color: #ffb347; }
.vb.crit .vn { color: #ff6a56; font-weight: 700; }
.vstatus { margin: 7px 0 0; color: #ffb347; font-weight: 600; letter-spacing: 0.02em; }
.vstatus[hidden] { display: none; }
.vev { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; color: var(--ink); }
.vev li { display: flex; gap: 6px; white-space: nowrap; overflow: hidden; }
.vev li[hidden] { display: none; }
.vev li span:first-child { overflow: hidden; text-overflow: ellipsis; }
.vev li::before { content: ""; flex: none; width: 4px; height: 4px; margin-top: 6px; border-radius: 50%; background: var(--gold); }
.vev .ago { margin-left: auto; padding-left: 6px; flex: none; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .vs.crit i, .vb.crit .vt i { animation: none; } }
@media (max-width: 640px) {
  .vit-bars { grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .vb { grid-template-columns: 13px 1fr 22px; gap: 5px; }
  .vl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* pane 6: still read aloud */
}

/* live/sim: names */
#follow .family { display: block; font-size: 11px; color: var(--muted); font-style: italic; margin-top: 1px; }
.chip .sur { margin-left: -2px; }
@media (max-width: 640px) { .chip .sur { display: none; } }

/* live/sim: activity log */
.tools button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
#activity { position: fixed; top: 64px; right: 66px; bottom: 12px; width: min(480px, calc(100vw - 90px)); z-index: 6; display: flex; flex-direction: column; font-size: 13px; color: var(--ink); }
#activity[hidden], #activity .view[hidden], #activity .more[hidden] { display: none; }
#activity header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 10px 8px 14px; border-bottom: 1px solid var(--line); }
#activity h3 { margin: 0; font-size: 15px; color: var(--gold); letter-spacing: 0.02em; }
#activity .tabs { display: flex; gap: 4px; margin-right: auto; }
#activity button { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 999px; min-height: 32px; padding: 4px 11px; font-size: 12px; }
#activity button[aria-pressed="true"] { background: rgba(227, 183, 74, 0.2); border-color: var(--gold); color: #fff3d0; }
#activity .tab { font-weight: 600; }
#activity .dl { border-color: rgba(227, 183, 74, 0.5); }
#activity .close { background: none; border: 0; font-size: 22px; line-height: 1; min-width: 36px; min-height: 36px; padding: 0; }
#activity .view { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 8px 12px 12px; }
#activity .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
#activity .chip { display: inline-flex; align-items: center; gap: 5px; }
#activity .dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c, #888); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
#activity .sum, #activity .note { margin: 4px 0 8px; color: var(--muted); font-size: 12px; }
#activity .rows { list-style: none; margin: 0; padding: 0; }
#activity .rows li { display: grid; grid-template-columns: 42px 10px 20px 1fr; gap: 6px; align-items: baseline; padding: 5px 2px; border-top: 1px solid rgba(255, 255, 255, 0.07); line-height: 1.35; }
#activity .rows li.empty { display: block; color: var(--muted); }
#activity .rows time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
#activity .rows .ic { text-align: center; }
#activity .rows .tx { min-width: 0; overflow-wrap: anywhere; }
#activity .rows b { font-weight: 600; }
#activity .rows .g-chat .tx { color: #f6efe0; }
#activity .rows .g-health { background: rgba(224, 72, 60, 0.1); }
#activity .rows .g-health b { color: #ff9a8a; }
#activity .more { display: block; margin: 8px auto 0; }
#activity h4 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#activity .tw { overflow-x: auto; }
#activity table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
#activity th, #activity td { padding: 3px 5px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
#activity th:first-child { text-align: left; color: var(--muted); font-weight: 500; }
#activity thead th { border-top: 0; font-weight: 600; color: var(--ink); }
#activity .nm { display: inline-flex; align-items: center; gap: 4px; }
#activity th.nm { display: table-cell; }
#activity th.nm .dot { margin-right: 4px; }
#activity .pairs td { text-align: center; background: rgba(227, 183, 74, calc(var(--a, 0) * 0.55)); }
#activity .pairs td.self { background: rgba(255, 255, 255, 0.04); }
#activity .bars { display: grid; gap: 6px; }
#activity .bar { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; }
#activity .stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(0, 0, 0, 0.4); box-shadow: 0 0 0 1px rgba(227, 183, 74, 0.18); }
#activity .stack i { flex: 0 0 0; min-width: 2px; }
#activity .legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
#activity .legend span { display: inline-flex; align-items: center; gap: 4px; }
#activity .legend i { width: 10px; height: 10px; border-radius: 2px; }
#activity .a-idle { background: #6f6a62; } #activity .a-walk { background: #5b9bd5; } #activity .a-work { background: #e3b74a; } #activity .a-gather { background: #7fb24a; }
#activity .a-eat { background: #e07a3f; } #activity .a-drink { background: #4fc6d8; } #activity .a-rest { background: #b07ad8; } #activity .a-sleep { background: #4a4fa8; }
@media (max-width: 700px) {
  #activity { inset: 0; width: auto; border-radius: 0; border: 0; padding-top: var(--safe-t); padding-bottom: var(--safe-b); z-index: 20; }
  #activity header { padding-left: 12px; }
  #activity button { min-height: 36px; padding: 6px 12px; }
  #activity .close { min-width: 44px; min-height: 44px; }
  #activity .rows li { grid-template-columns: 40px 10px 20px 1fr; }
}

/* Phone/tablet menu and shared desktop controls. */
#menuBtn, #sheet { display: none; }
.m .top, .m #status { display: none; }   /* the title is in the menu; the Free roam chip replaces the duplicate pill */
.m #menuBtn { display: grid; place-items: center; right: calc(10px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); width: 48px; height: 48px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(227, 183, 74, 0.55); background: radial-gradient(circle at 32% 26%, rgba(64, 55, 40, 0.96), rgba(16, 18, 24, 0.94)); color: var(--gold);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.14); z-index: 8; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.m #menuBtn::before, .m #sheet button::before, .m #sheet .back::before { content: ""; flex: none; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.m #menuBtn::before { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E"); transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.25, 1); }
.m.menu-open #menuBtn::before { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); transform: rotate(90deg); }
.m #menuBtn:active { transform: scale(0.94); }
.m #menuBtn:focus-visible, .m #sheet button:focus-visible, .m #sheet .back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.m #sheet { display: block; left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); margin-left: auto; bottom: calc(68px + var(--safe-b)); max-width: 440px;
  max-height: calc(100vh - 88px); max-height: calc(100dvh - 88px - var(--safe-t) - var(--safe-b)); overflow: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: 10px 12px 14px; border-radius: 20px; z-index: 8; background: linear-gradient(170deg, rgba(40, 34, 26, 0.97), rgba(15, 17, 23, 0.97));
  border: 1px solid rgba(227, 183, 74, 0.32); box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transform-origin: 100% 100%; opacity: 0; visibility: hidden; transform: translateY(14px) scale(0.97);
  transition: opacity 0.18s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.25, 1), visibility 0s linear 0.26s; }
.m.menu-open #sheet { opacity: 1; visibility: visible; transform: none; transition: opacity 0.18s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.25, 1); }
.m .sh-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.m .sh-head b { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); white-space: nowrap; }
.m #sheet .back { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 999px; font-size: 0; white-space: nowrap;
  color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); -webkit-tap-highlight-color: transparent; }
.m #sheet .back::before { width: 18px; height: 18px; }
.m #sheet .back::after { content: attr(data-label); font-size: 13px; }
.m #sheet h4 { margin: 10px 2px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.m #sheet .pad { position: static; transform: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.m #sheet .tools { margin: 0; max-width: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.m #sheet button { position: relative; width: auto; height: 56px; min-width: 0; min-height: 0; margin: 0; padding: 0 2px; border-radius: 14px; font-size: 0; opacity: 1; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink);
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s; }
.m #sheet button::after { content: attr(data-label); max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; line-height: 1.1; letter-spacing: 0.02em; color: var(--muted); }
.m #sheet button[data-label=""]::after { display: none; }
.m #sheet button:active { transform: scale(0.94); background: rgba(227, 183, 74, 0.22); }
.m #sheet button[aria-pressed="true"] { color: var(--gold); border-color: rgba(227, 183, 74, 0.7); background: rgba(227, 183, 74, 0.12); }
.m #sheet button[aria-pressed="true"]::after { color: var(--gold); }
/* camera: zoom, turn and tilt as joined pairs with one caption each, then the labelled tiles */
[data-k=zoomOut] { order: 1; } [data-k=zoomIn] { order: 2; } [data-k=rotL] { order: 3; } [data-k=rotR] { order: 4; } [data-k=tiltDown] { order: 5; } [data-k=tiltUp] { order: 6; }
.m #sheet .pad .cap { order: 7; }
[data-k=help] { order: 10; } [data-k=time] { order: 11; } [data-k=recenter] { order: 12; } [data-k=sound] { order: 13; } [data-k=watch] { order: 14; } [data-k=market] { order: 15; }
[data-k=asgard] { order: 1; } [data-k=log] { order: 2; } [data-k=perf] { order: 3; } [data-k=quality] { order: 4; } #load { order: 9; }   /* the same order on desktop and phone */
.m #sheet [data-k=zoomOut], .m #sheet [data-k=rotL], .m #sheet [data-k=tiltDown] { height: 46px; border-radius: 14px 5px 5px 14px; margin-right: -3px; }
.m #sheet [data-k=zoomIn], .m #sheet [data-k=rotR], .m #sheet [data-k=tiltUp] { height: 46px; border-radius: 5px 14px 14px 5px; margin-left: -3px; }
.m .cap { grid-column: span 2; margin: -1px 0 4px; text-align: center; font-size: 10.5px; letter-spacing: 0.04em; color: var(--muted); }
.m #load { position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m #chips { left: calc(10px + var(--safe-l)); right: calc(64px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); padding: 4px 20px 4px 2px;
  flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; touch-action: pan-x;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); }
.m #chips::-webkit-scrollbar { display: none; }
.m .chip .sur { display: none; }
.m .chip { flex: none; min-height: 40px; padding: 6px 11px; font-size: 12.5px; }
.m .chip.has-vitals { padding-top: 4px; padding-bottom: 9px; }
.m #follow { top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); }
.m #perf { top: calc(46px + var(--safe-t)); right: calc(10px + var(--safe-r)); }   /* R14: below the time pill */
.m #watch { bottom: calc(68px + var(--safe-b)); }
.m #market { left: calc(10px + var(--safe-l)); bottom: calc(68px + var(--safe-b)); max-height: 55vh; }
/* Desktop shares the phone icons/order; tooltips are hover/focus only. */
#status:empty { display: none; }
body:not(.m) .pad { right: 14px; border-radius: 18px;
  background: linear-gradient(170deg, rgba(40, 34, 26, 0.88), rgba(15, 17, 23, 0.88)); border: 1px solid rgba(227, 183, 74, 0.28);
  box-shadow: 0 14px 40px -14px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
body:not(.m) .pad button, body:not(.m) .tools button, body:not(.m) .top .back { position: relative; color: var(--ink); -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s; }
body:not(.m) .pad button { padding: 0; display: grid; place-items: center; font-size: 0; opacity: 1;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09); }
body:not(.m) .pad button::before, body:not(.m) .tools button::before, body:not(.m) .top .back::before { content: ""; flex: none;
  background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
body:not(.m) .pad [data-k=zoomOut], body:not(.m) .pad [data-k=rotL], body:not(.m) .pad [data-k=tiltDown] { border-radius: 11px 4px 4px 11px; }
body:not(.m) .pad [data-k=zoomIn], body:not(.m) .pad [data-k=rotR], body:not(.m) .pad [data-k=tiltUp] { border-radius: 4px 11px 11px 4px; }
body:not(.m) .pad [data-k=help], body:not(.m) .pad [data-k=time] { margin-top: 9px; }   /* camera pairs above, toggles below */
body:not(.m) .tools { gap: 6px; }
body:not(.m) .tools button, body:not(.m) .top .back { display: inline-flex; align-items: center; gap: 6px; height: 34px; min-height: 34px; padding: 0 13px 0 10px;
  border-radius: 999px; font-size: 13px; background: linear-gradient(170deg, rgba(40, 34, 26, 0.85), rgba(15, 17, 23, 0.85)); border: 1px solid rgba(227, 183, 74, 0.24); }
body:not(.m) .tools button::before, body:not(.m) .top .back::before { width: 16px; height: 16px; }
body:not(.m) .top .back { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); font-size: 0; gap: 4px; padding-left: 8px; }
body:not(.m) .top .back::after { content: attr(data-label); font-size: 13px; }
body:not(.m) .pad button:hover, body:not(.m) .tools button:hover, body:not(.m) .top .back:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(227, 183, 74, 0.5); }
body:not(.m) .pad button:active, body:not(.m) .tools button:active { transform: scale(0.94); background: rgba(227, 183, 74, 0.26); }
body:not(.m) .pad [data-k=sound][aria-pressed="true"]::after { content: attr(data-tip) "  ·  on"; }
body:not(.m) .pad [data-k=sound][aria-pressed="false"]::after { content: attr(data-tip) "  ·  off"; }
body:not(.m) .pad button[aria-pressed="true"], body:not(.m) .tools button[aria-pressed="true"] { color: var(--gold); border-color: rgba(227, 183, 74, 0.75); background: rgba(227, 183, 74, 0.13); }
body:not(.m) .pad button:focus-visible, body:not(.m) .tools button:focus-visible, body:not(.m) .top .back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body:not(.m) .pad button::after, body:not(.m) .tools button::after { content: attr(data-tip); position: absolute; z-index: 9; pointer-events: none; white-space: nowrap;
  padding: 5px 9px; border-radius: 8px; font-size: 12px; line-height: 1.2; letter-spacing: 0.01em; color: var(--ink); background: rgba(12, 14, 18, 0.95);
  border: 1px solid rgba(227, 183, 74, 0.35); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.8); opacity: 0; transition: opacity 0.12s, transform 0.12s; }
body:not(.m) .pad button::after { right: calc(100% + 12px); top: 50%; transform: translate(4px, -50%); }
body:not(.m) .tools button::after { right: 0; top: calc(100% + 8px); transform: translateY(-4px); }
body:not(.m) .pad button:is(:hover, :focus-visible)::after, body:not(.m) .tools button:is(:hover, :focus-visible)::after { opacity: 1; transition-delay: 0.25s; }
body:not(.m) .pad button:is(:hover, :focus-visible)::after { transform: translate(0, -50%); }
body:not(.m) .tools button:is(:hover, :focus-visible)::after { transform: none; }
@media (prefers-reduced-motion: reduce) {
  body:not(.m) .pad button, body:not(.m) .tools button, body:not(.m) .top .back, body:not(.m) .pad button::after, body:not(.m) .tools button::after { transition: none; }
}
/* pane 6 R2: the local time and weather readout (menu.js, hud.js readout()) */
#now { display: none; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); }
#now .d { color: var(--muted); }
#now .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#now .lv { padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: #a6e3b0; background: rgba(90, 200, 120, 0.12); border: 1px solid rgba(120, 210, 150, 0.35); }
#now .lv.preview { color: var(--gold); background: rgba(227, 183, 74, 0.14); border-color: rgba(227, 183, 74, 0.55); }
#now .wx { display: inline-flex; align-items: center; gap: 5px; padding-left: 9px; border-left: 1px solid var(--line); }
#now .wx[hidden] { display: none; }
#now i { width: 16px; height: 16px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
#now i[data-k=""] { display: none; }
body:not(.m) #now { display: inline-flex; position: relative; height: 34px; padding: 0 13px; margin-left: auto; border-radius: 999px;
  background: linear-gradient(170deg, rgba(40, 34, 26, 0.85), rgba(15, 17, 23, 0.85)); border: 1px solid rgba(227, 183, 74, 0.24); }
body:not(.m) #now + .tools { margin-left: 0; }
body:not(.m) #now::after { content: attr(data-tip); position: absolute; right: 0; top: calc(100% + 8px); z-index: 9; pointer-events: none; white-space: nowrap;
  padding: 5px 9px; border-radius: 8px; font-size: 12px; color: var(--ink); background: rgba(12, 14, 18, 0.95); border: 1px solid rgba(227, 183, 74, 0.35);
  opacity: 0; transform: translateY(-4px); transition: opacity 0.12s, transform 0.12s; }
body:not(.m) #now:hover::after { opacity: 1; transform: none; transition-delay: 0.25s; }
body:not(.m) .top > div { min-width: 0; }   /* the title card gives way to the readout and tools on narrower desktops */
body:not(.m) #now, body:not(.m) .tools { flex-shrink: 0; }
body:not(.m) .top p { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.m #now { display: flex; }
@media (prefers-reduced-motion: reduce) { body:not(.m) #now::after { transition: none; } }
/* One quiet panel language. No backdrop blur: these nearly opaque surfaces sit over the live canvas. */
:root {
  --panel-bg: linear-gradient(165deg, rgba(40, 34, 26, 0.96), rgba(14, 16, 22, 0.97));
  --panel-line: rgba(227, 183, 74, 0.34);
  --panel-shadow: 0 18px 48px -16px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --close-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
}
#follow, #follow.has-vitals, #market, #activity, #help, #perf, #bench { background: var(--panel-bg); backdrop-filter: none; box-shadow: var(--panel-shadow); }
#follow, #follow.has-vitals { border-radius: 16px; box-shadow: 0 0 28px -10px var(--c, transparent), var(--panel-shadow); }
#market, #help, body:not(.m) #activity { border: 1px solid var(--panel-line); border-radius: 16px; }
body:not(.m) #activity { right: calc(132px + var(--safe-r)); width: min(480px, calc(100vw - 156px - var(--safe-l) - var(--safe-r))); }
#follow.show ~ #market { max-height: calc(100vh - 480px); min-height: 160px; }
.m #follow.show ~ #market { max-height: min(55vh, calc(100vh - 250px)); max-height: min(55dvh, calc(100dvh - 250px)); }
#market .close, #activity .close { width: 34px; height: 34px; min-width: 0; min-height: 0; padding: 0; display: grid; place-items: center; font-size: 0; border-radius: 50%;
  color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); transition: background-color 0.15s, border-color 0.15s; }
#market .close::before, #activity .close::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--close-icon) center / contain no-repeat; mask: var(--close-icon) center / contain no-repeat; }
#market .close:hover, #activity .close:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(227, 183, 74, 0.5); }
#market .close:focus-visible, #activity .close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.m #market .close, .m #activity .close { width: 44px; height: 44px; }
#activity .rows li { padding-top: 6px; padding-bottom: 6px; line-height: 1.4; }
@keyframes paneIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes paneFade { from { opacity: 0; } }
#market:not([hidden]), body:not(.m) #activity:not([hidden]), #follow.show { animation: paneIn 0.2s var(--ease-out); }
.m #activity:not([hidden]), #help.show { animation: paneFade 0.16s ease-out; }
@media (prefers-reduced-motion: reduce) { #market, #activity, #follow, #help { animation: none !important; } }
/* pane 6 R4: the follow card's link to the Agent Window */
#follow .aw { display: inline-block; margin-top: 6px; padding: 4px 0; font-size: 12px; color: var(--gold); text-decoration: none; border-bottom: 1px solid rgba(227, 183, 74, 0.45); }
#follow .aw:hover { color: #ffd77a; border-bottom-color: #ffd77a; }
#follow .aw:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
/* Diagnostic surfaces, transient pills, and the welcome action use the same hierarchy. */
#perf, #bench { border: 1px solid var(--panel-line); border-radius: 12px; }
#bench { border-radius: 16px; }
#watch, #load { background: linear-gradient(170deg, rgba(40, 34, 26, 0.92), rgba(15, 17, 23, 0.92)); border-color: rgba(227, 183, 74, 0.45); box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.8); }
#watch:not([hidden]) { animation: paneFade 0.2s ease-out; }
@media (prefers-reduced-motion: reduce) { #watch:not([hidden]) { animation: none; } }
#help.first #helpClose { padding: 8px 16px; color: #1a1408; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.m #load { top: calc(46px + var(--safe-t)); }
body:not(.m) #activity { bottom: auto; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px - var(--safe-t) - var(--safe-b)); }
body:not(.m) .top p { -webkit-line-clamp: 1; line-clamp: 1; max-width: 720px; }
body:not(.m) .pad { grid-template-columns: repeat(2, 36px); gap: 5px; padding: 7px; }
body:not(.m) .pad button { width: 36px; height: 36px; border-radius: 10px; }
body:not(.m) .pad button::before { width: 18px; height: 18px; }
body:not(.m) .pad :is([data-k=zoomIn], [data-k=rotR], [data-k=tiltUp], [data-k=time], [data-k=sound], [data-k=market])::after { right: calc(100% + 53px); }
body:not(.m) .pad button.off, .m #sheet button.off { opacity: 1; }
[data-k=sound][aria-pressed="false"] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5h3.5L12 6v12l-4.5-3.5H4z'/%3E%3Cpath d='M16 9.5l5 5M21 9.5l-5 5'/%3E%3C/svg%3E"); }
@media (hover: none) and (pointer: coarse) { .chip .n { display: none; } }   /* R14: the 1 to 5 key hints mean nothing on touch (a zoomed desktop keeps them) */
.m #now { position: fixed; z-index: 3; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); margin: 0; height: 30px; padding: 0 10px;
  gap: 6px; font-size: 12px; flex-wrap: nowrap; border-radius: 999px; background: linear-gradient(170deg, rgba(40, 34, 26, 0.9), rgba(15, 17, 23, 0.9));
  border: 1px solid rgba(227, 183, 74, 0.3); }
.m #now .d, .m #now .lv:not(.preview) { display: none; }
.m #now .wx { padding-left: 6px; }
.m #now .wx[data-s=none] { display: none; }
@media not all and (hover: none) and (pointer: coarse) { #help th:nth-child(3), #help td:nth-child(3) { display: none; } }   /* R14: keyboard and mouse devices: the PC column only, whatever the layout */
.m #activity .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.m #activity .chips::-webkit-scrollbar { display: none; }
#market h4:has(+ .feed:empty) { display: none; }
#help .keys { margin: 4px 0 10px; font-size: 13px; color: var(--ink); }
#help .keys label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
#help .keys input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--gold); }
#help .keys input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#help.first .keys { display: none; }
@media (hover: none) and (pointer: coarse) { #help .keys { display: none; } }   /* touch only: a tablet or narrow window with a keyboard keeps the switch */
/* Narrow pointer-fine windows simplify the header. */
@media (max-width: 1180px) {
  body:not(.m) .top p, body:not(.m) #now .d { display: none; }
  body:not(.m) .top > div { flex-shrink: 0; }
}
@media (max-width: 1000px) {
  body:not(.m) .tools button { font-size: 0; gap: 0; padding: 0 9px; }
}
/* pane 6 R9: Esc dismisses hover tooltips (WCAG 1.4.13); the readout's tooltip on keyboard focus; a corner close on help */
body.tips-off .pad button::after, body.tips-off .tools button::after, body.tips-off #now::after { opacity: 0 !important; transition: none !important; }
body:not(.m) #now:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body:not(.m) #now:focus-visible::after { opacity: 1; transform: none; }
#help .x { position: sticky; top: 0; float: right; margin: -4px -6px 4px 10px; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  color: var(--ink); background: #2a2620; border: 1px solid rgba(227, 183, 74, 0.35); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.8); transition: background-color 0.15s, border-color 0.15s; }   /* opaque: rows scroll under it */
#help .x::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--close-icon) center / contain no-repeat; mask: var(--close-icon) center / contain no-repeat; }
#help .x:hover { background: #3a342a; border-color: rgba(227, 183, 74, 0.6); }
#help .x:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.m #help .x { width: 44px; height: 44px; }   /* floats at the top right and stays in view while the help scrolls */
#splash { position: fixed; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  transition: opacity 0.6s ease; pointer-events: none; }
#splash::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(900px 600px at 50% 40%, #2a2a26 0%, var(--bg) 70%); transition: opacity 0.6s ease; }
#splash::before, #splash.stage span::before { content: ""; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 50%; border: 2px solid rgba(227, 183, 74, 0.22);
  border-top-color: var(--gold); animation: splashSpin 1.1s linear infinite; }
#splash b { font-size: 15px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
#splash span { font-size: 13px; color: var(--muted); }
#splash.gone { opacity: 0; }
#splash.stage { justify-content: flex-start; padding-top: calc(12px + var(--safe-t)); }
#splash.stage::after { opacity: 0; }
#splash.stage::before, #splash.stage b { display: none; }
#splash.stage span { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 9px; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: linear-gradient(170deg, rgba(40, 34, 26, 0.92), rgba(15, 17, 23, 0.92)); border: 1px solid rgba(227, 183, 74, 0.45); border-radius: 999px; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.8); }
#splash.stage span::before { flex: none; width: 12px; height: 12px; margin: 0; }
body:not(.hud-ready) :is(.pad, nav.tools, .top > div, #menuBtn) { visibility: hidden; }   /* until menu.js has placed and labelled them */
@keyframes splashSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #splash::before, #splash.stage span::before { animation: none; border-top-color: rgba(227, 183, 74, 0.6); } #splash, #splash::after { transition: none; } }
body:not(.m) .tools [data-k=perf], body:not(.m) .tools [data-k=quality] { font-size: 0; gap: 0; padding: 0 9px; }
body:not(.m) #now { min-width: 250px; }
#chips { align-items: stretch; }
#follow .x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  color: var(--muted); background: transparent; border: 1px solid transparent; transition: background-color 0.15s, color 0.15s; }
#follow .x::before { content: ""; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--close-icon) center / contain no-repeat; mask: var(--close-icon) center / contain no-repeat; }
#follow .x:hover { color: var(--ink); background: rgba(255, 255, 255, 0.1); }
#follow .x:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#follow b { padding-right: 24px; }
.m #follow .x { top: 4px; right: 4px; width: 44px; height: 44px; }
.m #follow b { padding-right: 36px; }
#help table tr:first-child > * { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* R14: visually hidden, still read as headers */
@media (hover: none) and (pointer: coarse) { #help > .note:not(.credits) { display: none; } }   /* the style's note names desktop keys */
/* pane 6 R13: the Log's two filter rows say what they filter (the rows already carry .who and .groups); on phones the time
   pill stays visible while following, above the menu button instead of under the follow card */
#activity .chips.who::before, #activity .chips.groups::before { flex: none; align-self: center; margin-right: 4px; min-width: 38px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
#activity .chips.who::before { content: "Who"; }
#activity .chips.groups::before { content: "What"; }
.m #follow.show ~ #now { display: flex; top: auto; bottom: calc(68px + var(--safe-b)); }
.m #follow.show ~ #market:not([hidden]) ~ #now { display: none; }   /* the market board takes that spot */
.m #help.first.show ~ #now { display: none; }   /* R14: and the welcome card on a first visit */
@media (max-width: 1180px) { body:not(.m) #now .wx span { display: inline-block; vertical-align: bottom; max-width: 150px; overflow: hidden; text-overflow: ellipsis; } }   /* R14: a long partial report does not push the header */
/* pane 6 R18: the readout's source on a tap, click or Enter (phones have no hover); it hides by itself after 5 s */
#now { cursor: pointer; }
.m #now::after { content: attr(data-tip); position: absolute; right: 0; top: calc(100% + 8px); z-index: 9; width: max-content; max-width: calc(100vw - 44px);
  white-space: normal; padding: 6px 10px; border-radius: 10px; font-size: 12px; line-height: 1.35; color: var(--ink); background: rgba(12, 14, 18, 0.96);
  border: 1px solid rgba(227, 183, 74, 0.35); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.8); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.m #follow.show ~ #now::after { top: auto; bottom: calc(100% + 8px); }   /* the pill sits low while following: open upward */
.m #now.tip::after, body:not(.m) #now.tip::after { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .m #now::after { transition: none; } }
/* pane 6 R20: page zoom on phones (WCAG 1.4.4). The HUD may be pinch-zoomed (never by a double tap); zoomed in, the world
   gives pinch and pan back to the browser, and Reset zoom follows the visible area (menu.js places it) */
body.viewer { touch-action: manipulation; }
.zoomed canvas#c, .zoomed #sheet, .zoomed #chips { touch-action: manipulation; }   /* zoomed: pinch out from anywhere */
#zoomReset {
  position: fixed; left: 0; top: 0; z-index: 60; transform-origin: 0 0; min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid rgba(232, 196, 112, 0.85); background: rgba(22, 19, 14, 0.94); color: #f6ead0;
  font: 600 15px/1.2 system-ui, sans-serif; box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.85); cursor: pointer;
}
#zoomReset[hidden] { display: none; }
/* pane 6 R5: accessibility. Screen-reader-only text, and one gold focus ring for every HUD control. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chip:focus-visible, #helpClose:focus-visible, #activity button:focus-visible, #market button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* help: phones see the phone column only; a first visit gets a short hint card above the menu, not the table */
#help:not(.first) .hint > b, #help:not(.first) .hint ul { display: none; }   /* full help: the what-am-I-watching paragraph, then the table */
@media (hover: none) and (pointer: coarse) { #help th:nth-child(2), #help td:nth-child(2), #help tr.pc { display: none; } }   /* R14: touch devices: the phone column only */
.m #help.first { top: auto; left: calc(10px + var(--safe-l)); right: calc(66px + var(--safe-r)); bottom: calc(68px + var(--safe-b));
  transform: none; width: auto; max-width: 380px; padding: 12px 14px; border-color: rgba(227, 183, 74, 0.45); box-shadow: 0 12px 36px -12px rgba(0, 0, 0, 0.85); }
.m #help.first > :not(.hint):not(#helpClose), #help.first > :not(.hint):not(#helpClose) { display: none; }
#help.first .hint { display: block; }
#help .hint b { color: var(--gold); font-size: 14px; letter-spacing: 0.02em; }
#help .hint .what { margin: 6px 0 4px; font-size: 13px; line-height: 1.5; color: var(--ink); }   /* pane 6 R4: what am I watching */
#help .hint ul { margin: 6px 0 10px; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--ink); }
@media (hover: none) and (pointer: coarse) { #help .hint .mouse { display: none; } }
@media not all and (hover: none) and (pointer: coarse) { #help .hint .touch { display: none; } }
body:not(.m) #help.first { top: auto; bottom: 72px; left: 16px; transform: none; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 100px); padding: 14px 18px;
  border-color: rgba(227, 183, 74, 0.45); }   /* desktop welcome: bottom left above the chips, off the camp (R7) */
@media (max-width: 350px) {   /* 320 px phones: tighter edges and gaps keep the six camera columns at 44 px */
  .m #sheet button::after, .m .cap { font-size: 9.5px; }
  .m #sheet { left: calc(6px + var(--safe-l)); right: calc(6px + var(--safe-r)); padding-left: 8px; padding-right: 8px; }
  .m #sheet .pad, .m #sheet .tools { gap: 4px; }
}
/* landscape phones: the camera in one row of twelve, so the sheet stays short */
@media (orientation: landscape) and (max-height: 500px) {
  .m #sheet { max-width: 720px; }
  .m #sheet .pad { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .m #sheet .pad > * { grid-row: 1; }
  .m #sheet .pad .cap { grid-row: 2; }
  .m #sheet button { height: 46px; }
  .m #sheet h4 { margin-top: 6px; }
}
/* Responsive polish: one safe-edge vocabulary, readable touch targets, and loading inside the visible area. */
:root { --safe-t: env(safe-area-inset-top); --safe-r: env(safe-area-inset-right); --safe-b: env(safe-area-inset-bottom); --safe-l: env(safe-area-inset-left); }
.top h1 { line-height: 1.2; }
.top p { line-height: 1.35; }
body:not(.m) .top { top: max(12px, var(--safe-t)); left: max(12px, var(--safe-l)); right: max(12px, var(--safe-r)); }
body:not(.m) .pad { right: calc(14px + var(--safe-r)); }
body:not(.m) #perf { top: calc(64px + var(--safe-t)); right: calc(12px + var(--safe-r)); }
#bench { max-height: calc(100vh - 120px - var(--safe-t) - var(--safe-b)); max-height: calc(100dvh - 120px - var(--safe-t) - var(--safe-b)); }
#status { bottom: calc(62px + var(--safe-b)); max-width: calc(100vw - 32px - var(--safe-l) - var(--safe-r)); }
#watch { bottom: calc(100px + var(--safe-b)); max-width: calc(100vw - 32px - var(--safe-l) - var(--safe-r)); }
#chips { left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); }
#follow { top: calc(92px + var(--safe-t)); left: calc(12px + var(--safe-l)); max-width: min(360px, calc(100vw - 24px - var(--safe-l) - var(--safe-r))); }
#market { width: min(300px, calc(100vw - 32px - var(--safe-l) - var(--safe-r))); max-height: calc(100vh - 200px - var(--safe-t) - var(--safe-b)); max-height: calc(100dvh - 200px - var(--safe-t) - var(--safe-b)); }
@media (min-width: 701px) { #activity { top: calc(64px + var(--safe-t)); right: calc(66px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); } }
#help { max-height: calc(100vh - 140px - var(--safe-t) - var(--safe-b)); max-height: calc(100dvh - 140px - var(--safe-t) - var(--safe-b)); }
body:not(.m) #help.first { bottom: calc(72px + var(--safe-b)); left: calc(16px + var(--safe-l)); width: min(440px, calc(100vw - 32px - var(--safe-l) - var(--safe-r))); max-height: calc(100vh - 100px - var(--safe-t) - var(--safe-b)); max-height: calc(100dvh - 100px - var(--safe-t) - var(--safe-b)); }
.m #chips { bottom: calc(10px + var(--safe-b)); }
.m #follow { max-width: min(360px, calc(100vw - 20px - var(--safe-l) - var(--safe-r))); }
.m #market { right: calc(10px + var(--safe-r)); width: auto; max-width: 300px; }
.m #follow.show ~ #market { min-height: 0; }
.m #activity { padding-left: var(--safe-l); padding-right: var(--safe-r); }
.m #help:not(.first) { inset: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l)); width: auto; max-height: none; transform: none; }
.m #help.first { max-height: calc(100vh - 96px - var(--safe-t) - var(--safe-b)); max-height: calc(100dvh - 96px - var(--safe-t) - var(--safe-b)); }
.m #now { max-width: calc(100vw - 20px - var(--safe-l) - var(--safe-r)); }
.m #now .t { flex: none; }
.m #now .wx { min-width: 0; }
.m #now .wx span { max-width: min(42vw, 220px); overflow: hidden; text-overflow: ellipsis; }
.m #load { max-width: calc(100vw - 24px - var(--safe-l) - var(--safe-r)); }
.m .chip { min-height: 44px; }
.m #sheet button::after { font-size: 11px; line-height: 1.15; }
#zoomReset:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#splash { padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
#splash b { line-height: 1.3; }
#splash span { line-height: 1.4; }
#splash.stage { padding-top: calc(12px + var(--safe-t)); padding-right: calc(12px + var(--safe-r)); padding-left: calc(12px + var(--safe-l)); }
#splash.stage span { max-width: calc(100vw - 24px - var(--safe-l) - var(--safe-r)); }
@media (max-width: 350px) { .m #sheet button::after { font-size: 9.5px; } }
@media (prefers-reduced-motion: reduce) {
  .m #sheet, .m.menu-open #sheet { transform: none; transition: none; }
  .m #menuBtn::before, #market .close, #activity .close, #follow .x, #help .x { transition: none; }
}
[data-k=help] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M9.6 9.4a2.5 2.5 0 1 1 3.6 2.3c-.7.4-1.2.9-1.2 1.7v.4'/%3E%3Cpath d='M12 17.2h.01'/%3E%3C/svg%3E"); }
[data-k=time] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3.5 2'/%3E%3C/svg%3E"); }
[data-k=recenter] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='7'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3'/%3E%3C/svg%3E"); }
[data-k=zoomIn] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4M11 8v6M8 11h6'/%3E%3C/svg%3E"); }
[data-k=zoomOut] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4M8 11h6'/%3E%3C/svg%3E"); }
[data-k=rotL] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 13a7.5 7.5 0 1 0 2.2-6.3L4 9.5'/%3E%3Cpath d='M4 4v5.5h5.5'/%3E%3C/svg%3E"); }
[data-k=rotR] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19.5 13a7.5 7.5 0 1 1-2.2-6.3L20 9.5'/%3E%3Cpath d='M20 4v5.5h-5.5'/%3E%3C/svg%3E"); }
[data-k=tiltUp] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 14l6-6 6 6M5 19h14'/%3E%3C/svg%3E"); }
[data-k=tiltDown] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 10l6 6 6-6M5 5h14'/%3E%3C/svg%3E"); }
[data-k=sound] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5h3.5L12 6v12l-4.5-3.5H4z'/%3E%3Cpath d='M15.5 9.5a3.5 3.5 0 0 1 0 5M18 7a7 7 0 0 1 0 10'/%3E%3C/svg%3E"); }
[data-k=watch] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='5.5' cy='10.5' r='1.8'/%3E%3Ccircle cx='9.5' cy='6' r='1.8'/%3E%3Ccircle cx='14.5' cy='6' r='1.8'/%3E%3Ccircle cx='18.5' cy='10.5' r='1.8'/%3E%3Cpath d='M12 12c-2.6 0-5 3.4-5 5.8 0 1.6 1.2 2.4 2.6 2.4 1 0 1.6-.5 2.4-.5s1.4.5 2.4.5c1.4 0 2.6-.8 2.6-2.4 0-2.4-2.4-5.8-5-5.8z'/%3E%3C/svg%3E"); }
[data-k=market] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v16M8 20h8M4 7h16'/%3E%3Cpath d='M6 7l-3 6a3 3 0 0 0 6 0zM18 7l-3 6a3 3 0 0 0 6 0z'/%3E%3C/svg%3E"); }
[data-k=asgard] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 20h18M5 20V11l2-2 2 2v9M15 20V11l2-2 2 2v9M9 20v-6h6v6M12 4v4M9 11h6'/%3E%3C/svg%3E"); }
[data-k=log] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01'/%3E%3C/svg%3E"); }
[data-k=perf] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h4l3-7 4 14 3-7h4'/%3E%3C/svg%3E"); }
[data-k=moon] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.6A8 8 0 1 1 9.4 4a6.4 6.4 0 0 0 10.6 10.6z'/%3E%3C/svg%3E"); }
[data-k=sun] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E"); }
[data-k=cloudy] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .4-8 5.5 5.5 0 0 0-10.6 1.5A3.3 3.3 0 0 0 7 18z'/%3E%3C/svg%3E"); }
[data-k=fog] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 13h10a4 4 0 0 0 .4-8 5.5 5.5 0 0 0-10.6 1.5A3.3 3.3 0 0 0 7 13zM4 17h16M6 21h12'/%3E%3C/svg%3E"); }
[data-k=rain] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 14h10a4 4 0 0 0 .4-8 5.5 5.5 0 0 0-10.6 1.5A3.3 3.3 0 0 0 7 14zM8 17l-1 3M12 17l-1 3M16 17l-1 3'/%3E%3C/svg%3E"); }
[data-k=snow] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 14h10a4 4 0 0 0 .4-8 5.5 5.5 0 0 0-10.6 1.5A3.3 3.3 0 0 0 7 14zM8 18h.01M12 18h.01M16 18h.01M10 21h.01M14 21h.01'/%3E%3C/svg%3E"); }
[data-k=thunderstorm] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 14h10a4 4 0 0 0 .4-8 5.5 5.5 0 0 0-10.6 1.5A3.3 3.3 0 0 0 7 14zM13 14l-3 4h4l-3 4'/%3E%3C/svg%3E"); }
[data-k=quality] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h9M17 7h3M4 17h3M11 17h9'/%3E%3Ccircle cx='15' cy='7' r='2'/%3E%3Ccircle cx='9' cy='17' r='2'/%3E%3C/svg%3E"); }

/* click-to-watch (28 Oct): the Agent Window's live cabinet view (?embed=1) is the picture alone; the cabinet around it names the agent */
body.embed .hud, body.embed #labels, body.embed #help, body.embed #now, body.embed #activity, body.embed #market { display: none !important; }
body.embed canvas { pointer-events: none; }
