/* CyberVille frame styles, step 1. The tokens are the design session's tokens.css of 2026-10-22
   (the practice site's tokens: paper and ink, 1 amber accent, green means done and nothing else,
   red means not yet and nothing else), adapted to the cv- class names. System fonts only. The
   chrome over the world canvas (the bars, the prompt, the pad) is always the dark set. */
:root {
  --bg: #f2f4f1; --fg: #1c2420; --muted: #56605a; --surface: #ffffff; --surface-2: #f5f7f4;
  --rule: #d6dcd6; --rule-soft: #e7ebe6; --control-border: #808a84; --input-border: #77817b; --input-bg: #ffffff;
  --link-line: #c98a1c; --accent-text: #8a5000; --accent-soft: #fbf0dc;
  --btn-bg: #1c2420; --btn-fg: #ffffff; --btn-hover: #36433c;
  --sel-bg: #fbf0dc; --sel-border: #8a5000;
  --ok: #1a6b3a; --ok-fill: #2b8a4e; --ok-soft: #e2f1e6; --no: #b3261e; --no-soft: #fbe9e7;
  --focus: #8a5000;
  --mono-bg: #0f1412; --mono-fg: #e6ece7; --mono-amber: #f0b44c;
  --hud-bg: rgba(15, 20, 18, 0.88); --hud-fg: #e4eae5; --hud-muted: #a8b3ac; --hud-amber: #f0b44c; --hud-rule: #2f3a35;
  --hud-focus: #f0b44c; --hud-ok: #4fb873;
  --display: "DIN Alternate", Bahnschrift, "DIN Next", "Avenir Next Condensed", sans-serif;
  --ui: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", Ubuntu, Roboto, "Helvetica Neue", sans-serif;
  --prose: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Ubuntu Mono", monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-card: 6px; --r-control: 4px; --r-chip: 3px;
  --t-open: 150ms; --t-toast: 220ms;
  --bar-h: 56px; --bottom-h: 40px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151b18; --fg: #e4eae5; --muted: #9ba69f; --surface: #1c2420; --surface-2: #222b26;
    --rule: #313b36; --rule-soft: #28312c; --control-border: #76837b; --input-border: #7c8981; --input-bg: #151b18;
    --accent-text: #f0b44c; --accent-soft: #3b2f16;
    --btn-bg: #e4eae5; --btn-fg: #151b18; --btn-hover: #ffffff;
    --sel-bg: #3b2f16; --sel-border: #f0b44c;
    --ok: #74d394; --ok-fill: #4fb873; --ok-soft: #1a3324; --no: #ff8f85; --no-soft: #3a1d1a;
    --focus: #f0b44c;
  }
}
:root[data-theme="dark"] {
  --bg: #151b18; --fg: #e4eae5; --muted: #9ba69f; --surface: #1c2420; --surface-2: #222b26;
  --rule: #313b36; --rule-soft: #28312c; --control-border: #76837b; --input-border: #7c8981; --input-bg: #151b18;
  --accent-text: #f0b44c; --accent-soft: #3b2f16;
  --btn-bg: #e4eae5; --btn-fg: #151b18; --btn-hover: #ffffff;
  --sel-bg: #3b2f16; --sel-border: #f0b44c;
  --ok: #74d394; --ok-fill: #4fb873; --ok-soft: #1a3324; --no: #ff8f85; --no-soft: #3a1d1a;
  --focus: #f0b44c;
}

/* ---- the page: the game owns the viewport and nothing scrolls ----------------------- */
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0f1412; color: var(--fg);
  font: 16px/1.5 var(--ui); -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; outline: none; }
#game:focus-visible { outline: 2px solid var(--hud-focus); outline-offset: -2px; }
#game canvas { display: block; }
#overlay-root { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#overlay-root > * { pointer-events: auto; }
.cv-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.cv-pixel, .cv-portrait img, .cv-card img, .cv-clue img, .cv-brand img { image-rendering: pixelated; image-rendering: crisp-edges; }
kbd { font: 14px var(--mono); }
p { margin: 0 0 var(--s3); }

/* ---- the bars over the world (always the dark set) ---------------------------------- */
.cv-hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: var(--bar-h); padding: var(--s2) var(--s4);
  background: var(--hud-bg); color: var(--hud-fg); border-bottom: 1px solid var(--hud-rule);
}
.cv-room {
  margin: 0; min-width: 0; font: 600 18px/1.2 var(--display); letter-spacing: .005em; color: var(--hud-fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cv-hud-right { display: flex; align-items: center; gap: var(--s3); flex: none; }
.cv-progress { display: flex; align-items: center; gap: var(--s2); font: 700 16px/1.2 var(--display); white-space: nowrap; color: var(--hud-fg); }
.cv-progress:empty { display: none; }
.cv-cells { display: flex; gap: 3px; }
.cv-cell { width: 14px; height: 10px; border-radius: 2px; background: var(--hud-rule); }
.cv-cell.cv-done { background: var(--hud-ok); }
.cv-hud-btn {
  font: 600 15px/1 var(--ui); min-height: 44px; min-width: 44px; padding: 0 var(--s3); border-radius: var(--r-control);
  border: 1px solid var(--hud-muted); background: transparent; color: var(--hud-fg); cursor: pointer;
}
.cv-hud-btn kbd { color: var(--hud-amber); margin-left: var(--s1); }
.cv-hud-btn[aria-expanded="true"] { border-color: var(--hud-amber); }
.cv-hud-btn:focus-visible, .cv-dpad button:focus-visible, .cv-act:focus-visible, .cv-copy:focus-visible {
  outline: 2px solid var(--hud-focus); outline-offset: 2px;
}
.cv-hud-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); align-items: center;
  min-height: var(--bottom-h); padding: var(--s2) var(--s4);
  background: var(--hud-bg); color: var(--hud-muted); font-size: 14px; line-height: 1.5;
  border-top: 1px solid var(--hud-rule);
}
.cv-hud-bottom kbd { color: var(--hud-amber); }
#cv-presence:empty { display: none; }
#cv-presence { margin-left: auto; }

/* the prompt over the world */
.cv-prompt {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-h) + var(--s5)); z-index: 6;
  max-width: calc(100% - 32px); padding: var(--s2) var(--s3);
  background: var(--hud-bg); color: var(--hud-fg); border: 1px solid var(--hud-amber); border-radius: var(--r-control);
  font-size: 15px; line-height: 1.4; text-align: center;
}
.cv-prompt[hidden] { display: none; }
.cv-prompt kbd { color: var(--hud-amber); }

/* touch controls: phones and coarse pointers only */
.cv-touch { display: none; }
.cv-touch-only { display: none; }
.cv-dpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; }
.cv-dpad button {
  min-width: 44px; min-height: 44px; background: var(--hud-bg); border: 1px solid var(--hud-rule); color: var(--hud-fg);
  font: 20px var(--ui); border-radius: var(--r-control); padding: 0; touch-action: none; user-select: none; -webkit-user-select: none;
}
.cv-dpad .cv-blank { visibility: hidden; }
.cv-act {
  width: 96px; height: 96px; border-radius: 50%; background: var(--hud-bg); border: 2px solid var(--hud-amber);
  color: var(--hud-fg); font: 600 16px/1.2 var(--ui); touch-action: none; user-select: none; -webkit-user-select: none;
}

/* while the start page shows, the world chrome is hidden; while a box is open, the prompt is */
body.cv-at-start .cv-hud-top, body.cv-at-start .cv-hud-bottom, body.cv-at-start .cv-touch, body.cv-at-start .cv-prompt { display: none !important; }
body.cv-modal-open .cv-prompt { display: none; }

/* ---- shared controls ------------------------------------------------------------------ */
.cv-btn {
  font: 600 16px/1 var(--ui); min-height: 44px; min-width: 44px; padding: 0 var(--s4); border-radius: var(--r-control);
  border: 1px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-fg); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); text-decoration: none;
}
.cv-btn:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.cv-btn.cv-quiet { background: transparent; color: var(--fg); border-color: var(--control-border); }
.cv-btn.cv-quiet:hover { background: var(--surface-2); }
.cv-btn kbd { color: var(--accent-text); margin-left: var(--s1); }
.cv-btn:disabled { opacity: .55; cursor: not-allowed; }
.cv-btn:focus-visible, .cv-card:focus-within, .cv-input:focus-visible, a:focus-visible, .cv-thing:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.cv-label { display: block; font-size: 15px; font-weight: 600; margin: var(--s4) 0 var(--s1); color: var(--fg); }
.cv-input {
  display: block; width: 100%; font: 17px/1.3 var(--ui); padding: 10px var(--s3); min-height: 44px;
  border: 1px solid var(--input-border); border-radius: var(--r-control); background: var(--input-bg); color: var(--fg);
}
.cv-input:disabled { opacity: .6; }
.cv-hint { font-size: 14px; color: var(--muted); margin: var(--s1) 0 0; }
.cv-small { font-size: 14px; }
.cv-muted { color: var(--muted); }
.cv-status { min-height: 22px; font-size: 15px; margin: var(--s2) 0 0; color: var(--muted); }
.cv-status.cv-no { color: var(--no); font-weight: 600; }
.cv-row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; margin-top: var(--s4); }
.cv-hash {
  font: 14px/1.4 var(--mono); background: var(--surface-2); color: var(--fg); padding: 2px 6px; border-radius: var(--r-chip);
  border: 1px solid var(--rule); overflow-wrap: anywhere; word-break: break-all;
}
.cv-hash-label { font: 600 14px/1.4 var(--ui); color: var(--muted); margin-right: var(--s1); user-select: none; -webkit-user-select: none; }

/* ---- the start page ------------------------------------------------------------------- */
.cv-start {
  position: fixed; inset: 0; overflow-y: auto; overflow-x: hidden; background: var(--bg); color: var(--fg);
  -webkit-overflow-scrolling: touch;
}
.cv-page { max-width: 640px; margin: 0 auto; padding: var(--s6) var(--s4) var(--s7); }
.cv-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }
.cv-brand img { width: 40px; height: 40px; }
.cv-brand h1 { margin: 0; font: 700 31px/1.2 var(--display); letter-spacing: .005em; }
.cv-rulebox { border-left: 3px solid var(--link-line); padding: var(--s2) var(--s3); background: var(--surface-2); color: var(--fg); font-size: 15px; margin: var(--s4) 0; }
.cv-handle-row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.cv-handle {
  flex: 1 1 200px; min-height: 44px; display: flex; align-items: center; padding: 0 var(--s3);
  font: 600 18px/1.2 var(--ui); background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--r-control);
}
.cv-fieldset { border: 0; padding: 0; margin: var(--s5) 0 0; min-width: 0; }
.cv-legend { padding: 0; font-size: 15px; font-weight: 600; margin: 0 0 var(--s2); }
.cv-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.cv-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s2) var(--s1);
  min-height: 44px; border: 1px solid var(--control-border); border-radius: var(--r-card); background: var(--surface); cursor: pointer;
}
.cv-card input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.cv-card img { width: 48px; height: 48px; }
.cv-card-name { font-size: 14px; color: var(--muted); }
.cv-card:has(input:checked) { background: var(--sel-bg); border-color: var(--sel-border); box-shadow: inset 0 0 0 1px var(--sel-border); }
.cv-card:has(input:checked) .cv-card-name { color: var(--accent-text); font-weight: 600; }
.cv-card.cv-chosen { background: var(--sel-bg); border-color: var(--sel-border); box-shadow: inset 0 0 0 1px var(--sel-border); }
.cv-card.cv-chosen .cv-card-name { color: var(--accent-text); font-weight: 600; }
.cv-points { margin-top: var(--s6); }

/* ---- the speech card along the bottom -------------------------------------------------- */
.cv-speech {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-h) + var(--s4));
  width: min(720px, calc(100% - 32px)); max-height: calc(100% - var(--bar-h) - var(--bottom-h) - 32px); overflow: auto;
  background: var(--surface); color: var(--fg); border: 1px solid var(--rule); border-top: 3px solid var(--link-line); border-radius: var(--r-card);
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: var(--s3); padding: var(--s3) var(--s4) var(--s3) var(--s3);
  animation: cv-rise var(--t-open) ease-out;
}
.cv-portrait { width: 72px; height: 72px; margin: var(--s1) auto 0; background: var(--surface-2); border-radius: var(--r-card); display: grid; place-items: center; }
.cv-portrait img { width: 64px; height: 64px; object-fit: contain; }
.cv-who { font: 600 15px/1.3 var(--ui); color: var(--muted); margin: 0; }
.cv-words { font: 19px/1.45 var(--prose); margin: var(--s1) 0 var(--s2); white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.cv-added { font-size: 14px; color: var(--ok); font-weight: 600; }

/* ---- dialogs (the computer and the flag) ----------------------------------------------- */
.cv-scrim {
  position: fixed; inset: 0; background: rgba(15, 20, 18, 0.55);
  display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: var(--s4);
}
.cv-dialog {
  width: 100%; max-width: 560px; min-width: 0; max-height: 100%; overflow: auto;
  background: var(--surface); color: var(--fg); border: 1px solid var(--rule); border-radius: var(--r-card);
  padding: var(--s4) var(--s5) var(--s5); animation: cv-fade var(--t-open) ease-out;
}
.cv-dialog .cv-row .cv-btn { flex: 1 1 auto; }
.cv-kind { font-size: 14px; color: var(--muted); }
.cv-dialog h2 { margin: var(--s1) 0 var(--s2); font: 700 22px/1.2 var(--display); letter-spacing: .005em; }
.cv-lede { font: 17px/1.45 var(--prose); margin-bottom: var(--s2); white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-pw { position: relative; }
.cv-pw .cv-input { padding-right: 148px; min-height: 52px; }
.cv-pw .cv-toggle { position: absolute; right: 4px; top: 4px; bottom: 4px; min-height: 44px; font-size: 14px; padding: 0 var(--s2); }
.cv-flag-row {
  font: 17px/1.5 var(--mono); background: var(--mono-bg); color: var(--mono-fg); padding: var(--s3) var(--s4);
  border-radius: var(--r-control); border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.cv-flag { min-width: 0; overflow-wrap: anywhere; word-break: break-all; }
.cv-copy {
  font: 600 14px/1 var(--ui); min-height: 44px; min-width: 44px; padding: 0 var(--s3); white-space: nowrap; flex: none;
  border-radius: var(--r-control); border: 1px solid var(--mono-amber); background: transparent; color: var(--mono-amber); cursor: pointer;
}
.cv-takeaway { font: 18px/1.45 var(--prose); margin: var(--s4) 0 var(--s2); }
.cv-done-line { display: flex; align-items: center; gap: var(--s2); color: var(--ok); font-weight: 600; margin-top: var(--s3); }
.cv-done-line .cv-cell { width: 16px; background: var(--rule); }
.cv-done-line .cv-cell.cv-done { background: var(--ok-fill); }

/* ---- the journal drawer ---------------------------------------------------------------- */
.cv-drawer {
  position: fixed; top: var(--bar-h); right: 0; bottom: 0; width: min(380px, 100%); overflow-y: auto; overflow-x: hidden;
  background: var(--surface); color: var(--fg); border-left: 1px solid var(--rule);
  padding: var(--s4) var(--s4) var(--s7); box-shadow: -12px 0 32px rgba(28, 36, 32, .22);
  animation: cv-slide var(--t-open) ease-out;
}
.cv-drawer-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.cv-drawer h2 { margin: 0; font: 700 20px/1.2 var(--display); letter-spacing: .005em; }
.cv-drawer h3 { font: 600 14px/1.3 var(--ui); color: var(--muted); margin: var(--s5) 0 var(--s2); }
.cv-drawer ul { list-style: none; margin: 0; padding: 0; }
.cv-target { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--rule-soft); font-size: 15px; }
.cv-state { font-size: 14px; font-weight: 600; white-space: nowrap; flex: none; }
.cv-state.cv-ok { color: var(--ok); }
.cv-state.cv-todo { color: var(--muted); }
.cv-clue { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--s2); padding: var(--s2) 0; border-bottom: 1px solid var(--rule-soft); }
.cv-clue img { width: 32px; height: 32px; object-fit: contain; }
.cv-clue-src { font-size: 14px; color: var(--muted); }
.cv-clue-txt { font: 17px/1.45 var(--prose); white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-things { display: flex; flex-direction: column; gap: var(--s2); }
.cv-thing {
  width: 100%; min-height: 44px; text-align: left; font: 15px/1.3 var(--ui); padding: var(--s2) var(--s3);
  background: transparent; color: var(--fg); border: 1px solid var(--control-border); border-radius: var(--r-control); cursor: pointer;
}
.cv-thing:hover { background: var(--surface-2); }
.cv-where { font-size: 15px; }
.cv-method { font-size: 14px; }

/* ---- motion --------------------------------------------------------------------------- */
@keyframes cv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cv-rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes cv-slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes cv-sheet { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---- phones and touch screens ----------------------------------------------------------- */
@media (max-width: 640px), (pointer: coarse) {
  .cv-touch { display: block; }
  .cv-dpad { position: fixed; z-index: 6; left: var(--s4); bottom: calc(var(--bottom-h) + var(--s4)); width: 156px; height: 156px; }
  .cv-act { position: fixed; z-index: 6; right: var(--s4); bottom: calc(var(--bottom-h) + var(--s5) + 4px); }
  .cv-keys { display: none !important; }
  .cv-touch-only { display: inline; }
  .cv-hud-top { gap: var(--s2); }
  .cv-room { font-size: 16px; }
  .cv-hud-btn { padding: 0 var(--s2); }
  body.cv-no-presence { --bottom-h: 0px; }
  body.cv-no-presence .cv-hud-bottom { display: none; }
  .cv-prompt { bottom: calc(var(--bottom-h) + 196px); }
  .cv-speech { bottom: calc(var(--bottom-h) + 196px); grid-template-columns: 72px minmax(0, 1fr); max-height: calc(100% - var(--bar-h) - var(--bottom-h) - 212px); }
  body.cv-modal-open .cv-speech { bottom: calc(var(--bottom-h) + var(--s4)); max-height: calc(100% - var(--bar-h) - var(--bottom-h) - 32px); }
  .cv-portrait { width: 56px; height: 56px; }
  .cv-portrait img { width: 48px; height: 48px; }
  .cv-words { font-size: 17px; }
  .cv-dialog { padding: var(--s3) var(--s4) var(--s4); }
  .cv-flag-row { font-size: 15px; }
  .cv-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cv-drawer {
    top: auto; left: 0; right: 0; height: 70%; width: 100%; border-left: 0; border-top: 1px solid var(--rule);
    border-radius: var(--r-card) var(--r-card) 0 0; box-shadow: 0 -12px 32px rgba(28, 36, 32, .22);
    animation-name: cv-sheet;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
