:root {
  --bg: #0e0d0c;
  --bg-2: #171513;
  --panel: #1f1c19;
  --line: #2f2a25;
  --text: #efe7da;
  --muted: #a39a8c;
  --lamp: #e3a94f;
  --lamp-soft: rgba(227, 169, 79, 0.14);
  --stamp: #c23b2e;
  --paper: #f3ead8;
  --ink: #23201c;
  --ok: #6fae73;
  --radius: 14px;
  --gutter: 16px;
  --type: "Special Elite", "Courier New", monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% -10%, #2a231b 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

#app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* Barra superior */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: rgba(14, 13, 12, 0.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font: 20px/1.2 var(--type); margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .brand-sub { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  min-width: 40px; height: 40px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--text); font-size: 14px;
}
.icon-btn:active { transform: scale(.97); }

.page { padding: var(--gutter); display: flex; flex-direction: column; gap: 18px; flex: 1; }
.section-title { font: 13px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 6px 0 0; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 32px var(--gutter); }
.login .logo { font: 34px/1.1 var(--type); color: var(--lamp); text-shadow: 0 0 30px rgba(227,169,79,.35); }
.login p { color: var(--muted); margin: 0; }
.field { width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); font-size: 17px; }
.field:focus { outline: 2px solid var(--lamp); outline-offset: 1px; }
.btn {
  border: 0; border-radius: var(--radius); padding: 14px 18px; font-weight: 600;
  background: var(--lamp); color: #1a140b; width: 100%;
}
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--stamp); color: #fff; }
.btn:disabled { opacity: .5; }
.error { color: #ff8a7a; font-size: 14px; min-height: 1.2em; }

/* Tarjetas de caso */
.case-card {
  position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--panel); text-align: left; padding: 0; width: 100%;
}
.case-card .cover { aspect-ratio: 16/8; width: 100%; object-fit: cover; filter: sepia(.25) contrast(1.05) brightness(.8); }
.case-card .meta { position: absolute; inset: auto 0 0 0; padding: 40px 16px 14px; background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.case-card .num { font: 12px var(--type); color: var(--lamp); letter-spacing: .12em; }
.case-card h2 { font: 22px/1.15 var(--type); margin: 2px 0 0; }
.case-card .sub { color: var(--muted); font-size: 14px; }
.stamp {
  position: absolute; top: 12px; right: 12px; transform: rotate(6deg);
  border: 2px solid var(--stamp); color: var(--stamp); font: 12px var(--type); padding: 3px 8px; letter-spacing: .1em; background: rgba(0,0,0,.72);
}
.stamp.ok { border-color: var(--ok); color: var(--ok); }

.game-card { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); text-align: left; width: 100%; }
.game-card .badge { width: 52px; height: 52px; border-radius: 12px; background: var(--lamp-soft); display: grid; place-items: center; font-size: 26px; flex: none; }
.game-card h3 { margin: 0; font: 18px var(--type); }
.game-card p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* Pestañas del caso */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px var(--gutter); position: sticky; top: 61px; z-index: 4; background: rgba(14,13,12,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 9px 2px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.tabs button.on { background: var(--lamp-soft); color: var(--lamp); }

.briefing { background: var(--paper); color: var(--ink); border-radius: 4px; padding: 16px; font: 15px/1.55 var(--type); box-shadow: 0 10px 30px rgba(0,0,0,.4); position: relative; }
.briefing summary { cursor: pointer; font-weight: bold; list-style: none; }
.briefing summary::-webkit-details-marker { display: none; }
.briefing p { margin: 10px 0 0; white-space: pre-line; }

/* Grilla de sospechosos */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.person { display: flex; flex-direction: column; justify-content: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden; text-align: left; }
.person .ph { aspect-ratio: 3/4; width: 100%; object-fit: cover; object-position: top; filter: grayscale(.35) contrast(1.05); background: var(--bg-2); }
.person .ph.none { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 10px; }
.person .ph.none svg { width: 56%; opacity: .5; }
.person .info { padding: 10px 12px 12px; }
.person .name { font: 16px/1.2 var(--type); }
.person .role { color: var(--muted); font-size: 12.5px; line-height: 1.35; margin-top: 3px; }

/* Chat */
.chat-head { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; object-position: top; flex: none; background: var(--panel); border: 1px solid var(--line); }
.avatar.none { display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.chat-head .who { min-width: 0; }
.chat-head .who b { display: block; font: 17px/1.2 var(--type); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.meter .bars { display: flex; gap: 3px; }
.meter .bars i { width: 12px; height: 5px; border-radius: 3px; background: var(--line); transition: background .4s; }
.meter .bars i.on { background: var(--lamp); }
.meter .bars i.on.hot { background: var(--stamp); }

.chat { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: var(--gutter); padding-bottom: 120px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; position: relative; white-space: pre-wrap; word-wrap: break-word; }
.msg.them { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--lamp); color: #1a140b; border-bottom-right-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font: 14px var(--type); text-align: center; max-width: 92%; }
.msg em { color: var(--muted); font-style: italic; }
.msg.them .pin { position: absolute; right: -6px; bottom: -10px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-2); font-size: 14px; display: grid; place-items: center; }
.msg.them .pin.on { background: var(--lamp); color: #1a140b; }
.msg .speaker { display: block; font-size: 12px; color: var(--lamp); font-weight: 600; }
.typing { align-self: flex-start; color: var(--muted); font-size: 14px; font-style: italic; }

.composer {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 720px; z-index: 6;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: rgba(14,13,12,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.composer textarea { flex: 1; resize: none; max-height: 120px; min-height: 46px; padding: 12px 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg-2); font-size: 16px; }
.composer textarea:focus { outline: 2px solid var(--lamp); outline-offset: 0; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center; font-size: 18px; }
.round.send { background: var(--lamp); color: #1a140b; }
.round.mic { background: var(--panel); border: 1px solid var(--line); }
.round.mic.on { background: var(--stamp); color: #fff; }
.quick { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(68px + env(safe-area-inset-bottom)); width: 100%; max-width: 720px; z-index: 6; display: flex; gap: 8px; flex-wrap: wrap; padding: 8px var(--gutter) 4px; background: linear-gradient(transparent, rgba(14,13,12,.95) 40%); }
.has-quick .chat { padding-bottom: 170px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; font-size: 14px; }

/* Libreta */
.note { background: var(--paper); color: var(--ink); border-radius: 4px; padding: 12px 14px; font: 14.5px/1.5 var(--type); position: relative; }
.note .by { font-weight: bold; display: block; margin-bottom: 4px; }
.note button { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; color: #8a2a20; font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* Selección y modal */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg-2); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; width: 100%; max-width: 720px; max-height: 80dvh; overflow: auto; padding: 18px var(--gutter) calc(18px + env(safe-area-inset-bottom)); }
.sheet h3 { font: 18px var(--type); margin: 0 0 12px; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); margin-bottom: 8px; }

.reveal { background: var(--paper); color: var(--ink); border-radius: 4px; padding: 20px 18px; font: 15.5px/1.6 var(--type); white-space: pre-line; position: relative; }
.reveal h2 { margin: 0 0 10px; color: var(--stamp); }

.pair-names { display: grid; gap: 10px; }

@media (max-width: 440px) { .icon-btn .lbl { display: none; } }
