/* CHEESDOKU — cozy noir.
   Ratón detective, no dibujo animado: madera quemada, luz de flexo y el amarillo
   del queso como único color vivo. El tablero ES el queso, agujeros incluidos. */

:root {
  --ink: #f4ecdd;
  --ink-soft: #ad9f88;
  --bg: #171310;
  --surface: #221c16;
  --surface-2: #2c241c;
  --cheese: #f0bf4c;
  --cheese-deep: #c9922c;
  --cheese-board: #e6b957;
  --hole: #c2942f;
  --wall: #4b3a26;
  --good: #7cc47f;
  --bad: #e0705a;
  --note: #8fb3d9;
  --radius: 14px;
  --tap: 44px;
  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --ink: #241d15;
    --ink-soft: #6d604c;
    --bg: #f6efe1;
    --surface: #fffaf0;
    --surface-2: #f2e7d3;
    --cheese-board: #f2ca6b;
    --hole: #d9a53e;
    --wall: #8a6b40;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 78% -10%, rgba(240, 191, 76, 0.12), transparent 62%),
    radial-gradient(700px 420px at 6% 108%, rgba(240, 191, 76, 0.07), transparent 60%),
    var(--bg);
  min-height: 100svh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

/* ── Cabecera ───────────────────────────────────────────────────────────── */

.top { max-width: 560px; margin: 0 auto; padding: 18px 16px 6px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.wordmark {
  font-size: clamp(21px, 6.2vw, 28px);
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cheese);
}
/* El punto sobre la marca es un agujero de queso: la mecánica en el logotipo. */
.wordmark-hole {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, var(--cheese), var(--cheese-deep));
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.35);
  flex: none;
}

.top-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.streak { color: var(--cheese); font-weight: 700; white-space: nowrap; }
.timer { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.soundbtn {
  background: transparent; border: 0; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 6px;
  min-width: 30px; min-height: 30px;
  filter: grayscale(0.2);
}
.soundbtn[aria-pressed="false"] { opacity: 0.5; }

.langbar { display: inline-flex; border: 1px solid rgba(240, 191, 76, 0.35); border-radius: 999px; overflow: hidden; }
.lang {
  background: transparent; border: 0; color: var(--ink-soft);
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  padding: 5px 9px; cursor: pointer; min-height: 28px;
}
.lang.is-on { background: var(--cheese); color: #241d15; }

.tagline { color: var(--ink-soft); font-size: 14px; margin-top: 10px; }
.caseline { color: var(--ink-soft); font-size: 12.5px; margin-top: 3px; opacity: 0.85; }

/* ── Tablero: una loncha de queso ───────────────────────────────────────── */

.wrap { max-width: 560px; margin: 0 auto; padding: 10px 16px 40px; }

.board {
  display: grid;
  grid-template-columns: repeat(var(--n, 5), 1fr);
  gap: 3px;
  padding: 10px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 12% 18%, var(--hole) 0 10px, transparent 11px),
    radial-gradient(circle at 88% 12%, var(--hole) 0 7px, transparent 8px),
    radial-gradient(circle at 92% 82%, var(--hole) 0 12px, transparent 13px),
    radial-gradient(circle at 8% 88%, var(--hole) 0 8px, transparent 9px),
    var(--cheese-board);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  aspect-ratio: 1;
}

.cell {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.82);
  color: #2b2218;
  font: inherit;
  font-size: clamp(8.5px, 2.5vw, 11px);
  line-height: 1.1;
  text-align: center;
  padding: 2px;
  cursor: pointer;
  overflow: hidden;
  min-width: 0;
  transition: background 0.12s ease, transform 0.08s ease;
}
.cell:focus-visible { outline: 3px solid var(--cheese); outline-offset: 2px; z-index: 2; }
.cell--free:active { transform: scale(0.95); }

/* Paredes de las habitaciones: el plano de la casa se lee sin leyenda. */
.wall-t { border-top: 3px solid var(--wall); }
.wall-b { border-bottom: 3px solid var(--wall); }
.wall-l { border-left: 3px solid var(--wall); }
.wall-r { border-right: 3px solid var(--wall); }

/* La habitación donde está el queso: es la que decide el caso, así que se ve.
   Solo sobre casillas libres — si no, por especificidad taparía el fondo oscuro
   de las pistas y su texto se volvería ilegible. */
.cell--free.is-scene { background: #fdeec6; }
.cell--cheese { background: rgba(255, 255, 255, 0.42); cursor: default; }
.cell--blocked { background: rgba(120, 95, 60, 0.30); cursor: default; }
.cell--clue { background: #2c241c; color: #f3e8d4; cursor: pointer; }

/* El rayo de la pista activa: las casillas de las que habla se encienden.
   Es lo que enseña la mecánica sin tutorial, así que va con baño de color y no
   solo con un aro — un borde ámbar de 3 px sobre casilla crema y tablero
   amarillo se perdía por completo. El baño va como background-image para
   superponerse a cualquier fondo, incluido el oscuro de las casillas de pista. */
.cell.is-ray {
  box-shadow: inset 0 0 0 3px var(--cheese-deep);
  background-image: linear-gradient(rgba(240, 191, 76, 0.45), rgba(240, 191, 76, 0.45));
}
.cell--clue.is-active { background: var(--cheese); color: #241d15; }
.cell.is-conflict { background: rgba(224, 112, 90, 0.55); }

.cheese { font-size: clamp(20px, 6.5vw, 30px); }
.furniture { font-size: clamp(15px, 4.6vw, 22px); opacity: 0.75; }
.arrow { font-size: clamp(12px, 3.6vw, 16px); line-height: 1; color: var(--cheese); }
.cell--clue.is-active .arrow { color: #241d15; }
.cluetext { font-size: clamp(7.5px, 2.3vw, 10px); font-weight: 600; word-break: break-word; }

/* Retratos de ratón. El rasgo va dibujado, no escrito: se lee de un vistazo
   desde el propio tablero sin volver a la ficha del sospechoso. */
.token { display: block; flex: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28)); }
.token svg { width: 100%; height: 100%; display: block; overflow: visible; }
.token--md { width: clamp(26px, 8.2vw, 38px); height: clamp(26px, 8.2vw, 38px); }
.token--lg { width: 42px; height: 42px; }

/* La abreviatura sigue haciendo falta: las pistas hablan por nombre. */
.token-name {
  font-size: clamp(7px, 2.2vw, 9.5px);
  font-weight: 800; line-height: 1;
  color: #4a3c2a; letter-spacing: 0.2px;
}

/* Descartes del jugador. Ficha con el color del ratón: el tachado suelto sobre
   texto gris hacía que varios descartes seguidos parecieran una sola raya. */
.notes { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; align-content: center; }
.note {
  display: inline-block;
  padding: 0 3px;
  border-radius: 4px;
  background: var(--fill);
  color: #241d15;
  font-size: clamp(6.5px, 2.1vw, 9px);
  font-weight: 800;
  line-height: 1.35;
  opacity: 0.62;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(30, 22, 12, 0.85);
}
.note[data-dark="true"] { color: #f6efe1; text-decoration-color: rgba(255, 250, 240, 0.9); }

/* ── Estado y pista activa ──────────────────────────────────────────────── */

.status { min-height: 20px; margin-top: 12px; font-size: 13.5px; font-weight: 600; text-align: center; }
.status.good { color: var(--good); }
.status.bad { color: var(--bad); }
.status.note { color: var(--note); }

.cluebar {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding: 12px 14px;
  min-height: 58px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(240, 191, 76, 0.22);
  font-size: 14px; line-height: 1.35;
}
.cluebar.is-empty { color: var(--ink-soft); font-style: italic; border-style: dashed; }
.cluebar-arrow { font-size: 22px; color: var(--cheese); flex: none; }

/* ── Sospechosos ────────────────────────────────────────────────────────── */

.panel { margin-top: 14px; }
.rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }

.suspect {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--surface);
  color: var(--ink);
  font: inherit; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.suspect.is-selected { border-color: var(--cheese); background: var(--surface-2); }
.suspect.is-placed { opacity: 0.55; }
.suspect-name { font-size: 12.5px; font-weight: 700; }
.suspect-attrs { font-size: 10.5px; color: var(--ink-soft); text-align: center; line-height: 1.2; }

/* ── Herramientas ───────────────────────────────────────────────────────── */

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }

.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tap);
  padding: 9px 4px;
  border-radius: var(--radius);
  border: 1px solid rgba(240, 191, 76, 0.22);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 11.5px; font-weight: 600;
  cursor: pointer;
}
.tool span:first-child { font-size: 16px; line-height: 1; }
.tool.is-on { background: var(--cheese); color: #241d15; border-color: var(--cheese); }
.tool--primary { background: var(--cheese); color: #241d15; border-color: var(--cheese); font-weight: 800; }
.tool:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary { display: flex; justify-content: center; gap: 20px; margin-top: 22px; }
.link {
  background: none; border: 0; color: var(--ink-soft);
  font: inherit; font-size: 13px; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; min-height: var(--tap); padding: 0 6px;
}

/* ── Diálogos ───────────────────────────────────────────────────────────── */

.modal {
  border: 0; border-radius: 18px; padding: 22px;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.modal::backdrop { background: rgba(10, 8, 6, 0.72); }
.modal h2 { font-size: 19px; margin-bottom: 14px; color: var(--cheese); }
.modal p { font-size: 14.5px; line-height: 1.5; }

.rules { padding-left: 20px; display: grid; gap: 9px; font-size: 14px; line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .tool { flex: 1; flex-direction: row; }

.accuse-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; }
.accuse-list .suspect { flex-direction: column; }

.win-line { font-size: 17px; font-weight: 700; }
.win-time { color: var(--ink-soft); margin-top: 6px; }

/* Selector del modo libre */
.field { margin-bottom: 16px; }
.field-label {
  display: block; margin-bottom: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--ink-soft);
}
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 7px; }
.choice {
  min-height: var(--tap);
  padding: 9px 6px;
  border-radius: 11px;
  border: 2px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.choice.is-on { border-color: var(--cheese); background: var(--cheese); color: #241d15; }

.archive { display: grid; gap: 6px; max-height: 55vh; overflow-y: auto; }
.archive-day {
  display: flex; justify-content: space-between; align-items: center;
  min-height: var(--tap); padding: 9px 13px;
  border-radius: 10px; border: 1px solid rgba(240, 191, 76, 0.18);
  background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.archive-day.is-won { border-color: var(--cheese); }

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