:root {
  --bg: #0d0b14;
  --bg2: #17131f;
  --card: #221b2e;
  --border: #352b47;
  --text: #f3eefb;
  --muted: #9c93ad;
  --red: #e0455f;
  --red-dim: #5a2330;
  --blue: #3f8ae0;
  --blue-dim: #1f3d5c;
  --neutral: #c9b48a;
  --neutral-dim: #4a4234;
  --assassin: #0a0a0a;
  --gold: #e6b34a;
  --cyan: #35d0c0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
body { min-height: 100dvh; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Landing */
#landing { align-items: center; justify-content: center; padding: 24px; }
.lobby-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(160deg, var(--bg2), var(--card));
  border: 1px solid var(--border); border-radius: 20px; padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.logo { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: -.5px; }
.logo span { color: var(--red); }
.tagline { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 14px; font-size: 17px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; outline: none;
}
.field input:focus { border-color: var(--red); }
.fineprint { color: var(--muted); font-size: 11px; text-align: center; margin: 14px 0 0; }

/* Buttons */
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .05s ease, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.score { font-size: 26px; font-weight: 800; min-width: 42px; text-align: center; }
.score.red { color: var(--red); }
.score.blue { color: var(--blue); }
.topmid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.turnpill { font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); }
.turnpill.red { background: var(--red-dim); color: #ffd7de; border-color: var(--red); }
.turnpill.blue { background: var(--blue-dim); color: #d4e8ff; border-color: var(--blue); }
.roomchip { font-size: 11px; letter-spacing: .3px; color: var(--muted); background: transparent; border: none; cursor: pointer; padding: 0; }

/* Share bar — the one link everyone opens to land in the same room */
.sharebar {
  display: block; width: calc(100% - 20px); margin: 8px 10px 0; text-align: left;
  padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(90deg, #2a2140, #241a33);
  border: 1px solid var(--gold); color: var(--text); font: inherit;
}
.sharebar:active { transform: scale(.99); }
.sb-label { font-size: 12px; color: var(--muted); }
.sb-url { display: block; font-size: 15px; font-weight: 800; color: var(--gold); word-break: break-all; margin-top: 2px; }
.sb-copy { font-size: 11px; color: var(--muted); }

/* Role bar — 2x2: Red op/spy, Blue op/spy */
.rolebar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 10px 0; }
.roleopt {
  font-size: 13px; font-weight: 600; padding: 10px 4px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted); cursor: pointer;
}
.roleopt.red.active { color: #fff; border-color: var(--red); background: var(--red-dim); }
.roleopt.blue.active { color: #fff; border-color: var(--blue); background: var(--blue-dim); }

/* Status hint */
.controls { padding: 8px 10px 0; }
.controls:empty { padding: 0; }
.hint { font-size: 13px; color: var(--muted); text-align: center; padding: 4px 0; }
.hint b { font-weight: 800; }

/* Board */
.boardwrap { padding: 8px; display: flex; }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; align-content: start; }
.tile {
  position: relative; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
  text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  font-size: 11px; font-weight: 700; line-height: 1.1; padding: 3px; cursor: pointer;
  user-select: none; overflow: hidden; word-break: break-word;
}
.tile:active { transform: scale(.96); }
.tile.dim { opacity: .55; }
.tile.t-red { background: var(--red-dim); border-color: var(--red); color: #ffd7de; }
.tile.t-blue { background: var(--blue-dim); border-color: var(--blue); color: #d4e8ff; }
.tile.t-neutral { background: var(--neutral-dim); border-color: var(--neutral); color: #efe4c9; }
.tile.t-assassin { background: var(--assassin); border-color: #000; color: #ff5a5a; }
.tile.revealed { font-size: 10px; }
.tile.revealed.t-red { background: var(--red); color: #fff; }
.tile.revealed.t-blue { background: var(--blue); color: #fff; }
.tile.revealed.t-neutral { background: var(--neutral); color: #2a2410; }
.tile.revealed.t-assassin { background: #000; color: #ff5a5a; border-color: #ff5a5a; }
.tile .mark { position: absolute; top: 3px; right: 4px; font-size: 11px; }
/* private pick (pre-reveal) */
.tile.picked { outline: 3px dashed var(--gold); outline-offset: -3px; }
/* wavelength reveal markers */
.tile.wl-intent { box-shadow: inset 0 0 0 3px var(--gold); }
.tile.wl-guess { box-shadow: inset 0 0 0 3px var(--cyan); }
.tile.wl-match { box-shadow: inset 0 0 0 3px #34d399; }

/* Win banner */
.winbanner { margin: 8px; padding: 14px; border-radius: 14px; text-align: center; font-size: 20px; font-weight: 800; }
.winbanner.red { background: var(--red); color: #fff; }
.winbanner.blue { background: var(--blue); color: #fff; }
.winbanner small { display: block; margin-top: 6px; font-size: 12px; font-weight: 600; opacity: .9; }

/* Wavelength panel */
.samepage { margin: 8px 10px 0; padding: 12px; border-radius: 14px; background: linear-gradient(160deg, #241a33, #1c1526); border: 1px solid var(--gold); }
.wl-head { font-size: 15px; font-weight: 800; color: var(--gold); margin-bottom: 6px; }
.wl-prompt { font-size: 13px; color: var(--muted); line-height: 1.35; }
.wl-prompt b { color: var(--text); }
.wl-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.wl-count { font-size: 13px; color: var(--muted); }
.wl-btns { display: flex; gap: 8px; }
.wl-line { font-size: 13px; margin-top: 6px; line-height: 1.4; }
.wl-score { color: var(--gold); font-weight: 700; margin-left: 4px; }
.c-red { color: var(--red); } .c-blue { color: var(--blue); }

/* Feed */
.feed { margin: 8px 10px 0; }
.feed summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.feed ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 130px; overflow-y: auto; }
.feed li { font-size: 12px; color: var(--muted); padding: 3px 0; border-bottom: 1px solid var(--border); }
.feed li.game { color: var(--text); font-weight: 700; }
.feed li.wave { color: var(--gold); }

/* Bottom */
.bottombar { display: flex; gap: 8px; padding: 10px; margin-top: auto; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.bottombar .btn { flex: 1; }
.endturn { background: var(--gold); border-color: var(--gold); color: #201800; font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: #000; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: .95; }
