/* ============================================================
   Murdoku · La Búsqueda del Tesoro
   ============================================================ */

:root {
  --ink: #211b14;
  --ink-soft: #5b4c3d;
  --ink-faint: #8a7966;
  --paper: #f7f1e2;
  --paper-2: #efe4cc;
  --card: #fffaf0;
  --card-2: #fbf4e4;
  --line: rgba(33, 27, 20, 0.14);
  --line-strong: rgba(33, 27, 20, 0.28);
  --gold: #c9a227;
  --gold-deep: #9a7414;
  --gold-soft: rgba(201, 162, 39, 0.16);
  --red: #b23a3a;
  --red-soft: rgba(178, 58, 58, 0.12);
  --green: #3f7d5a;
  --blue: #3e6f9a;
  --shadow-sm: 0 2px 6px rgba(35, 24, 12, 0.12);
  --shadow: 0 14px 34px rgba(35, 24, 12, 0.16);
  --shadow-lg: 0 28px 70px rgba(25, 16, 8, 0.24);
  --radius: 18px;
  --radius-sm: 11px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --script: "Caveat", "Segoe Script", cursive;
  --board-max: min(100%, 82vh);
}

@media (max-height: 1000px) {
  :root { --board-max: min(100%, 74vh); }
}

* { box-sizing: border-box; }

html, body { height: 100%; background-color: #efe7d5; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 12% -10%, rgba(201, 162, 39, 0.16), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(63, 125, 90, 0.12), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, rgba(62, 111, 154, 0.12), transparent 60%),
    #efe7d5;
  background-attachment: fixed;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(rgba(90, 70, 45, 0.14) 0.6px, transparent 0.6px),
    radial-gradient(rgba(90, 70, 45, 0.1) 0.6px, transparent 0.6px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
  mix-blend-mode: multiply;
  z-index: 0;
}

button { font-family: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(201, 162, 39, 0.7);
  outline-offset: 2px;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------- Top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px 14px;
  max-width: 1820px;
  width: 100%;
  margin: 0 auto;
}

.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }

.brand-mark {
  font-family: var(--serif);
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: clamp(20px, 2.1vw, 30px);
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

.brand-sub {
  font-family: var(--script);
  font-size: clamp(18px, 2vw, 26px);
  color: var(--gold-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

@media (max-width: 900px) {
  #btnFullscreen { display: none !important; }
}

/* ---------------- Buttons ---------------- */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fffdf7, #f5ecd9);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 2px 0 rgba(33, 27, 20, 0.12), var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 rgba(33, 27, 20, 0.12), var(--shadow); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(33, 27, 20, 0.12); }
.btn.ghost { background: rgba(255, 250, 240, 0.62); backdrop-filter: blur(6px); }
.btn.primary {
  background: linear-gradient(180deg, #d9b64a, #b8901f);
  border-color: #8a6a10;
  color: #211b14;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.danger { background: linear-gradient(180deg, #c95a5a, #a63232); border-color: #842525; color: #fff; }
.btn.ghost-danger { background: rgba(178, 58, 58, 0.08); color: #8f2b2b; border-color: rgba(178, 58, 58, 0.35); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(255, 250, 240, 0.9);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, transform 0.12s ease;
}
.icon-btn:hover { background: #fff; transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* ---------------- Layout ---------------- */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1820px;
  margin: 0 auto;
  padding: 0 20px 18px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 252, 245, 0.96), rgba(249, 242, 228, 0.94));
  border: 1px solid rgba(33, 27, 20, 0.16);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.roster-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 92px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 15px 6px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.02em;
}

.panel-count {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  background: var(--gold-soft);
  border: 1px solid rgba(201, 162, 39, 0.28);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.panel-hint {
  margin: 0;
  padding: 0 15px 10px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* ---------------- Roster ---------------- */

.roster-filters {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px 8px;
  flex-wrap: wrap;
}
.roster-filters .chip { font-size: 10px; padding: 4px 9px; }
.used-badge {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--ink-faint);
  white-space: nowrap;
}
.clue-used-toggle {
  appearance: none;
  align-self: flex-start;
  margin-top: 2px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.7);
  color: var(--ink-faint);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.clue-used-toggle:hover { background: #fff; color: var(--ink); }
.clue-used-toggle[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 2px 12px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  flex: 1 1 auto;
  min-height: 0;
}

.person-card {
  position: relative;
  cursor: pointer;
  user-select: none;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 5px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(35, 24, 12, 0.06);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.person-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: rgba(33, 27, 20, 0.26); }
.person-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.36), var(--shadow-sm);
  background: #fffdf4;
}
.person-card.placed { border-color: rgba(63, 125, 90, 0.35); }

.person-card .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--card);
  border: 1px solid rgba(33, 27, 20, 0.1);
}
.person-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  display: block;
}
.person-card .thumb::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 0%;
  background: transparent;
  pointer-events: none;
  z-index: 1;
}
.person-card .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.person-card .name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  padding: 0 1px;
}
.person-card .name {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-card .pos {
  font-size: 9px;
  font-weight: 800;
  color: var(--green);
  background: rgba(63, 125, 90, 0.1);
  border-radius: 999px;
  padding: 1px 5px;
  white-space: nowrap;
}
.person-card .tag {
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 1px 1px;
}
.person-card .clue-snippet {
  display: block;
  margin-top: 1px;
  padding: 3px 2px 1px;
  border-top: 1px dashed var(--line);
  font-size: 9px;
  line-height: 1.35;
  color: var(--ink-soft);
  text-align: left;
  overflow-wrap: anywhere;
}
.person-card .check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.person-card.wrong-flash { animation: shake 0.36s ease; border-color: var(--red); }
.person-card .check[hidden],
.person-card .pos[hidden] { display: none; }
.person-card[hidden] { display: none; }
.person-card.used .clue-snippet { opacity: 0.55; }

.treasure-card {
  margin: 0 12px 12px;
  border: 1px dashed rgba(201, 162, 39, 0.55);
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.14), rgba(255, 250, 240, 0.7));
  border-radius: 12px;
  padding: 7px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.treasure-card-img {
  position: relative;
  width: 52px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff6df;
}
.treasure-card-img img { width: 100%; height: 100%; object-fit: contain; padding: 2px; filter: saturate(1.1); }
.treasure-card-lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 14, 8, 0.55);
  color: #f4d47a;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 800;
}
.treasure-card.solved .treasure-card-lock { display: none; }
.treasure-card-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.treasure-card-body strong { font-size: 12px; }
.treasure-card-body span { font-size: 10px; color: var(--ink-soft); }

/* ---------------- Board panel ---------------- */

.board-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.tool-group { display: flex; gap: 4px; flex-wrap: wrap; }

.tool {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  min-height: 34px;
}
.tool:hover { background: rgba(33, 27, 20, 0.06); color: var(--ink); }
.tool.active {
  background: var(--ink);
  color: #fff8e8;
  border-color: var(--ink);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.tool.active span[aria-hidden] { color: #f4d47a; }

.placing-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px 4px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(201, 162, 39, 0.38);
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  max-width: 210px;
}
.placing-badge[hidden] { display: none; }
.placing-badge i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, var(--gold));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.65);
  flex-shrink: 0;
}
.placing-badge span { overflow: hidden; text-overflow: ellipsis; }
.placing-badge button {
  appearance: none;
  border: none;
  background: rgba(33, 27, 20, 0.08);
  color: var(--ink-soft);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.placing-badge button:hover { background: rgba(33, 27, 20, 0.16); color: var(--ink); }

.board-meta { display: flex; align-items: center; gap: 5px; padding-right: 3px; }
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  background: rgba(33, 27, 20, 0.05);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
}

/* Board shell + labels */
.board-shell {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  grid-template-rows: 20px minmax(0, 1fr);
  width: var(--board-max);
  margin: 0 auto;
  filter: drop-shadow(0 18px 26px rgba(35, 24, 12, 0.22));
}

.corner-label { grid-column: 1; grid-row: 1; }

.col-labels {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: end;
  font-size: clamp(7px, 0.6vw, 9px);
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  padding-bottom: 2px;
  letter-spacing: -0.02em;
}
.col-labels span.highlight { color: var(--gold-deep); background: rgba(201, 162, 39, 0.22); border-radius: 3px; }

.row-labels {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(24, 1fr);
  align-items: center;
  justify-items: end;
  font-size: clamp(7px, 0.6vw, 9px);
  font-weight: 700;
  color: var(--ink-soft);
  padding-right: 4px;
  letter-spacing: -0.02em;
}
.row-labels span.highlight { color: var(--gold-deep); background: rgba(201, 162, 39, 0.22); border-radius: 3px; padding: 0 2px; }

.board {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  outline: 4px solid #2a2119;
  outline-offset: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #cfe4f0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
  transition: box-shadow 0.18s ease;
}
.board.has-selection {
  box-shadow: inset 0 0 0 3px rgba(201, 162, 39, 0.55), 0 0 0 1px rgba(201, 162, 39, 0.35);
}
.board[data-tool="x"] { cursor: cell; }
.board[data-tool="erase"] { cursor: not-allowed; }
.board[data-tool="place"] { cursor: pointer; }

.board-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  grid-template-rows: repeat(24, 1fr);
  z-index: 3;
}

.cell {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 0;
  margin: 0;
  position: relative;
  cursor: inherit;
  border-radius: 1px;
  transition: background 0.08s ease, box-shadow 0.08s ease;
}
.cell:hover { background: rgba(255, 255, 255, 0.24); box-shadow: inset 0 0 0 2px rgba(201, 162, 39, 0.8); z-index: 2; }
.cell.selected-target:hover { background: rgba(201, 162, 39, 0.2); }
.cell.blocked:hover {
  background: rgba(178, 58, 58, 0.16);
  box-shadow: inset 0 0 0 2px rgba(178, 58, 58, 0.65);
}
.board[data-tool="place"] .cell.blocked { cursor: not-allowed; }
.cell.wrong { animation: wrongCell 0.7s ease; }
.cell.hint-pulse::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 4px;
  border: 2px solid var(--gold);
  animation: hintPulse 1.2s ease infinite;
  pointer-events: none;
}

/* Tokens + notes overlays */
.tokens {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.token {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px;
  transform-origin: 50% 60%;
  animation: tokenPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.token-inner {
  position: relative;
  width: 92%;
  height: 92%;
  border-radius: 50%;
  border: 2px solid var(--c, #333);
  background: #fff8ea;
  box-shadow: 0 2px 6px rgba(20, 14, 8, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  overflow: hidden;
}
.token-face {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: 100%;
  background-position: 50% 50%;
  transform: scale(1.02);
}
.token-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 -8px 14px rgba(20, 14, 8, 0.22);
  pointer-events: none;
}
.token-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 38%;
  height: 38%;
  min-width: 11px;
  min-height: 11px;
  border-radius: 50%;
  background: var(--c, #333);
  color: #fff;
  font-size: clamp(6px, 0.55vw, 9px);
  font-weight: 900;
  display: grid;
  place-items: center;
  border: 1.5px solid #fff8ea;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.token.wrong-token .token-inner { animation: shake 0.4s ease; border-color: var(--red); }

.notes {
  position: absolute;
  inset: 2%;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 1px;
  align-content: center;
  justify-items: center;
  pointer-events: none;
}
.note {
  font-size: clamp(6px, 0.62vw, 9px);
  font-weight: 900;
  line-height: 1;
  color: var(--c, #333);
  background: rgba(255, 251, 240, 0.86);
  border-radius: 3px;
  padding: 1px 2px;
  box-shadow: 0 1px 2px rgba(20, 14, 8, 0.2);
  max-width: 100%;
}
.note.more { color: var(--ink-soft); background: transparent; box-shadow: none; }
.notes.one { grid-template-columns: 1fr; }

.xmark {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: rgba(160, 45, 45, 0.78);
  font-size: clamp(13px, 1.45vw, 24px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.xmark.soft { color: rgba(160, 45, 45, 0.45); }

/* Victory cross + treasure */
.cross-overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.cross-overlay[hidden] { display: none; }
.cross-row, .cross-col {
  position: absolute;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.06), rgba(201, 162, 39, 0.42), rgba(201, 162, 39, 0.06));
  box-shadow: 0 0 18px rgba(201, 162, 39, 0.45);
  animation: crossGlow 2.4s ease-in-out infinite;
}
.cross-row { left: 0; right: 0; height: calc(100% / 24); }
.cross-col { top: 0; bottom: 0; width: calc(100% / 24); background: linear-gradient(180deg, rgba(201, 162, 39, 0.06), rgba(201, 162, 39, 0.42), rgba(201, 162, 39, 0.06)); }

.treasure-burst {
  position: absolute;
  left: 0; top: 0;
  width: calc(100% / 24);
  height: calc(100% / 24);
  display: grid;
  place-items: center;
  z-index: 6;
}
.treasure-glow {
  position: absolute;
  width: 280%;
  height: 280%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 224, 120, 0.9), rgba(255, 206, 70, 0.35) 45%, transparent 70%);
  animation: treasureGlow 1.8s ease-in-out infinite;
}
.treasure-burst img {
  position: relative;
  width: 135%;
  height: 135%;
  object-fit: contain;
  background: #fff6df;
  border-radius: 50%;
  border: 2px solid #f6d974;
  box-shadow: 0 6px 18px rgba(20, 14, 8, 0.5);
  animation: chestBounce 1.6s ease-in-out infinite;
}
.treasure-label {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b2118;
  color: #f6d974;
  font-size: clamp(6px, 0.55vw, 9px);
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.board-toast {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translate(-50%, 12px);
  background: rgba(33, 27, 20, 0.92);
  color: #fff8e8;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 13px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 10;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.board-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Board footer */
.board-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(255, 250, 240, 0.78);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
}
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 10.5px; color: var(--ink-soft); }
.legend b { color: var(--ink); }
.board-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* ---------------- Clues ---------------- */

.clue-filters { display: flex; gap: 5px; padding: 0 12px 8px; flex-wrap: wrap; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.7);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.chip:hover { background: #fff; }
.chip.active { background: var(--ink); color: #fff8e8; border-color: var(--ink); }

.clue-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 2px 12px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  flex: 1 1 auto;
  min-height: 0;
}

.clue-card {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--gold));
  border-radius: 10px;
  padding: 7px 8px;
  cursor: pointer;
  transition: opacity 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
.clue-card:hover { transform: translateX(1px); box-shadow: var(--shadow-sm); }
.clue-card.used { opacity: 0.52; }
.clue-card.selected { box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.45); background: #fffdf4; }
.clue-card .clue-face {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--c, var(--gold));
  background: #efe6d4;
}
.clue-card .clue-face img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}
.clue-card .clue-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.clue-card .clue-name {
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
}
.clue-card .clue-name .tag {
  font-size: 7.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}
.clue-card .clue-text { font-size: 11px; line-height: 1.35; color: var(--ink-soft); }
.clue-card .clue-check {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: #fffdf7;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  color: transparent;
}
.clue-card.used .clue-check { background: var(--green); border-color: var(--green); color: #fff; }
.clue-card[hidden] { display: none; }

/* ---------------- Credits ---------------- */

.credits {
  max-width: 1820px;
  width: 100%;
  margin: 0 auto;
  padding: 4px 24px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-faint);
}
.credits a { color: var(--ink-soft); text-underline-offset: 2px; }
.credits a:hover { color: var(--ink); }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 18px);
  background: rgba(33, 27, 20, 0.94);
  color: #fff8e8;
  border: 1px solid rgba(246, 217, 116, 0.25);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  max-width: min(92vw, 560px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Modals ---------------- */

.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 16, 10, 0.58);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.18s ease;
}
.modal-card {
  position: relative;
  width: min(92vw, 760px);
  max-height: min(88vh, 900px);
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.99), rgba(249, 241, 225, 0.99));
  border: 1px solid rgba(33, 27, 20, 0.22);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modalIn 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.1);
  scrollbar-width: thin;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.9);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  display: grid;
  place-items: center;
}
.modal-close:hover { background: #fff; color: var(--ink); }

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--gold-deep);
  margin-bottom: 4px;
}

.how-card { width: min(94vw, 980px); }
.how-head h2 {
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 40px);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.how-head p { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--ink-soft); max-width: 760px; }

.how-grid { display: grid; grid-template-columns: 1.2fr 1.2fr 0.9fr; gap: 18px; }
.how-block h3 {
  font-family: var(--serif);
  font-size: 17px;
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.how-block ul { margin: 0; padding-left: 17px; font-size: 12px; line-height: 1.5; color: var(--ink-soft); }
.how-block li { margin-bottom: 5px; }
.how-block b { color: var(--ink); }

.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 11px; color: var(--ink-soft); }
.legend-grid span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.2); display: inline-block; flex-shrink: 0; }
.swatch.sand { background: #e7d6a6; }
.swatch.forest { background: #8fc46a; }
.swatch.water { background: #9fcfe8; }
.swatch.cliff { background: #a9b6c4; }
.swatch.cave { background: #8d99a8; }
.swatch.clearing { background: #b7d98a; }
.swatch.cabin { background: #e8d9b8; }
.swatch.ship { background: #c9a67a; }
.small { font-size: 10.5px; color: var(--ink-faint); line-height: 1.4; }

.how-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.remember { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-soft); cursor: pointer; }
.remember input { accent-color: var(--gold-deep); width: 15px; height: 15px; }

.confirm-card { width: min(92vw, 460px); text-align: center; }
.confirm-card h2 { font-family: var(--serif); font-size: 26px; margin: 4px 0 8px; }
.confirm-card p { font-size: 13px; line-height: 1.5; color: var(--ink-soft); margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Victory */
.victory-card { width: min(92vw, 560px); text-align: center; overflow: hidden; }
.victory-rays {
  position: absolute;
  inset: -40% -20% auto;
  height: 70%;
  background: conic-gradient(from 0deg, rgba(201, 162, 39, 0.18), transparent 10%, rgba(201, 162, 39, 0.18) 20%, transparent 30%, rgba(201, 162, 39, 0.18) 40%, transparent 50%, rgba(201, 162, 39, 0.18) 60%, transparent 70%, rgba(201, 162, 39, 0.18) 80%, transparent 90%, rgba(201, 162, 39, 0.18));
  animation: spin 26s linear infinite;
  pointer-events: none;
}
.victory-chest {
  position: relative;
  width: 120px;
  height: 100px;
  margin: 0 auto 8px;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #f0cf6a;
  box-shadow: 0 10px 26px rgba(80, 55, 10, 0.35);
  background: #fff6df;
  animation: chestBounce 2s ease-in-out infinite;
}
.victory-chest img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.victory-card h2 { position: relative; font-family: var(--serif); font-size: clamp(26px, 4vw, 36px); margin: 2px 0 6px; }
.victory-coords {
  position: relative;
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 800;
  color: #7a5a0c;
  background: linear-gradient(180deg, #ffe9a6, #f3cf61);
  border: 1px solid #c9a227;
  border-radius: 12px;
  padding: 6px 18px;
  margin: 6px 0 8px;
  box-shadow: 0 3px 0 #a67c1a, 0 8px 20px rgba(120, 85, 10, 0.25);
}
.victory-sub { position: relative; font-size: 12px; color: var(--ink-soft); margin: 0 auto 10px; max-width: 380px; line-height: 1.5; }
.victory-stats { position: relative; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0 18px; }
.victory-stat {
  background: rgba(33, 27, 20, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--ink-soft);
}
.victory-stat b { display: block; font-size: 15px; color: var(--ink); }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 350; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -10vh;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation: confettiFall linear forwards;
}

/* ---------------- Animations ---------------- */

@keyframes tokenPop { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }
@keyframes wrongCell { 0%, 100% { background: transparent; } 30% { background: rgba(178, 58, 58, 0.35); } 60% { background: rgba(178, 58, 58, 0.15); } }
@keyframes hintPulse { 0%, 100% { opacity: 0.25; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.02); } }
@keyframes crossGlow { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }
@keyframes treasureGlow { 0%, 100% { transform: scale(0.9); opacity: 0.65; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes chestBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes confettiFall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(720deg); opacity: 0.85; }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1320px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .roster-grid { gap: 6px; padding-inline: 10px; }
  .person-card .name { font-size: 10.5px; }
}

@media (max-width: 1120px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .how-grid { grid-template-columns: 1fr 1fr; }
  .how-grid .how-block:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .topbar { padding: 14px 16px 10px; }
  .brand { gap: 8px; }
  .brand-sub { display: none; }
  .layout { grid-template-columns: 1fr; padding: 0 10px 14px; gap: 10px; }
  .board-panel { order: 1; }
  .roster-panel { order: 2; position: static; max-height: none; }
  .roster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: none; overflow: visible; }
  .board-shell { width: min(100%, 86vh); }
  .board-toolbar { flex-wrap: wrap; }
  .tool-label { display: none; }
  .tool { padding: 8px 10px; }
  .legend { display: none; }
  .board-footer { justify-content: center; }
  .board-actions { margin-left: 0; justify-content: center; width: 100%; }
  .how-grid { grid-template-columns: 1fr; }
  .how-grid .how-block:last-child { grid-column: auto; }
  .modal-card { padding: 18px; }
}

@media (max-width: 520px) {
  .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-mark { font-size: 18px; }
  .topbar-actions .btn { padding: 8px 11px; font-size: 11px; }
  .board-shell { width: 100%; grid-template-columns: 20px minmax(0, 1fr); }
  .col-labels, .row-labels { font-size: 6.5px; }
  .timer { font-size: 11px; padding: 5px 8px; }
  .icon-btn { width: 30px; height: 30px; }
  .btn { padding: 8px 12px; font-size: 12px; }
  .victory-chest { width: 96px; height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
