:root {
  --bg: #0f0d0b;
  --paper: #efe4cc;
  --paper-2: #e3d4b3;
  --ink: #2a2118;
  --ink-soft: #5b4b3a;
  --tape: #f2c230;
  --red: #b3261e;
  --green: #2f7d4a;
  --muted: #a89a86;
  --line: rgba(42, 33, 24, .18);
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg) radial-gradient(ellipse at top, #2a2219 0%, var(--bg) 70%) fixed;
  color: #eadfca;
  font: 16px/1.55 "Courier Prime", "Courier New", ui-monospace, monospace;
  min-height: 100vh;
}
h1, h2, h3 { font-family: "Special Elite", "Courier New", monospace; font-weight: 400; margin: 0 0 .4em; line-height: 1.2; }
a { color: var(--tape); }
.tape {
  background: repeating-linear-gradient(-45deg, var(--tape) 0 22px, #111 22px 44px);
  height: 14px;
}
.tape-text {
  background: var(--tape); color: #111; text-align: center; font-weight: 700; letter-spacing: .25em;
  font-size: 12px; padding: 4px 8px; text-transform: uppercase;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; color: var(--muted); font-size: 14px; }
.topbar b { color: #eadfca; }
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--tape); color: #111; padding: 12px 18px; border-radius: 8px;
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid #3a3229; }
.file .btn.ghost { color: var(--ink); border-color: var(--ink-soft); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ok { background: var(--green); color: #fff; }

.file {
  background: linear-gradient(var(--paper), var(--paper-2));
  color: var(--ink);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: 0 18px 40px rgba(0,0,0,.55), inset 0 0 60px rgba(120, 90, 50, .18);
  position: relative;
}
.file::before {
  content: ""; position: absolute; top: -12px; left: 24px; width: 120px; height: 24px;
  background: var(--paper-2); border-radius: 8px 8px 0 0;
}
.file .kicker { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
.file h2 { font-size: 26px; }
.stamp {
  display: inline-block; border: 3px solid var(--red); color: var(--red); padding: 2px 10px;
  transform: rotate(-6deg); font-weight: 700; letter-spacing: .2em; margin: 0 0 10px;
}
.small { font-size: 14px; color: var(--ink-soft); }
.suspects { padding-left: 20px; }
.question { font-weight: 700; border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 18px; }

table.lock { border-collapse: collapse; width: 100%; margin: 10px 0; }
table.lock td { border-bottom: 1px solid var(--line); padding: 8px 6px; vertical-align: middle; }
table.lock td.code { font-size: 22px; font-weight: 700; letter-spacing: .15em; white-space: nowrap; width: 1%; padding-right: 16px; }

blockquote { margin: 14px 0; padding: 14px 16px; background: rgba(255,255,255,.45); border-left: 4px solid var(--ink-soft); border-radius: 4px; }
blockquote.note { font-size: 19px; letter-spacing: .12em; word-break: break-word; font-weight: 700; }
blockquote.statement { white-space: pre-line; font-style: italic; }
.clock { display: block; width: 220px; max-width: 70%; margin: 14px auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }
ol.clues li { margin: 4px 0; }
.quotes p { margin: 6px 0; padding: 8px 12px; background: rgba(255,255,255,.4); border-radius: 6px; }

.wires { background: #8c857b; border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.wire { display: flex; align-items: center; gap: 10px; height: 30px; }
.wire-n { color: #1b1510; font-weight: 700; width: 16px; font-size: 13px; }
.wire-line { flex: 1; height: 9px; border-radius: 5px; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.35); }

.answer { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.answer input { flex: 1 1 200px; }
input, select {
  font: inherit; padding: 12px 14px; border-radius: 8px; border: 2px solid var(--ink-soft);
  background: #fffaf0; color: var(--ink); min-width: 0;
}
input:focus, select:focus { outline: 3px solid var(--tape); outline-offset: 1px; }
.feedback { min-height: 24px; margin-top: 10px; font-weight: 700; }
.feedback.bad { color: var(--red); }
.feedback.good { color: var(--green); }
.hints { margin-top: 18px; }
.hint { background: #fff6d8; border: 1px dashed #c7a84a; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }

.progress { display: flex; gap: 6px; margin: 0 0 18px; }
.progress span { flex: 1; height: 8px; border-radius: 4px; background: #2e2720; }
.progress span.done { background: var(--tape); }
.progress span.now { background: #8a6d1d; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.center { text-align: center; }
.login { max-width: 380px; margin: 8vh auto 0; }
.login form { display: grid; gap: 12px; }
.login label { font-size: 13px; color: var(--ink-soft); display: grid; gap: 4px; }
.error { color: var(--red); font-weight: 700; min-height: 1.4em; }
.big-time { font-size: 40px; font-family: "Special Elite", monospace; color: var(--ink); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.flash { animation: flash .8s; }
@keyframes flash { from { box-shadow: 0 0 0 6px var(--green), 0 18px 40px rgba(0,0,0,.55); } }
.spinner { width: 46px; height: 46px; border: 4px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.members { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.chip { background: rgba(0,0,0,.08); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; font-size: 14px; }

/* ---------- personajes ---------- */
.px { image-rendering: pixelated; display: block; }
.who { display: inline-flex; align-items: center; gap: 8px; }
.who .px { background: var(--paper); border-radius: 6px; padding: 2px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 8px; }
.avatar-card {
  appearance: none; font: inherit; cursor: pointer; display: grid; justify-items: center; gap: 4px;
  background: #fffaf0; border: 2px solid var(--line); border-radius: 10px; padding: 10px 6px; color: var(--ink);
  transition: transform .08s, border-color .15s;
}
.avatar-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--ink-soft); }
.avatar-card.mine { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,125,74,.25); background: #eef7ee; }
.avatar-card.taken { cursor: not-allowed; opacity: .5; }
.avatar-card.taken .px { filter: grayscale(1); }
.av-name { font-weight: 700; font-size: 13px; text-align: center; line-height: 1.2; }
.av-owner { font-size: 11px; color: var(--ink-soft); text-align: center; line-height: 1.2; }
.avatar-card.mine .av-owner { color: var(--green); font-weight: 700; }
.team { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 14px 0; }
.team-member { display: grid; justify-items: center; gap: 4px; font-size: 14px; }
.team-member .px, .av-empty { background: #fffaf0; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.av-empty { width: 56px; height: 56px; display: grid; place-items: center; color: var(--muted); font-size: 24px; }
.mini { display: inline-flex; align-items: center; gap: 6px; }
.mini .px { background: var(--paper); border-radius: 4px; }

/* ---------- admin ---------- */
.admin .wrap { max-width: 1100px; }
.panel { background: #1b1713; border: 1px solid #332b22; border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 20px; color: var(--tape); }
.panel input, .panel select { background: #0f0d0b; color: #eadfca; border-color: #3a3229; padding: 9px 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.gcard { background: #231e19; border: 1px solid #3a3229; border-radius: 10px; padding: 14px; display: grid; gap: 8px; }
.gcard h3 { font-size: 18px; margin: 0; color: #fff; }
.badge { display: inline-block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.badge.waiting { background: #3a3229; color: #d9cbb3; }
.badge.active { background: #8a6d1d; color: #fff; }
.badge.finished { background: var(--green); color: #fff; }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.stats b { color: #eadfca; }
.log { font-size: 12px; color: var(--muted); max-height: 92px; overflow: auto; border-top: 1px solid #332b22; padding-top: 6px; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #332b22; }
table.users select { padding: 5px 8px; }
.table-scroll { overflow-x: auto; }
.mono { font-family: ui-monospace, monospace; }
details summary { cursor: pointer; color: var(--tape); }
.muted { color: var(--muted); }
@media (max-width: 520px) {
  .file { padding: 22px 16px; }
  .file h2 { font-size: 22px; }
  table.lock td.code { font-size: 18px; }
  blockquote.note { font-size: 16px; }
}
