/* Maha Lilah — o tabuleiro da selva
   Design system: madeira escura entalhada, pergaminho com letreiro vermelho e
   preto, trilha de osso, folhas verdes sobre ocre, cristal verde com aro de
   bronze. Tokens abaixo; cada um tem consumidor nesta folha. */

:root {
  --night: #070d08;
  --night-2: #10200f;
  --wood-dark: #1e1108;
  --wood: #3b2412;
  --wood-light: #6b4526;
  --brass: #c8963e;
  --brass-light: #f0cf8a;
  --parchment: #ebe0c3;
  --ink: #21170d;
  --ink-soft: #4a3a26;
  --lacquer: #9a1f17;
  --lacquer-dark: #5e120d;
  --glow-green: #9dffa6;
  --glass: #06200e;
  --gold: #ffd76a;
  --focus: #ffd76a;
  --flap-w: clamp(250px, 21vw, 330px);
  --read-w: clamp(270px, 24vw, 370px);
  --frame: clamp(12px, 1.6vw, 22px);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.005 0.13' numOctaves='4' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 0.09 0 0 0 0 0.05 0 0 0 0 0.02 0 0 0 1.25 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --chip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='15'%3E%3Cpath d='M11 1 L21 7.5 L11 14 L1 7.5Z' fill='%23231307'/%3E%3Cpath d='M11 1 L21 7.5 L11 7.5Z' fill='%23704a28'/%3E%3Cpath d='M1 7.5 L11 1 L11 7.5Z' fill='%238f6136'/%3E%3Cpath d='M1 7.5 L11 14 L11 7.5Z' fill='%233a200d'/%3E%3Cpath d='M21 7.5 L11 14 L11 7.5Z' fill='%23170b04'/%3E%3C/svg%3E");
  --paper-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0.33 0 0 0 0 0.24 0 0 0 0 0.12 0 0 0 0.22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
  --carved-leaves: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='96' viewBox='0 0 120 96'%3E%3Cg fill='%23160b04' stroke='%23835a30' stroke-width='1.2' stroke-opacity='.55'%3E%3Cpath d='M4 20 C16 6 38 6 50 18 C38 30 16 32 4 20Z'/%3E%3Cpath d='M62 10 C76 -2 98 2 108 14 C96 26 74 24 62 10Z'/%3E%3Cpath d='M30 52 C44 38 66 40 76 52 C64 66 42 66 30 52Z'/%3E%3Cpath d='M84 58 C96 46 116 48 124 60 C112 72 94 70 84 58Z'/%3E%3Cpath d='M-4 70 C8 58 26 60 34 72 C24 84 6 82 -4 70Z'/%3E%3Cpath d='M44 84 C56 72 78 74 88 86 C76 98 54 96 44 84Z'/%3E%3C/g%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.45' stroke-width='1'%3E%3Cpath d='M8 20 H46 M66 12 H104 M34 52 H72 M88 58 H120 M0 70 H30 M48 85 H84'/%3E%3C/g%3E%3C/svg%3E");
  --jungle-leaves: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='%23132614' stroke='%23050a05' stroke-width='3'%3E%3Cpath d='M-20 60 C40 -10 150 0 200 60 C140 120 40 120 -20 60Z' transform='rotate(-24 90 60)'/%3E%3Cpath d='M230 30 C290 -30 400 -20 450 40 C390 100 290 100 230 30Z' transform='rotate(18 340 30)'/%3E%3Cpath d='M100 230 C160 170 270 180 320 240 C260 300 160 300 100 230Z' transform='rotate(-8 210 235)'/%3E%3Cpath d='M-40 330 C20 270 130 280 180 340 C120 400 20 400 -40 330Z' transform='rotate(30 70 335)'/%3E%3Cpath d='M260 350 C320 290 430 300 480 360 C420 420 320 420 260 350Z' transform='rotate(-30 370 355)'/%3E%3C/g%3E%3Cg fill='none' stroke='%23050a05' stroke-width='2'%3E%3Cpath d='M-10 60 H190' transform='rotate(-24 90 60)'/%3E%3Cpath d='M240 30 H440' transform='rotate(18 340 30)'/%3E%3Cpath d='M110 232 H310' transform='rotate(-8 210 235)'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--parchment);
  font-family: "Alegreya", Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(120% 90% at 50% 45%, #1a3319 0%, #0d1a0d 45%, var(--night) 100%);
  overflow-x: hidden;
}

.jungle {
  position: fixed;
  inset: -40px;
  pointer-events: none;
  background-image: var(--jungle-leaves), var(--jungle-leaves);
  background-size: 520px 520px, 760px 760px;
  background-position: 0 0, 230px 180px;
  opacity: 0.55;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, #000 100%);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, #000 100%);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ layout */

.app {
  position: relative;
  overflow-x: clip;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.case {
  --board-h: min(calc(100dvh - 32px), 1180px);
  display: grid;
  grid-template-columns: var(--flap-w) auto var(--read-w);
  align-items: stretch;
  grid-template-rows: minmax(0, 1fr);
  gap: 6px;
  perspective: 2400px;
  height: var(--board-h);
}

.board-frame {
  position: relative;
  height: 100%;
  aspect-ratio: calc(1000 + 2 * 22) / calc(1240 + 2 * 22);
  padding: var(--frame);
  border-radius: 10px;
  background:
    var(--chip) 0 0 / 22px 15px repeat,
    var(--wood-dark);
  box-shadow:
    0 0 0 3px #0d0703,
    0 0 0 6px #4a2c14,
    0 30px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 0 2px rgba(240, 207, 138, 0.12);
  z-index: 2;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 0 3px #120a04, 0 0 0 2px #7a5430;
  background: #b58530;
  container-type: inline-size;
}

.board-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  will-change: transform;
}

.tile-number {
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-size: 30px;
  fill: #3a2614;
  paint-order: stroke;
  stroke: #f4ead0;
  stroke-width: 2px;
  pointer-events: none;
}

.hotspot {
  fill: transparent;
  cursor: help;
  transition: fill 120ms;
}
.hotspot:hover { fill: rgba(255, 215, 106, 0.22); }

.tile-highlight {
  fill: var(--gold);
  opacity: 0.5;
  pointer-events: none;
  animation: tile-pulse 1.6s ease-in-out infinite;
}
.tile-highlight.is-serpent { fill: #9dffa6; }

@keyframes tile-pulse {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 0.6; }
}

.pawn .turn-ring {
  fill: none;
  stroke: transparent;
  stroke-width: 3.5;
}
.pawn.is-active .turn-ring {
  stroke: var(--gold);
  animation: ring-pulse 1.3s ease-in-out infinite;
}
.pawn.is-unborn { opacity: 0.78; }

@keyframes ring-pulse {
  0%, 100% { stroke-opacity: 0.35; }
  50% { stroke-opacity: 1; }
}

.crystal-mist {
  animation: mist 22s linear infinite;
}
@keyframes mist {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------- abas laterais */

.flap {
  position: relative;
  height: 100%;
  min-height: 0;
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--chip) 0 0 / 22px 15px repeat, var(--wood-dark);
  box-shadow: 0 0 0 3px #0d0703, 0 0 0 5px #4a2c14, 0 24px 50px rgba(0, 0, 0, 0.6);
  transition: transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 500ms;
  z-index: 1;
}
.flap-left { transform-origin: right center; }
.flap-right { transform-origin: left center; }

.flap-inner {
  height: 100%;
  overflow: auto;
  border-radius: 4px;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #a88f60 transparent;
}

.parchment {
  color: var(--ink);
  background:
    var(--paper-noise),
    radial-gradient(130% 100% at 50% 35%, #f2e9d0 0%, #e7d9b4 55%, #cdb483 100%);
  box-shadow: inset 0 0 30px rgba(92, 60, 20, 0.35), inset 0 0 0 2px rgba(58, 36, 14, 0.35);
}

.flap-head { text-align: center; }

.game-title {
  margin: 0;
  font-family: "Rye", "Georgia", serif;
  font-weight: 400;
  font-size: clamp(30px, 2.6vw, 42px);
  line-height: 1;
  color: var(--lacquer);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.game-sub {
  margin: 4px 0 0;
  font-family: "Oswald", sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--ink-soft);
}

.rule-title {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.rule-title::before,
.rule-title::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink) 20%, var(--ink) 80%, transparent);
  opacity: 0.55;
}

/* jogadores */
.roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.roster li {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.18);
  transition: border-color 200ms, background 200ms;
}
.roster li.is-turn {
  border-color: var(--lacquer);
  background: rgba(255, 244, 205, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 215, 106, 0.5);
}
.roster .pawn-portrait { width: 40px; height: 49px; }
.roster .who {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 15px;
  line-height: 1.1;
}
.roster .where {
  font-size: 14px;
  line-height: 1.2;
  color: var(--ink-soft);
}

/* dado */
.tray {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(58, 36, 14, 0.12);
  box-shadow: inset 0 2px 8px rgba(58, 36, 14, 0.25);
}
.tray-actions { display: grid; gap: 6px; }
.turn-hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  color: var(--ink-soft);
}

.die {
  width: 84px;
  height: 84px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  background:
    radial-gradient(circle at 30% 25%, #fffaf0 0%, #eee2c3 45%, #cbb88b 100%);
  box-shadow:
    inset -4px -6px 10px rgba(92, 70, 30, 0.45),
    inset 3px 3px 6px rgba(255, 255, 255, 0.8),
    0 6px 0 #8f7a50,
    0 10px 16px rgba(0, 0, 0, 0.45);
  transition: transform 120ms;
}
.die:hover { transform: translateY(-2px) rotate(-2deg); }
.die:active { transform: translateY(2px); }
.die-face {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}
.die-face i {
  position: absolute;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3a2a1a, #0c0703 70%);
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.6);
}
.die.is-rolling { animation: die-tumble 90ms linear infinite; }
.die.is-landing { animation: die-land 320ms cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes die-tumble {
  0% { transform: rotate(0deg) translateY(-6px) scale(0.96); }
  50% { transform: rotate(18deg) translateY(4px) scale(1.04); }
  100% { transform: rotate(-12deg) translateY(-6px) scale(0.96); }
}
@keyframes die-land {
  0% { transform: scale(1.25, 0.8) translateY(6px); }
  60% { transform: scale(0.94, 1.08); }
  100% { transform: scale(1); }
}

/* botões */
.btn {
  appearance: none;
  border: 2px solid #a8782e;
  border-radius: 7px;
  padding: 9px 14px;
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass-light);
  background: var(--grain), linear-gradient(180deg, #5a371b, #2a170a);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.25), 0 3px 0 #140b04, 0 6px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 100ms, filter 150ms, box-shadow 150ms;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.25), 0 1px 0 #140b04; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-roll {
  font-size: 17px;
  padding: 11px 16px;
  color: #fff3d0;
  border-color: var(--brass);
  background: var(--grain), linear-gradient(180deg, #b52a20, var(--lacquer-dark));
}
.btn-small { font-size: 13px; padding: 6px 10px; }
.btn[aria-pressed="false"].toggle-off,
#btn-sound[aria-pressed="false"] { opacity: 0.7; text-decoration: line-through; }
#btn-speed[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--gold), 0 3px 0 #140b04; }

.tools {
  margin-top: auto;
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

/* trilha */
.trail-wrap { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.trail {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 60px;
  font-size: 14px;
  line-height: 1.3;
  scrollbar-width: thin;
}
.trail li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(58, 36, 14, 0.25);
}
.trail .d {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #f7efd9;
  border: 1px solid #8f7a50;
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 13px;
}
.trail .serpent { color: #2f5a17; font-weight: 700; }
.trail .arrow { color: #8a5a0a; font-weight: 700; }

.intention {
  margin: 0;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  border-left: 3px solid var(--lacquer);
  padding-left: 8px;
}

/* ---------------------------------------------------------------- leitura */

.reading { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.reading > * { min-width: 0; }
.reading .kicker {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.reading .gem {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #2a1a0a;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.45);
  flex: none;
}
.reading h2 {
  margin: 0;
  font-family: "Rye", serif;
  font-weight: 400;
  font-size: clamp(21px, 1.75vw, 30px);
  overflow-wrap: anywhere;
  hyphens: auto;
  line-height: 1.05;
  color: var(--lacquer);
  text-transform: uppercase;
}
.reading .num {
  display: block;
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.12em;
  color: var(--ink);
}
.reading .sanskrit {
  margin: -4px 0 0;
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
}
.reading .keywords {
  margin: 0;
  font-family: "Oswald", sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 14px;
}
.reading .link {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.3;
}
.reading .link.is-serpent { background: rgba(47, 90, 23, 0.14); border-left: 4px solid #2f5a17; }
.reading .link.is-arrow { background: rgba(200, 150, 62, 0.18); border-left: 4px solid #a8782e; }
.reading .link strong { font-family: "Oswald", sans-serif; letter-spacing: 0.06em; text-transform: uppercase; font-size: 13px; }
.reading .link q { font-style: italic; }
.reading .from { margin: 0; font-size: 14px; color: var(--ink-soft); }
.reading .desc { margin: 0; font-size: 16px; line-height: 1.45; }
.reading .question {
  margin: 0;
  padding: 10px 12px;
  border: 2px solid rgba(154, 31, 23, 0.4);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.35;
  font-style: italic;
  background: rgba(255, 250, 235, 0.55);
}
.reading .question b {
  display: block;
  font-style: normal;
  font-family: "Oswald", sans-serif;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lacquer);
}
.reading .empty {
  margin: auto 0;
  text-align: center;
}
.reading .empty h2 { font-size: clamp(24px, 2.1vw, 34px); }
.reading .empty p { font-size: 16px; line-height: 1.45; }
.reading .rules-list {
  margin: 0;
  padding-left: 18px;
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
}
.reading .rules-list li { margin-bottom: 4px; }

/* ----------------------------------------------------------------- cristal */

.lens {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0.41);
  opacity: 0;
  pointer-events: none;
  transition: transform 420ms cubic-bezier(0.2, 0.9, 0.25, 1.1), opacity 320ms;
  z-index: 3;
}
.lens.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}
.lens-glass {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 13%;
  background:
    radial-gradient(circle at 38% 30%, rgba(160, 255, 170, 0.22) 0%, transparent 32%),
    radial-gradient(circle at 50% 55%, #174d22 0%, #07260f 45%, #020c05 80%);
  box-shadow:
    0 0 0 7px #2a1706,
    0 0 0 13px #b88a44,
    0 0 0 16px #3d240b,
    0 20px 50px rgba(0, 0, 0, 0.75),
    inset 0 0 50px rgba(0, 0, 0, 0.9),
    0 0 60px rgba(125, 255, 138, 0.35);
}
.lens-text {
  text-align: center;
  color: var(--glow-green);
  text-shadow: 0 0 6px rgba(125, 255, 138, 0.85), 0 0 18px rgba(125, 255, 138, 0.45);
  font-size: clamp(14px, 3.2cqi, 24px);
  line-height: 1.25;
}
.lens-text .l-kicker {
  display: block;
  font-family: "Oswald", sans-serif;
  font-weight: 500;
  letter-spacing: 0.2em;
  font-size: 0.72em;
  text-transform: uppercase;
  opacity: 0.85;
}
.lens-text .l-title {
  display: block;
  margin: 0.15em 0;
  font-family: "Rye", serif;
  font-size: 1.45em;
  line-height: 1.02;
  text-transform: uppercase;
}
.lens-text .l-sub { display: block; font-style: italic; opacity: 0.9; }
.lens-text .l-line { display: block; margin-top: 0.45em; font-style: italic; }
.lens-text .l-big {
  display: block;
  font-family: "Rye", serif;
  font-size: 3.4em;
  line-height: 1;
}
.lens.is-open .lens-text > * {
  animation: emerge 900ms ease-out both;
}
.lens.is-open .lens-text > *:nth-child(2) { animation-delay: 120ms; }
.lens.is-open .lens-text > *:nth-child(3) { animation-delay: 240ms; }
.lens.is-open .lens-text > *:nth-child(4) { animation-delay: 360ms; }
.lens.is-open .lens-text > *:nth-child(5) { animation-delay: 480ms; }
@keyframes emerge {
  from { opacity: 0; filter: blur(8px); transform: scale(0.9); }
  to { opacity: 1; filter: blur(0); transform: none; }
}

.tooltip {
  position: absolute;
  z-index: 4;
  max-width: 230px;
  padding: 8px 10px;
  border-radius: 6px;
  pointer-events: none;
  color: var(--ink);
  background: var(--paper-noise), #efe5ca;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(58, 36, 14, 0.35);
  font-size: 14px;
  line-height: 1.25;
}
.tooltip b {
  font-family: "Oswald", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.tooltip i { color: var(--ink-soft); }
.tooltip .t-link { display: block; margin-top: 3px; font-weight: 700; }

/* ------------------------------------------------------------------ tampa */

.lid {
  position: absolute;
  inset: 0;
  z-index: 5;
  perspective: 1800px;
  pointer-events: none;
}
.door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transition: transform 1500ms cubic-bezier(0.55, 0.05, 0.25, 1), opacity 500ms 1100ms;
  transform-style: preserve-3d;
}
.door-left { left: 0; transform-origin: left center; }
.door-right { right: 0; transform-origin: right center; }
.door-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--grain), linear-gradient(90deg, #3a2211, #2a170a 60%, #3a2211);
  box-shadow: inset 0 0 0 var(--frame) transparent, inset 0 0 40px rgba(0, 0, 0, 0.6);
  display: grid;
  align-items: center;
}
.door-left .door-face { border-radius: 10px 0 0 10px; justify-items: end; box-shadow: inset -3px 0 0 #120a04, inset 0 0 40px rgba(0, 0, 0, 0.6); }
.door-right .door-face { border-radius: 0 10px 10px 0; justify-items: start; box-shadow: inset 3px 0 0 #120a04, inset 0 0 40px rgba(0, 0, 0, 0.6); }
.door-face::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--chip) 0 0 / 22px 15px repeat;
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: var(--frame);
}
.door-carve {
  position: absolute;
  inset: calc(var(--frame) + 14px);
  border-radius: 6px;
  overflow: hidden;
  background: #24140a;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 220, 160, 0.15);
}
.door-carve svg { display: block; width: 100%; height: 100%; }
.door-word {
  text-shadow: none;
}
.door-plaque {
  position: relative;
  z-index: 1;
  padding: 0.1em 0.2em;
  border-radius: 8px;
  background: radial-gradient(ellipse at center, rgba(20, 10, 3, 0.85) 30%, rgba(20, 10, 3, 0) 72%);
}
.door-word {
  position: relative;
  z-index: 1;
  padding: 0.25em 0.35em;
  font-family: "Rye", serif;
  font-size: clamp(34px, 9cqi, 96px);
  color: #140a03;
  text-transform: uppercase;
  line-height: 1;
  background: linear-gradient(180deg, #d4b577, #a17f43);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.85)) drop-shadow(0 -1px 0 rgba(255, 230, 170, 0.25));
}
.lid { container-type: inline-size; }
.latch {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 64px;
  transform: translate(-50%, -50%);
  border-radius: 6px;
  background: linear-gradient(90deg, #7a5222, #e6bf72 45%, #8a5a22);
  box-shadow: 0 0 0 3px #2a1706, 0 6px 12px rgba(0, 0, 0, 0.6);
  transition: opacity 300ms, transform 500ms;
}
.latch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #2a1706;
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.8);
}

/* título */
.title-panel {
  position: absolute;
  left: 50%;
  bottom: 7vh;
  transform: translateX(-50%);
  z-index: 6;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  width: min(92vw, 520px);
  transition: opacity 500ms, transform 500ms;
}
.tagline {
  margin: 0;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: clamp(16px, 1.6vw, 20px);
  font-style: italic;
  color: #f3e3b5;
  background: rgba(12, 7, 3, 0.72);
  box-shadow: 0 0 0 2px rgba(200, 150, 62, 0.4);
}
.title-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.load-status { margin: 0; font-size: 14px; color: #d8c79a; min-height: 1.2em; }
.load-status.is-error { color: #ffb0a0; }

/* estados de tela */
.app[data-screen="title"] .flap { opacity: 0; pointer-events: none; }
.app[data-screen="title"] .flap-left { transform: rotateY(-88deg); }
.app[data-screen="title"] .flap-right { transform: rotateY(88deg); }
.app:not([data-screen="title"]) .flap { transition-delay: 700ms; }
.app:not([data-screen="title"]) .title-panel { opacity: 0; pointer-events: none; transform: translate(-50%, 20px); }
.app:not([data-screen="title"]) .door-left { transform: rotateY(-104deg); opacity: 0; }
.app:not([data-screen="title"]) .door-right { transform: rotateY(104deg); opacity: 0; }
.app:not([data-screen="title"]) .latch { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
.app[data-screen="title"] .lid { pointer-events: auto; }
.app.is-opened .lid { display: none; }

.app[data-busy="true"] #roll { filter: saturate(0.6) brightness(0.9); }

/* ---------------------------------------------------------------- diálogos */

dialog.sheet {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 0 0 4px #2a1706, 0 0 0 7px #a8782e, 0 30px 80px rgba(0, 0, 0, 0.8);
}
dialog.sheet-wide { width: min(760px, calc(100vw - 24px)); }
dialog.sheet form { padding: 22px 24px 20px; display: grid; gap: 14px; }
dialog::backdrop { background: rgba(3, 7, 4, 0.72); backdrop-filter: blur(3px); }
dialog[open] { animation: sheet-in 380ms cubic-bezier(0.2, 0.9, 0.25, 1.1); }
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.sheet-title {
  margin: 0;
  font-family: "Rye", serif;
  font-weight: 400;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.05;
  color: var(--lacquer);
  text-transform: uppercase;
  text-align: center;
}
.sheet-lead { margin: 0; text-align: center; font-size: 17px; line-height: 1.4; }
.sheet-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sheet-actions.stack { flex-direction: column; align-items: stretch; }
.rule-note { margin: 0; font-size: 15px; line-height: 1.4; text-align: center; color: var(--ink-soft); }
.keys { margin: 0; font-size: 13px; text-align: center; color: var(--ink-soft); }
kbd {
  font-family: "Oswald", sans-serif;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #8f7a50;
  background: #f7efd9;
}

.idol-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.idol {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: start;
}
.idol-btn {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 100%;
  padding: 8px 4px 6px;
  border-radius: 8px;
  border: 2px dashed rgba(58, 36, 14, 0.4);
  background: rgba(255, 255, 255, 0.2);
  color: var(--ink);
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 150ms, background 150ms, border-color 150ms;
}
.idol-btn small { font-family: "Alegreya", serif; font-weight: 400; font-style: italic; text-transform: none; letter-spacing: 0; color: var(--ink-soft); }
.idol-btn[aria-pressed="true"] {
  opacity: 1;
  border-style: solid;
  border-color: var(--lacquer);
  background: rgba(255, 246, 215, 0.85);
  box-shadow: 0 0 0 3px rgba(255, 215, 106, 0.45);
}
.idol-btn .pawn-portrait { width: 52px; height: 64px; }
.idol input {
  width: 100%;
  padding: 5px 6px;
  border-radius: 5px;
  border: 1px solid #8f7a50;
  background: #fbf6e7;
  font: inherit;
  font-size: 14px;
  text-align: center;
}
.idol input:disabled { visibility: hidden; }

.field { display: grid; gap: 4px; font-family: "Oswald", sans-serif; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.field textarea {
  font: inherit;
  font-family: "Alegreya", serif;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #8f7a50;
  background: #fbf6e7;
  resize: vertical;
}

.full h2 { margin: 0; font-family: "Rye", serif; font-weight: 400; font-size: clamp(26px, 4vw, 38px); color: var(--lacquer); text-transform: uppercase; line-height: 1.05; }
.full .meta { margin: 2px 0 0; font-family: "Oswald", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; color: var(--ink-soft); }
.full p { font-size: 17px; line-height: 1.5; margin: 10px 0; }
.full h3 { margin: 14px 0 4px; font-family: "Oswald", sans-serif; letter-spacing: 0.14em; text-transform: uppercase; font-size: 14px; color: var(--lacquer); }
.full ul { margin: 0; padding-left: 20px; font-size: 16px; line-height: 1.45; }
.full .link { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: rgba(58, 36, 14, 0.08); }
.full .link dl { margin: 6px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; font-size: 15px; }
.full .link dt { font-weight: 700; }
.full .link dd { margin: 0; }

.victory-head { text-align: center; }
.victory-head .crown { font-family: "Oswald", sans-serif; letter-spacing: 0.2em; text-transform: uppercase; font-size: 13px; color: var(--ink-soft); }
.victory-head h2 { margin: 4px 0; font-family: "Rye", serif; font-weight: 400; font-size: clamp(28px, 5vw, 44px); color: var(--lacquer); text-transform: uppercase; line-height: 1; }
.victory-head p { margin: 4px 0 0; font-size: 18px; }
.journeys { display: grid; gap: 10px; margin-top: 8px; }
.journey { padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.25); box-shadow: inset 0 0 0 1px rgba(58, 36, 14, 0.25); }
.journey.is-winner { background: rgba(255, 246, 215, 0.85); box-shadow: inset 0 0 0 2px var(--lacquer); }
.journey header { display: flex; align-items: center; gap: 8px; }
.journey header .pawn-portrait { width: 34px; height: 42px; }
.journey header b { font-family: "Oswald", sans-serif; letter-spacing: 0.06em; text-transform: uppercase; }
.journey .stats { font-size: 15px; color: var(--ink-soft); }
.path-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.path-chips span {
  font-family: "Oswald", sans-serif;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f7efd9;
  border: 1px solid #b8a276;
}
.path-chips .s { background: #dbe8cf; border-color: #2f5a17; }
.path-chips .a { background: #f6e3b0; border-color: #a8782e; }
.integration {
  margin: 6px 0 0;
  text-align: center;
  font-style: italic;
  font-size: 18px;
}

/* ------------------------------------------------------------- responsivo */

@media (max-width: 1100px), (max-aspect-ratio: 5/4) {
  .app { display: block; padding: 10px 10px 0; }
  .case {
    display: flex;
    flex-direction: column;
    height: auto;
    gap: 14px;
    perspective: none;
  }
  .board-frame {
    order: 1;
    width: min(100%, calc((100dvh - 150px) * 1044 / 1284));
    height: auto;
    margin: 0 auto;
  }
  .board { aspect-ratio: 1000 / 1240; height: auto; }
  .flap { order: 2; height: auto; }
  .flap-right { order: 3; margin-bottom: 110px; }
  .flap-inner { overflow: visible; }
  .trail { max-height: 180px; }
  .app[data-screen="title"] .flap { display: none; }
  .app[data-screen="title"] .flap-left,
  .app[data-screen="title"] .flap-right { transform: none; }
  .tray {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 8;
    grid-template-columns: auto 1fr;
    background: var(--paper-noise), #eadfbf;
    box-shadow: 0 0 0 3px #2a1706, 0 0 0 5px #a8782e, 0 10px 30px rgba(0, 0, 0, 0.6);
  }
  .die { width: 68px; height: 68px; border-radius: 13px; }
  .die-face i { width: 12px; height: 12px; margin: -6px 0 0 -6px; }
  .title-panel { position: relative; left: auto; bottom: auto; transform: none; margin: 18px auto 30px; }
  .app:not([data-screen="title"]) .title-panel { display: none; }
  .lens { width: 78%; transform: translate(-50%, -50%) scale(0.31); }
  .lens-text { font-size: clamp(13px, 4.2cqi, 22px); }
}

@media (max-width: 520px) {
  .idol-picker { grid-template-columns: repeat(2, 1fr); }
  dialog.sheet form { padding: 18px 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .crystal-mist, .tile-highlight, .pawn.is-active .turn-ring { animation: none; }
  .door, .flap { transition-duration: 200ms; transition-delay: 0ms !important; }
  .lens, .lens.is-open .lens-text > * { transition-duration: 120ms; animation-duration: 120ms; }
  .die.is-rolling { animation: none; }
  dialog[open] { animation: none; }
}
