:root {
  --bg: #111014;
  --card: #1C1A20;
  --card2: #24212A;
  --line: #2E2B33;
  --text: #EDE6DA;
  --muted: #8C857C;
  --soft: #B9B1A6;
  --accent: #B3261E;
  --accent-text: #fff;
  --town: #6C9BD0;
  --town-bg: #1B2433;
  --mafia: #E8776B;
  --mafia-bg: #2A1517;
  --solo: #A9A0D6;
  --solo-bg: #1C1A28;
  --gold: #C9A25A;
  --star: #E0B54A;
  --ok: #8FC79A;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 15px; }
body { min-height: 100vh; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: inherit; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.top { height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--card2); gap: 12px; flex-shrink: 0; }
.top .title { font-weight: 600; }
.top .link { background: none; border: 0; color: var(--muted); padding: 10px 0; min-width: 52px; text-align: left; }
.top .right { min-width: 52px; text-align: right; }

.page { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.center { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }

.h1 { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 26px; line-height: 1.1; margin: 0; }
.h-logo { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 44px; line-height: 1; margin: 0; }
.h2 { font-family: 'Unbounded', sans-serif; font-weight: 500; font-size: 18px; margin: 0; }
.label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: 13px; }
.mono { font-family: 'IBM Plex Mono', monospace; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.spacer { margin-top: auto; }

.btn { min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid #3A3640; background: transparent; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); min-height: 56px; font-size: 17px; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.ghost { border: 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.big-btn { width: 100%; text-align: left; display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); }
.big-btn.hero { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-btn .ico { width: 46px; height: 46px; border-radius: 13px; background: var(--card2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.big-btn.hero .ico { background: rgba(0,0,0,.22); }
.big-btn .t { font-size: 17px; font-weight: 600; }
.big-btn.hero .t { font-family: 'Unbounded', sans-serif; font-weight: 500; font-size: 19px; }
.big-btn .s { font-size: 13px; color: var(--muted); }
.big-btn.hero .s { color: #F6DCD8; }

.seg { display: grid; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.seg button.on { background: #2E2B33; color: var(--text); }
.seg button small { font-weight: 400; font-size: 11px; color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 16px; border-radius: 14px; background: var(--card); min-height: 52px; }
.stepper button { width: 44px; height: 44px; border: 0; border-radius: 10px; background: #2A2830; font-size: 20px; }
.stepper .val { width: 34px; text-align: center; font-family: 'IBM Plex Mono', monospace; font-size: 18px; }

.mode { width: 100%; text-align: left; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.mode.on { border: 2px solid var(--accent); background: var(--mafia-bg); }
.mode .name { font-family: 'Unbounded', sans-serif; font-size: 19px; font-weight: 500; }
.mode .desc { font-size: 14px; line-height: 1.45; color: var(--soft); }

.input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid #3A3640; background: #15141A; width: 100%; }
.input.code { font: 600 18px 'IBM Plex Mono', monospace; letter-spacing: .2em; text-transform: uppercase; }

.room-row { padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--card); display: flex; align-items: center; gap: 12px; }
.chip { padding: 3px 9px; border-radius: 7px; font-size: 12px; font-weight: 600; background: var(--card2); }
.chip.classic { color: #CFC7BB; background: #2A2830; }
.chip.syndicate { color: #E8B4AE; background: #3A1D20; }
.chip.draft { color: #D9C79A; background: #33291A; }
.chip.town { color: #A9C8E8; background: #23324A; }
.chip.mafia { color: #F1C9C3; background: #3A1D20; }
.chip.solo { color: #C4BCEB; background: #2C2945; }
.bar { height: 6px; border-radius: 3px; background: #2A2830; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; }

.code-big { font-family: 'Unbounded', sans-serif; font-size: 34px; font-weight: 700; letter-spacing: .08em; }
.pl { min-height: 52px; padding: 0 4px 0 12px; background: var(--card); border-radius: 12px; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.pl.empty { border: 1px dashed #3A3640; background: transparent; justify-content: center; color: #6E685F; font-size: 14px; }
.ava { width: 30px; height: 30px; border-radius: 15px; background: #3A3640; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.ava.me { background: var(--accent); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: #555; flex-shrink: 0; }
.dot.on { background: var(--ok); }
.x { width: 36px; height: 44px; border: 0; background: transparent; color: #6E685F; margin-left: auto; display: flex; align-items: center; justify-content: center; }

.tabs { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); }
.tabs button { height: 50px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 600; font-size: 14px; }
.tabs button small { font: 500 11px 'IBM Plex Mono', monospace; }
.tabs button.on.town { background: #23324A; color: #DCE6F2; }
.tabs button.on.mafia { background: #3A1D20; color: #F6DCD8; }
.tabs button.on.solo { background: #2C2945; color: #E6E2F6; }

.role-row { min-height: 58px; padding: 6px 8px 6px 14px; border-radius: 12px; background: var(--card); display: flex; align-items: center; gap: 6px; }
.role-row.mafia { background: var(--mafia-bg); }
.role-row.solo { background: var(--solo-bg); }
.role-row.off { opacity: .55; }
.stars { font-size: 11px; color: var(--star); letter-spacing: 1px; }
.switch { width: 52px; height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.switch i { width: 46px; height: 28px; border-radius: 14px; background: #3A3640; display: flex; padding: 3px; }
.switch i::after { content: ''; width: 22px; height: 22px; border-radius: 11px; background: #fff; }
.switch.on i { background: var(--accent); justify-content: flex-end; }
.switch:disabled { opacity: .45; }
.info { width: 36px; height: 44px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; }

.phase { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.timer { width: 60px; height: 60px; border-radius: 30px; border: 3px solid var(--accent); display: flex; align-items: center; justify-content: center; font-family: 'IBM Plex Mono', monospace; font-size: 16px; flex-shrink: 0; }
.role-card { padding: 16px; border-radius: 16px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); background: var(--card); text-align: left; width: 100%; }
.role-card.town { background: var(--town-bg); border-color: #2E3E58; }
.role-card.mafia { background: var(--mafia-bg); border-color: #5A2A26; }
.role-card.solo { background: var(--solo-bg); border-color: #3A3560; }
.role-card .rn { font-family: 'Unbounded', sans-serif; font-size: 22px; font-weight: 700; }

.targets { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.target { min-height: 72px; border-radius: 12px; border: 1px solid #2A2836; background: #15141E; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px; font-size: 14px; }
.target b { font-size: 17px; }
.target.on { border: 2px solid var(--accent); background: var(--mafia-bg); color: #fff; }
.target.second.on { border-color: var(--gold); background: #2A2217; }
.target small { font-size: 11px; color: var(--muted); }

.plist { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip { padding: 6px 10px; border-radius: 10px; background: var(--card); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pchip.dead { opacity: .45; text-decoration: line-through; }
.pchip .r { font-size: 11px; color: var(--muted); text-decoration: none; }

.news { padding: 14px 16px; border-radius: 14px; background: #1A1714; color: #EDE6DA; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.45; }
.news .h { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.private { padding: 12px 14px; border-radius: 12px; background: #23324A; color: #DCE6F2; font-size: 14px; }

.chat { flex: 1; min-height: 160px; max-height: 320px; overflow-y: auto; padding: 12px; border-radius: 14px; background: var(--card); display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; }
.chat.mafia { background: #1F1218; }
.chat.dead { background: #16151B; }
.chat b { color: #E8B4AE; }
.chat-form { display: flex; gap: 8px; }
.chat-form .input { height: 46px; }

.vote-row { min-height: 54px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.vote-row.on { border: 2px solid var(--accent); }
.vote-row .bar { max-width: 110px; }
.vote-row .bar > i { background: var(--accent); }

.result { text-align: center; padding: 24px 16px; border-radius: 18px; background: var(--card); }
.win { color: var(--ok); }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 12px 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.modal .grab { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: #3A3640; }
.kv { display: flex; gap: 12px; font-size: 14px; line-height: 1.45; }
.kv span:first-child { width: 72px; flex-shrink: 0; color: var(--muted); font-size: 13px; }

.banner { position: fixed; top: 0; left: 0; right: 0; z-index: 30; background: #5A3A10; color: #FFE7B8; text-align: center; padding: 8px; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: #2E2B33; color: var(--text); padding: 12px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
