:root {
  --bg: #0e1214;
  --paper: #1a2226;
  --ink: #e8efe8;
  --muted: #8aa0a0;
  --line: #2a3a3c;
  --accent: #3ecf9a;
  --warn: #e35d6a;
  --safe: #1e2a2c;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  padding: 12px 12px 28px;
}
.app { max-width: 520px; margin: 0 auto; }
header { margin: 4px 0 14px; }
.brand {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin: 0 0 4px;
}
h1 { margin: 0; font-size: 28px; letter-spacing: 0.04em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
#levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}
#levels button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--safe);
  color: var(--ink);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  padding: 0;
}
#levels button.on { border-color: var(--accent); color: var(--accent); }
#levels button.lock { opacity: 0.35; }
.story {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 14px;
}


.app { max-width: 640px; margin: 0 auto; }

.board-wrap { overflow-x: auto; margin: 0 0 10px; }
#board {
  --cols: 6;
  display: grid;
  grid-template-columns: 16px repeat(var(--cols), minmax(44px, 1fr));
  gap: 0;
  min-width: 340px;
  background: #080c0e;
}
.hd {
  font-size: 10px;
  color: var(--muted);
  display: grid;
  place-items: center;
  min-height: 14px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid #ffffff10;
  color: var(--ink);
  padding: 0;
  min-height: 48px;
  overflow: hidden;
}
.cell.block { filter: saturate(0.7); }
.cell.wall-n { border-top: 3px solid var(--wall); }
.cell.wall-s { border-bottom: 3px solid var(--wall); }
.cell.wall-w { border-left: 3px solid var(--wall); }
.cell.wall-e { border-right: 3px solid var(--wall); }
.roomlab {
  position: absolute;
  top: 2px;
  left: 3px;
  z-index: 2;
  font-size: 7px;
  letter-spacing: 0.08em;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.item-img {
  position: absolute;
  left: 8%;
  top: 16%;
  width: 84%;
  height: 78%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 1px 1px #0008);
}
.item-img.win {
  left: 4%;
  top: 4%;
  width: 92%;
  height: 46%;
  z-index: 0;
}
.cell.has-window .item-img:not(.win) {
  top: 28%;
  height: 66%;
}

.xmark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  color: #e35d6acc;
  pointer-events: none;
  z-index: 3;
}
.who {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 42%;
  z-index: 4;
  border-radius: 3px;
  border: 1px solid #0008;
  object-fit: cover;
  object-position: top;
}
.v {
  position: absolute;
  left: 3px;
  bottom: 3px;
  z-index: 4;
  background: var(--warn);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
}

.tools {
  display: flex;
  gap: 6px;
  margin: 10px 0;
}
.tools button, .actions button, .win button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--safe);
  color: var(--ink);
  padding: 10px 8px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
}
.tools button.on { border-color: var(--accent); color: var(--accent); }
#btn-submit { background: #16352d; border-color: var(--accent); color: var(--accent); }

#people {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 14px;
}
.person {
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  color: inherit;
}
.person img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  object-position: top;
  border-radius: 6px;
  background: #111;
}
.person strong, .person span { display: block; }
.person span { font-size: 11px; color: var(--muted); }
.person.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.person.used { opacity: 0.55; }
.person.victim { border-color: #e35d6a66; }

h3 { margin: 16px 0 8px; font-size: 13px; letter-spacing: 0.16em; color: var(--muted); }
#clues { margin: 0; padding: 0; list-style: none; }
#clues li {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 8px 10px;
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.4;
}
#clues i {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #16352d;
  color: var(--accent);
  font-style: normal;
  font-size: 11px;
  margin-right: 4px;
}
.help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 14px 0 0;
}
#status {
  min-height: 20px;
  margin: 8px 0 0;
  color: #f0c36a;
  font-size: 13px;
}
.actions { display: flex; gap: 6px; margin-top: 10px; }

#overlay {
  position: fixed;
  inset: 0;
  background: #000a;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 5;
}
#overlay[hidden] { display: none; }
.card.win {
  background: #141c1e;
  border: 1px solid var(--accent);
  padding: 22px 18px;
  max-width: 360px;
  text-align: center;
}
.card.win img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
}
.card.win h2 { margin: 10px 0 6px; font-size: 22px; }
.tag { letter-spacing: 0.2em; color: var(--accent); font-size: 11px; }
.card.win button { margin-top: 12px; width: 100%; }

@media (max-width: 420px) {
  .plan { grid-template-columns: 1fr; }
  #minimap { grid-template-columns: repeat(4, 1fr); }
  .mini-room { min-height: 40px; }
}
