/* ─── Cuarto Cerrado — estilo archivo detective vintage ───────────────── */

@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=IM+Fell+English+SC&family=IM+Fell+English:ital@0;1&family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=Caveat:wght@400;600;700&display=swap');

:root {
  --paper:        oklch(0.93 0.025 78);
  --paper-2:      oklch(0.88 0.035 78);
  --paper-3:      oklch(0.82 0.04 75);
  --paper-edge:   oklch(0.72 0.05 70);
  --ink:          oklch(0.22 0.025 60);
  --ink-2:        oklch(0.35 0.03 60);
  --ink-faded:    oklch(0.48 0.04 65);
  --ink-soft:     oklch(0.6 0.04 65);
  --stamp-red:    oklch(0.46 0.18 28);
  --stamp-red-2:  oklch(0.38 0.16 25);
  --stamp-blue:   oklch(0.38 0.1 245);
  --stamp-green:  oklch(0.4 0.1 145);
  --pencil:       oklch(0.32 0.015 80);
  --tape:         rgba(245, 230, 175, 0.55);
  --tape-edge:    rgba(180, 160, 110, 0.4);
  --shadow:       0 1px 1px rgba(50,30,15,.12), 0 6px 18px rgba(50,30,15,.18);
  --shadow-deep:  0 2px 2px rgba(50,30,15,.18), 0 18px 40px rgba(50,30,15,.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 16px;
  line-height: 1.55;
}

body {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(120, 80, 30, 0.08), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(80, 50, 20, 0.10), transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 240, 200, 0.25), transparent 70%),
    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='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.25  0 0 0 0 0.18  0 0 0 0 0.10  0 0 0 0.10 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-attachment: fixed, fixed, fixed, fixed;
  background-size: auto, auto, auto, 180px 180px;
}

/* ─── Tipografía ──────────────────────────────────────────────────────── */
.font-typewriter { font-family: 'Special Elite', 'Courier Prime', monospace; }
.font-display    { font-family: 'IM Fell English SC', 'IM Fell English', serif; letter-spacing: 0.02em; }
.font-serif      { font-family: 'IM Fell English', serif; }
.font-hand       { font-family: 'Caveat', cursive; }
.font-mono       { font-family: 'Courier Prime', 'Courier New', monospace; }

h1, h2, h3, h4 { font-family: 'IM Fell English SC', serif; font-weight: 400; color: var(--ink); margin: 0 0 .4em; letter-spacing: 0.02em; }
h1 { font-size: 2.6rem; }
h2 { font-size: 1.9rem; }
h3 { font-size: 1.35rem; }

p { margin: 0 0 .8em; }

a { color: var(--stamp-blue); text-decoration: underline; text-underline-offset: 3px; }

/* ─── Layout shell ────────────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px dashed var(--ink-soft);
  background: linear-gradient(to bottom, rgba(255,245,220,.3), transparent);
}

.topbar .brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-family: 'IM Fell English SC', serif;
  font-size: 1.3rem;
  letter-spacing: 0.05em;
}
.topbar .brand .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--stamp-red); display: inline-block;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--stamp-red-2);
}
.topbar .brand small {
  font-family: 'Special Elite', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--ink-faded);
  text-transform: uppercase;
}

.topbar nav {
  display: flex; gap: .25rem; align-items: center;
}

.navlink {
  font-family: 'Special Elite', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: .4rem .7rem;
  border-radius: 2px;
  cursor: pointer;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid transparent;
  transition: all .12s ease;
}
.navlink:hover { background: rgba(140,90,40,.08); color: var(--ink); }
.navlink.active { background: var(--ink); color: var(--paper); }

.main { flex: 1; padding: 2rem 1.5rem 4rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ─── Paper card ──────────────────────────────────────────────────────── */
.paper {
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at 100% 0%, rgba(120,80,30,.12), transparent 40%),
    radial-gradient(ellipse at 0% 100%, rgba(120,80,30,.10), transparent 40%);
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
}
.paper.torn {
  /* edge-imperfections */
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><defs><filter id='r'><feTurbulence baseFrequency='0.04' numOctaves='2'/><feDisplacementMap in='SourceGraphic' scale='4'/></filter></defs><rect width='400' height='400' fill='black' filter='url(%23r)'/></svg>");
}
.paper.aged::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 90%, rgba(100,60,15,.18), transparent 6%),
    radial-gradient(circle at 80% 12%, rgba(100,60,15,.12), transparent 4%);
  mix-blend-mode: multiply;
}

/* ─── Folder card (game tile) ─────────────────────────────────────────── */
.folder {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--paper-edge);
  padding: 1.2rem 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}
.folder:hover {
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow: var(--shadow-deep);
}
.folder::before {
  /* file tab */
  content: '';
  position: absolute;
  top: -14px; left: 18px;
  width: 110px; height: 18px;
  background: var(--paper-2);
  border: 1px solid var(--paper-edge);
  border-bottom: none;
  border-radius: 4px 12px 0 0;
  transform: skewX(-12deg);
}
.folder::after {
  /* paperclip */
  content: '';
  position: absolute;
  top: -10px; right: 22px;
  width: 16px; height: 38px;
  border: 2px solid #888;
  border-bottom-color: transparent;
  border-radius: 8px 8px 2px 2px;
  background: transparent;
  transform: rotate(8deg);
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,.2));
  opacity: .65;
}
.folder .tag {
  position: absolute;
  top: -8px; left: 32px;
  font-family: 'Special Elite', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--ink-faded);
  text-transform: uppercase;
}

/* ─── Stamp ───────────────────────────────────────────────────────────── */
.stamp {
  display: inline-block;
  padding: .35rem .8rem;
  border: 3px double var(--stamp-red);
  color: var(--stamp-red);
  font-family: 'Special Elite', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  transform: rotate(-6deg);
  background: rgba(255,255,255,.05);
  opacity: 0.88;
  text-shadow: 0 0 1px var(--stamp-red);
  filter: contrast(1.05);
  user-select: none;
}
.stamp.blue { color: var(--stamp-blue); border-color: var(--stamp-blue); }
.stamp.green { color: var(--stamp-green); border-color: var(--stamp-green); }
.stamp.solid { background: var(--stamp-red); color: var(--paper); border-color: var(--stamp-red-2); }

/* ─── Tape ────────────────────────────────────────────────────────────── */
.tape {
  position: absolute;
  width: 90px; height: 22px;
  background: var(--tape);
  border-left: 1px dashed var(--tape-edge);
  border-right: 1px dashed var(--tape-edge);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  pointer-events: none;
}

/* ─── Polaroid ────────────────────────────────────────────────────────── */
.polaroid {
  background: #f7f3e8;
  padding: 10px 10px 36px;
  box-shadow: var(--shadow);
  display: inline-block;
  position: relative;
}
.polaroid img, .polaroid .ph {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--paper-3);
}
.polaroid .cap {
  position: absolute;
  bottom: 6px; left: 0; right: 0;
  text-align: center;
  font-family: 'Caveat', cursive;
  font-size: 1.15rem;
  color: var(--ink-2);
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  font-family: 'Special Elite', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: .65rem 1.2rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 1px;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--ink), 0 2px 6px rgba(0,0,0,.18);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 0 var(--ink), 0 4px 10px rgba(0,0,0,.22); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: rgba(0,0,0,.06); }

.btn.red { background: var(--stamp-red); border-color: var(--stamp-red-2); }
.btn.blue { background: var(--stamp-blue); border-color: var(--stamp-blue); }
.btn.small { padding: .35rem .75rem; font-size: 0.7rem; letter-spacing: 0.15em; }

/* ─── Inputs ──────────────────────────────────────────────────────────── */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font-family: 'Courier Prime', monospace;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink-soft);
  color: var(--ink);
  padding: .35rem 0;
  width: 100%;
  outline: none;
  transition: border-color .15s ease;
}
input:focus, textarea:focus, select:focus { border-bottom-color: var(--ink); }
textarea { border: 1px solid var(--ink-soft); padding: .6rem; border-radius: 2px; resize: vertical; min-height: 80px; }
select { border: 1px solid var(--ink-soft); padding: .4rem .5rem; border-radius: 2px; background: var(--paper); }
label { font-family: 'Special Elite', monospace; font-size: 0.75rem; letter-spacing: 0.15em; color: var(--ink-faded); text-transform: uppercase; display: block; margin-bottom: .25rem; }

.field { margin-bottom: 1.1rem; }

/* ─── Pills / chips ───────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: .15rem .55rem;
  font-family: 'Special Elite', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  border: 1px solid var(--ink-faded);
  color: var(--ink-faded);
  text-transform: uppercase;
  border-radius: 2px;
}
.pill.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.red { color: var(--stamp-red); border-color: var(--stamp-red); }

/* ─── Loader ──────────────────────────────────────────────────────────── */
.loader {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: 'Special Elite', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--ink-faded);
  text-transform: uppercase;
}
.loader .dots { display: inline-flex; gap: .25rem; }
.loader .dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faded);
  animation: blink 1.2s infinite;
}
.loader .dots span:nth-child(2) { animation-delay: 0.15s; }
.loader .dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.2; } 30% { opacity: 1; } }

.loader-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  text-align: center;
}
.loader-big .typewriter {
  font-family: 'Special Elite', monospace;
  font-size: 1rem;
  letter-spacing: 0.15em;
  color: var(--ink-2);
  border-right: 2px solid var(--ink);
  white-space: nowrap;
  overflow: hidden;
  animation: caret 0.7s steps(1) infinite;
}
@keyframes caret { 50% { border-color: transparent; } }

/* ─── Modal ───────────────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(20, 12, 5, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--paper);
  max-width: 560px;
  width: 100%;
  padding: 2rem;
  box-shadow: var(--shadow-deep);
  border: 1px solid var(--paper-edge);
  position: relative;
  max-height: 90vh;
  overflow: auto;
}

/* ─── Grid / Mapdoku ──────────────────────────────────────────────────── */
.mdk-grid {
  display: grid;
  background:
    linear-gradient(var(--paper-edge) 1px, transparent 1px) 0 0 / 100% var(--cell, 88px),
    linear-gradient(90deg, var(--paper-edge) 1px, transparent 1px) 0 0 / var(--cell, 88px) 100%,
    var(--paper);
  border: 2px solid var(--ink);
  position: relative;
}
.mdk-cell {
  width: var(--cell, 88px);
  height: var(--cell, 88px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--ink);
  transition: background .1s ease;
}
.mdk-cell:hover { background: rgba(140,90,40,.08); }
.mdk-cell.selected { background: rgba(80,140,200,.15); }
.mdk-cell .ic { font-size: 1.8rem; }
.mdk-header {
  font-family: 'Special Elite', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--ink-faded);
  text-transform: uppercase;
  text-align: center;
}

/* ─── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: 'Special Elite', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  padding: .8rem 1.4rem;
  border-radius: 2px;
  box-shadow: var(--shadow-deep);
  z-index: 100;
  animation: toastIn .25s ease;
}
.toast.ok { background: var(--stamp-green); }
.toast.bad { background: var(--stamp-red); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ─── Utils ───────────────────────────────────────────────────────────── */
.row { display: flex; gap: 1rem; }
.col { display: flex; flex-direction: column; gap: 1rem; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: .5rem; }
.gap-lg { gap: 1.5rem; }
.muted { color: var(--ink-faded); }
.tiny { font-size: 0.75rem; }
.center-text { text-align: center; }
.divider { height: 1px; background: var(--ink-soft); margin: 1rem 0; opacity: .4; }
.divider.dashed { background: none; border-top: 1px dashed var(--ink-soft); }
.spin { animation: spinrot 1.4s linear infinite; }
@keyframes spinrot { to { transform: rotate(360deg); } }

/* ─── Game-specific helpers ──────────────────────────────────────────── */
.chat-log {
  display: flex; flex-direction: column; gap: .8rem;
  max-height: 56vh; overflow-y: auto;
  padding-right: .5rem;
}
.bubble {
  padding: .7rem 1rem;
  border-radius: 2px;
  max-width: 88%;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.bubble.them {
  background: rgba(255, 250, 230, .6);
  border: 1px solid var(--paper-edge);
  align-self: flex-start;
  font-family: 'Courier Prime', monospace;
}
.bubble.me {
  background: var(--ink);
  color: var(--paper);
  align-self: flex-end;
  font-family: 'Special Elite', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

/* riddle/cipher display */
.glyph-box {
  font-family: 'Special Elite', monospace;
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  line-height: 1.7;
  padding: 1.5rem;
  background: var(--paper-2);
  border: 1px dashed var(--ink-soft);
  border-radius: 2px;
  white-space: pre-wrap;
  text-align: center;
}

.medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, oklch(0.72 0.13 75), oklch(0.45 0.12 60));
  border: 3px double oklch(0.35 0.1 55);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  font-family: 'IM Fell English SC', serif;
  font-size: 1.4rem;
  color: var(--paper);
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.medal.silver { background: radial-gradient(circle at 35% 30%, oklch(0.85 0.02 80), oklch(0.6 0.02 80)); border-color: oklch(0.5 0.02 80); }
.medal.bronze { background: radial-gradient(circle at 35% 30%, oklch(0.68 0.12 50), oklch(0.45 0.12 40)); border-color: oklch(0.35 0.1 35); }

/* ─── Hotspots sobre imágenes ──────────────────────────────────────────── */
.image-with-hotspots {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.image-with-hotspots img {
  display: block;
  width: 100%;
  height: auto;
}
.hotspot {
  position: absolute;
  border: 2px dashed oklch(0.5 0.18 28 / 0.75);
  background: oklch(0.85 0.15 80 / 0.06);
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s ease, border-color .15s ease, box-shadow .2s ease;
  z-index: 2;
}
.hotspot:hover {
  background: oklch(0.85 0.15 80 / 0.22);
  border-color: oklch(0.5 0.18 28 / 1);
  box-shadow: 0 0 14px oklch(0.5 0.18 28 / 0.55);
}
.hotspot.examined {
  border-color: oklch(0.5 0.1 145 / 0.55);
  border-style: solid;
  background: oklch(0.85 0.1 145 / 0.10);
}
.hotspot.examined:hover {
  background: oklch(0.85 0.1 145 / 0.18);
}
.hotspot .label {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  font-family: 'Caveat', cursive;
  font-size: 1rem;
  color: var(--ink);
  background: oklch(0.95 0.04 78 / 0.95);
  border: 1px solid var(--paper-edge);
  padding: 1px 7px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.hotspot:hover .label { opacity: 1; transform: translateY(0); }
.hotspot .pin {
  position: absolute;
  top: -8px; left: -8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--stamp-red);
  border: 2px solid var(--paper);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Special Elite', monospace;
  font-size: .65rem;
  color: var(--paper);
  z-index: 3;
}
.hotspot.examined .pin { background: var(--stamp-green); }

/* Pulso suave para hotspots sin examinar */
@keyframes pulse-hot {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.5 0.18 28 / 0.4); }
  50%      { box-shadow: 0 0 0 6px oklch(0.5 0.18 28 / 0); }
}
.hotspot:not(.examined) .pin {
  animation: pulse-hot 2s infinite;
}
