:root {
  --ink: #2d2620;
  --paper: #fffdf8;
  --page: #ece6dc;
  --muted: #6b5f55;
  --line: #d8cfc2;
  --accent: #8b1e1e;
  --focus: #b8860b;
  --pressed: #f6efe2;
  --placed: #f3f0ea;
  --kw: #6d4c0f;
  --ok: #2e6b2e;
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #ece4d8;
  --paper: #26211d;
  --page: #1a1714;
  --muted: #b3a797;
  --line: #4a4038;
  --accent: #e07a6c;
  --focus: #e0b04a;
  --pressed: #3a322b;
  --placed: #201c18;
  --kw: #e9c46a;
  --ok: #8fd18f;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --ink: #ece4d8;
    --paper: #26211d;
    --page: #1a1714;
    --muted: #b3a797;
    --line: #4a4038;
    --accent: #e07a6c;
    --focus: #e0b04a;
    --pressed: #3a322b;
    --placed: #201c18;
    --kw: #e9c46a;
    --ok: #8fd18f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.45 Georgia, 'Times New Roman', serif;
}

a { color: var(--accent); }

/* Brand (see docs/identidad.md). Zilla Slab: SIL Open Font License, see fonts/OFL.txt. */
@font-face {
  font-family: 'Zilla Slab';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/zilla-slab-600.woff2') format('woff2');
}
.brand { display: inline-flex; align-items: center; gap: .35em; }
.brand .ak-logo { flex: none; }
.brand-name { font-family: 'Zilla Slab', Rockwell, 'Roboto Slab', Georgia, serif; font-weight: 600; letter-spacing: .01em; }
.hero { margin: 8px 0 4px; font-size: 44px; line-height: 1; }
.hero .brand { gap: 14px; }
.on-dark { display: none; }
html[data-theme="dark"] .on-light { display: none; }
html[data-theme="dark"] .on-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .on-light { display: none; }
  html:not([data-theme="light"]) .on-dark { display: inline; }
}

button, input, select {
  font: inherit;
  font-family: system-ui, 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
}

button {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); background: var(--pressed); }
button.icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; font-size: 16px; }

.muted { color: var(--muted); font-size: 14px; }

a.button {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: 15px system-ui, 'Segoe UI', Arial, sans-serif;
  text-decoration: none;
}
a.button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
a.button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.daily p { margin: 6px 0; }
.daily a.button { margin-right: 10px; }

/* Index */
.narrow { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.narrow h1 { font-size: 40px; margin: 8px 0 4px; }
.lead { margin-top: 0; color: var(--muted); }
.site-footer { max-width: 720px; margin: 0 auto; padding: 8px 16px 24px; text-align: center; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 2px 0; }
.site-footer a { color: inherit; }
.card { background: var(--paper); border-radius: 10px; padding: 16px 20px; margin: 16px 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.cases { margin: 0; padding-left: 20px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row label { display: flex; flex-direction: column; gap: 4px; font-family: system-ui, sans-serif; font-size: 13px; color: var(--muted); }
.row label.check { flex-direction: row; align-items: center; }
.row input[type="number"] { width: 110px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
.row select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }

/* Game header */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #2d2620;
  color: #fffdf8;
}
.bar .home { color: #fffdf8; font-size: 18px; text-decoration: none; white-space: nowrap; }
.bar .home:hover .brand-name { text-decoration: underline; text-underline-offset: 3px; }
.bar h1 { margin: 0; font-size: 21px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .muted { color: #cfc4b6; }
.bar button.icon { background: transparent; color: #fffdf8; border-color: #6b5f55; }
.bar a.icon {
  width: 34px; height: 34px; border: 1px solid #6b5f55; border-radius: 50%; display: inline-grid; place-items: center;
  color: #fffdf8; font-size: 16px; text-decoration: none;
}
.bar a.icon:hover { border-color: #cfc4b6; }
.bar a.icon:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.timer { font: 600 15px system-ui, sans-serif; font-variant-numeric: tabular-nums; color: #f4ede2; min-width: 3.2em; text-align: right; }

/* Game layout */
.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  align-items: start;
}

.board-wrap svg { display: block; width: min(100%, 720px, calc(100vh - 100px)); margin: 0 auto; user-select: none; }
.ak-board.is-pencil .ak-hit-cell[data-occupiable="1"] { cursor: crosshair; }

.panel { background: var(--paper); border-radius: 10px; padding: 14px; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

.people { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 8px 10px; }
.person.is-placed { background: var(--placed); }
.person.is-placed:not([aria-pressed="true"]) .badge,
.person.is-placed:not([aria-pressed="true"]) .who { opacity: .5; }
.person.is-flagged { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.who { font-family: Georgia, serif; font-size: 15px; }
.who em { color: var(--accent); font-size: 13px; }
.clues { display: block; font-size: 14px; color: var(--muted); }
.clues > span { display: block; }
.victim-note { font-style: italic; }
.kw { color: var(--kw); font-weight: 700; border-radius: 3px; }
.kw:hover { background: rgba(214, 164, 26, .25); }

.badge {
  flex: none;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 15px system-ui, sans-serif;
  background: var(--paper);
}
.badge.victim { background: #8b1e1e; border-color: #8b1e1e; color: #fffdf8; }

.tools, .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.message { min-height: 1.4em; margin: 12px 0 0; font-size: 15px; }
.message.solved { color: var(--ok); font-weight: bold; }
.message.wrong, .message.conflict, .message.invalid { color: var(--accent); }

.hint-panel { margin-top: 12px; padding: 10px 12px; border: 2px solid #2b6cb0; border-radius: 8px; background: var(--paper); }
.hint-panel header { display: flex; align-items: center; gap: 8px; }
.hint-panel header .icon { margin-left: auto; width: 28px; height: 28px; font-size: 13px; }
.hint-panel p { margin: 8px 0; font-size: 15px; }
.hint-nav { display: flex; gap: 8px; justify-content: space-between; }
.hint-nav #hint-place { flex: 1; }
html[data-theme="dark"] .hint-panel { border-color: #6ea8e0; }

.solved .sheet-body { font-size: 17px; }
.solved .sheet-foot { gap: 8px; }
.solved-time { color: var(--muted); }

/* Mobile quick bar: people and tools always at hand under the board. Hidden on wide screens. */
.quickbar { display: none; }

@media (max-width: 860px) {
  body { padding-bottom: 116px; }
  .bar .brand-name { display: none; }
  .quickbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .12);
  }
  .quick-people, .quick-tools { display: flex; gap: 6px; justify-content: center; }
  .quick-people { overflow-x: auto; }
  .quickbar button { padding: 0; width: 42px; height: 42px; display: inline-grid; place-items: center; font-size: 17px; }
  .quick-tools button { width: 52px; height: 40px; }
  .quick-person { border-radius: 50%; flex: none; }
  .quick-person .portrait { width: 36px; height: 36px; }
  .quick-person.is-placed:not([aria-pressed="true"]) .portrait { opacity: .4; }
  .quick-person.is-flagged { box-shadow: inset 0 0 0 2px var(--accent); }
}

/* Tokens placed by play.js */
.ak-token.ak-conflict { --ak-token-stroke: #c0392b; }

/* Portraits outside the board (cards, quick bar) reuse the token symbols. */
.portrait { flex: none; width: 36px; height: 36px; display: block; overflow: visible; }
.person.is-placed:not([aria-pressed="true"]) .portrait { opacity: .5; }

/* Animations: only with .ak-anim on <html> (setting on and no reduced-motion request). */
.ak-anim .ak-token.ak-new, .ak-anim .ak-mark.ak-new, .ak-anim .ak-celebrate .ak-token {
  transform-box: fill-box;
  transform-origin: center;
}
.ak-anim .ak-token.ak-new { animation: ak-pop .34s cubic-bezier(.3, 1.5, .6, 1) both; }
.ak-anim .ak-mark.ak-new { animation: ak-mark-in .24s ease-out both; animation-delay: var(--delay, 0ms); }
.ak-anim .ak-celebrate .ak-token { animation: ak-cheer .7s ease-in-out both; animation-delay: var(--delay, 0ms); }
.ak-anim .ak-murderer-ring.ak-draw { stroke-dasharray: 100; animation: ak-draw .9s .5s ease-out both; }
.ak-anim .ak-hit-cell.ak-hint { animation: ak-pulse 1.4s ease-in-out infinite; }
.ak-anim .person, .ak-anim .quick-person { transition: background-color .2s, box-shadow .2s, opacity .2s; }
.ak-anim dialog.sheet[open] { animation: ak-rise .22s ease-out; }

@keyframes ak-pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes ak-mark-in { from { transform: scale(.3) rotate(-30deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes ak-cheer { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-14%) scale(1.12); } 70% { transform: translateY(0) scale(.96); } }
@keyframes ak-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes ak-pulse { 0%, 100% { fill-opacity: 1; } 50% { fill-opacity: .45; } }
@keyframes ak-rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ak-anim * { animation: none !important; transition: none !important; }
}

/* Dialogs */
dialog.sheet {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
dialog.sheet::backdrop { background: rgba(20, 16, 12, .55); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); margin: 0; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-body { padding: 8px 16px 16px; overflow: auto; max-height: calc(100vh - 170px); }
.sheet-foot { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); margin: 0; }

.help-step { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.help-step h3, .help-controls h3 { margin: 0 0 4px; font-size: 17px; }
.help-step p { margin: 0; font-size: 15px; }
.help-board svg { display: block; width: 100%; }
.help-controls ul { margin: 6px 0 0; padding-left: 20px; font-size: 15px; }
.help-controls li { margin: 4px 0; }

.settings label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.settings label input { margin-top: 4px; }
.settings label span { display: flex; flex-direction: column; }
.settings small { color: var(--muted); font-size: 13px; }
.settings label.select { align-items: center; justify-content: space-between; font-weight: bold; border-bottom: 0; }
.settings select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }

/* Dark theme for the SVG board (its own palette lives in .ak-board custom properties). */
/* Floors and walls go dark; furniture keeps its colours with a darker outline. */
html[data-theme="dark"] .ak-board {
  --ak-ink: #eee5d8; --ak-paper: #2a2420; --ak-grid: rgba(255, 255, 255, .08);
  --ak-wall-top: #6d6258; --ak-outline: #1c1612; --ak-shadow-color: rgba(0, 0, 0, .55);
  --ak-wood-floor: #3f362d; --ak-wood-floor-alt: #3a3129; --ak-wood-line: #4c4136;
  --ak-tiles: #33393c; --ak-tiles-alt: #2e3437; --ak-tiles-line: #414a4e;
  --ak-carpet: #3d3338; --ak-carpet-line: #4e4148; --ak-grass: #33402c; --ak-grass-line: #44563a;
  --ak-stone: #3b3834; --ak-stone-line: #4b4742; --ak-plain: #35302b;
  --ak-victim: #c0453a; --ak-mark: #d8cbb8; --ak-note: #9cc7ee; --ak-highlight: rgba(233, 196, 106, .3);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .ak-board {
    --ak-ink: #eee5d8; --ak-paper: #2a2420; --ak-grid: rgba(255, 255, 255, .08);
    --ak-wall-top: #6d6258; --ak-outline: #1c1612; --ak-shadow-color: rgba(0, 0, 0, .55);
    --ak-wood-floor: #3f362d; --ak-wood-floor-alt: #3a3129; --ak-wood-line: #4c4136;
    --ak-tiles: #33393c; --ak-tiles-alt: #2e3437; --ak-tiles-line: #414a4e;
    --ak-carpet: #3d3338; --ak-carpet-line: #4e4148; --ak-grass: #33402c; --ak-grass-line: #44563a;
    --ak-stone: #3b3834; --ak-stone-line: #4b4742; --ak-plain: #35302b;
    --ak-victim: #c0453a; --ak-mark: #d8cbb8; --ak-note: #9cc7ee; --ak-highlight: rgba(233, 196, 106, .3);
  }
}

@media (max-width: 860px) {
  .play { grid-template-columns: 1fr; }
  .board-wrap svg { width: 100%; }
}

@media (max-width: 520px) {
  /* Title and subtitle on their own rows under the logo and buttons, so they are not cut short. */
  .bar { flex-wrap: wrap; gap: 2px 8px; padding: 8px 10px; }
  .bar .timer { margin-left: auto; }
  .bar h1 { order: 1; flex-basis: 100%; font-size: 18px; line-height: 1.25; white-space: normal; }
  .bar .subtitle { order: 2; flex-basis: 100%; font-size: 12px; }
  .hero { font-size: 34px; }
  .hero .ak-logo { width: 48px; height: 48px; }
  .help-step { grid-template-columns: 1fr; }
  .help-board svg { max-width: 220px; margin: 0 auto; }
}

/* Only for screen readers: announcements, timer label, each person's place. */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Case of the day: streak and the last days (home), and the solved dialog's record. */
.daily-status { font-weight: bold; }
.week { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 10px 0; padding: 0; }
.week a, .calendar a.day {
  display: flex; flex-direction: column; align-items: center; width: 46px; padding: 4px 0 5px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none;
  font: 12px system-ui, 'Segoe UI', Arial, sans-serif;
}
.week a b, .calendar .day b { font-size: 16px; line-height: 1.2; }
.week a::after, .calendar a.day::after { content: '·'; height: 15px; line-height: 15px; color: var(--muted); }
.week a.is-solved, .calendar a.day.is-solved { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.week a.is-solved::after, .calendar a.day.is-solved::after { content: '✔'; color: inherit; }
.week a.is-late::after, .calendar a.day.is-late::after { content: '✓'; }
.week a.is-started::after, .calendar a.day.is-started::after { content: '…'; }
.week a.is-today, .calendar a.day.is-today { border: 2px solid var(--accent); padding: 3px 0 4px; }
.week a:hover, .calendar a.day:hover { border-color: var(--ink); }
.week a:focus-visible, .calendar a.day:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
.calendar .weekday { text-align: center; font: 12px system-ui, 'Segoe UI', Arial, sans-serif; color: var(--muted); }
.calendar a.day { width: auto; }
.calendar .day.off { display: flex; justify-content: center; padding: 6px 0; color: var(--line); font: 14px system-ui, 'Segoe UI', Arial, sans-serif; }
.solved-stats { margin: 8px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 15px; }

/* ♀ / ♂ beside each person, with the "symbols" setting. */
.sex { display: none; margin-left: 5px; font: bold 15px system-ui, sans-serif; }
html.ak-symbols .sex { display: inline; }
.sex-feminine { color: #c2255c; }
.sex-masculine { color: #1864ab; }
html[data-theme="dark"] .sex-feminine { color: #f783ac; }
html[data-theme="dark"] .sex-masculine { color: #74c0fc; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .sex-feminine { color: #f783ac; }
  html:not([data-theme="light"]) .sex-masculine { color: #74c0fc; }
}
.quick-person { position: relative; }
.quick-person .sex {
  position: absolute; top: -3px; right: -3px; margin: 0; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); font-size: 12px; line-height: 16px; text-align: center;
}
html.ak-symbols .quick-person .sex { display: block; }

/* A few lines of atmosphere above the people (Text\StoryText): never a clue. */
.story { margin: 0 0 12px; font-style: italic; color: var(--muted); font-size: 15px; line-height: 1.45; }
