/* Chronicle — "Archive Codex" design system. Light archive base: parchment
   and cream surfaces, aged-gold tooling, burgundy + forest accents.
   Tokens live in css/brand-tokens.css (imported before this file).
   Mobile-first for iPhone (390x844). */

:root {
  --paper: var(--ch-paper);
  --ink: var(--ch-text-primary);
  --muted: var(--ch-text-muted);
  --rule: var(--ch-line);
  --soft: var(--ch-parchment);
  --sel: var(--ch-pale-gold);      /* selected cell */
  --selword: #C9D6C6;              /* selected word — muted sage, archive-ink */
  --green: var(--ch-forest);
  --red: var(--ch-burgundy);
  --gold: var(--ch-gold);
  --serif: var(--ch-font-display);
  --sans: var(--ch-font-ui);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; overflow-x: hidden; }
body {
  font-family: var(--ch-font-text);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}
/* iOS (html.ios set by js/app.js) gets its native rubber band back — the
   real thing, momentum flicks included; the queen pull rides it. Everywhere
   else keeps the solid stop above: Android Chrome's built-in pull-to-refresh
   would fight the gesture, and desktop has no bounce to give. */
html.ios, html.ios body { overscroll-behavior: auto; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
#app { max-width: 600px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

.view { display: flex; flex-direction: column; min-height: 100dvh; }
.view[hidden] { display: none; }
.safe-top { padding-top: max(12px, env(safe-area-inset-top)); }
.scroll-main { flex: 1; overflow-y: auto; padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); }
.center-main { display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: center; gap: 8px; }

/* ---------- Home ---------- */
#view-home { background-color: var(--ch-paper); background-image: radial-gradient(rgba(11,11,11,.09) 1px, transparent 1.2px); background-size: 14px 14px; }
.masthead { text-align: left; padding: 18px 20px 12px; border-bottom: 3px solid var(--ch-ink); margin: 0 20px; position: relative; }
.masthead-seal { width: 44px; height: 44px; display: block; margin: 0 auto 6px; border-radius: 11px; }
.masthead h1 {
  font-family: var(--ch-font-display); font-size: 44px; letter-spacing: -0.01em; margin: 0;
  font-weight: 400; line-height: .92; color: var(--ch-text-primary); text-transform: uppercase;
}
.dateline { margin: 8px 0 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--ch-text-primary); font-family: var(--ch-font-ui); }
.masthead-sticker { position: absolute; right: 12px; top: 8px; width: 92px; transform: rotate(6deg); }

/* Masthead punch card: this week as die-punched ticket squares (streak). */
#punch-card { display: flex; gap: 5px; align-items: center; margin: 8px 0 2px; }
#punch-card .punch-day {
  width: 17px; height: 17px; border: 2px solid var(--ch-ink); background: var(--ch-cream);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--ch-font-ui); font-weight: 700; font-size: 8.5px; color: var(--ch-text-muted);
}
#punch-card .punch-day.future { border-color: var(--ch-line-soft); color: var(--ch-sage); }
#punch-card .punch-day.today { box-shadow: 2px 2px 0 var(--ch-ink); }
#punch-card .punch-day.punched i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--ch-ink);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.35);
}
#punch-card .punch-count {
  margin-left: 7px; font-family: var(--ch-font-ui); font-weight: 700; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ch-ink);
}

/* Celebration milestone postmark (streak days 2/3/5/7/10/25/50/100). */
.dd-postmark { display: flex; justify-content: center; margin: 2px 0 8px; }
.dd-postmark .postmark {
  width: 76px; height: 76px; border: 2.5px solid var(--ch-ink); border-radius: 50%;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-8deg); position: relative; color: var(--ch-ink);
}
.dd-postmark .postmark::after { content: ''; position: absolute; inset: 4px; border: 1px solid var(--ch-ink); border-radius: 50%; }
.dd-postmark b { font-family: var(--ch-font-display); font-size: 24px; line-height: 1; font-weight: 400; }
.dd-postmark small { font-family: var(--ch-font-ui); font-weight: 700; font-size: 6.5px; letter-spacing: .14em; text-transform: uppercase; text-align: center; line-height: 1.5; }

/* ---------- Game rows (NYT-Games-style: hero + day-card strip + Archive) --
   Built by js/app.js (renderGameRows). Each row carries its own accent tint
   via inline custom properties (--row-tint-strong/--row-tint-soft) computed
   once from GAME_ROWS so the CSS below stays purely structural. */
.home-rows { flex: 1; padding: 10px 0 14px; display: flex; flex-direction: column; gap: 18px; }
.game-row { display: flex; flex-direction: column; }
.game-strip {
  display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden;
  padding: 0 24px 10px; scroll-padding: 0 24px; scroll-snap-type: x proximity;
  scrollbar-width: none; -ms-overflow-style: none;
}
.game-strip::-webkit-scrollbar { display: none; }
/* .day-cards is just a semantic wrapper around the day-card buttons in the
   markup; display:contents lifts its children to be direct flex items of
   .game-strip (siblings of .hero-card) without an extra nested flex layer. */
.day-cards { display: contents; }

.hero-card {
  width: calc(100% - 40px); margin: 0 20px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  text-align: left; border: 2.5px solid var(--ch-ink); border-left: 12px solid var(--row-tint-strong, var(--ch-ink));
  padding: 16px 18px; background: var(--ch-cream);
  box-shadow: var(--ch-shadow-card); min-height: 118px;
  transition: transform .12s ease;
}
.hero-card:active { transform: scale(.985); }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero-text { flex: 1; min-width: 0; }
.hero-name { font-family: var(--ch-font-display); font-weight: 400; margin: 0 0 4px; font-size: 26px; text-transform: uppercase; letter-spacing: .01em; color: var(--ch-text-primary); }
.hero-tagline { margin: 0; color: var(--ch-text-secondary); font-size: 14px; line-height: 1.4; }
.hero-glyph { width: 66px; height: 66px; flex: none; border: none; display: block; }
.hero-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hero-edition {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--ch-tracking-smallcaps);
  font-weight: 700; color: var(--ch-text-label); font-family: var(--ch-font-ui); white-space: nowrap;
}
.hero-status { font-size: 12px; font-weight: 700; color: var(--ch-text-muted); font-family: var(--ch-font-ui); white-space: nowrap; }
.hero-card.row-done .hero-status { color: var(--ch-forest); }
.hero-card.row-progress .hero-status { color: var(--ch-gold); }

.day-card {
  flex: 0 0 27%; max-width: 27%; scroll-snap-align: start;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px;
  text-align: left; border: 2px solid var(--ch-ink);
  padding: 10px 12px; background: var(--ch-cream); min-height: 92px;
}
.day-card:active { transform: scale(.97); }
.day-weekday { font-family: var(--ch-font-ui); font-weight: 700; font-size: 15px; text-transform: uppercase; color: var(--ch-text-primary); line-height: 1.15; }
.day-status { font-size: 10px; font-family: var(--ch-font-ui); color: var(--ch-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.day-card.day-done { background: var(--row-tint-strong, var(--ch-pale-gold)); }
.day-card.day-done .day-status { color: var(--ch-ink); font-weight: 700; }

.row-archive {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: calc(100% - 40px); margin: 0 20px; padding: 9px 0;
  background: var(--ch-cream); border: 2px solid var(--ch-ink); border-top: none;
  font-size: 12px; font-weight: 700; letter-spacing: var(--ch-tracking-smallcaps); text-transform: uppercase;
  color: var(--ch-text-label); font-family: var(--ch-font-ui);
}
.row-archive:active { background: var(--ch-parchment); }
.row-archive-glyph { width: 14px; height: 14px; color: var(--ch-ink); }

.home-foot { text-align: center; color: var(--ch-text-muted); font-size: 12px; padding: 4px 0 calc(16px + env(safe-area-inset-bottom)); font-family: var(--ch-font-ui); }
.foot-toggle { background: none; border: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- Archive ---------- */
.archive-filters { display: flex; gap: 6px; overflow-x: auto; padding: 10px 20px; border-bottom: 1px solid var(--ch-line); background: var(--ch-paper); }
.archive-chip { flex: none; border-color: var(--ch-line); color: var(--ch-text-muted); font-family: var(--ch-font-ui); }
.archive-chip.active { background: var(--ch-ink); color: var(--ch-text-inverse); border-color: var(--ch-ink); }
.archive-row { width: 100%; }
.archive-marks { display: flex; gap: 5px; flex: none; }
.archive-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ch-line); display: inline-block; }
.archive-dot.done { background: var(--ch-forest); }
.archive-dot.progress { background: var(--ch-gold); }

/* Back Issues calendar (The Morgue): one month per section, Monday-first. */
.cal-month { padding: 12px 20px 2px; }
.cal-title { font-family: var(--ch-font-display); font-weight: 400; font-size: 20px; text-transform: uppercase; margin: 8px 0 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-family: var(--ch-font-ui); font-size: 10px; font-weight: 700; color: var(--ch-text-muted); padding-bottom: 2px; }
.cal-cell {
  position: relative; aspect-ratio: 1; padding: 0; cursor: pointer;
  border: 1.5px solid var(--ch-line-soft); background: var(--ch-paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-family: var(--ch-font-ui);
}
.cal-cell b { font-size: 13px; font-weight: 700; color: var(--ch-ink); line-height: 1; }
button.cal-cell:active { background: var(--ch-parchment); }
.cal-cell.blank, .cal-cell.dead { border-color: transparent; background: transparent; cursor: default; }
.cal-cell.dead { color: var(--ch-text-muted); font-size: 12px; opacity: .35; }
.cal-cell.future { opacity: .45; }
.cal-cell.today { border: 2.5px solid var(--ch-ink); box-shadow: 2px 2px 0 var(--ch-ink); cursor: default; }
.cal-dots { display: flex; gap: 3px; }
.cal-dots .archive-dot { width: 6px; height: 6px; }

.conn-list-intro { margin: 12px 20px 0; color: var(--ch-text-secondary); font-size: 14px; font-style: italic; line-height: 1.4; }

#ios-tip {
  margin: 0 20px 10px; padding: 12px 38px 12px 14px; position: relative;
  background: var(--ch-cream); border: 1px solid var(--ch-line); border-radius: 12px; font-size: 14px;
  font-family: var(--ch-font-ui); color: var(--ch-text-primary);
}
#ios-tip p { margin: 0; }
#ios-tip .share-glyph { width: 13px; height: 17px; vertical-align: -3px; color: var(--ch-forest); }
#ios-tip button { position: absolute; right: 8px; top: 6px; font-size: 20px; color: var(--muted); padding: 4px 8px; }

/* First-visit orientation line (see initHome): one sentence, then gone. */
#stranger-line {
  margin: 12px 24px 0; padding: 10px 36px 10px 12px; position: relative;
  background: var(--ch-cream); border: 2px solid var(--ch-ink); box-shadow: 3px 3px 0 var(--ch-ink);
  font-family: var(--ch-font-ui); font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; line-height: 1.55; color: var(--ch-text-primary);
}
#stranger-line button { position: absolute; right: 6px; top: 4px; font-size: 18px; color: var(--ch-text-muted); padding: 4px 8px; }

/* "New edition off the presses" bar: appears (via js/app.js) once a freshly
   deployed version has installed underneath the running page. Fixed over
   every view — the pull-to-refresh, or tapping it, reloads into the update. */
#new-edition {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--ch-ink); color: var(--ch-text-inverse);
  border: none; border-bottom: 3px solid var(--df-magenta);
  font-family: var(--ch-font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; text-align: center;
  cursor: pointer; animation: new-edition-in 320ms cubic-bezier(.2,1,.4,1);
}
#new-edition b { color: var(--df-yellow); font-weight: 700; }
@keyframes new-edition-in { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 2.5px solid var(--ch-ink);
  background: var(--ch-paper); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-family: var(--ch-font-display); font-weight: 400; font-size: 18px; text-transform: uppercase; letter-spacing: .02em; margin: 0; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ch-text-primary); }
#view-conn .topbar h2, #view-connsum .topbar h2 {
  white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.1; padding: 2px 0;
}
.topbar-right { display: flex; align-items: center; gap: 6px; min-width: 44px; justify-content: flex-end; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 50%; font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  color: var(--ch-text-primary);
}
.iconbtn:active { background: var(--ch-parchment); }
#map-score { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ch-text-muted); font-family: var(--ch-font-ui); }

/* ---------- Buttons ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--ch-ink); border-radius: 0;
  padding: 9px 18px; font-size: 14px; font-weight: 700; background: var(--ch-cream);
  color: var(--ch-text-primary); font-family: var(--ch-font-ui); text-transform: uppercase; letter-spacing: .03em;
}
.pill:active { background: var(--ch-parchment); }
.pill.primary { background: var(--ch-ink); color: var(--ch-text-inverse); border-color: var(--ch-ink); box-shadow: 4px 4px 0 rgba(11,11,11,.28); }
.pill.primary:active { background: #2A2A26; transform: translate(2px,2px); box-shadow: 2px 2px 0 rgba(11,11,11,.28); }
.pill.ghost { border-color: var(--ch-line); color: var(--ch-text-secondary); background: transparent; }
.pill.warn { border-color: var(--ch-burgundy); color: var(--ch-burgundy); }
.pill.small { padding: 7px 13px; font-size: 13px; }
.pill.big { width: 100%; padding: 15px; font-size: 16px; font-family: var(--ch-font-display); font-weight: 400; letter-spacing: .05em; }
.pill:disabled { opacity: .35; pointer-events: none; }
.pill .cost { font-weight: 400; color: inherit; opacity: .65; font-size: .85em; }

.view-game { height: 100dvh; overflow: hidden; }

/* ---------- Sheets, modals, toast ---------- */
.sheet { position: fixed; inset: 0; background: rgba(43,33,24,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-card {
  background: var(--ch-paper); border-radius: 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 600px; max-height: 86dvh; display: flex; flex-direction: column; gap: 10px;
  border-top: 3px solid var(--ch-ink);
}
.sheet-card h3 { margin: 4px 0 2px; font-size: 12px; font-family: var(--ch-font-ui); text-transform: uppercase; letter-spacing: var(--ch-tracking-smallcaps); font-weight: 700; color: var(--ch-text-label); }
.sheet-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-close { margin-top: 8px; }
.confirm-msg { margin: 6px 0 10px; font-size: 16px; font-weight: 600; color: var(--ch-text-primary); }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01s !important; transition-duration: .01s !important; }
}

/* ---------- Map game ---------- */
.b-birth { color: var(--ch-map-destination); }
.b-death { color: var(--ch-map-origin); }
#map-panel { position: relative; background: var(--ch-parchment); border-bottom: 1px solid var(--ch-line); }
#map-svg { display: block; width: 100%; height: 38dvh; }
.map-land { fill: var(--ch-parchment); stroke: var(--ch-line-soft); stroke-width: .6; }
.mk-dot { stroke: var(--ch-cream); stroke-width: .8; }
.mk-birth { fill: var(--ch-map-destination); }
.mk-death { fill: var(--ch-map-origin); }
.mk-label { font-family: var(--ch-font-ui); font-weight: 700; paint-order: stroke; stroke: var(--ch-map-origin-halo); fill: var(--ch-map-label); }
#map-streak {
  position: absolute; top: 8px; right: 10px; background: var(--ch-ink); color: var(--ch-text-inverse);
  font-size: 12px; font-weight: 700; border-radius: 0; padding: 4px 10px; font-family: var(--ch-font-ui); border: 2px solid var(--ch-ink);
}
.map-main { flex: 1; overflow-y: auto; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; background: var(--ch-cream); }
#map-question { margin: 0; font-size: 15px; color: var(--ch-text-primary); }
#map-form { display: flex; gap: 8px; }
#map-input {
  flex: 1; font-family: var(--ch-font-ui); font-size: 15px; padding: 12px 14px;
  border: 2px solid var(--ch-ink); border-radius: 0; min-width: 0; background: var(--ch-cream);
  color: var(--ch-text-primary); text-transform: uppercase;
}
#map-input:focus { outline: 3px solid var(--ch-gold); outline-offset: 1px; }
#map-input.shake { animation: shake .35s ease; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
#map-hints { display: flex; gap: 8px; flex-wrap: wrap; }
#map-feedback { border-radius: 0; padding: 12px 14px; font-size: 15px; line-height: 1.45; }
#map-feedback.good { background: var(--ch-cream); border: 2px solid var(--ch-ink); border-left: 10px solid var(--ch-thread-green); }
#map-feedback.info { background: var(--ch-cream); border: 2px solid var(--ch-ink); }
#map-feedback b.fig { font-family: var(--ch-font-display); font-weight: 400; font-size: 17px; }
#map-feedback .pts { font-weight: 800; color: var(--ch-gold); }
#map-guesses { display: flex; flex-wrap: wrap; gap: 6px; }
#map-next { position: sticky; bottom: 2px; }
.guess-chip {
  font-size: 12px; color: var(--ch-text-muted); background: var(--ch-cream); font-family: var(--ch-font-ui);
  border: 1.5px solid var(--ch-line-soft); border-radius: 0; padding: 4px 10px; text-decoration: line-through; text-transform: uppercase;
}
.hint-chip { font-size: 13px; background: var(--ch-pale-gold); border: 2px solid var(--ch-ink); border-radius: 0; padding: 8px 12px; color: var(--ch-text-primary); font-family: var(--ch-font-ui); }

/* ---------- Zoom In game (Face Value / Relic) ---------- */
/* The image frame keeps a dark neutral backing (#111) — artwork needs it —
   but its chrome/border goes parchment+gold per the brand spec. */
#rv-panel { position: relative; background: var(--ch-parchment); border-bottom: 1px solid var(--ch-line); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 12px; }
/* Positioning context for the verdict badge: it sits OUTSIDE the frame so the
   frame's overflow:hidden can never clip the stamp. Sized to the frame's
   content width, so the badge's negative offsets land on the frame's corner. */
#rv-frame-wrap { position: relative; }
#rv-frame-wrap.pz-active { overflow: hidden; }
#rv-frame-wrap .df-moment-badge { z-index: 5; }
#rv-frame {
  width: min(80vw, 40dvh); aspect-ratio: 1 / 1; border-radius: 0; position: relative;
  background-repeat: no-repeat; background-color: #111; overflow: hidden;
  box-shadow: var(--ch-shadow-card); border: 3px solid var(--ch-ink);
  transition: width .35s ease, aspect-ratio .35s ease;   /* morph to the image's shape on reveal */
}
#rv-timerbar {
  width: min(76vw, 38dvh); height: 6px; border-radius: 999px;
  background: rgba(43,33,24,.12); overflow: hidden;
}
#rv-timerfill { height: 100%; width: 100%; background: var(--ch-forest); }
#rv-streak {
  position: absolute; top: 14px; right: 16px; background: var(--ch-ink); color: var(--ch-text-inverse);
  font-size: 12px; font-weight: 700; border-radius: 0; padding: 4px 10px; font-family: var(--ch-font-ui); border: 2px solid var(--ch-ink);
}
#rv-pause {
  font-size: 12px; font-weight: 700; padding: 4px 12px;
  background: var(--ch-forest); color: var(--ch-text-inverse); border-color: var(--ch-forest);
}
#rv-prompt { margin: 0; font-size: 15px; font-weight: 700; color: var(--ch-text-primary); }
#rv-form { display: flex; gap: 8px; }
#rv-input {
  flex: 1; font-family: var(--ch-font-ui); font-size: 15px; padding: 12px 14px;
  border: 2px solid var(--ch-ink); border-radius: 0; min-width: 0; background: var(--ch-cream);
  color: var(--ch-text-primary); text-transform: uppercase;
}
#rv-input:focus { outline: 3px solid var(--ch-gold); outline-offset: 1px; }
#rv-input.shake { animation: shake .35s ease; }
#rv-controls { display: flex; gap: 8px; flex-wrap: wrap; }
#rv-guesses { display: flex; flex-wrap: wrap; gap: 6px; }
#rv-feedback { border-radius: 0; padding: 12px 14px; font-size: 15px; line-height: 1.45; }
#rv-feedback.good { background: var(--ch-cream); border: 2px solid var(--ch-ink); border-left: 10px solid var(--ch-thread-green); }
#rv-feedback.info { background: var(--ch-cream); border: 2px solid var(--ch-ink); }
#rv-feedback b.fig { font-family: var(--ch-font-display); font-weight: 400; font-size: 17px; }
#rv-feedback .pts { font-weight: 800; color: var(--ch-gold); }
.rv-credit { color: var(--ch-text-muted); font-size: 11px; }
#rv-next { position: sticky; bottom: 2px; }

/* ---------- Map start & summary ---------- */
.start-glyph { width: 200px; margin: 10px auto 0; }
.start-title { font-family: var(--ch-font-display); font-weight: 400; font-size: 27px; margin: 8px 0 0; color: var(--ch-text-primary); }
.start-copy { color: var(--ch-text-primary); font-size: 15px; line-height: 1.5; max-width: 330px; margin: 6px 0 0; }
.start-copy.small { color: var(--ch-text-muted); font-size: 13px; }
#map-best { margin-top: 4px; }
#map-start { margin-top: 14px; max-width: 330px; }

.sum-total { text-align: center; margin: 18px 0 0; }
.sum-total::before {
  content: ''; display: block; height: 5px; margin: 0 auto 12px; max-width: 160px;
  background: var(--ch-ink);
}
#sum-total { font-family: var(--ch-font-display); font-weight: 400; font-size: 64px; display: block; line-height: 1; color: var(--ch-text-primary); }
.sum-total-label { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: var(--ch-text-muted); font-family: var(--ch-font-ui); }
.sum-remark { text-align: center; color: var(--ch-text-muted); margin: 6px 0 18px; font-style: italic; }
.sum-list { list-style: none; margin: 0 0 18px; padding: 0; }
.sum-list li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--ch-parchment); font-size: 15px; color: var(--ch-text-primary); }
.sum-list .sum-name { flex: 1; }
.sum-list .sum-name small { display: block; color: var(--ch-text-muted); font-size: 12px; }
.sum-list .sum-pts { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ch-gold); }
.sum-list .sum-pts.zero { color: var(--ch-text-muted); font-weight: 400; }
.sum-actions { display: flex; flex-direction: column; gap: 10px; }

/* Desktop niceties */
@media (min-width: 700px) {
  body { background: #E4DFCE; }
  #app { background: var(--ch-paper); border-left: 2.5px solid var(--ch-ink); border-right: 2.5px solid var(--ch-ink); }
}

/* ---------- Connections (Thread) ---------- */
.conn-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; margin: 10px 0;
}
.conn-tile {
  aspect-ratio: 1 / 1; border-radius: 0;
  background: var(--ch-cream); border: 2px solid var(--ch-ink); box-shadow: 2.5px 2.5px 0 var(--ch-ink);
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 13px; font-weight: 700;
  padding: 6px; cursor: pointer; user-select: none;
  transition: background .1s, transform .1s;
  line-height: 1.15; color: var(--ch-text-primary);
  /* Whole words only: never break mid-word. JS (fitConnTiles) shrinks the font
     so long single words fit on one line; multi-word tiles wrap at spaces. */
  min-width: 0; overflow: hidden; overflow-wrap: normal; word-break: normal; hyphens: manual;
}
.conn-tile:active { transform: translate(2px,2px); box-shadow: .5px .5px 0 var(--ch-ink); }
.conn-selected { background: var(--df-cyan); color: var(--ch-ink); border-color: var(--ch-ink); }
.conn-grid.conn-shake { animation: shake .35s ease; }
.conn-group {
  border-radius: 0; border: 2px solid var(--ch-ink); box-shadow: 3px 3px 0 var(--ch-ink);
  padding: 12px 14px; margin-bottom: 10px; text-align: center;
}
/* Muted archive-ink versions of the classic yellow/green/blue/purple solved
   groups — kept clearly distinct from each other for gameplay clarity while
   fitting the parchment palette. Hex values also live as --ch-thread-* tokens
   in css/brand-tokens.css. */
.conn-group-yellow  { background: var(--ch-thread-yellow); color: var(--ch-text-primary); }
.conn-group-green   { background: var(--ch-thread-green); color: var(--ch-text-primary); }
.conn-group-blue    { background: var(--ch-thread-blue); color: var(--ch-text-primary); }
.conn-group-purple  { background: var(--ch-thread-purple); color: var(--ch-text-primary); }
.conn-group-label {
  font-size: 12px; font-family: var(--ch-font-display); font-weight: 400; text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 4px;
}
.conn-group-items { font-size: 14px; font-weight: 600; }
.conn-actions {
  display: flex; gap: 8px; justify-content: center; margin: 10px 0;
}
.conn-feedback {
  text-align: center; font-size: 14px; font-weight: 700;
  padding: 10px; border-radius: 10px; margin: 4px 0;
}
.conn-wrong { background: var(--ch-cream); color: var(--ch-burgundy); border: 2px solid var(--ch-burgundy); }
.conn-mistakes-dots { display: flex; gap: 6px; align-items: center; }
.conn-dot {
  width: 10px; height: 10px; border-radius: 0; border: 1.5px solid var(--ch-ink);
  background: var(--ch-cream);
}
.conn-dot-on { background: var(--ch-ink); border-color: var(--ch-ink); }

.conn-shake { animation: shake .3s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* The queen pull (home, iOS only). The page's own motion — pull, flick,
   bounce, spring-back — is the OS rubber band (see the html.ios override up
   top), not ours; only the badge is scripted. #ptr-badge is a purely
   positional wrapper (JS drives its `translate`); .ptr-badge-face carries the
   visible chrome and is what actually rotates/scales, via the standalone
   `rotate`/`scale` CSS properties so JS's inline styles and the CSS keyframe
   animations below never fight over the same `transform` property. */
#ptr-badge {
  position: fixed; top: calc(env(safe-area-inset-top) * .5); left: 50%;
  width: 76px; height: 76px; margin-left: -38px; z-index: 40;
  pointer-events: none;
}
.ptr-badge-face {
  width: 100%; height: 100%; border-radius: 50%; box-sizing: border-box;
  background: var(--ch-cream); border: 2.5px solid var(--ch-ink);
  box-shadow: 4px 4px 0 var(--ch-ink);
  display: flex; align-items: center; justify-content: center;
  transform-origin: 50% 50%; rotate: 0deg; scale: .55;
}
.ptr-badge-face svg { width: 56%; height: 56%; fill: var(--ch-ink); display: block; }
.ptr-badge-face img { height: 74%; width: auto; display: block; }
@keyframes ptr-spin { from { rotate: 0deg; } to { rotate: 360deg; } }
@keyframes ptr-pop { 0% { scale: 1; } 38% { scale: 1.22; } 64% { scale: .93; } 100% { scale: 1; } }
#ptr-badge.ptr-armed .ptr-badge-face { animation: ptr-spin .85s linear infinite, ptr-pop .45s cubic-bezier(.3,1.5,.4,1) 1; }
@keyframes ptr-go-spin { 0% { rotate: 0deg; scale: 1; } 55% { scale: 1.25; } 100% { rotate: 720deg; scale: 1; } }
#ptr-badge.ptr-go .ptr-badge-face { animation: ptr-go-spin .65s cubic-bezier(.25,.75,.3,1.1) 1 forwards; }

/* On release the badge rides the same spring back up behind the top edge
   (its 0% mirrors the JS badgeY() formula below the arm threshold) while the
   face tucks itself away. */
@keyframes ptr-badge-settle {
  0%   { translate: 0 calc(var(--pull) * 1.04 - 76px); animation-timing-function: cubic-bezier(.26,.86,.32,1); }
  52%  { translate: 0 calc(var(--pull) * -0.088 - 76px); animation-timing-function: cubic-bezier(.34,0,.36,1); }
  100% { translate: 0 -76px; }
}
#ptr-badge.ptr-settle { animation: ptr-badge-settle .62s both; }
@keyframes ptr-face-away { 0%, 45% { opacity: 1; } 100% { scale: .3; opacity: 0; } }
#ptr-badge.ptr-settle .ptr-badge-face { animation: ptr-face-away .62s both; }

/* ================= DEAD FAMOUS components ================= */
/* Loud moment surfaces: full CMYK is allowed here ONLY. */
.view-loud { background: var(--df-magenta); }
.view-loud.loud-cyan { background: var(--df-cyan); }
.view-loud.loud-yellow { background: var(--df-yellow); }
.loud-block { background: var(--ch-cream); border: 3px solid var(--ch-ink); box-shadow: 6px 6px 0 var(--ch-ink); }

/* Latin sting: inked rubber stamp, session-level screens only. */
.df-stamp {
  display: inline-block; padding: 6px 14px; border: 3px double var(--df-red);
  color: var(--df-red); font-family: var(--ch-font-ui); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; font-size: 15px;
  transform: rotate(-7deg); opacity: .9; pointer-events: none;
  mix-blend-mode: multiply;
}
/* Interim art for the Alea Iacta Fest stamp: two inline dice flanking the
   text. Swapped for an illustrated PNG later (see HTML comment at call site);
   this fallback keeps the slot data-driven in the meantime. */
/* Illustrated stamp art (red ink on transparency) replaces the typographic
   dice fallback: the art brings its own lettering, so no border/padding. */
.df-stamp-alea { border: none; padding: 0; right: 12px; bottom: 4px; }
.df-stamp-alea img { width: 98px; display: block; }
/* Zero-score receipts trade the celebratory dice for the Roman erasure —
   scoring nothing in Dead Famous is being struck from the record. Same
   inked-rubber language as MEMENTO MORI / the .df-stamp base. */
.df-stamp-damnatio { text-align: center; line-height: 1.15; bottom: 18px; }
.df-stamp-damnatio small {
  display: block; font-size: 9px; font-weight: 700; letter-spacing: .14em;
  margin-top: 2px;
}

/* Receipt: the share object. */
.df-receipt {
  background: #FFFFFF; border: 2px solid var(--ch-ink); box-shadow: var(--ch-shadow-soft);
  font-family: var(--ch-font-ui); color: #111; padding: 20px 18px 86px; position: relative;
  margin: 16px 0;
}
.df-receipt-head { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 10px; }
.df-receipt hr { border: none; border-top: 2px dashed #111; margin: 10px 0; }
.df-receipt-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 0; text-transform: uppercase; }
.df-receipt-row .pts { font-variant-numeric: tabular-nums; }
.df-receipt-row.zero { color: #8a8a8a; }
.df-receipt-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.df-receipt-total b { font-family: var(--ch-font-display); font-size: 34px; font-weight: 400; }
.df-receipt-total span { font-size: 15px; font-weight: 700; text-transform: uppercase; }
.df-receipt-meta { font-size: 11px; color: #6a6a6a; text-transform: uppercase; margin-top: 6px; }
.df-receipt .df-stamp { position: absolute; right: 10px; bottom: 34px; }

/* Scrap-tear grid (Face Value / Relic) */
.df-scraps { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); }
.df-scrap {
  position: relative; border: 1px solid rgba(11,11,11,.5); cursor: pointer;
  background:
    radial-gradient(rgba(11,11,11,.08) 1px, transparent 1.2px) 0 0/9px 9px,
    linear-gradient(160deg, #F4F0E4 0%, #EDE7D5 55%, #E4DDC8 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .28s ease, transform .28s ease;
}
.df-scrap::after {
  content: 'DEAD FAMOUS'; font-family: var(--ch-font-ui); font-size: 8px; font-weight: 700;
  letter-spacing: .1em; color: rgba(11,11,11,.28); transform: rotate(-14deg);
}
.df-scrap:active { filter: brightness(.96); }
.df-scrap.torn { opacity: 0; transform: rotate(6deg) scale(1.06); pointer-events: none; }
/* Honest offline state: shown when a round's image never arrived — better to
   say "not downloaded" than deal nine scraps over a blank void. */
#rv-offline {
  position: absolute; inset: 0; z-index: 3; background: var(--ch-cream);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 18px; text-align: center;
}
#rv-offline p { font-family: var(--ch-font-ui); font-size: 14px; line-height: 1.5; margin: 0; }

.df-worth { font-family: var(--ch-font-ui); font-weight: 700; font-size: 14px; text-transform: uppercase; }
.df-worth b { color: var(--ch-gold); font-size: 17px; }

/* Moment card (correct / wrong) */
.df-moment { text-align: center; padding: 10px 20px 20px; }
.df-moment-frame {
  position: relative; width: min(72vw, 340px); margin: 18px auto 0;
  border: 3px solid var(--ch-ink); box-shadow: var(--ch-shadow-card); background: #111;
}
.df-moment-frame img { display: block; width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.df-moment-badge {
  position: absolute; top: -14px; right: -18px; transform: rotate(8deg);
  background: var(--ch-cream); border: 2.5px solid var(--ch-ink); box-shadow: 3px 3px 0 var(--ch-ink);
  padding: 8px 16px 6px; text-align: center;
}
.df-moment-badge b { display: block; font-family: var(--ch-font-display); font-weight: 400; font-size: 20px; letter-spacing: .02em; color: var(--df-magenta); text-transform: uppercase; }
.df-moment-badge small { font-family: var(--ch-font-ui); font-weight: 700; font-size: 11px; }
/* Wrong answer: a red rubber ink stamp, same language as .df-stamp — no cream
   card, double red border. A faint translucent paper backing (instead of
   mix-blend multiply) keeps the red legible over dark photo areas while
   still reading as ink rather than a sticker. */
.df-moment-badge.bad {
  background: rgba(242, 239, 230, .58); border: 3px double var(--df-red); box-shadow: none;
  color: var(--df-red); font-family: var(--ch-font-ui); font-weight: 700;
  text-transform: uppercase; transform: rotate(-8deg);
  opacity: .96;
}
.df-moment-badge.bad b { color: var(--df-red); font-family: var(--ch-font-ui); font-weight: 800; }
.df-moment-badge.bad small { color: var(--df-red); }
.df-moment-name { font-family: var(--ch-font-display); font-weight: 400; font-size: 30px; text-transform: uppercase; margin: 18px 0 2px; line-height: 1; }
.df-moment-dates { font-family: var(--ch-font-ui); font-weight: 700; font-size: 13px; color: var(--ch-text-muted); letter-spacing: .06em; }
.df-fact {
  margin: 14px auto 0; max-width: 340px; background: var(--ch-cream);
  border: 2px solid var(--ch-ink); box-shadow: 3px 3px 0 var(--ch-ink);
  padding: 12px 14px; font-family: var(--ch-font-text); font-size: 15.5px; line-height: 1.45; text-align: left;
}

/* Duotone/halftone treatment for moment + brand imagery (never during guessing) */
.df-duotone { position: relative; }
.df-duotone img { filter: grayscale(1) contrast(1.08) brightness(1.02); }
.df-duotone::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(rgba(11,11,11,.22) 1px, transparent 1.35px) 0 0/4px 4px;
  mix-blend-mode: overlay;
}
.df-duotone .df-moment-badge { filter: none; }

/* Weekday strip (home rows) */
.df-week { display: flex; gap: 6px; padding: 8px 24px 0; }
.df-week span {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--ch-font-ui); font-weight: 700; font-size: 11px;
  border: 1.5px solid var(--ch-line-soft); color: var(--ch-text-muted); background: transparent;
}
.df-week span.done { background: var(--ch-ink); border-color: var(--ch-ink); color: var(--ch-text-inverse); }
.df-week span.today { border: 2px solid var(--ch-ink); color: var(--ch-ink); }
.df-week span.today.done { background: var(--row-tint-strong, var(--ch-ink)); color: var(--ch-ink); }

.df-receipt-list { list-style: none; margin: 0; padding: 0; }
.df-receipt-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: none; font-family: var(--ch-font-ui); font-size: 13px; text-transform: uppercase; color: #111; }
.df-receipt-list .sum-name small { display: none; }
.df-receipt-list .sum-pts { color: #111; font-weight: 700; }
.df-receipt-list .sum-pts.zero { color: #9a9a9a; }
.df-receipt-stamp { position: absolute; right: 22px; bottom: 6px; }
.df-receipt .df-receipt-total b { font-variant-numeric: tabular-nums; }
.sum-actions { margin-top: 14px; }

/* ---------- You Made History / You're History ---------- */
#view-daydone { background: var(--df-magenta); }
#view-daydone.obituary { background: #24211C; }
#view-daydone.obituary .dd-title { color: var(--ch-text-inverse); }
.dd-title { font-family: var(--ch-font-display); font-weight: 400; font-size: 46px; line-height: .95; text-transform: uppercase; text-align: left; margin: 18px 0 22px; color: var(--ch-ink); }
.dd-score, .dd-streak { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px; margin: 0 0 14px; position: relative; }
.dd-score span, .dd-streak span { font-family: var(--ch-font-ui); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.dd-score b, .dd-streak b { font-family: var(--ch-font-display); font-weight: 400; font-size: 40px; line-height: 1; }
#dd-stamp { position: absolute; right: 8px; top: -12px; font-size: 18px; }
.dd-countdown { font-family: var(--ch-font-ui); font-weight: 700; font-size: 14px; text-transform: uppercase; text-align: center; margin: 18px 0 6px; }
.dd-countdown b { font-family: var(--ch-font-display); font-weight: 400; font-size: 30px; display: block; }
.dd-carpet { text-align: center; margin: 4px 0 10px; }
#view-daydone .topbar h2 { text-align: left; }

#view-daydone.obituary .pill.ghost { border-color: var(--ch-text-inverse); color: var(--ch-text-inverse); }
#view-daydone.obituary .topbar { border-bottom-color: var(--ch-text-inverse) !important; }
#view-daydone.obituary .topbar h2, #view-daydone.obituary .iconbtn { color: var(--ch-text-inverse); }

/* Archive masthead: a typographic band standing in for a photo banner.
   Repeating diagonal stripes at very low contrast give it some print
   texture without competing with the sticker or title. */
.df-morgue-banner {
  position: relative; margin: 22px 20px 30px; min-height: 60px;
  display: flex; align-items: center; padding: 0 18px;
  background-color: var(--ch-ink);
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 2px, transparent 2px 11px);
  border: 2px solid var(--ch-ink); box-shadow: var(--ch-shadow-card);
  overflow: visible;
}
.df-morgue-title {
  font-family: var(--ch-font-display); font-weight: 400; font-size: 26px; line-height: 1;
  text-transform: uppercase; letter-spacing: .01em; color: var(--ch-text-inverse);
  white-space: nowrap; max-width: 65%; overflow: hidden; text-overflow: ellipsis;
}
.df-morgue-sticker {
  position: absolute; right: -8px; top: -16px; max-width: 118px; text-align: center;
  transform: rotate(-4deg);
  background: var(--df-yellow); border: 2px solid var(--ch-ink); color: var(--ch-ink);
  font-family: var(--ch-font-ui); font-weight: 700; text-transform: uppercase;
  font-size: 9.5px; letter-spacing: .02em; line-height: 1.25; padding: 5px 9px;
  box-shadow: 2px 2px 0 var(--ch-ink);
}

/* Adjacency tearing: only scraps touching an open scrap are tearable. */
.df-scrap.locked { cursor: default; }
.df-scrap.locked::after { opacity: .5; }
.df-scrap.tearable { border: 2px dashed rgba(11,11,11,.75); }
.df-scrap.tearable:active { filter: brightness(.94); }
#rv-panel { padding-top: 24px !important; }
#rv-frame.df-duotone { background-color: #FFFFFF !important; }
#rv-prompt[hidden] { display: none; }
