:root {
  --bg: #0e0e10;
  --panel: #1a1a1c;
  --panel-2: #262629;
  --ink: #f4f4f5;
  --muted: #b6b6bd;
  --line: #333338;
  --gold: #e0b558;
  --red: #b8453f;
  --green: #4f8f5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #1c1c20, var(--bg) 70%);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 2.6rem; color: var(--gold); letter-spacing: .06em; }
.sub { color: var(--muted); margin: .25rem 0 1rem; }
.hidden { display: none !important; }
.error { color: #ff8b84; min-height: 1.2em; margin: .6rem 0 0; }

/* ------------------------------------------------------------ screens */
.screen { min-height: 100vh; }
#screen-home, #screen-join, #screen-lobby {
  display: flex; align-items: center; justify-content: center; padding: 2rem 1rem;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 2rem; width: 100%; max-width: 420px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.panel.wide { max-width: 620px; }

/* ------------------------------------------------------------ controls */
button {
  font: inherit; font-weight: 600; border-radius: 9px; border: 1px solid transparent;
  padding: .6rem 1rem; cursor: pointer; transition: filter .12s, opacity .12s;
}
button:hover:not(:disabled) { filter: brightness(1.12); }
button:disabled { opacity: .4; cursor: not-allowed; }
.primary { background: var(--gold); color: #241a08; }
.ghost { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.danger { background: var(--red); color: #fff; }
.big { width: 100%; padding: .8rem; font-size: 1.05rem; margin-top: 1rem; }

input {
  font: inherit; background: #141416; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: .6rem .8rem; width: 100%;
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: block; margin: 1rem 0 .35rem; color: var(--muted); font-size: .9rem; }

.row { display: flex; gap: .5rem; }
.row input { flex: 1; }
.or { text-align: center; color: var(--muted); margin: 1rem 0 .5rem; font-size: .85rem; }
.code { color: var(--gold); font-family: ui-monospace, monospace; letter-spacing: .12em; }

/* admin login on the home panel */
.login { margin-bottom: .5rem; }
.login label:first-child { margin-top: 0; }
#btn-logout { width: 100%; margin-top: .5rem; }

/* --------------------------------------------------------- characters */
.character-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.character {
  display: flex; align-items: center; gap: .6rem; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .7rem; cursor: pointer;
}
.character.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.character:disabled { opacity: .35; cursor: not-allowed; }
.swatch { width: 20px; height: 20px; border-radius: 50%; flex: none; border: 2px solid #0004; }
.character .who { font-weight: 650; font-size: .92rem; color: var(--ink); }
.character .de { color: var(--muted); font-size: .78rem; }

/* ------------------------------------------------------------- lists */
.player-list { list-style: none; margin: 0; padding: 0; }
.player-list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.player-list li:last-child { border-bottom: 0; }
.player-list .meta { margin-left: auto; color: var(--muted); font-size: .82rem; }
.offline { opacity: .45; }
.is-turn { color: var(--gold); font-weight: 700; }
.eliminated { text-decoration: line-through; opacity: .55; }

/* -------------------------------------------------------------- game */
.game-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem; padding: 1rem; align-items: start; max-width: 1600px; margin: 0 auto;
}
.board-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: .75rem; position: sticky; top: 1rem;
}
#board { width: 100%; }
.board-svg { width: 100%; height: auto; display: block; }
.room-label { font-weight: 700; letter-spacing: .06em; pointer-events: none; }
.weapon-label { pointer-events: none; }
.token { pointer-events: none; }
.token-out { opacity: .45; }
.target { cursor: pointer; }
.target:hover rect, rect.target:hover { opacity: .8; }
.target-room:hover rect { opacity: .55; }

.side { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: .9rem 1rem;
}
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.actions button { flex: 1 1 46%; }

.dice { display: flex; gap: .5rem; margin: .5rem 0; }
.die {
  width: 40px; height: 40px; border-radius: 8px; background: #ededed; color: #1a1a1a;
  display: grid; place-items: center; font-size: 1.3rem; font-weight: 700;
}

.cards { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .25rem .7rem; font-size: .85rem;
}
.chip.suspect { border-color: #8d5a5a; }
.chip.weapon { border-color: #8d7c5a; }
.chip.room { border-color: #5a7d8d; }

.log { max-height: 220px; overflow-y: auto; font-size: .86rem; color: var(--muted); }
.log div { padding: .18rem 0; border-bottom: 1px solid #262629; }

/* ------------------------------------------------------------- notes */
.notes-card table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.notes-card th { text-align: left; font-weight: 500; color: var(--muted); padding: .15rem 0; }
.notes-card td { text-align: center; }
.note-cell {
  width: 24px; height: 22px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--panel-2); color: var(--ink); cursor: pointer; font-size: .8rem;
  padding: 0;
}
.note-cell[data-v="no"] { background: #4a2020; color: #ff9d95; }
.note-cell[data-v="yes"] { background: #1f4426; color: #8fe3a1; }
.notes-group { margin-top: .5rem; color: var(--gold); font-size: .75rem; letter-spacing: .08em; }

/* ------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.78);
  display: grid; place-items: center; padding: 1rem; z-index: 50;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.5rem; width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto;
}
.modal-actions { display: flex; gap: .5rem; margin-top: 1.2rem; }
.modal-actions button { flex: 1; }
.pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; margin-bottom: .4rem; }
.pick {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: .5rem .6rem; cursor: pointer; text-align: left; font-size: .88rem; color: var(--ink);
}
.pick.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.reveal {
  background: var(--panel-2); border: 1px dashed var(--gold); border-radius: 10px;
  padding: 1rem; text-align: center; font-size: 1.15rem; font-weight: 650; color: var(--gold);
}

/* ------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--red); color: #fff; padding: .7rem 1.2rem; border-radius: 10px;
  z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

@media (max-width: 1050px) {
  .game-layout { grid-template-columns: 1fr; }
  .board-wrap { position: static; }
}
