/* Sherloku — visual de época, a partir da imagem de referência (assets/origem/referencia-interface.png):
   pergaminho cor de pêssego com manchas e vinheta, cabeçalho verde-oliva quase negro com gravura,
   molduras de cantos cortados (a mesma dos cartões pintados), bronze e ouro, vermelho profundo nos botões.
   As cores foram medidas na referência. Tudo vem de variáveis; o modo escuro ("à luz do candeeiro") só as
   redefine, automaticamente pelo sistema ou à mão com o botão ◐ (que fica guardado). Sem fontes externas:
   o ar de época vem das serifas do sistema, de maiúsculas espaçadas, de carimbos e das ilustrações.
   Os url() de imagens são relativos a este ficheiro; scripts/empacotar.mjs troca-os por data URI. */

:root {
  --fundo: #f1d7ae;
  --papel: #f6dcb2;
  --papel-2: #ecd0a0;
  --tinta: #2b1d12;
  --texto: #2b1d12;
  --suave: #7a5f3e;
  --linha: #c8a56f;
  --parede: #2b1d12;
  --verde: #3f4231;
  --verde-texto: #f0dcae;
  --acento: #8b1e15;            /* vermelho profundo dos botões */
  --acento-texto: #fbeccd;
  --ouro: #c8963c;
  --ouro-escuro: #8a5a28;       /* bronze das molduras */
  --ouro-claro: #f0cf84;
  --selo: #9c2418;
  --ok: #4f6b34;
  --sombra: 3px 3px 0 rgba(60, 35, 12, .3);
  --decor-filtro: none;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Times New Roman", serif;
  --sala-0: #ecc9b6; --sala-1: #cdd7b6; --sala-2: #efd596; --sala-3: #bfd0d6; --sala-4: #dcbdc2;
  --sala-5: #dcc9a4; --sala-6: #bed1bd; --sala-7: #e6c19b; --sala-8: #cfc0d2;
  /* cor de cada material de piso (como nos livros: relva verde, areia amarela, tijolo rosado, pedra cinzenta…) */
  --mat-madeira: #d9a566; --mat-relva: #8dc25d; --mat-ladrilho: #a6c2d0; --mat-losango: #e3a698; --mat-pedra: #b1aba1; --mat-areia: #f3da88; --mat-agua: #8fc6e6; --mat-asfalto: #9a9da3; --mat-terra: #c49a6c; --mat-metal: #b4bec6;
  color-scheme: light;
}

:root[data-tema="escuro"],
:root[data-theme="dark"]:not([data-tema="claro"]) {
  --fundo: #1d140b; --papel: #2e2113; --papel-2: #3a2a18; --tinta: #f0dcae; --texto: #f0dcae; --suave: #bba47c; --linha: #5e4a2e;
  --parede: #0d0905; --verde: #2a2d1f; --verde-texto: #f0dcae; --acento: #a8362a; --acento-texto: #fbeccd;
  --ouro: #d9a94a; --ouro-escuro: #b8892f; --ouro-claro: #f6dc95; --selo: #e0675a; --ok: #8fc16a;
  --sombra: 3px 3px 0 rgba(0, 0, 0, .55); --decor-filtro: brightness(.6) saturate(.9);
  --sala-0: #5b4436; --sala-1: #475238; --sala-2: #5e5430; --sala-3: #3d4e52; --sala-4: #583f40;
  --sala-5: #54492f; --sala-6: #3c5042; --sala-7: #5c4630; --sala-8: #4c4153;
  --mat-madeira: #6d4b2b; --mat-relva: #3f6c2f; --mat-ladrilho: #3e5b69; --mat-losango: #6e403b; --mat-pedra: #56534d; --mat-areia: #6f6030; --mat-agua: #2f5f80; --mat-asfalto: #44474d; --mat-terra: #6a4f35; --mat-metal: #4f5a63;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]):not([data-theme="light"]) {
    --fundo: #1d140b; --papel: #2e2113; --papel-2: #3a2a18; --tinta: #f0dcae; --texto: #f0dcae; --suave: #bba47c; --linha: #5e4a2e;
    --parede: #0d0905; --verde: #2a2d1f; --verde-texto: #f0dcae; --acento: #a8362a; --acento-texto: #fbeccd;
    --ouro: #d9a94a; --ouro-escuro: #b8892f; --ouro-claro: #f6dc95; --selo: #e0675a; --ok: #8fc16a;
    --sombra: 3px 3px 0 rgba(0, 0, 0, .55); --decor-filtro: brightness(.6) saturate(.9);
    --sala-0: #5b4436; --sala-1: #475238; --sala-2: #5e5430; --sala-3: #3d4e52; --sala-4: #583f40;
    --sala-5: #54492f; --sala-6: #3c5042; --sala-7: #5c4630; --sala-8: #4c4153;
    --mat-madeira: #6d4b2b; --mat-relva: #3f6c2f; --mat-ladrilho: #3e5b69; --mat-losango: #6e403b; --mat-pedra: #56534d; --mat-areia: #6f6030; --mat-agua: #2f5f80; --mat-asfalto: #44474d; --mat-terra: #6a4f35; --mat-metal: #4f5a63;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  position: relative;
  margin: 0;
  color: var(--texto);
  font: 17px/1.4 var(--serif);
  min-height: 100vh;
  background-color: var(--fundo);
  /* papel antigo, de cima para baixo: vinheta nos cantos, manchas de oxidação (ruído de baixa
     frequência) e grão fino, tudo em SVG embebido (sem pedidos de rede) */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='700' height='700'><filter id='m' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.008' numOctaves='3' seed='11' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .52  0 0 0 0 .30  0 0 0 0 .09  0 0 0 1.5 -.62'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .36  0 0 0 0 .24  0 0 0 0 .10  0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
/* vinheta de papel queimado nos cantos do ecrã: uma película fixa à parte (um fundo "fixed" no body
   fazia a textura só cobrir a altura do primeiro ecrã) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 48%, rgba(120, 66, 14, .34) 100%);
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .celula:focus-visible { outline: 3px solid var(--ouro); outline-offset: 2px; }

/* ---------- topo: verde-oliva quase negro com a gravura da mansão ---------- */
.topo {
  position: relative; overflow: hidden;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, color-mix(in srgb, var(--verde) 90%, #fff 10%), color-mix(in srgb, var(--verde) 88%, #000 12%));
  color: var(--verde-texto);
  border-bottom: 4px double var(--ouro);
  box-shadow: 0 3px 0 rgba(43, 25, 8, .3);
}
.topo::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: 120px; width: min(490px, 62%); pointer-events: none;
  background: url("../assets/decoracao/cabecalho.webp") right center / cover no-repeat; opacity: .7;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 38%, #000 80%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 38%, #000 80%, transparent);
}
.topo > * { position: relative; z-index: 1; }
.logo { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0; color: inherit; font-family: var(--serif); font-weight: 700; font-size: 1.55rem; letter-spacing: .12em; text-transform: uppercase; }
.logo span { background: linear-gradient(180deg, var(--ouro-claro), var(--ouro) 55%, var(--ouro-escuro)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .55)); }
.logo svg { width: 26px; height: 26px; color: var(--ouro); }
.topo-acoes { display: flex; gap: 8px; }
.topo-acoes button {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--ouro); background: rgba(20, 14, 6, .45);
  color: var(--ouro-claro); font-weight: 700; font-size: 1.05rem; line-height: 1; font-family: var(--serif);
  box-shadow: inset 0 0 0 2px rgba(20, 14, 6, .5), 0 1px 0 rgba(0, 0, 0, .4);
}

/* ---------- ecrãs ---------- */
#app { position: relative; z-index: 1; padding: 16px max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left, 0px)); max-width: 1180px; margin: 0 auto; }
.aviso { padding: 16px; text-align: center; }

/* objetos de secretária nos cantos (só em ecrãs largos, sempre no fim da página) */
.decor { position: absolute; bottom: 0; display: none; pointer-events: none; z-index: 0; filter: var(--decor-filtro); }
.decor.esq {
  left: 0; width: 228px; height: 172px; background: url("../assets/decoracao/livros.webp") left bottom / contain no-repeat;
  -webkit-mask-image: linear-gradient(to top, #000 55%, transparent), linear-gradient(to right, #000 62%, transparent);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to top, #000 55%, transparent), linear-gradient(to right, #000 62%, transparent); mask-composite: intersect;
}
.decor.dir {
  right: 0; width: 340px; height: 297px; background: url("../assets/decoracao/relogio.webp") right bottom / contain no-repeat;
  -webkit-mask-image: linear-gradient(to top, #000 50%, transparent), linear-gradient(to left, #000 55%, transparent);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to top, #000 50%, transparent), linear-gradient(to left, #000 55%, transparent); mask-composite: intersect;
}
@media (min-width: 1200px) {
  .decor { display: block; }
  #app { padding-bottom: 210px; }
}

.intro { text-align: center; margin: 14px 0 22px; }
.intro h1 { margin: 0 0 6px; font-size: 1.9rem; font-weight: 700; line-height: 1.15; font-variant: small-caps; letter-spacing: .03em; }
.intro p { margin: 0 auto; max-width: 560px; color: var(--suave); font-style: italic; }
.intro::after { content: "❦"; display: block; margin-top: 10px; font-size: 1.5rem; color: var(--acento); }

.nivel { margin: 22px 0 8px; }
.nivel h2 { margin: 0 0 14px; display: flex; align-items: center; gap: 12px; font-size: 1rem; }
.nivel h2::after { content: ""; flex: 1; height: 0; border-top: 3px double var(--ouro-escuro); opacity: .6; }
.etiqueta {
  font-size: .8rem; font-weight: 700; padding: 4px 22px; background: var(--acento); color: var(--acento-texto);
  text-transform: uppercase; letter-spacing: .16em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%, 9px 50%);
}
.lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }

/* Molduras de cantos cortados: a moldura dos cartões pintados, em nove partes (só o rebordo de 12 px;
   o miolo é o papel do elemento). Tudo o que é "cartão" no jogo usa-a. */
.puzzle, .cartao, .gerais, .modal-caixa {
  border: 12px solid transparent;
  border-image: url("../assets/ui/moldura.webp") 12 / 12px stretch;
  background: var(--papel);
  box-shadow: var(--sombra);
}

.puzzle {
  position: relative; padding: 4px 4px 6px; text-align: left;
  display: flex; flex-direction: column; gap: 4px; transition: transform .12s;
}
.puzzle::before {
  content: ""; position: absolute; top: -22px; left: 50%; width: 58px; height: 17px; z-index: 2;
  background: color-mix(in srgb, var(--ouro) 62%, transparent); transform: translateX(-50%) rotate(-3deg);
  box-shadow: 0 1px 0 rgba(43, 33, 24, .15);
}
.puzzle:nth-child(odd) { transform: rotate(-.6deg); }
.puzzle:nth-child(even) { transform: rotate(.5deg); }
.puzzle:hover { transform: rotate(0) translateY(-2px); }
.puzzle .mini { width: 100%; aspect-ratio: 1; border: 2px solid var(--tinta); display: block; margin-bottom: 4px; background: var(--fundo); }
.puzzle strong { font-size: 1rem; line-height: 1.15; }
.puzzle small { color: var(--suave); font-style: italic; }
.puzzle .estado { font-size: .85rem; font-variant: small-caps; letter-spacing: .06em; font-weight: 700; }
.puzzle .meio { color: var(--acento); }

/* carimbo vermelho (casos resolvidos) */
.carimbo {
  display: inline-block; border: 3px double var(--selo); color: var(--selo); padding: 1px 9px; border-radius: 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; transform: rotate(-7deg);
  background: color-mix(in srgb, var(--selo) 6%, transparent);
}
.puzzle .carimbo { position: absolute; right: -4px; top: 6px; background: var(--papel); }
.carimbo.grande { display: block; width: max-content; margin: 4px auto 14px; padding: 6px 18px; font-size: 1.15rem; }

/* ---------- jogo ---------- */
.jogo-cabeca { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.jogo-cabeca .voltar { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ouro-escuro); background: var(--papel); font-size: 1.2rem; box-shadow: inset 0 0 0 2px var(--papel), inset 0 0 0 3px var(--ouro), 2px 2px 0 rgba(60, 35, 12, .35); }
.jogo-cabeca .titulo { flex: 1; line-height: 1.15; }
.jogo-cabeca .titulo strong { display: block; font-size: 1.25rem; }
.jogo-cabeca .titulo span { color: var(--suave); font-size: .9rem; font-style: italic; }
.relogio { font-variant-numeric: tabular-nums; font-weight: 700; background: var(--papel); border: 2px solid var(--ouro-escuro); padding: 4px 14px; letter-spacing: .06em; box-shadow: inset 0 0 0 2px var(--papel), inset 0 0 0 3px var(--ouro), 2px 2px 0 rgba(60, 35, 12, .35); }

.jogo-corpo { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) {
  .jogo-corpo { grid-template-columns: minmax(380px, 600px) 1fr; }
  .lado-tabuleiro { position: sticky; top: 12px; }
}

/* o mapa: uma planta em pergaminho, com moldura dupla de bronze e cantos ornamentados */
.tabuleiro {
  --n: 6;
  display: grid; grid-template-columns: repeat(var(--n), 1fr);
  width: 100%; max-width: 600px; aspect-ratio: 1; margin: 0 auto;
  border: 3px solid var(--tinta); background: var(--papel);
  container-type: inline-size; touch-action: manipulation;
}
.moldura {
  position: relative; max-width: 620px; margin: 0 auto; padding: 10px; background: var(--papel-2);
  border: 2px solid var(--ouro-escuro); box-shadow: inset 0 0 0 2px var(--papel), inset 0 0 0 3px var(--ouro), 6px 6px 0 rgba(60, 35, 12, .28);
}
.canto {
  position: absolute; width: 34px; height: 34px; pointer-events: none; z-index: 5;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'><g fill='none' stroke='%238a5a28' stroke-width='2.2' stroke-linecap='round'><path d='M3 3H26M3 3V26'/><path d='M9 9C9 20 20 20 20 11 20 7 15 8 15 12'/></g><circle cx='5' cy='5' r='3.2' fill='%238a5a28'/></svg>") no-repeat center / contain;
}
.canto.c1 { left: -7px; top: -7px; }
.canto.c2 { right: -7px; top: -7px; transform: scaleX(-1); }
.canto.c3 { left: -7px; bottom: -7px; transform: scaleY(-1); }
.canto.c4 { right: -7px; bottom: -7px; transform: scale(-1, -1); }
.celula {
  position: relative; padding: 0; margin: 0; border: 1px solid color-mix(in srgb, var(--parede) 25%, transparent);
  border-radius: 0; background-color: color-mix(in srgb, var(--cs) 30%, var(--cp, var(--cs))); display: block; min-width: 0; min-height: 0;
  -webkit-tap-highlight-color: transparent;
}
/* Piso da divisão: uma textura por cima da cor, em cada casa (os desenhos encaixam de casa para casa). A cor da
   divisão mistura-se com a cor própria do piso (--cp) para a relva ser verde mesmo numa divisão "rosa". */
.celula::before { content: ""; position: absolute; inset: 0; background: var(--piso) 0 0 / 100% 100%; pointer-events: none; }
.sala-0 { --cs: var(--sala-0); } .sala-1 { --cs: var(--sala-1); } .sala-2 { --cs: var(--sala-2); }
.sala-3 { --cs: var(--sala-3); } .sala-4 { --cs: var(--sala-4); } .sala-5 { --cs: var(--sala-5); }
.sala-6 { --cs: var(--sala-6); } .sala-7 { --cs: var(--sala-7); } .sala-8 { --cs: var(--sala-8); }
.piso-madeira { --cp: var(--mat-madeira); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g stroke='%232b1d12' stroke-opacity='.22' stroke-width='1.2' fill='none'><path d='M0 13.3H40M0 26.6H40'/><path d='M27 0V13.3M11 13.3V26.6M31 26.6V40'/></g><g stroke='%23fff' stroke-opacity='.18' stroke-width='.8' fill='none'><path d='M3 5C14 3 24 7 37 5M3 19C12 17 26 21 37 18M3 33C16 31 22 35 37 32'/></g></svg>"); }
.piso-relva { --cp: var(--mat-relva); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g stroke='%232f5a22' stroke-opacity='.45' stroke-width='1.6' stroke-linecap='round' fill='none'><path d='M6 12l1.5-6 1.5 6M24 9l1-5 2 5M33 24l1.5-6 1.5 6M12 31l1-5 2 5M20 20l1-4 1.5 4M3 36l1-4 2 4'/></g><g stroke='%23fff' stroke-opacity='.25' stroke-width='1.2' stroke-linecap='round'><path d='M16 6l.8-3M30 35l.8-3M37 10l.8-3'/></g></svg>"); }
.piso-ladrilho { --cp: var(--mat-ladrilho); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><rect width='20' height='20' fill='%23fff' fill-opacity='.28'/><rect x='20' y='20' width='20' height='20' fill='%23fff' fill-opacity='.28'/><rect x='20' width='20' height='20' fill='%232b1d12' fill-opacity='.10'/><rect y='20' width='20' height='20' fill='%232b1d12' fill-opacity='.10'/></svg>"); }
.piso-losango { --cp: var(--mat-losango); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><path d='M20 3L37 20 20 37 3 20Z' fill='%23fff' fill-opacity='.30' stroke='%238a5a28' stroke-opacity='.45' stroke-width='1.2'/><path d='M20 12L28 20 20 28 12 20Z' fill='%232b1d12' fill-opacity='.12'/></svg>"); }
.piso-pedra { --cp: var(--mat-pedra); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g stroke='%232b1d12' stroke-opacity='.28' stroke-width='1.4' fill='none'><path d='M0 20H40M13 0V20M29 20V40M0 0H40'/></g><g fill='%23fff' fill-opacity='.18'><rect x='2' y='2' width='9' height='8'/><rect x='31' y='24' width='7' height='8'/></g><g fill='%232b1d12' fill-opacity='.10'><rect x='15' y='24' width='12' height='9'/></g></svg>"); }
.piso-areia { --cp: var(--mat-areia); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g fill='%238a6a28' fill-opacity='.28'><circle cx='6' cy='8' r='.9'/><circle cx='22' cy='5' r='.7'/><circle cx='33' cy='14' r='.9'/><circle cx='14' cy='22' r='.8'/><circle cx='28' cy='30' r='.9'/><circle cx='5' cy='34' r='.7'/><circle cx='36' cy='37' r='.7'/></g><path d='M2 16C12 14 20 18 30 15M8 28C16 26 26 30 38 27' stroke='%23fff' stroke-opacity='.25' stroke-width='.8' fill='none'/></svg>"); }
.piso-agua { --cp: var(--mat-agua); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g stroke='%23fff' stroke-opacity='.55' stroke-width='1.3' stroke-linecap='round' fill='none'><path d='M3 10q4-4 8 0t8 0M22 24q4-4 8 0t8 0M4 34q3-3 6 0t6 0'/></g><g stroke='%231e5c85' stroke-opacity='.28' stroke-width='1.1' stroke-linecap='round' fill='none'><path d='M22 8q3-3 6 0t6 0M3 22q3-3 6 0t6 0'/></g></svg>"); }
.piso-asfalto { --cp: var(--mat-asfalto); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g fill='%23fff' fill-opacity='.22'><circle cx='5' cy='6' r='.8'/><circle cx='18' cy='12' r='.7'/><circle cx='31' cy='8' r='.9'/><circle cx='10' cy='24' r='.9'/><circle cx='26' cy='28' r='.7'/><circle cx='35' cy='36' r='.8'/><circle cx='14' cy='36' r='.7'/></g><g fill='%23000' fill-opacity='.14'><circle cx='24' cy='18' r='.9'/><circle cx='4' cy='16' r='.7'/><circle cx='32' cy='22' r='.7'/></g><path d='M0 20H12M18 20H30M36 20H40' stroke='%23fff' stroke-opacity='.38' stroke-width='1.6' fill='none'/></svg>"); }
.piso-terra { --cp: var(--mat-terra); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g fill='%233b2410' fill-opacity='.28'><ellipse cx='8' cy='9' rx='2.4' ry='1.4'/><ellipse cx='28' cy='14' rx='2' ry='1.2'/><ellipse cx='15' cy='28' rx='2.6' ry='1.4'/><ellipse cx='34' cy='33' rx='2' ry='1.2'/></g><g fill='%23fff' fill-opacity='.2'><circle cx='20' cy='6' r='.9'/><circle cx='4' cy='22' r='.8'/><circle cx='26' cy='24' r='.8'/><circle cx='36' cy='6' r='.7'/></g><path d='M3 17q8-3 15 0M22 36q7-3 15 0' stroke='%233b2410' stroke-opacity='.22' stroke-width='.9' fill='none'/></svg>"); }
.piso-metal { --cp: var(--mat-metal); --piso: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' preserveAspectRatio='none'><g stroke='%23263238' stroke-opacity='.3' stroke-width='1.2' fill='none'><path d='M0 20H40M20 0V40'/></g><g fill='%23fff' fill-opacity='.45'><circle cx='3.5' cy='3.5' r='1.3'/><circle cx='36.5' cy='3.5' r='1.3'/><circle cx='3.5' cy='36.5' r='1.3'/><circle cx='36.5' cy='36.5' r='1.3'/><circle cx='23.5' cy='23.5' r='1.3'/><circle cx='16.5' cy='16.5' r='1.3'/></g><g fill='%23263238' fill-opacity='.2'><circle cx='4.3' cy='4.3' r='1'/><circle cx='37.3' cy='4.3' r='1'/><circle cx='4.3' cy='37.3' r='1'/><circle cx='37.3' cy='37.3' r='1'/></g></svg>"); }
.pt { border-top: 3px solid var(--parede); } .pr { border-right: 3px solid var(--parede); }
.pb { border-bottom: 3px solid var(--parede); } .pl { border-left: 3px solid var(--parede); }
.celula:not(.ob):hover { filter: brightness(1.07); }

/* Cada ícone é um objeto solto (estilo autocolante, com contorno escuro) sobre a cor da divisão. O que bloqueia
   (obstáculo) vê-se "levantado", com uma sombra suave; o que é chão onde se pode estar (superfície) vê-se plano. */
.icone { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.icone.obst { filter: drop-shadow(1px 2px 1px rgba(43, 25, 8, .5)); }
.icone.sup { filter: saturate(.95); }
/* Nome da divisão: etiqueta de pergaminho sobreposta à planta (pode passar para as casas ao lado), sempre legível
   por cima de qualquer piso. Não apanha toques: quem toca nela toca na casa que está por baixo. */
.rotulo {
  position: absolute; left: 2px; top: 2px; z-index: 6; pointer-events: none; width: max-content; max-width: calc(100cqw / var(--n) * 3.4);
  font-family: var(--serif); font-size: clamp(6px, 2.3cqw, 11px); font-weight: 700; font-style: normal; text-transform: uppercase; letter-spacing: .05em; line-height: 1.08;
  padding: .12em .55em; border-radius: 999px; background: var(--papel); color: var(--tinta); text-align: center;
  border: 1.5px solid var(--tinta); box-shadow: 0 1px 0 var(--ouro), 1px 2px 2px rgba(43, 25, 8, .35);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word;
}
.xis { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(14px, 8.5cqw, 40px); line-height: 1; color: var(--selo); opacity: .62; font-weight: 700; pointer-events: none; text-shadow: 0 0 1px var(--papel); }
.notas { position: absolute; inset: 3px; display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: flex-end; gap: 1px 3px; pointer-events: none; z-index: 3; }
.notas b { font-size: clamp(7px, 3.2cqw, 14px); background: var(--papel); color: var(--texto); border-radius: 2px; padding: 0 3px; border: 1px solid var(--tinta); line-height: 1.2; }
.ficha {
  position: absolute; inset: 7%; border-radius: 50%; overflow: hidden; z-index: 4;
  border: 3px solid var(--ouro-escuro); box-shadow: 0 2px 0 rgba(43, 25, 8, .5), inset 0 0 0 1px var(--tinta); background: var(--papel);
}
.ficha svg { display: block; width: 100%; height: 100%; }
.ficha .retrato.pintado { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.ficha.vitima { border-color: var(--selo); }
.ficha.sel { box-shadow: 0 0 0 3px var(--papel), 0 0 0 6px var(--ouro); }
.ficha.vitima::after {
  content: "✕"; position: absolute; right: 0; bottom: 0; width: 38%; height: 38%; display: grid; place-items: center;
  background: var(--selo); color: #fff; font-size: clamp(7px, 3.2cqw, 14px); font-weight: 700; border-radius: 50%;
}

.legenda { list-style: none; margin: 16px auto 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; max-width: 600px; font-size: .88rem; color: var(--suave); font-style: italic; }
.legenda li { display: flex; align-items: center; gap: 6px; }
.legenda i { width: 14px; height: 14px; border: 2px solid var(--tinta); display: inline-block; background-color: color-mix(in srgb, var(--cs) 30%, var(--cp, var(--cs))); }

/* ferramentas: botões de pergaminho com filete dourado; o principal é vermelho profundo */
.ferramentas { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px auto 0; max-width: 600px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 2px solid var(--ouro-escuro); border-radius: 6px; padding: 7px 14px; font-weight: 700; color: var(--texto);
  background: linear-gradient(180deg, color-mix(in srgb, var(--papel) 88%, #fff 12%), color-mix(in srgb, var(--papel) 82%, var(--ouro) 18%));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--papel) 80%, #fff 20%), inset 0 0 0 3px var(--ouro), 2px 3px 0 rgba(60, 35, 12, .38);
  font-variant: small-caps; letter-spacing: .06em; font-size: 1.02rem; min-height: 44px;
}
.btn .ico { width: 19px; height: 19px; flex: none; color: var(--ouro-escuro); }
.btn:active { transform: translate(1px, 2px); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--papel) 80%, #fff 20%), inset 0 0 0 3px var(--ouro); }
.btn[aria-pressed="true"] { background: linear-gradient(180deg, var(--ouro-claro), var(--ouro)); color: #2b1d12; }
.btn.primario { color: var(--acento-texto); border-color: #4a130e; background: linear-gradient(180deg, color-mix(in srgb, var(--acento) 88%, #fff 12%), color-mix(in srgb, var(--acento) 80%, #000 20%)); }
.btn.primario .ico { color: var(--ouro-claro); }
.btn:disabled { opacity: .45; cursor: default; }

/* regras gerais e cartões das personagens (a moldura vem do bloco de molduras acima) */
.gerais { padding: 6px 10px 8px; margin: 0 0 16px; }
.gerais h3::before { content: "❦ "; }
.gerais h3 { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .16em; color: var(--acento); }
.gerais p { margin: 3px 0; font-weight: 700; }
.cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.cartao {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; position: relative;
}
.cartao::before {
  content: "Nº " attr(data-n); position: absolute; right: 5px; top: 5px; z-index: 2; font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  background: linear-gradient(180deg, var(--ouro-claro), var(--ouro)); color: #2b1d12; border: 1px solid var(--ouro-escuro); border-radius: 2px;
  padding: 0 7px; text-transform: uppercase; box-shadow: 0 1px 0 rgba(43, 25, 8, .4);
}
.cartao::after { content: "❧"; position: absolute; right: 6px; bottom: 2px; color: var(--ouro-escuro); opacity: .55; font-size: 1.15rem; line-height: 1; pointer-events: none; }
.cartao .retrato { display: block; width: 100%; height: auto; border-bottom: 2px solid var(--ouro-escuro); }
.cartao svg.retrato { aspect-ratio: 64 / 52; }
.cartao img.retrato { aspect-ratio: 1; object-fit: cover; }
.cartao .nome { font-weight: 700; padding: 6px 8px 0; font-size: 1.12rem; }
.cartao .textos { padding: 2px 8px 18px; font-size: .95rem; }
.cartao .textos p { margin: 4px 0; }
.cartao.sel { box-shadow: 0 0 0 4px var(--ouro), var(--sombra); }
.cartao.colocado .nome::after { content: " ✓"; color: var(--ok); }
.cartao.vitima .nome { color: var(--selo); }
.cartao.vitima::before { background: var(--selo); color: #fff; border-color: #5e1109; content: "Vítima"; }

/* mensagens e janelas */
.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--verde); color: var(--verde-texto); padding: 10px 20px; border-radius: 4px; max-width: min(92vw, 460px);
  border: 2px solid var(--ouro); box-shadow: inset 0 0 0 2px rgba(20, 14, 6, .55), 4px 4px 0 rgba(0, 0, 0, .3);
  font-weight: 700; text-align: center;
}
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(28, 18, 8, .66); display: grid; place-items: center; padding: 16px; }
.modal[hidden], .toast[hidden] { display: none; }
.modal-caixa { padding: 14px; max-width: 480px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 8px 8px 0 rgba(0, 0, 0, .35); }
.modal-caixa h2 { margin: 0 0 8px; text-align: center; font-size: 1.4rem; font-variant: small-caps; letter-spacing: .04em; }
.modal-caixa h2::after { content: "❦"; display: block; color: var(--acento); font-size: 1.1rem; margin-top: 2px; }
.modal-caixa ul { padding-left: 20px; margin: 8px 0; }
.modal-caixa li { margin: 6px 0; }
.modal-caixa .opiniao { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 12px; font-size: .95rem; }
.modal-caixa .opiniao span { flex-basis: 100%; text-align: center; color: var(--suave); }
.modal-caixa .opiniao .btn { padding: 6px 12px; font-size: .9rem; }
.modal-caixa .acoes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.assassino { display: flex; align-items: center; gap: 16px; margin: 12px 0; }
.assassino .retrato { width: 118px; flex: none; border: 3px solid var(--selo); }
.assassino img.retrato { height: auto; aspect-ratio: 1; object-fit: cover; }
.assassino svg.retrato { height: 96px; }
.assassino strong { font-size: 1.4rem; }

/* ecrãs estreitos: gravura do cabeçalho mais discreta (não tapa o nome) e cartões mais compactos */
@media (max-width: 700px) {
  .topo::before { width: 36%; right: 96px; opacity: .5; }
  /* botões de ferramentas: todos na mesma linha, compactos */
  .ferramentas { flex-wrap: nowrap; gap: 4px; margin-top: 12px; }
  .ferramentas .btn { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .64rem; line-height: 1.1; text-align: center; letter-spacing: 0; }
  .ferramentas .btn .ico { width: 16px; height: 16px; }
  /* personagens: 3 por linha no telemóvel */
  .cartoes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .cartao .nome { font-size: .78rem; padding: 4px 4px 0; overflow-wrap: anywhere; }
  .cartao .nome .papel { font-size: .58rem; }
  .cartao .textos { font-size: .66rem; padding: 2px 4px 14px; overflow-wrap: anywhere; }
  .cartao .textos p { margin: 2px 0; }
  .cartao::before { font-size: .5rem; padding: 0 3px; }
  .cartao::after { font-size: .85rem; right: 3px; }
  .cartao.marca-fora .nome::before { font-size: .5rem; letter-spacing: 0; }
}

/* fora-da-lei: seletor de apoio nas regras gerais e marca no cartão do suspeito apontado */
.nota-fora { display: block; margin-top: 8px; font-style: italic; font-weight: 400; }
.nota-fora select {
  font: inherit; margin-left: 6px; padding: 3px 8px; color: var(--texto); background: var(--papel);
  border: 2px solid var(--ouro-escuro); border-radius: 4px;
}
.cartao.marca-fora .nome::before { content: "Fora-da-lei?"; display: block; font-size: .68rem; font-style: italic; letter-spacing: .08em; text-transform: uppercase; color: var(--selo); }

/* mapas grandes (10×10 ou mais): casas nunca abaixo de ~38 px, para o dedo acertar; o mapa desliza para os lados */
.rolagem { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.rolagem .tabuleiro { min-width: calc(var(--n) * 38px); }
.dica-rolar { margin: 8px 0 0; text-align: center; font-size: .85rem; font-style: italic; color: var(--suave); }
@media (min-width: 700px) { .dica-rolar { display: none; } }
.cartao .nome .papel { display: block; font-size: .72rem; font-weight: 400; font-style: italic; color: var(--suave); letter-spacing: .04em; }

/* ---------- movimento de entrada e dossiês por abrir ---------- */
/* Os quadros "dão-se" um a um (atraso --i). A animação só corre dentro de .entrando, que se tira ao fim
   de 1,6 s: sem isso, cada toque num cartão voltava a redesenhá-los e eles saltavam de novo. */
@keyframes entrar {
  from { opacity: 0; translate: 0 26px; scale: .94; }
  60% { opacity: 1; }
}
@keyframes entrar-lado {
  from { opacity: 0; translate: -20px 8px; scale: .96; }
}
.entrando .puzzle, .entrando .cartao, .entrando .gerais {
  animation: entrar .55s cubic-bezier(.2, .8, .3, 1.15) backwards; animation-delay: calc(var(--i, 0) * 55ms + 80ms);
}
.entrando .moldura, .entrando .legenda, .entrando .ferramentas { animation: entrar-lado .5s ease-out backwards; }
.entrando .intro, .entrando .filtros, .entrando .jogo-cabeca { animation: entrar-lado .45s ease-out backwards; }

.filtros { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 8px; }
.filtro {
  padding: 5px 14px; border: 2px solid var(--ouro-escuro); border-radius: 999px; background: var(--papel);
  font-weight: 700; font-size: .88rem; min-height: 38px;
}
.filtro b { color: var(--acento); margin-left: 3px; }
.filtro.ativo { background: var(--acento); color: var(--acento-texto); border-color: var(--acento); }
.filtro.ativo b { color: inherit; }

/* Dossiê lacrado: envelope de papel pardo com selo de lacre, desenhado só com CSS. Por dentro tem a folha do caso, com a
   fotografia da vítima a espreitar; ao tocar, a aba abre, a folha sobe e o jogo sai de dentro do envelope. */
.puzzle .envelope {
  position: relative; display: block; width: 100%; aspect-ratio: 1; margin-bottom: 4px;
  border: 2px solid var(--tinta); background: linear-gradient(160deg, #c9a46a, #b08848); overflow: hidden;
}
.puzzle.a-abrir .envelope { overflow: visible; }
.puzzle .envelope .folha {
  position: absolute; left: 9%; right: 9%; top: 34%; bottom: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 5px 0; background: var(--papel); border: 1.5px solid var(--tinta); box-shadow: 0 -1px 3px rgba(43, 25, 8, .3);
  transition: transform .55s cubic-bezier(.3, .8, .3, 1) .35s;
}
.puzzle .envelope .folha .foto-vitima { position: relative; width: 62%; aspect-ratio: 1; overflow: hidden; border: 1.5px solid var(--tinta); filter: sepia(.5) saturate(.8); }
.puzzle .envelope .folha .foto-vitima img, .puzzle .envelope .folha .foto-vitima svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.puzzle .envelope .folha .foto-vitima::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--selo); font-size: 2.4rem; line-height: 1; opacity: .8; }
.puzzle .envelope .folha em { font-size: .62rem; font-variant: small-caps; letter-spacing: .1em; color: var(--selo); font-style: normal; font-weight: 700; }
.puzzle .envelope .bolso {
  position: absolute; left: 0; right: 0; bottom: 0; height: 66%; z-index: 2;
  background: linear-gradient(180deg, #c9a46a, #b48c4c); clip-path: polygon(0 0, 50% 46%, 100% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 -1px 1px rgba(43, 25, 8, .45));
}
.puzzle .envelope .aba {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 3; background: linear-gradient(180deg, #d8b67c, #bf9a5c);
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top center; transition: transform .45s ease-in;
  filter: drop-shadow(0 2px 1px rgba(43, 25, 8, .45));
}
.puzzle .envelope .lacre {
  position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; z-index: 4;
  display: grid; place-items: center; font-style: normal; color: #f1d7ae; font-size: 1.5rem;
  background: radial-gradient(circle at 35% 30%, #b8372a, var(--selo) 55%, #5e1109); box-shadow: 0 2px 3px rgba(43, 25, 8, .5);
  transition: opacity .2s, transform .3s;
}
.puzzle.fechado .estado.novo { color: var(--selo); }
.puzzle.fechado strong { font-style: italic; }
.puzzle.a-abrir .envelope .aba { transform: rotateX(180deg); z-index: 0; }
.puzzle.a-abrir .envelope .lacre { opacity: 0; transform: scale(.4) rotate(40deg); }
.puzzle.a-abrir .envelope .folha { transform: translateY(-62%) scale(1.06); z-index: 5; }
.puzzle.a-abrir { animation: abrir .9s ease-in-out; z-index: 6; }
@keyframes abrir { 25% { translate: 0 -6px; scale: 1.05; } 100% { translate: 0 -6px; scale: 1.05; } }

/* o jogo sai de dentro do envelope: sobe e desdobra-se, vindo de baixo e pequeno */
@keyframes sai-da-pasta {
  from { opacity: 0; transform: translateY(46vh) scale(.5) rotate(-3deg); transform-origin: 50% 100%; }
  55% { opacity: 1; }
}
#app.sai-do-envelope { animation: sai-da-pasta .75s cubic-bezier(.2, .85, .3, 1) both; }

/* dossiês já abertos: a fotografia da vítima, com uma cruz, prende-se ao canto da capa como num processo */
.puzzle .capa { position: relative; display: block; margin-bottom: 4px; }
.puzzle .capa .mini { margin-bottom: 0; }
.puzzle .vitima-selo {
  position: absolute; right: -6px; bottom: -8px; width: 34%; aspect-ratio: 1; overflow: hidden; z-index: 2; transform: rotate(4deg);
  border: 2px solid var(--papel); outline: 1.5px solid var(--tinta); box-shadow: 1px 2px 3px rgba(43, 25, 8, .45); background: var(--papel);
}
.puzzle .vitima-selo img, .puzzle .vitima-selo svg { display: block; width: 100%; height: 100%; object-fit: cover; filter: sepia(.35); }
.puzzle .vitima-selo::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--selo); font-size: 1.5rem; line-height: 1; opacity: .85; }

@media (prefers-reduced-motion: reduce) {
  .entrando *, .puzzle.a-abrir, #app.sai-do-envelope { animation: none !important; }
  .puzzle .envelope .aba, .puzzle .envelope .folha { transition: none; }
}

/* ---------- ajudas: dica explicada, glossário, solução passo a passo ---------- */
@keyframes pulsar { 50% { box-shadow: inset 0 0 0 4px var(--ouro), 0 0 10px 2px var(--ouro); } }
.celula.dica-casa { z-index: 3; box-shadow: inset 0 0 0 3px var(--acento), 0 0 8px 2px var(--ouro); animation: pulsar 1.2s ease-in-out infinite; }
.glossario { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.glossario figure { display: flex; gap: 10px; align-items: center; margin: 0; padding: 6px; background: var(--papel-2); border: 1px solid var(--linha); }
.glossario .diagrama { width: 58px; height: 58px; flex: none; }
.glossario figcaption { display: flex; flex-direction: column; font-size: .88rem; line-height: 1.2; }
.passos { padding-left: 1.3em; display: grid; gap: 8px; font-size: .95rem; }
.modal-caixa h3 { margin: 12px 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--acento); }
@media (prefers-reduced-motion: reduce) { .celula.dica-casa { animation: none; } }

/* ---------- montagem do mapa ao abrir o caso (classe .montando posta por animarMontagem) ---------- */
/* a divisão cai inteira (as casas dela partilham o atraso), bate no chão, ressalta e assenta */
@keyframes pop-casa {
  0% { opacity: 0; translate: 0 calc(var(--queda, 300px) * -1); animation-timing-function: cubic-bezier(.45, 0, .8, .5); }
  12% { opacity: 1; }
  62% { opacity: 1; translate: 0 0; animation-timing-function: cubic-bezier(.3, .8, .5, 1); }
  76% { translate: 0 -9px; animation-timing-function: cubic-bezier(.5, 0, .8, .5); }
  88% { translate: 0 0; animation-timing-function: ease-out; }
  94% { translate: 0 -2px; }
  100% { opacity: 1; translate: 0 0; }
}
@keyframes pop-objeto {
  0% { opacity: 0; scale: 0; rotate: var(--rot, 0deg); }
  55% { opacity: 1; scale: 1.12; rotate: calc(var(--rot, 0deg) * -.25); }
  78% { scale: .96; rotate: 0deg; }
  100% { opacity: 1; scale: 1; rotate: 0deg; }
}
@keyframes assentar { 0% { scale: 1; } 40% { scale: 1.012; } 100% { scale: 1; } }
.tabuleiro.montando { animation: assentar .36s ease-out var(--assenta, 1.6s) both; }
.tabuleiro.montando .celula { animation: pop-casa .65s linear var(--d, 0ms) both; }
.tabuleiro.montando .objeto-grande { animation: pop-objeto .42s cubic-bezier(.3, .8, .3, 1.1) var(--d, 0ms) both; }
@media (prefers-reduced-motion: reduce) { .tabuleiro.montando, .tabuleiro.montando .celula, .tabuleiro.montando .objeto-grande { animation: none; } }

/* casas fora da silhueta do mapa: não existem (fundo do papel) */
.vazio-mapa { background: transparent; min-width: 0; min-height: 0; }
.nota-inspetor { font-style: italic; color: var(--suave); font-weight: 400 !important; }

/* janelas e portas: peças desenhadas na aresta da casa, a meio da linha grossa */
.abertura { position: absolute; z-index: 5; pointer-events: none; border: 2px solid var(--tinta); box-sizing: border-box; border-radius: 2px; }
.abertura.norte, .abertura.sul { width: 54%; height: 9px; left: 23%; }
.abertura.norte { top: -5px; } .abertura.sul { bottom: -5px; }
.abertura.oeste, .abertura.este { height: 54%; width: 9px; top: 23%; }
.abertura.oeste { left: -5px; } .abertura.este { right: -5px; }
.abertura.jan { background: linear-gradient(135deg, #cdeaf2, #8fc4d6); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7); }
.abertura.jan::after { content: ""; position: absolute; background: var(--tinta); }
.abertura.jan.norte::after, .abertura.jan.sul::after { left: 50%; top: 0; bottom: 0; width: 1.5px; }
.abertura.jan.oeste::after, .abertura.jan.este::after { top: 50%; left: 0; right: 0; height: 1.5px; }
.abertura.por { background: linear-gradient(135deg, #b07a3c, #7c4f22); }
.abertura.por::after { content: ""; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: var(--ouro-claro); box-shadow: 0 0 0 .5px var(--tinta); right: 15%; top: 50%; translate: 0 -50%; }
/* casas marcadas (regra 'glifos'): um ponto = sozinho na divisão, dois pontos = acompanhado */
.glifo { position: absolute; z-index: 4; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tinta); box-sizing: border-box; background-color: var(--ouro-claro, #f3d98b); pointer-events: none; }
.glifo.sozinho { background-image: radial-gradient(circle at 50% 50%, var(--tinta) 0 2.2px, transparent 2.6px); }
.glifo.acompanhado { background-image: radial-gradient(circle at 28% 50%, var(--tinta) 0 1.8px, transparent 2.2px), radial-gradient(circle at 72% 50%, var(--tinta) 0 1.8px, transparent 2.2px); }
.glifo.tarefa { background-image: linear-gradient(var(--tinta), var(--tinta)), linear-gradient(var(--tinta), var(--tinta)); background-size: 2.4px 8px, 8px 2.4px; background-position: center; background-repeat: no-repeat; border-radius: 3px; transform: rotate(45deg); }
.glifo.leg { position: static; display: inline-block; flex: none; }
.abertura.por.oeste::after, .abertura.por.este::after { right: auto; top: 15%; left: 50%; translate: -50% 0; }

/* etiquetas perto do limite direito do mapa: crescem para a esquerda, para não ficarem cortadas */
.rotulo.dir { left: auto; right: 2px; }

/* ---------- menu: atalhos, pastas por nível, tutorial ---------- */
.atalhos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 4px auto 14px; max-width: 640px; }
.btn.atalho { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 14px; text-align: center; }
.btn.atalho small { font-weight: 400; font-size: .78rem; opacity: .85; letter-spacing: 0; text-transform: none; }
.btn.atalho.dia { border-color: var(--ouro-escuro); }
details.nivel > summary { list-style: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
details.nivel > summary::-webkit-details-marker { display: none; }
details.nivel > summary h2::before { content: "▸"; color: var(--ouro-escuro); font-size: 1.1rem; transition: transform .2s; order: -1; }
details.nivel[open] > summary h2::before { transform: rotate(90deg); }
.nivel h2 .contagem { font-size: .8rem; font-weight: 700; color: var(--suave); font-style: italic; letter-spacing: .06em; }
.nivel h2 { flex-wrap: nowrap; }
.tutorial { display: flex; gap: 14px; align-items: center; margin: 6px 0 8px; }
.tutorial .diagrama { width: 96px; height: 96px; flex: none; }
.tutorial h2 { margin: 0 0 4px; font-size: 1.1rem; }
.tutorial p { margin: 0; }
.passo-tut { margin: 0 0 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .14em; color: var(--acento); font-weight: 700; }
.tutorial h2 { text-align: left; }
.tutorial h2::after { content: none; }

/* casos resolvidos: pastilhas reduzidas, a cinzento-sépia, com o carimbo «Resolvido» atravessado sobre o mapa */
.lista.compacta { grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 14px 10px; margin-top: 16px; }
.lista + .lista.compacta { padding-top: 4px; border-top: 1px dashed color-mix(in srgb, var(--ouro-escuro) 55%, transparent); }
.puzzle.feito { border-width: 8px; border-image-width: 8px; padding: 2px 2px 4px; gap: 2px; }
.puzzle.feito .capa { position: relative; display: block; }
.puzzle.feito .mini { filter: sepia(.45) saturate(.6) brightness(.97); opacity: .85; margin-bottom: 2px; }
.puzzle.feito strong { font-size: .76rem; line-height: 1.1; }
.puzzle.feito .estado { font-size: .72rem; letter-spacing: .02em; }
.puzzle.feito::before { top: -16px; width: 40px; height: 12px; }
.carimbo-grande {
  position: absolute; left: 50%; top: 50%; z-index: 3; translate: -50% -50%; rotate: -16deg; white-space: nowrap;
  padding: 1px 7px; border: 2.5px double var(--selo); border-radius: 4px; color: var(--selo);
  background: color-mix(in srgb, var(--papel) 72%, transparent); font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  font-size: .68rem; line-height: 1.3; box-shadow: 0 0 0 1px color-mix(in srgb, var(--papel) 60%, transparent);
}

/* toque demorado: sem seleção de texto nem menu de contexto do browser em cima das casas */
.celula { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* objetos de várias casas: uma imagem esticada por cima das casas (itens da grelha), abaixo das pessoas, dos X e das notas */
.objeto-grande { position: relative; z-index: 2; width: 100%; height: 100%; padding: 3%; box-sizing: border-box; object-fit: fill; pointer-events: none; user-select: none; -webkit-user-drag: none; align-self: stretch; justify-self: stretch; }
.objeto-grande.obst { filter: drop-shadow(1px 2px 1px rgba(43, 25, 8, .5)); }
.xis { z-index: 3; }
/* linhas e colunas com tamanho fixo e igual: as imagens dos objetos grandes não podem puxar pelas linhas da grelha */
.tabuleiro { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: repeat(var(--n), minmax(0, 1fr)); }
.objeto-grande { min-width: 0; min-height: 0; }

/* ---------- legenda dos objetos («podem / não podem ser ocupados») ---------- */
.tipos-obj { max-width: 600px; margin: 14px auto 0; }
.tipos-obj > summary { cursor: pointer; font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; color: var(--suave); list-style: none; text-align: center; }
.tipos-obj > summary::-webkit-details-marker { display: none; }
.tipos-obj > summary::after { content: " ▾"; }
.tipos-obj:not([open]) > summary::after { content: " ▸"; }
.tipos-grupo { margin-top: 8px; padding: 6px 10px 8px; border-radius: 14px; }
.tipos-grupo.pode { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.tipos-grupo.nao { background: color-mix(in srgb, var(--selo) 13%, transparent); }
.tipos-grupo.aber { background: color-mix(in srgb, #5aa6c8 16%, transparent); }
.tipos-grupo h4 { margin: 0 0 4px; font-size: .95rem; text-align: center; }
.tipos-grupo ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
.tipos-grupo li { display: flex; flex-direction: column; align-items: center; width: 62px; text-align: center; font-size: .72rem; line-height: 1.1; }
.ico-leg { width: 38px; height: 38px; object-fit: contain; display: block; }
.ico-jan { display: block; width: 14px; height: 36px; border: 2px solid var(--tinta); border-radius: 4px; background: linear-gradient(135deg, #cdeaf2, #8fc4d6); }

/* ---------- acertos de pormenor ---------- */
/* paredes das divisões: 3 px num tom escuro mas suave (--parede-fina), por cima da cor das arestas interiores */
.celula.pt { border-top: 3px solid var(--parede-fina) !important; } .celula.pr { border-right: 3px solid var(--parede-fina) !important; }
.celula.pb { border-bottom: 3px solid var(--parede-fina) !important; } .celula.pl { border-left: 3px solid var(--parede-fina) !important; }
:root { --parede-fina: color-mix(in srgb, var(--parede) 62%, #8a8478); }
:root[data-tema="escuro"] { --parede-fina: #04060a; }
@media (prefers-color-scheme: dark) { :root:not([data-tema="claro"]) { --parede-fina: #04060a; } }
/* fotografia da vítima no canto do envelope fechado (a folha só se vê quando a aba abre) */
.puzzle .envelope > .vitima-selo { right: 8px; bottom: 8px; width: 36%; z-index: 5; transform: rotate(5deg); transition: opacity .2s; }
.puzzle.a-abrir .envelope > .vitima-selo { opacity: 0; }
/* cartão selecionado: aro mais forte */
.cartao.sel { box-shadow: 0 0 0 4px var(--ouro), 0 0 0 7px color-mix(in srgb, var(--ouro) 30%, transparent), var(--sombra) !important; }

/* casas de tarefa (regra 'tarefas'): letra da tarefa no canto superior esquerdo */
.marca-tarefa { position: absolute; z-index: 4; top: 3px; left: 3px; min-width: 16px; height: 16px; padding: 0 2px; box-sizing: border-box; border-radius: 4px; border: 2px solid var(--tinta); background: #f0e4c4; color: var(--tinta); font: 700 10px/12px system-ui, sans-serif; font-style: normal; text-align: center; pointer-events: none; }

/* Relevo "de livro" (MURDOKU): a planta pousa no papel com uma faixa plana e mais escura do tom do papel, deslocada
   para baixo e para a direita; cada objeto assenta numa mancha de chão (elipse escura achatada) e não tem sombra
   projetada nem desfocada; as paredes ficam lisas. Só visual. */
.rolagem { filter: drop-shadow(7px 9px 0 rgba(138, 106, 40, .4)); border-radius: 0; }   /* drop-shadow segue a silhueta (mapas não retangulares) */
.celula.ob::after { content: ""; position: absolute; z-index: 0; left: 12%; right: 12%; bottom: 4%; height: 15%; border-radius: 50%; background: rgba(60, 38, 14, .42); pointer-events: none; }
.icone.obst { z-index: 1; filter: none; }
.icone.sup { filter: saturate(.95); }
.ficha { box-shadow: 2px 3px 0 rgba(43, 25, 8, .4), inset 0 0 0 1px var(--tinta); }
.ficha.sel { box-shadow: 0 0 0 3px var(--papel), 0 0 0 6px var(--ouro), 2px 3px 0 rgba(43, 25, 8, .3); }
.celula.dica-casa { box-shadow: inset 0 0 0 3px var(--acento), 0 0 8px 2px var(--ouro); }
/* Sombra dos edifícios sobre o exterior: faixa plana (cerca de 14 % da casa) do lado que encosta ao interior. */
.celula { --se-t: 0px; --se-r: 0px; --se-b: 0px; --se-l: 0px; --se: calc(16cqw / var(--n)); }
.celula.se-t, .celula.se-r, .celula.se-b, .celula.se-l {
  box-shadow: inset 0 var(--se-t) 0 rgba(20, 45, 10, .36), inset calc(-1 * var(--se-r)) 0 0 rgba(20, 45, 10, .36),
              inset 0 calc(-1 * var(--se-b)) 0 rgba(20, 45, 10, .36), inset var(--se-l) 0 0 rgba(20, 45, 10, .36);
}
.celula.se-t { --se-t: var(--se); } .celula.se-r { --se-r: var(--se); } .celula.se-b { --se-b: var(--se); } .celula.se-l { --se-l: var(--se); }
.celula.dica-casa.se-t, .celula.dica-casa.se-r, .celula.dica-casa.se-b, .celula.dica-casa.se-l { box-shadow: inset 0 0 0 3px var(--acento), 0 0 8px 2px var(--ouro); }

/* Variantes de piso: divisões com o mesmo material (várias de madeira, por exemplo) ficam distinguíveis por tom e por motivo.
   v0 = base; v1 = mais claro, com a textura virada de lado; v2 = mais escuro, com pontos ou losangos por cima. */
.celula.v1, .legenda i.v1 { background-color: color-mix(in srgb, var(--cs) 30%, color-mix(in srgb, var(--cp, var(--cs)) 82%, #fff)); }
.celula.v2, .legenda i.v2 { background-color: color-mix(in srgb, var(--cs) 30%, color-mix(in srgb, var(--cp, var(--cs)) 80%, #3a1c00)); }
.celula.v1::before { transform: rotate(90deg); }
.celula.v2 { background-image: radial-gradient(circle at 50% 50%, rgba(43, 25, 8, .16) 0 9%, transparent 10%), radial-gradient(circle at 0 0, rgba(43, 25, 8, .12) 0 7%, transparent 8%); background-size: 50% 50%; }
.celula.v2:hover, .celula.v1:hover { filter: brightness(1.07); }

/* cruzes azuis postas pelo jogador (botão «Cruz azul») */
.xis.azul { color: #2563c9; opacity: .9; z-index: 4; }
:root[data-tema="escuro"] .xis.azul { color: #6aa5ff; }
.btn .ico.cruz-ico { color: #2563c9 !important; font-weight: 800; font-size: 1.2em; line-height: 1; }
#b-cruz.btn[aria-pressed="true"] { background: #2563c9 !important; color: #fff !important; box-shadow: 0 4px 12px rgba(37,99,201,.35) !important; }
#b-cruz.btn[aria-pressed="true"] .ico.cruz-ico { color: #fff !important; }

/* o desenho do aparador (1 casa) tem uns 13% de espaço vazio em baixo: desce-se para assentar na sua sombra */
.celula .icone.obst[src*="aparador"] { translate: 0 13.5%; }

/* Aviso dos resultados anónimos, no fim da lista de casos */
.aviso-dados { margin: 28px auto 8px; max-width: 46ch; text-align: center; font-size: .8rem; color: var(--suave); line-height: 1.45; }
.aviso-dados button { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
