/* ============ tokens ============ */
:root {
  --bg: #0d0b14;
  --bg-2: #14111f;
  --surface: #1a1626;
  --surface-2: #221c33;
  --border: #322a4a;
  --text: #f3efe6;
  --text-dim: #a49bb8;
  --gold: #c9982a;
  --gold-bright: #e8b93c;
  --blood: #a3202c;
  --blood-bright: #d92637;
  --night: #0a0e1f;
  --ok: #3dbd72;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0,0,0,.5);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 'Inter', system-ui, sans-serif;
  overflow-x: hidden;
  transition: background 1.2s ease;
  touch-action: manipulation;
}
body.night { background: var(--night); }
h1, h2, h3 { font-family: 'Playfair Display', serif; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }

/* ambient */
.bg-noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .05; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}
.bg-spot {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 70% 45% at 50% -5%, rgba(201,152,42,.13), transparent 65%);
  transition: opacity 1.2s ease;
}
body.night .bg-spot {
  background: radial-gradient(ellipse 55% 38% at 50% -5%, rgba(90,120,220,.10), transparent 65%);
}

.screen { position: relative; z-index: 1; min-height: 100dvh; padding-top: var(--safe-t); }
.hidden { display: none !important; }

/* ============ auth ============ */
#screen-auth { display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.auth-wrap { width: 100%; max-width: 400px; animation: rise .6s ease both; }
.logo { text-align: center; margin-bottom: 28px; }
.logo-hat { width: 72px; color: var(--text); filter: drop-shadow(0 6px 18px rgba(201,152,42,.35)); }
.logo h1 {
  font-size: 52px; font-weight: 800; letter-spacing: .14em; margin-top: 4px;
  background: linear-gradient(180deg, #f7ecd0, var(--gold-bright) 65%, #8a6516);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 42px rgba(201,152,42,.25);
}
.tagline { color: var(--text-dim); font-style: italic; letter-spacing: .35em; font-size: 13px; }

.card {
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 10px; border-radius: 8px; color: var(--text-dim);
  font-weight: 600; transition: all .2s ease; min-height: 44px;
}
.tab.active { background: var(--surface-2); color: var(--gold-bright); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field input[type=text], .field input[type=password], .field input[type=number] {
  width: 100%; padding: 12px 14px; min-height: 48px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,152,42,.18); }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 48px; }
.pass-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center; color: var(--text-dim);
}
.form-error { color: var(--blood-bright); font-size: 14px; min-height: 21px; margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; min-height: 48px; border-radius: 12px;
  font-weight: 700; letter-spacing: .02em;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
  user-select: none;
}
.btn:active { transform: scale(.965); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 60%, #9a7420);
  color: #17110a;
  box-shadow: 0 4px 20px rgba(201,152,42,.35), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-gold:hover { box-shadow: 0 6px 26px rgba(201,152,42,.5), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-blood {
  background: linear-gradient(180deg, var(--blood-bright), var(--blood));
  color: #fff; box-shadow: 0 4px 18px rgba(163,32,44,.4);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.auth-note { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 16px; }

/* ============ topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(13,11,20,.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
body.night .topbar { background: rgba(10,14,31,.82); }
.brand { display: flex; align-items: center; gap: 8px; font-family: 'Playfair Display', serif; font-weight: 800; letter-spacing: .1em; }
.brand svg { color: var(--text); }
.profile { display: flex; align-items: center; gap: 10px; }
.profile-meta { display: flex; flex-direction: column; line-height: 1.15; }
.profile-meta b { font-size: 14px; }
.profile-meta small { color: var(--text-dim); font-size: 11px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
  background: var(--av, #6a5acd); box-shadow: inset 0 -6px 12px rgba(0,0,0,.3);
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  color: var(--text-dim); transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--gold-bright); background: var(--surface-2); }

/* ============ lobby ============ */
.lobby-body { max-width: 640px; margin: 0 auto; padding: 18px 16px calc(28px + var(--safe-b)); }
.lobby-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.join-code { display: flex; gap: 8px; }
.join-code input {
  flex: 1; min-width: 0; padding: 12px 14px; min-height: 48px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  text-transform: uppercase; letter-spacing: .12em; font-weight: 600;
}
.join-code input:focus { outline: none; border-color: var(--gold); }
.section-title { font-size: 20px; margin: 22px 0 12px; color: var(--text); }
.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-item {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer;
  transition: transform .18s ease, border-color .2s ease; animation: rise .35s ease both;
}
.room-item:hover { border-color: var(--gold); transform: translateY(-2px); }
.room-item .room-info { flex: 1; min-width: 0; }
.room-item .room-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .room-info small { color: var(--text-dim); }
.room-count { font-weight: 700; color: var(--gold-bright); white-space: nowrap; }
.lock-icon { color: var(--text-dim); flex: none; }
.empty-state { text-align: center; color: var(--text-dim); padding: 34px 12px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ============ chat ============ */
.chat-box {
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.chat-messages { height: 240px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.chat-msg { display: flex; gap: 8px; align-items: flex-start; animation: rise .25s ease both; }
.chat-msg .avatar { width: 28px; height: 28px; font-size: 12px; margin-top: 2px; }
.chat-msg .bubble { background: var(--surface-2); border-radius: 4px 12px 12px 12px; padding: 7px 11px; max-width: 85%; overflow-wrap: anywhere; }
.chat-msg .bubble b { font-size: 12px; color: var(--gold-bright); display: block; }
.chat-msg .bubble p { font-size: 14px; }
.chat-msg.system { justify-content: center; }
.chat-msg.system p { font-size: 12px; color: var(--text-dim); font-style: italic; }
.chat-msg.ch-mafia .bubble { background: #2c1420; border: 1px solid #5c2233; }
.chat-msg.ch-mafia .bubble b { color: var(--blood-bright); }
.chat-msg.ch-dead .bubble { background: #1c2030; opacity: .75; }
.chat-msg.ch-dead .bubble b { color: #8fa3d0; }
.chat-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; min-width: 0; padding: 10px 14px; min-height: 44px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
}
.chat-input input:focus { outline: none; border-color: var(--gold); }
.send-btn { color: var(--gold-bright); background: var(--surface-2); border-radius: 10px; flex: none; }

/* ============ sheets ============ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(5,4,10,.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .25s ease both;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 14px 20px calc(22px + var(--safe-b));
  animation: sheetup .32s cubic-bezier(.2,.9,.3,1) both;
}
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 14px; }
.sheet h2 { margin-bottom: 16px; font-size: 24px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.roles-fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.roles-fieldset legend { font-size: 13px; font-weight: 600; color: var(--text-dim); padding: 0 6px; }
.role-toggle { display: flex; align-items: center; gap: 10px; padding: 9px 2px; min-height: 44px; cursor: pointer; }
.role-toggle small { color: var(--text-dim); }
.role-toggle input {
  appearance: none; width: 44px; height: 26px; border-radius: 13px; flex: none;
  background: var(--bg); border: 1px solid var(--border); position: relative;
  transition: background .2s ease; cursor: pointer;
}
.role-toggle input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-dim); transition: all .2s ease;
}
.role-toggle input:checked { background: var(--gold); border-color: var(--gold); }
.role-toggle input:checked::after { left: 21px; background: #17110a; }
input[type=range] { width: 100%; accent-color: var(--gold); min-height: 32px; }
.timers-row { display: flex; gap: 10px; }
.timers-row label { flex: 1; font-size: 12px; color: var(--text-dim); font-weight: 600; }
.timers-row input { width: 100%; margin-top: 4px; padding: 9px 10px; min-height: 44px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; }

/* ============ room ============ */
.room-topbar .room-title { flex: 1; min-width: 0; text-align: center; line-height: 1.2; }
.room-title b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.room-title small { color: var(--text-dim); font-size: 12px; }
.room-code { color: var(--gold-bright); letter-spacing: .12em; font-weight: 700; user-select: all; }
.phase-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.phase-icon { display: grid; place-items: center; }
.phase-timer { color: var(--gold-bright); font-variant-numeric: tabular-nums; min-width: 2ch; }
.phase-chip.warn .phase-timer { color: var(--blood-bright); animation: pulse 1s infinite; }

.role-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 14px; font-size: 14px;
  background: linear-gradient(90deg, transparent, rgba(201,152,42,.14), transparent);
  border-bottom: 1px solid var(--border);
}
.role-banner .role-name { font-weight: 700; color: var(--gold-bright); }
.role-banner.dead .role-name { color: var(--text-dim); text-decoration: line-through; }
.role-status { color: var(--text-dim); font-size: 13px; }

.room-body { max-width: 640px; margin: 0 auto; padding: 16px 14px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }

/* players */
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.player-card {
  position: relative;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 6px 10px; text-align: center;
  transition: border-color .25s ease, transform .2s ease, filter .5s ease, opacity .5s ease;
  animation: rise .3s ease both;
}
.player-card .avatar { width: 46px; height: 46px; margin: 0 auto 6px; font-size: 18px; }
.player-card .p-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.player-card .p-sub { font-size: 11px; color: var(--text-dim); min-height: 16px; }
.crown-ic { display: inline-flex; width: 13px; margin-right: 3px; vertical-align: -2px; }
.crown-ic svg { width: 13px; height: 13px; }
.player-card.offline { opacity: .5; }
.player-card.offline .p-sub { color: var(--blood-bright); }
.player-card.me { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(201,152,42,.2); }
.player-card.dead { filter: grayscale(1) brightness(.6); }
.player-card.dead::after {
  content: ''; position: absolute; inset: 0; border-radius: 12px;
  background:
    linear-gradient(45deg, transparent 46%, rgba(217,38,55,.8) 47%, rgba(217,38,55,.8) 53%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, rgba(217,38,55,.8) 47%, rgba(217,38,55,.8) 53%, transparent 54%);
}
.player-card.selectable { cursor: pointer; border-color: var(--gold); animation: glowpulse 1.6s infinite; }
.player-card.selectable:active { transform: scale(.95); }
.player-card.selected { border-color: var(--blood-bright); box-shadow: 0 0 0 2px var(--blood-bright), 0 0 22px rgba(217,38,55,.4); }
.player-card .p-role-tag {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 8px; color: var(--gold-bright);
}
.player-card .vote-badge {
  position: absolute; top: -8px; right: -6px;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--blood-bright); color: #fff; font-size: 13px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 2px 10px rgba(217,38,55,.5);
  animation: pop .25s ease both;
}
.kick-btn {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--bg); color: var(--text-dim);
  display: grid; place-items: center; font-size: 14px; line-height: 1;
}
.kick-btn:hover { color: var(--blood-bright); }

/* lobby controls / summary */
.settings-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.tagchip {
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.tagchip.on { color: var(--gold-bright); border-color: rgba(201,152,42,.5); }
.host-actions { margin-top: 4px; }
.host-hint, .waiting-hint { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 8px; }

/* action panels */
.action-panel {
  background: linear-gradient(160deg, #241a2e, var(--bg-2));
  border: 1px solid #4a3560; border-radius: var(--radius);
  padding: 16px; text-align: center; animation: rise .35s ease both;
}
body.night .action-panel { background: linear-gradient(160deg, #141a33, #0c1024); border-color: #2c3a6e; }
.action-panel h3 { font-size: 20px; margin-bottom: 4px; }
.action-panel p { color: var(--text-dim); font-size: 14px; }
.action-panel .btn { margin-top: 12px; }
.action-done { color: var(--ok) !important; font-weight: 600; }

/* log */
.log-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log-box summary { padding: 12px 16px; cursor: pointer; font-weight: 600; color: var(--text-dim); user-select: none; min-height: 44px; display: flex; align-items: center; }
.log-entries { max-height: 180px; overflow-y: auto; padding: 0 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.log-entries p { font-size: 13px; color: var(--text-dim); border-left: 2px solid var(--border); padding-left: 10px; }
.log-entries p.blood { color: var(--blood-bright); border-color: var(--blood-bright); }

.room-chat .chat-messages { height: 200px; }

/* ============ phase overlay (day/night transition) ============ */
.phase-overlay {
  position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0;
  display: grid; place-items: center;
  transition: opacity .6s ease;
}
.phase-overlay.show { opacity: 1; }
.phase-overlay .po-inner { text-align: center; animation: phasein 2.4s ease both; }
.phase-overlay .po-icon { font-size: 0; margin-bottom: 12px; }
.phase-overlay .po-icon svg { width: 90px; height: 90px; filter: drop-shadow(0 0 30px currentColor); }
.phase-overlay h2 { font-size: 40px; letter-spacing: .1em; }
.phase-overlay p { color: var(--text-dim); margin-top: 4px; }
.phase-overlay.po-night { background: radial-gradient(ellipse at 50% 30%, rgba(16,24,60,.94), rgba(4,6,16,.97)); color: #aebbe8; }
.phase-overlay.po-day { background: radial-gradient(ellipse at 50% 30%, rgba(80,60,20,.92), rgba(20,14,6,.96)); color: var(--gold-bright); }

/* ============ role reveal ============ */
.reveal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(5,4,10,.88);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; animation: fadein .4s ease both;
}
.reveal-card { width: min(78vw, 300px); aspect-ratio: 3/4.3; perspective: 1200px; cursor: pointer; }
.reveal-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.3,.9,.35,1); }
.reveal-card.flipped .reveal-inner { transform: rotateY(180deg); }
.reveal-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 22px; text-align: center;
}
.reveal-back {
  background: linear-gradient(160deg, #241d38, #131022);
  border: 2px solid var(--gold); box-shadow: 0 0 60px rgba(201,152,42,.25);
}
.reveal-back p { font-family: 'Playfair Display', serif; font-size: 22px; }
.reveal-back small { color: var(--text-dim); }
.reveal-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, var(--surface-2), var(--bg-2));
  border: 2px solid var(--border);
}
.reveal-front.team-mafia { border-color: var(--blood-bright); box-shadow: 0 0 60px rgba(217,38,55,.35); }
.reveal-front.team-town { border-color: var(--gold); box-shadow: 0 0 60px rgba(201,152,42,.3); }
.reveal-front.team-maniac { border-color: #7c3aed; box-shadow: 0 0 60px rgba(124,58,237,.4); }
.reveal-icon svg { width: 120px; height: 120px; filter: drop-shadow(0 6px 24px rgba(0,0,0,.55)); }
.reveal-front h2 { font-size: 30px; }
.reveal-front p { color: var(--text-dim); font-size: 14px; }

/* ============ FX overlay (kills etc.) ============ */
.fx-overlay {
  position: fixed; inset: 0; z-index: 95; pointer-events: none;
  display: grid; place-items: center;
}
.fx-content { text-align: center; }
.fx-kill { animation: fxkill 2.6s ease both; }
.fx-kill svg { width: 130px; height: 130px; }
.fx-kill h2 { font-size: 34px; color: var(--blood-bright); text-shadow: 0 0 30px rgba(217,38,55,.6); }
.fx-kill p { color: var(--text-dim); }
body.shake { animation: shake .5s ease; }
.blood-vignette {
  position: fixed; inset: 0; z-index: 94; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(163,32,44,.5));
  animation: fadeinout 2.2s ease both;
}

/* ============ game over ============ */
.over-sheet { text-align: center; }
.over-winner { font-size: 22px; font-family: 'Playfair Display', serif; color: var(--gold-bright); margin-bottom: 16px; }
.over-winner.mafia-win { color: var(--blood-bright); }
.over-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; max-height: 40dvh; overflow-y: auto; }
.over-row {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.over-row .avatar { width: 32px; height: 32px; font-size: 13px; }
.over-row b { flex: 1; }
.over-row small { color: var(--text-dim); }
.over-row.dead-row { opacity: .6; }
.over-row.dead-row b { text-decoration: line-through; }

/* ============ voice ============ */
#voiceAudio { position: absolute; width: 0; height: 0; overflow: hidden; }
.mic-btn.mic-on { color: var(--ok); background: rgba(61,189,114,.12); }
.mic-btn.mic-on:hover { color: var(--ok); }
.mic-btn.mic-muted-phase { color: var(--blood-bright); background: rgba(217,38,55,.12); animation: pulse 1.6s infinite; }
.voice-hint {
  text-align: center; font-size: 12.5px; font-weight: 600; color: var(--ok);
  padding: 5px 12px; background: rgba(61,189,114,.08);
  border-bottom: 1px solid var(--border);
}
.voice-hint.muted { color: var(--blood-bright); background: rgba(217,38,55,.08); }
.mic-ind {
  position: absolute; top: 4px; left: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(61,189,114,.18); color: var(--ok);
}
.mic-ind.off { background: rgba(217,38,55,.16); color: var(--blood-bright); }

/* ============ rules ============ */
.rules-sheet { max-width: 560px; }
.rules-intro { color: var(--text-dim); margin-bottom: 16px; }
.rules-roles { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.rules-role {
  display: flex; gap: 14px; align-items: center;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.rules-role .rules-art { flex: none; width: 64px; height: 64px; }
.rules-role .rules-art svg { width: 64px; height: 64px; }
.rules-role b { display: block; margin-bottom: 2px; }
.rules-role p { font-size: 13px; color: var(--text-dim); }
.rules-sheet h3 { margin: 16px 0 8px; font-size: 18px; color: var(--gold-bright); }
.rules-list { padding-left: 20px; display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.rules-list li { font-size: 14px; color: var(--text-dim); }
.rules-list b { color: var(--text); }
.rules-sheet .btn { margin-top: 10px; }

/* ============ misc ============ */
.toast {
  position: fixed; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow);
  font-size: 14px; font-weight: 600; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--blood-bright); color: #ffb3ba; }
.conn-badge {
  position: fixed; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  z-index: 300; background: var(--blood); color: #fff; font-size: 13px; font-weight: 600;
  padding: 6px 16px; border-radius: 14px; animation: pulse 1.2s infinite;
}

/* ============ keyframes ============ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeinout { 0% { opacity: 0; } 25% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sheetup { from { transform: translateY(60%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }
@keyframes glowpulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold), 0 0 10px rgba(201,152,42,.15); }
  50% { box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(201,152,42,.45); }
}
@keyframes phasein {
  0% { opacity: 0; transform: scale(.85); }
  25% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}
@keyframes fxkill {
  0% { opacity: 0; transform: scale(.5); }
  15% { opacity: 1; transform: scale(1.08); }
  22% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--border); }
  .players-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .chat-messages { height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
