:root {
  --red: #8f1d1d;
  --red2: #b42323;
  --gold: #e9b949;
  --paper: #fff7e6;
  --ink: #2b1b12;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  background: radial-gradient(circle at 30% 20%, #7a1414, #3a0606 70%);
  min-height: 100vh;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: .3em 0; color: var(--red); }
h1 { font-size: 2.2em; }
.sub { color: #6b4f3a; margin-top: 0; }
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
#game.screen { display: block; padding: 0; }
.card {
  background: var(--paper);
  border: 4px solid var(--gold);
  border-radius: 16px;
  padding: 22px 26px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  max-width: 720px;
  width: 100%;
}
.center { text-align: center; }
.logo { font-size: 64px; line-height: 1; }
.col { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 18px auto 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; justify-content: flex-end; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 10px; }
.split > div { background: #fdecc8; border-radius: 12px; padding: 12px; }
@media (max-width: 600px) { .split { grid-template-columns: 1fr; } }

button {
  font: inherit; cursor: pointer;
  border: 2px solid var(--red); background: #fff; color: var(--red);
  padding: 8px 14px; border-radius: 10px; transition: transform .08s, filter .15s;
}
button:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--red); color: #fff; }
button.danger { background: #111; color: var(--gold); border-color: #111; }
button.big { font-size: 1.1em; padding: 12px 18px; }
button.small { padding: 4px 9px; font-size: .85em; }
input, select {
  font: inherit; padding: 7px 10px; border: 2px solid #c9a46a; border-radius: 8px; background: #fff;
}
label { display: block; margin: 8px 0; }
label input { display: block; width: 100%; margin-top: 4px; }
.codein { text-transform: uppercase; letter-spacing: 6px; width: 140px; text-align: center; font-weight: bold; margin: 6px 0 8px; display: block; }
.prow { display: flex; gap: 8px; margin: 6px 0; align-items: center; }
.prow input { flex: 1; }
.prow .dot { width: 18px; height: 18px; border-radius: 50%; flex: none; }

/* -------- lobby -------- */
.code { background: #111; color: var(--gold); padding: 2px 12px; border-radius: 8px; letter-spacing: 6px; }
.link { width: 100%; margin-top: 4px; }
.plist { list-style: none; padding: 0; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px dashed #d9b77a; }
.plist li .grow { flex: 1; }
.chip { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #0004; vertical-align: middle; flex: none; }

/* -------- partida -------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: #1a0303; color: var(--gold); border-bottom: 3px solid var(--gold);
}
.brand { font-weight: bold; font-size: 1.1em; }
.grow { flex: 1; }
.topbar button { border-color: var(--gold); color: var(--gold); background: transparent; }
.layout { display: flex; gap: 14px; padding: 14px; align-items: flex-start; }
.boardCol { flex: 1; min-width: 0; position: relative; }
#boardWrap { width: 100%; }
.board { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 24px rgba(0,0,0,.5)); user-select: none; }
#panel {
  width: 380px; flex: none; background: var(--paper); border: 3px solid var(--gold); border-radius: 14px;
  padding: 12px 14px; max-height: calc(100vh - 80px); overflow-y: auto;
}
@media (max-width: 1000px) {
  .layout { flex-direction: column; }
  #panel { width: 100%; max-height: none; }
}
.lname { font-size: 12px; font-weight: bold; fill: #4a1010; paint-order: stroke; stroke: #fff7e6; stroke-width: 4px; }
.hl { cursor: pointer; }
.hlc { fill: rgba(255, 210, 0, .45); stroke: #f59e0b; stroke-width: 3; animation: glow 1s infinite alternate; }
@keyframes glow { from { opacity: .55; } to { opacity: 1; } }
.tok.cur { animation: pulse 0.9s infinite alternate; }
@keyframes pulse { from { stroke: #fff; } to { stroke: #ffd60a; stroke-width: 5; } }

.section { margin-top: 12px; }
.section h3 { font-size: 1em; margin: 0 0 6px; border-bottom: 2px solid var(--gold); padding-bottom: 2px; }
.case { background: #2b0909; color: #ffe8b0; border-radius: 10px; padding: 10px 12px; }
.ctitle { color: var(--gold); font-weight: bold; margin-bottom: 4px; }
.turn { margin-top: 10px; font-size: 1.05em; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.die { font-size: 34px; line-height: 1; color: var(--red); }
.actions { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.actions p { margin: 4px 0; }
.wait { color: #7a5a40; font-style: italic; }
.players div { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.players .out { text-decoration: line-through; opacity: .55; }
.players .me { font-weight: bold; }
.clue { background: #fff; border-left: 4px solid var(--red2); padding: 5px 8px; margin: 5px 0; border-radius: 0 6px 6px 0; font-size: .92em; }
.clue b { color: var(--red); }
.private { background: #eee3cc; border-radius: 8px; padding: 10px; text-align: center; color: #6b4f3a; margin-top: 12px; }
.log { font-size: .85em; max-height: 190px; overflow-y: auto; }
.log div { padding: 2px 0; border-bottom: 1px dotted #e2c895; }

/* -------- cuaderno / sospechosos -------- */
.sgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.scard {
  position: relative; background: #fff; border: 2px solid #d9b77a; border-radius: 8px; padding: 2px;
  color: var(--ink); font-size: 11px; text-align: center; display: flex; flex-direction: column; align-items: center;
}
.scard svg { width: 100%; max-width: 64px; height: auto; }
.scard.crossed { opacity: .35; }
.scard.crossed::after {
  content: '✕'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 44px; color: #b42323; font-weight: bold;
}
.accuse .scard { font-size: 13px; }
.accuse .scard svg { max-width: 90px; }
.legend { font-size: .8em; color: #6b4f3a; margin: 4px 0 6px; }

/* -------- overlays -------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 2, 2, .82); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 16px; overflow-y: auto;
}
#curtain { background: #1a0303; z-index: 60; }
#modalBox { max-height: 94vh; overflow-y: auto; }
.hint { color: #6b4f3a; font-style: italic; }

.lensBox {
  position: relative; overflow: hidden; border-radius: 10px; border: 3px solid #333;
  cursor: none; touch-action: none; max-width: 580px; margin: 0 auto;
}
.lensBox canvas { display: block; width: 100%; height: auto; }
#lensCanvas { position: absolute; inset: 0; pointer-events: none; }
.lensRing {
  position: absolute; width: 160px; height: 160px; border-radius: 50%; display: none; pointer-events: none;
  transform: translate(-50%, -50%); border: 5px solid #222; box-shadow: 0 0 0 2px #e9b949, 0 6px 14px rgba(0,0,0,.4);
}

.parch {
  background: linear-gradient(#f6e3b4, #e9cf8f); border: 3px solid #a37a2c; border-radius: 10px;
  padding: 28px 18px; text-align: center; font-size: 1.5em; font-weight: bold; color: #3b2208;
}
.mirror { display: inline-block; transform: scaleX(-1); transition: transform .5s; }
.mirror.flip { transform: scaleX(1); }

.cookie { text-align: center; }
.cookie .big { font-size: 60px; }
.dragonBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.dragonBtns button { color: #fff; border: none; font-weight: bold; }

.reveal { display: flex; gap: 18px; align-items: center; background: #fdecc8; border-radius: 12px; padding: 12px; }
.reveal svg { width: 120px; height: auto; flex: none; }
.rules p, .rules li { line-height: 1.45; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: #111; color: var(--gold); padding: 10px 18px; border-radius: 10px; z-index: 100;
  transition: transform .25s; max-width: 90vw; text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* -------- botones de sonido -------- */
.center-btns { justify-content: center; }
button.off { opacity: .5; text-decoration: line-through; }

/* -------- dado 3D -------- */
.diceStage {
  position: absolute; left: 50%; top: 46%; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  perspective: 700px; pointer-events: none; z-index: 5;
}
.diceStage.roll { animation: diceBounce 1.3s ease-out; }
@keyframes diceBounce {
  0%   { transform: translate(-220px, -160px) scale(.55); }
  35%  { transform: translate(-40px, 12px) scale(1.05); }
  55%  { transform: translate(12px, -30px) scale(1); }
  75%  { transform: translate(0, 0); }
  88%  { transform: translateY(-7px); }
  100% { transform: none; }
}
.dice { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; }
.diceStage.settled .face { border-color: #e9b949; box-shadow: 0 0 22px #ffd60a, inset 0 0 14px rgba(0,0,0,.2); }
.face {
  position: absolute; inset: 0; background: #fffaf0; border: 3px solid #9b2226; border-radius: 18px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 14px;
  box-shadow: inset 0 0 14px rgba(0,0,0,.2); backface-visibility: hidden;
}
.pip { width: 20px; height: 20px; border-radius: 50%; background: #9b2226; align-self: center; justify-self: center; box-shadow: inset 0 -2px 3px rgba(0,0,0,.35); }
.f1 { transform: translateZ(60px); }
.f6 { transform: rotateY(180deg) translateZ(60px); }
.f3 { transform: rotateY(90deg) translateZ(60px); }
.f4 { transform: rotateY(-90deg) translateZ(60px); }
.f2 { transform: rotateX(90deg) translateZ(60px); }
.f5 { transform: rotateX(-90deg) translateZ(60px); }
