/* --- pistas: fichas de cartulina con cinta, agentes-sticker, nota de pista, sellos de tiempo --- */
.pistas { --giver: var(--tomato); position: relative; }
.pistas.shake { animation: ps-shake .5s ease-in-out; }
@keyframes ps-shake { 20% { translate: -8px 2px; } 40% { translate: 7px -3px; } 60% { translate: -5px 1px; } 80% { translate: 3px 0; } }

.pistas .ps-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-soft); }

/* ---- cabecera ---- */
.ps-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.ps-title {
  margin: 0 auto 0 0; font-size: 2.6rem; color: var(--mint); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink); transform: rotate(-3deg);
}
.ps-meter {
  display: flex; align-items: center; gap: 12px; background: var(--sheet); border: var(--stroke); border-radius: var(--r-sm);
  box-shadow: var(--shadow); padding: 6px 14px;
}
.ps-meter:first-of-type { transform: rotate(1deg); }
#found { font-family: var(--display); font-weight: 400; font-size: 1.8rem; line-height: 1; color: var(--ink); }
#found small { font-size: .9rem; color: var(--ink-soft); }
.ps-stamps { display: flex; gap: 2px; }
.ps-stamp {
  width: 34px; height: 34px; display: grid; place-items: center; color: var(--cobalt); position: relative;
  transform: rotate(var(--r, 0deg)); transition: color .3s, opacity .3s;
}
.ps-stamp svg { width: 100%; height: 100%; }
.ps-stamp.used { color: #1f1a1740; }
.ps-stamp.used::after {
  content: ''; position: absolute; inset: 7px; background:
    linear-gradient(45deg, transparent 43%, var(--tomato) 43% 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--tomato) 43% 57%, transparent 57%);
}
.ps-stamp.thump { animation: ps-thump .55s var(--ease-pop) both; }
@keyframes ps-thump { 0% { transform: rotate(var(--r)) scale(2.2); opacity: 0; } 60% { transform: rotate(var(--r)) scale(.9); opacity: 1; } }

/* ---- layout ---- */
.ps-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 30px; align-items: start; }

/* ---- tablero de fichas ---- */
.ps-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px 14px;
  background: var(--paper-2); border: 4px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow-lg); padding: 22px 18px 18px;
  max-width: calc((100vh - 150px) * 1.5); width: 100%; justify-self: center;
}
.ps-card {
  --tilt: 0deg; position: relative; aspect-ratio: 7 / 5; padding: 0; overflow: visible; border-radius: 6px; border-width: 2.5px;
  box-shadow: 3px 3px 0 var(--ink); transform: rotate(var(--tilt));
  /* cartulina rayada: línea roja arriba + renglones celestes */
  background:
    linear-gradient(transparent 0 22%, #ff5a3c88 22% calc(22% + 2px), transparent 0),
    repeating-linear-gradient(transparent 0 calc(22% + 2px), transparent 0 13px, #3b6cff2e 13px 14px) ,
    var(--sheet);
  display: grid; place-items: center; cursor: default;
  transition: transform .15s var(--ease-pop), box-shadow .15s, opacity .3s, filter .3s;
}
@keyframes ps-deal { from { opacity: 0; transform: translateY(-14px) rotate(calc(var(--tilt) * 4)) scale(.85); } }
.ps-card:hover:not(:disabled) { transform: rotate(var(--tilt)); box-shadow: 3px 3px 0 var(--ink); }
.ps-card:active:not(:disabled) { transform: rotate(var(--tilt)); box-shadow: 3px 3px 0 var(--ink); }
.ps-grid.deal .ps-card { animation: ps-deal .45s var(--ease-pop) both; animation-delay: var(--d); }
.ps-tape {
  position: absolute; top: -9px; left: 50%; width: 44%; height: 16px; transform: translateX(-50%) rotate(calc(var(--tilt) * -2 - 2deg));
  background: #ffe28acc; border-left: 2px dashed #1f1a1726; border-right: 2px dashed #1f1a1726; z-index: 2; pointer-events: none;
}
.ps-card { container-type: inline-size; }
.ps-word {
  font-family: var(--body); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
  font-size: clamp(.5rem, calc((100cqi - 16px) / (var(--len) * .78)), 1.15rem);
  color: var(--ink); line-height: 1.05; padding: 14% 6px 0; text-align: center; max-width: 100%;
}

/* puntita doblada = mi clave */
.ps-ear { position: absolute; top: -2.5px; right: -2.5px; width: 0; height: 0; pointer-events: none; }
.ps-card.k-g .ps-ear, .ps-card.k-b .ps-ear {
  width: 22px; height: 22px; border-radius: 0 6px 0 0;
  background: linear-gradient(225deg, var(--paper-2) 0 50%, var(--ear) 50%);
  border-top: 2.5px solid var(--ink); border-right: 2.5px solid var(--ink);
}
.ps-card.k-g .ps-ear::after, .ps-card.k-b .ps-ear::after { content: ''; position: absolute; left: 0; top: 0; width: 31px; height: 2.5px; background: var(--ink); transform-origin: 0 0; transform: rotate(45deg); }
.ps-card.k-g { --ear: var(--mint); }
.ps-card.k-b { --ear: var(--ink); }

/* se puede adivinar */
.ps-grid.guessing .ps-card { cursor: not-allowed; }
.ps-grid.guessing .ps-card.can { cursor: pointer; }
@media (hover: hover) {
  .ps-card.can:hover { transform: rotate(0) translateY(-5px) scale(1.04); box-shadow: 6px 7px 0 var(--ink); z-index: 3; }
  .ps-card.can:hover .ps-word { color: var(--giver); }
}
.ps-card.can:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); transition-duration: .05s; }
.ps-grid.guessing .ps-card.can { outline: 3px dashed color-mix(in srgb, var(--giver) 55%, transparent); outline-offset: 3px; }

/* transeúntes */
.ps-card.faded { filter: saturate(.4); opacity: .66; }
.ps-card.faded .ps-word { color: var(--ink-soft); }
.ps-card.gone { opacity: .38; }
.ps-card.faded.can { opacity: .85; }
.ps-bys { position: absolute; left: 6px; bottom: 4px; display: flex; gap: 2px; }
.ps-person { width: 18px; height: 21px; display: block; }
.ps-card.wob { animation: ps-wob .5s ease-in-out; }
@keyframes ps-wob { 25% { transform: rotate(-6deg); } 50% { transform: rotate(5deg); } 75% { transform: rotate(-3deg); } }

/* agente encontrado */
.ps-card.agent { background: radial-gradient(circle, #ffffff66 2.2px, transparent 2.8px) 0 0 / 14px 14px, var(--mint); }
.ps-card.agent .ps-word {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%) rotate(-2deg); padding: 1px 8px; white-space: nowrap;
  background: var(--sheet); border: 2px solid var(--ink); border-radius: 6px; font-size: min(.7rem, calc((100cqi - 8px) / (var(--len) * .8))); box-shadow: 2px 2px 0 var(--ink); z-index: 2;
  max-width: 108%; overflow: hidden; text-overflow: ellipsis;
}
.ps-sticker { position: absolute; inset: 6% 0 14%; display: grid; place-items: center; }
.ps-agent { height: 100%; width: auto; transform: rotate(-6deg); }
.ps-card:nth-child(even) .ps-agent { transform: rotate(7deg); }
.ps-card.pop { animation: ps-pop .6s var(--ease-pop) both; z-index: 4; }
@keyframes ps-pop { 0% { transform: scale(.6) rotate(-14deg); } 60% { transform: scale(1.14) rotate(4deg); } }

/* asesino */
.ps-card.dead { background: var(--sheet); z-index: 3; }
.ps-splat { position: absolute; inset: -18% -14%; width: 128%; height: 136%; pointer-events: none; }
.ps-card.dead .ps-word { position: relative; z-index: 2; color: #fff; background: var(--ink); border-radius: 4px; padding: 0 6px; margin-top: 46%; }
.ps-card.boom .ps-splat { animation: ps-splat .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes ps-splat { from { transform: scale(.1) rotate(-30deg); opacity: 0; } }

/* final: agentes que faltaban */
.ps-card.missed { box-shadow: 3px 3px 0 var(--ink), 0 0 0 4px var(--mint); }

/* ---- panel ---- */
.ps-side { display: flex; flex-direction: column; gap: 16px; }
.ps-side h3 { margin: 6px 0 -6px 4px; }

/* nota de la pista: post-it rayado */
.ps-note {
  position: relative; min-height: 150px; padding: 26px 20px 18px; border: var(--stroke); border-radius: 4px 4px 22px 4px;
  box-shadow: var(--shadow-lg); transform: rotate(-1.5deg);
  background: repeating-linear-gradient(transparent 0 27px, #1f1a171a 27px 29px), #ffe9a3;
}
.ps-note-tape {
  position: absolute; top: -14px; left: 50%; width: 110px; height: 26px; transform: translateX(-50%) rotate(3deg);
  background: #ff8fc7b3; border-left: 2px dashed #0002; border-right: 2px dashed #0002;
}
.ps-note.shown { animation: ps-note .55s var(--ease-pop) both; }
@keyframes ps-note { from { transform: rotate(-12deg) scale(.6); opacity: 0; } }
.ps-clue {
  margin: 4px 0 0; font-family: var(--display); font-size: clamp(2rem, 3.4vw, 2.8rem); line-height: 1.05; color: var(--ink);
  overflow-wrap: anywhere; transform: rotate(-2deg); text-decoration: underline wavy var(--giver) 3px; text-underline-offset: 8px; padding-right: 54px;
}
.ps-n {
  position: absolute; right: 14px; bottom: 14px; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-size: 2rem; color: #fff; background: var(--giver); border: var(--stroke); box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(8deg);
}
.ps-wait { margin: 30px 0 0; text-align: center; font-family: var(--display); font-size: 1.3rem; color: var(--ink-soft); }
.ps-note.empty .ps-wait { animation: ps-breathe 2.4s ease-in-out infinite; }
@keyframes ps-breathe { 50% { opacity: .45; } }

.ps-note form { display: flex; flex-direction: column; gap: 10px; }
.ps-note input { font-family: var(--display); font-weight: 400; font-size: 1.5rem; background: #fffdf7cc; }
.ps-nums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ps-nums button { padding: 4px 0; font-family: var(--display); font-weight: 400; font-size: 1.15rem; background: var(--sheet); box-shadow: 2px 2px 0 var(--ink); border-width: 2.5px; }
.ps-nums button.sel { background: var(--giver); color: #fff; transform: rotate(-6deg) scale(1.08); }

/* estado */
.ps-play {
  position: relative; padding: 14px 16px; background: var(--sheet); border: var(--stroke); border-radius: var(--r); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.ps-play.mine { background: color-mix(in srgb, var(--mint) 22%, var(--sheet)); }
.ps-play.mine::before {
  content: '★'; position: absolute; top: -14px; right: -10px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sun); border: var(--stroke); font-size: 1rem; animation: ps-spinstar 3s linear infinite;
}
@keyframes ps-spinstar { to { rotate: 1turn; } }
.ps-status { margin: 0; font-weight: 800; font-size: 1.05rem; }
.ps-actions:empty { display: none; }
.ps-actions button { width: 100%; }

/* mi clave: mapa-sticker */
.ps-keybox { padding: 14px 16px 12px; background: var(--sheet); border: var(--stroke); border-radius: var(--r); box-shadow: var(--shadow); transform: rotate(1deg); }
.ps-keybox[hidden] { display: none; }
.ps-keybox h3 { margin: 0 0 10px; }
.ps-key { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 8px; background: var(--paper-2); border: 2.5px solid var(--ink); border-radius: 10px; }
.ps-key i { aspect-ratio: 7 / 5; border: 2px solid var(--ink); border-radius: 4px; background: var(--sheet); position: relative; }
.ps-key i.g { background: var(--mint); }
.ps-key i.b { background: var(--ink); }
.ps-key i.b::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: .75rem; }
.ps-key i.done, .ps-key i.seen { opacity: .3; }
.ps-key i.g.done::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: .8rem; }
.ps-legend { display: flex; gap: 12px; margin: 10px 0 2px; font-size: .82rem; font-weight: 700; }
.ps-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ps-legend i { width: 14px; height: 11px; border: 2px solid var(--ink); border-radius: 3px; background: var(--sheet); }
.ps-legend i.g { background: var(--mint); } .ps-legend i.b { background: var(--ink); }
.ps-keybox small { display: block; font-size: .78rem; line-height: 1.3; }

/* bitácora */
.ps-log { max-height: 260px; min-height: 120px; overflow-y: auto; }
.ps-log li { display: flex; gap: 8px; align-items: baseline; }
.ps-bullet { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); translate: 0 1px; }
.ps-log .ok { color: #13945c; font-weight: 800; }
.ps-log .bad { color: var(--tomato); font-weight: 800; }
.ps-log .clue { font-weight: 800; }
.ps-log .sys { color: var(--ink-soft); font-style: italic; }

/* ---- fin ---- */
.ps-over h2 { margin-top: 6px; }
.ps-over .row { justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.ps-over-art { display: flex; justify-content: center; gap: 4px; height: 110px; margin: -8px 0 4px; }
.ps-over-art .ps-agent { height: 100%; width: auto; animation: ps-hop 1s var(--ease-pop) infinite alternate; }
.ps-over-art .ps-agent:nth-child(2) { animation-delay: .2s; height: 120%; translate: 0 -10%; }
.ps-over-art .ps-agent:nth-child(3) { animation-delay: .4s; }
@keyframes ps-hop { to { translate: 0 -10px; } }
.ps-over-art.dead { height: 150px; }
.ps-over-art.dead .ps-splat { position: static; width: 200px; height: 160px; animation: ps-splat .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.ps-over-art.time .ps-stamp.big { width: 110px; height: 110px; --r: -12deg; animation: ps-thump .7s var(--ease-pop) both; }

/* confeti */
.ps-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: visible; }
.over > .ps-confetti { position: fixed; overflow: hidden; }
.ps-confetti i {
  position: absolute; width: var(--w); height: var(--h); background: var(--bg); border: 1.5px solid var(--ink); border-radius: 2px;
  animation: ps-conf var(--t) cubic-bezier(.2, .6, .4, 1) var(--d) both;
}
@keyframes ps-conf {
  0% { transform: translate(0, 0) rotate(0) scale(.4); }
  30% { transform: translate(calc(var(--dx) * .6), var(--up)) rotate(calc(var(--r) * .4)) scale(1); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--fall)) rotate(var(--r)); opacity: 0; }
}
.ps-confetti.rain i { animation-name: ps-rain; animation-timing-function: linear; }
@keyframes ps-rain {
  0% { transform: translate(0, 0) rotate(0); }
  50% { transform: translate(var(--dx), var(--up)) rotate(calc(var(--r) * .5)); }
  100% { transform: translate(calc(var(--dx) * -.5), var(--fall)) rotate(var(--r)); }
}

@media (max-width: 1000px) {
  .ps-main { grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; }
  .ps-grid { gap: 12px 10px; padding: 18px 12px 12px; }
}
@media (max-width: 780px) {
  .ps-main { grid-template-columns: 1fr; }
  .ps-head { gap: 10px; }
  .ps-title { font-size: 2rem; }
}

/* ---- tablet / táctil ---- */
.ps-grid, .ps-card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (pointer: coarse) {
  .ps-nums button { min-height: 44px; }
  .ps-note input { min-height: 52px; }
  .ps-actions button { min-height: 48px; }
}
/* vertical (≤780): primero tablero, abajo pista | estado+clave lado a lado → todo a la vista */
@media (max-width: 780px) {
  .ps-side { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px 18px; align-items: start; }
  .ps-note { grid-row: span 2; min-height: 0; }
  .ps-side > h3, .ps-log { grid-column: 1 / -1; }
  .ps-log { max-height: 180px; }
  .ps-key { max-width: 220px; gap: 4px; padding: 6px; }
  .ps-keybox small { display: none; }
  .ps-grid { max-width: calc((100svh - 330px) * 1.5); gap: 12px 10px; padding: 18px 14px 14px; }
  .ps-head { margin-bottom: 14px; }
  .ps-note { padding: 22px 16px 14px; }
}
