:root {
  --bg: #12101f;
  --panel: #1e1a33;
  --panel2: #2a2447;
  --text: #ece8ff;
  --muted: #9a92c2;
  --accent: #f5c542;
  --good: #4cd17a;
  --bad: #ff6b6b;
  --door: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: radial-gradient(circle at top, #241d45, var(--bg) 60%) fixed; color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0.4em 0; }
h1 { color: var(--accent); }
a { color: var(--accent); }
button {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 14px 18px; cursor: pointer;
  background: var(--accent); color: #1b1630; min-height: 48px;
}
button.secondary { background: var(--panel2); color: var(--text); }
button.selected { outline: 3px solid var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
input, select {
  font: inherit; padding: 12px; border-radius: 10px; border: 1px solid #4a4175; background: #0f0d1c; color: var(--text);
  width: 100%; min-height: 48px;
}
.panel { background: var(--panel); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.8em; color: var(--muted); font-weight: normal; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 6px 0; border-bottom: 1px solid #2f2950; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.urgent { color: var(--bad); }
.window-open { color: var(--good); font-weight: 700; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 1.8em; height: 1.8em;
  border-radius: 50%; font-size: 1.1em; box-shadow: 0 0 0 2px #0008; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
img.icon { height: 1.6em; aspect-ratio: 3 / 2; object-fit: contain; vertical-align: middle; }
.slot .e img.icon { height: 2.4em; }
img.card { width: 140px; border-radius: 8px; box-shadow: 0 4px 16px #000a; }

/* Map */
.map { display: grid; gap: 0; }
.room {
  background: var(--panel2); border-radius: 10px; padding: 6px; min-height: 70px;
  display: flex; flex-direction: column; gap: 4px; border: 2px solid transparent;
}
.room .name { font-weight: 700; font-size: 0.85em; }
.room .who { display: flex; flex-wrap: wrap; gap: 4px; }
.door { background: #8a6d3b; border-radius: 3px; align-self: center; justify-self: center; }
.door.h { width: 100%; height: 22px; }
.door.v { height: 100%; width: 22px; }

/* Host */
.host { display: grid; grid-template-columns: 1fr 360px; gap: 16px; padding: 16px; min-height: 100vh; }
.host .map .room { min-height: 110px; font-size: 1.1em; }
.host .map .avatar { font-size: 1.5em; }
.lobby-host { max-width: 900px; margin: 0 auto; padding: 24px; text-align: center; }
.qr svg { width: 260px; height: 260px; background: #fff; padding: 8px; border-radius: 12px; }
.code { font-size: 3em; letter-spacing: 0.2em; color: var(--accent); font-weight: 800; }
.players-big { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; font-size: 1.3em; }
.feed li { font-size: 0.95em; }
table.results { width: 100%; border-collapse: collapse; }
table.results td, table.results th { padding: 8px; border-bottom: 1px solid #2f2950; text-align: left; vertical-align: top; }

/* Phone */
.phone { max-width: 520px; margin: 0 auto; padding: 12px 12px 110px; }
.chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chars button { padding: 0; background: none; border-radius: 8px; overflow: hidden; line-height: 0; }
.chars button img { width: 100%; }
.chars button:disabled { opacity: 0.25; }
.targets li { display: flex; justify-content: space-between; }
.tag { font-size: 0.75em; padding: 2px 8px; border-radius: 99px; background: var(--panel2); }
.tag.seen { background: #3b5bdb; }
.tag.stolen { background: var(--good); color: #102; }
.tag.caught { background: var(--bad); color: #102; }
.slots { display: flex; gap: 8px; }
.slot { flex: 1; text-align: center; background: var(--panel2); border-radius: 10px; padding: 10px; font-size: 1.1em; }
.slot .e { font-size: 2em; display: block; }
.moves { display: grid; gap: 8px; }
.moves button { text-align: left; }
.note-room { padding: 8px 0; border-bottom: 1px solid #2f2950; }
button.note, div.note {
  display: flex; gap: 8px; align-items: center; width: 100%; margin-top: 6px; min-height: 44px;
  padding: 8px 12px; background: var(--panel2); color: var(--text); font-weight: normal; text-align: left;
}
button.note.bad { color: var(--bad); }
.log { max-height: 240px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 0.85em; }
.big { width: 100%; font-size: 1.15em; }
.status-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }

#toasts { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 10; width: min(92vw, 480px); }
.toast { background: var(--panel2); padding: 12px 16px; border-radius: 12px; box-shadow: 0 4px 20px #0008; }
.toast.good { border-left: 6px solid var(--good); }
.toast.bad { border-left: 6px solid var(--bad); }
.toast.info { border-left: 6px solid var(--accent); }
#conn-status { position: fixed; top: 8px; right: 8px; background: var(--bad); color: #fff; padding: 6px 12px; border-radius: 8px; z-index: 20; }

@media (max-width: 900px) { .host { grid-template-columns: 1fr; } }
button.mini { min-height: 0; padding: 2px 8px; font-size: 0.7em; border-radius: 8px; }
#version { position: fixed; bottom: 6px; left: 8px; font-size: 0.75em; color: var(--muted); opacity: 0.7; z-index: 1; pointer-events: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); box-shadow: 0 -4px 20px #0008; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { background: none; color: var(--muted); border-radius: 0; padding: 8px 0; font-size: 1.3em; min-height: 58px; }
.tabbar button span { display: block; font-size: 0.55em; font-weight: 600; }
.tabbar button.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); vertical-align: middle; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--panel2); border-radius: 99px; padding: 4px 10px; font-size: 0.9em; }
.chip small { color: var(--muted); }
.chip.seen { box-shadow: inset 0 0 0 2px #3b5bdb; }
.chip.stolen { background: var(--good); color: #102; }
.chip.stolen small, .chip.caught small { color: #102; }
.chip.caught { background: var(--bad); color: #102; }
button.slot { font: inherit; color: var(--text); min-height: 0; }
.slot.steal { box-shadow: inset 0 0 0 3px var(--good); background: #1f3a2c; }
.slot.steal.on { background: var(--good); color: #102; }
.slot b { display: block; font-size: 0.8em; margin-top: 4px; }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.moves button { min-height: 64px; font-size: 1.05em; }
.hint { color: var(--muted); text-align: center; margin: 10px 0; }
.dark-banner { background: #000; color: #c9c2ff; padding: 10px 14px; border-radius: 12px; margin: 6px 0; font-weight: 700; }
.lights-out .room { filter: brightness(0.3); }
.lights-out .door { filter: brightness(0.3); }
.who-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 10px; }
.who-pick button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; font-size: 0.85em; }
