/* =============================================================== MAFIA
   Retro terminal / speakeasy UI over a 3D scene. Pixel fonts, brass borders,
   notched corners, CRT scanlines. */
:root {
  --ink: #0a0506;
  --panel: rgba(12, 7, 7, 0.84);
  --panel-solid: #120a09;
  --brass: #c9a24a;
  --brass-dim: #6b4f1e;
  --bone: #eadfc4;
  --dim: #9c8f78;
  --red: #e0323c;
  --red-deep: #7a0f16;
  --amber: #ffb347;
  --gold: #f2c14e;
  --ice: #8fd0ff;
  --green: #5fd38a;
  --ghost: #9fc4ff;
  --pix: 'Press Start 2P', monospace;
  --term: 'VT323', monospace;
  --notch: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  /* the interface is scaled up on big screens (CSS zoom, set by ui.js); viewport units inside it
     are multiplied by that zoom, so every vh/vw in the UI goes through these instead */
  --z: 1;
  --vw: calc(1vw / var(--z));
  --vh: calc(1vh / var(--z));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--bone); }
body { font-family: var(--term); font-size: 20px; line-height: 1.15; -webkit-font-smoothing: none; user-select: none; font-variant-ligatures: none; font-feature-settings: "liga" 0, "clig" 0; }
input, button { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; touch-action: none; }
#app { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#app > * { pointer-events: auto; }
#app > .screen { position: absolute; inset: 0; display: none; pointer-events: none; }
#app > .screen.active { display: block; }
.screen > * { pointer-events: auto; }

/* CRT overlay */
#crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
  animation: flicker 6s infinite steps(1);
}
body.no-crt #crt { background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.35) 100%); animation: none; }
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: 0.92; } 48% { opacity: 1; } 83% { opacity: 0.96; } }

/* ---------------------------------------------------------------- basics */
.panel {
  background: var(--panel);
  border: 2px solid var(--brass-dim);
  box-shadow: inset 0 0 0 1px rgba(201,162,74,0.25), 0 0 0 2px #000, 6px 6px 0 rgba(0,0,0,0.55);
  clip-path: var(--notch);
  padding: 14px 16px;
}
.panel-title, .label {
  font-family: var(--pix); font-size: 10px; letter-spacing: 1px; color: var(--brass);
  text-shadow: 0 0 6px rgba(201,162,74,0.35);
}
.panel-title { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { font-family: var(--term); font-size: 16px; color: var(--dim); letter-spacing: 0; text-shadow: none; }

.btn {
  font-family: var(--pix); font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  background: #1a0e0a; color: #f2d58a; border: 2px solid var(--brass);
  padding: 12px 16px; box-shadow: 4px 4px 0 #000; clip-path: var(--notch);
  transition: background 0.08s, color 0.08s, transform 0.05s;
  text-shadow: 0 0 6px rgba(242,213,138,0.4);
}
.btn:hover:not(:disabled) { background: var(--brass); color: #140a06; text-shadow: none; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.big { font-size: 13px; padding: 16px 20px; }
.btn.small { font-size: 9px; padding: 8px 10px; }
.btn.primary { background: var(--red-deep); border-color: #ff5a5f; color: #ffe6d0; }
.btn.primary:hover:not(:disabled) { background: #ff5a5f; color: #1a0506; }
.btn.danger { border-color: #a33; color: #ff9a9a; }
.btn.on { background: var(--brass); color: #140a06; }
.btn.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 4px 4px 0 #000, 0 0 18px rgba(255,90,95,0.8); } }

.arrow {
  font-family: var(--pix); font-size: 10px; width: 28px; height: 28px; padding: 0;
  background: #1a0e0a; border: 2px solid var(--brass-dim); color: var(--brass);
}
.arrow:hover:not(:disabled) { background: var(--brass); color: #140a06; }
.arrow:disabled { opacity: 0.3; cursor: default; }

.toggle {
  width: 58px; height: 26px; border: 2px solid var(--brass-dim); background: #1a0e0a;
  font-family: var(--pix); font-size: 9px; color: var(--dim); padding: 0;
}
.toggle::after { content: 'OFF'; }
.toggle.on { background: #2b4a1f; border-color: #6fbf5a; color: #d8ffcc; }
.toggle.on::after { content: 'ON'; }
.toggle:disabled { cursor: default; }

input[type=text], input:not([type]) {
  background: #070404; border: 2px solid var(--brass-dim); color: var(--bone); padding: 8px 10px; outline: none;
  font-family: var(--term); font-size: 22px; width: 100%;
  user-select: text;
}
input:focus { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 0 12px rgba(201,162,74,0.3); }
input[type=range] { width: 100%; accent-color: var(--brass); }

.dots::after { content: ''; animation: dots 1.4s infinite steps(4); }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------------------------------------------------------------- title */
#title { background: #000; }
.title-art {
  position: absolute; inset: -4%; background: url('../assets/img/title.jpg') center/cover no-repeat;
  animation: kenburns 38s ease-in-out infinite alternate; filter: saturate(0.95) contrast(1.05);
}
@keyframes kenburns { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.12) translate(-2%, 1%); } }
.title-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(4,2,2,0.97) 0%, rgba(4,2,2,0.9) 30%, rgba(4,2,2,0.35) 55%, rgba(4,2,2,0.1) 75%, rgba(4,2,2,0.5) 100%),
    linear-gradient(0deg, rgba(0,0,0,0.8), transparent 30%);
}
.title-col {
  position: absolute; left: clamp(20px, calc(6 * var(--vw)), 110px); top: 0; bottom: 0; width: min(440px, calc(calc(100 * var(--vw)) - 40px));
  display: flex; flex-direction: column; justify-content: flex-start; gap: 22px;
  padding: 14px 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
}
.title-col::-webkit-scrollbar { display: none; }
/* centred when there's room, top-aligned (never clipped) when there isn't */
.title-col > :first-child { margin-top: auto; }
.title-col > :last-child { margin-bottom: auto; }
.logo { text-align: left; }
.logo-kicker { font-family: var(--pix); font-size: 11px; color: var(--brass); letter-spacing: 3px; margin-bottom: 14px; }
.logo-main {
  font-family: var(--pix); font-size: clamp(56px, calc(8 * var(--vw)), 96px); margin: 0; color: #ff3b45; letter-spacing: 6px; line-height: 1;
  text-shadow: 0 0 10px rgba(255,40,60,0.9), 0 0 32px rgba(255,20,40,0.6), 4px 4px 0 #2a0206, 8px 8px 0 #000;
  animation: neon 7s infinite;
  position: relative;
}
@keyframes neon { 0%, 18%, 22%, 62%, 64%, 100% { opacity: 1; } 20%, 63% { opacity: 0.55; } }
.logo-suits { margin-top: 12px; font-size: 30px; letter-spacing: 16px; color: var(--bone); }
.logo-suits .r { color: var(--red); }
.menu { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.menu .btn { width: 100%; }
.menu-row { display: flex; gap: 10px; }
.menu .btn .rec, .menu .btn .sub { display: block; font-size: 7px; letter-spacing: 2px; margin-top: 6px; opacity: 0.85; }
.menu .btn .rec { color: #ffd9a0; }
.menu-note { margin: -2px 2px 0; font-size: 17px; line-height: 1.1; color: var(--dim); }
.btn.kofi { display: block; text-align: center; text-decoration: none; font-size: 9px; padding: 10px 8px; background: #2a0f12; border-color: #ff5e5b; color: #ffc9c4; }
.btn.kofi:hover { background: #ff5e5b; color: #1a0506; }
.menu-row .btn { flex: 1; font-size: 9px; padding: 10px 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.who { display: flex; gap: 14px; align-items: stretch; }
.look-slot {
  width: 120px; height: 168px; flex: none; position: relative; cursor: pointer;
  border: 2px solid var(--brass-dim); box-shadow: 0 0 0 2px #000, 3px 3px 0 #000;
  background: radial-gradient(ellipse at 50% 32%, #4a2416, #0a0506 72%);
}
.look-slot:hover { border-color: var(--brass); }
.look-slot::after { content: 'EDIT'; position: absolute; right: 4px; bottom: 4px; font-family: var(--pix); font-size: 7px; color: var(--brass); background: rgba(0,0,0,0.7); padding: 3px 4px; opacity: 0; transition: opacity 0.15s; }
.look-slot:hover::after { opacity: 1; }
.look-preview { width: 100%; height: 100%; display: block; }
.who-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.who-sum { font-size: 17px; line-height: 1.1; color: var(--dim); flex: 1; }
.who-sum div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-sum div:first-child { color: var(--bone); }
.who-info .btn { align-self: flex-start; }
.swatch { display: inline-block; width: 14px; height: 14px; border: 2px solid #000; box-shadow: 0 0 0 1px var(--brass-dim); flex: none; }
.title-foot { font-family: var(--pix); font-size: 8px; color: var(--dim); letter-spacing: 2px; }

/* ---------------------------------------------------------------- layout columns */
.col-left { position: absolute; left: 14px; top: 14px; bottom: 14px; width: 270px; display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.col-left > * { pointer-events: auto; }
.col-right { position: absolute; right: 14px; top: 64px; width: 330px; display: flex; flex-direction: column; gap: 12px; }
.list-panel { min-height: 0; flex: 0 1 auto; overflow: hidden; display: flex; flex-direction: column; }
.roster { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.roster li {
  display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px;
  padding: 4px 6px; border-bottom: 1px dashed rgba(201,162,74,0.15); font-size: 21px; position: relative;
}
.roster li:last-child { border-bottom: 0; }
.roster .dot { width: 12px; height: 12px; border: 2px solid #000; box-shadow: 0 0 0 1px rgba(255,255,255,0.15); }
.roster .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .tagx { font-family: var(--pix); font-size: 8px; color: var(--dim); margin-left: 6px; }
.roster .ttl { font-size: 16px; color: var(--dim); margin-left: 8px; }
.roster .right { display: flex; gap: 6px; align-items: center; font-size: 18px; }
.roster li.dead .nm { text-decoration: line-through; color: #6a6258; }
.roster li.dead .dot { opacity: 0.3; }
.roster li.me { background: rgba(201,162,74,0.08); }
.roster li.target { cursor: pointer; }
.roster li.target:hover { background: rgba(255,120,60,0.15); }
.roster li.sel { background: rgba(255,60,60,0.22); outline: 1px solid rgba(255,90,90,0.6); }
.roster li.off .nm { opacity: 0.5; }
.roster .kick { font-family: var(--pix); font-size: 8px; background: none; border: 1px solid #733; color: #f99; padding: 3px 5px; }
.roster .kick:hover { background: #733; color: #fff; }
.roster .votes { font-family: var(--pix); font-size: 9px; background: var(--red-deep); color: #fff; padding: 3px 5px; border: 1px solid #ff5a5f; }
.roster .role-chip { font-family: var(--pix); font-size: 8px; padding: 2px 4px; border: 1px solid currentColor; }
.crown { color: var(--gold); }
.mk { display: inline-block; font-family: var(--pix); font-size: 9px; padding: 2px 3px; margin-right: 5px; vertical-align: 2px; border: 1px solid currentColor; }
.mk.sus { color: #ff6a55; background: rgba(120,20,10,0.5); }
.mk.ok { color: #7fe08f; background: rgba(20,90,30,0.45); }

/* ---------------------------------------------------------------- lobby */
.roomcard { text-align: center; }
.roomcard .code { font-family: var(--pix); font-size: 30px; letter-spacing: 6px; color: var(--amber); margin: 10px 0 4px; text-shadow: 0 0 12px rgba(255,179,71,0.6), 3px 3px 0 #000; user-select: text; }
.roomcard .mode { font-size: 17px; color: var(--dim); margin-bottom: 10px; }
.solocard .solo-title { font-family: var(--pix); font-size: 16px; color: var(--amber); letter-spacing: 2px; margin: 10px 0 4px; text-shadow: 0 0 12px rgba(255,179,71,0.5), 3px 3px 0 #000; }
.solocard .solo-sub { font-size: 18px; color: var(--dim); margin-bottom: 8px; }
.solocard .set-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.wits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 2px; }
.wits button { font-family: var(--pix); font-size: 7px; padding: 8px 2px; background: #1a0e0a; border: 2px solid var(--brass-dim); color: var(--dim); }
.wits button:hover { color: var(--bone); border-color: var(--brass); }
.wits button.on { background: var(--brass); color: #140a06; border-color: var(--brass); }
.wits-hint { font-size: 16px; color: var(--dim); margin-top: 6px; line-height: 1.05; min-height: 34px; }
#lobby .list-panel .btn { margin-top: 8px; align-self: flex-start; }
.settings .set-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; gap: 10px; }
.set-name { font-size: 20px; }
.set-name b { font-family: var(--pix); font-size: 10px; font-weight: normal; }
b.joker { color: var(--red); } b.king { color: var(--gold); } b.ace { color: var(--ice); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper > span { min-width: 44px; text-align: center; font-size: 22px; color: var(--amber); }
.balance { font-size: 16px; color: var(--dim); margin: -2px 0 6px; min-height: 16px; }
.balance.warn { color: #ff8a6a; }
.balance.good { color: var(--green); }
.deck-line { margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(201,162,74,0.25); font-size: 18px; color: var(--bone); }
.deck-line .k { color: var(--gold); } .deck-line .j { color: var(--red); } .deck-line .a { color: var(--ice); }
.settings.readonly .arrow, .settings.readonly .toggle { pointer-events: none; }
.settings.readonly .arrow { visibility: hidden; }
.lobby-bottom { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: auto; }
.waiting { font-family: var(--pix); font-size: 11px; color: var(--brass); background: rgba(0,0,0,0.7); padding: 12px 16px; clip-path: var(--notch); }
#lobby .col-right { top: 64px; max-height: calc(calc(100 * var(--vh)) - 64px - min(340px, calc(36 * var(--vh))) - 28px); overflow-y: auto; overflow-x: hidden; }
#lobby .col-right::-webkit-scrollbar { width: 6px; }
#lobby .col-right::-webkit-scrollbar-thumb { background: var(--brass-dim); }
body.in-lobby .chat { height: min(340px, calc(36 * var(--vh))); }

/* ---------------------------------------------------------------- chat */
.chat {
  position: absolute; right: 14px; bottom: 14px; width: 330px; height: min(420px, calc(46 * var(--vh)));
  display: flex; flex-direction: column; padding: 10px 12px; z-index: 5;
}
body.in-game .chat { height: calc(calc(100 * var(--vh)) - 80px); top: 66px; bottom: auto; max-height: 720px; }
/* in game, side panels fade back so the table stays visible; they come forward when used */
body.in-game .chat, body.in-game #hud .list-panel { background: rgba(12,7,7,0.66); transition: background 0.25s; }
body.in-game .chat:hover, body.in-game .chat:focus-within, body.in-game #hud .list-panel:hover { background: rgba(12,7,7,0.9); }
.chat.min { height: 44px !important; }
.chat.min .chat-log, .chat.min .chat-form { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.chan { font-family: var(--pix); font-size: 9px; padding: 4px 6px; border: 1px solid var(--brass-dim); color: var(--brass); }
.chan.mafia { color: #ff6a70; border-color: #a3222a; background: rgba(120,10,16,0.35); }
.chan.dead { color: var(--ghost); border-color: #3a5a8a; background: rgba(30,50,90,0.35); }
.chan.mute { color: #777; border-color: #444; }
.chat-min { background: none; border: 1px solid var(--brass-dim); color: var(--brass); font-family: var(--pix); font-size: 9px; width: 24px; height: 20px; padding: 0; }
.chat-log { flex: 1; overflow-y: auto; min-height: 0; padding-right: 4px; user-select: text; }
.chat-log::-webkit-scrollbar, .roster::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb, .roster::-webkit-scrollbar-thumb { background: var(--brass-dim); }
.msg { padding: 2px 0; font-size: 19px; word-wrap: break-word; animation: msgIn 0.2s steps(3); }
@keyframes msgIn { from { opacity: 0; transform: translateX(6px); } }
.msg .who { font-weight: normal; margin-right: 6px; }
.msg.sys { color: var(--amber); font-size: 18px; }
.msg.sys.dim, .msg.priv.dim { color: #8a7d68; }
.msg.sys.phase { color: #e8d49a; border-top: 1px dashed rgba(201,162,74,0.3); margin-top: 4px; padding-top: 4px; font-family: var(--pix); font-size: 9px; line-height: 1.5; }
.msg.sys.death, .msg.priv.death { color: #ff6a6a; }
.msg.sys.save, .msg.priv.save { color: #9fe0ff; }
.msg.sys.win { color: var(--gold); font-family: var(--pix); font-size: 10px; line-height: 1.5; }
.msg.sys.vote { color: #d7a36a; font-size: 17px; }
.msg.priv { color: var(--gold); }
.msg.mafia { color: #ffb0b0; }
.msg.mafia .tag { color: #ff4a55; font-family: var(--pix); font-size: 8px; margin-right: 4px; }
.msg.dead { color: var(--ghost); font-style: italic; }
.msg.dead .tag { color: #6fa0ff; font-family: var(--pix); font-size: 8px; margin-right: 4px; font-style: normal; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { font-size: 20px; padding: 6px 8px; }
.chat-form input:disabled { opacity: 0.5; }

/* ---------------------------------------------------------------- HUD */
.phase-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center;
  min-width: 300px; padding: 7px 20px 8px; background: rgba(8,4,4,0.8); clip-path: var(--notch);
  border: 2px solid var(--brass-dim); box-shadow: 0 0 0 2px #000;
}
.phase-name { font-family: var(--pix); font-size: 15px; color: var(--amber); letter-spacing: 3px; text-shadow: 0 0 12px rgba(255,179,71,0.5), 3px 3px 0 #000; }
.phase-banner.night .phase-name { color: var(--ice); text-shadow: 0 0 12px rgba(143,208,255,0.6), 3px 3px 0 #000; }
.phase-banner.vote .phase-name, .phase-banner.lastwords .phase-name { color: #ff5a5f; text-shadow: 0 0 12px rgba(255,60,70,0.6), 3px 3px 0 #000; }
.phase-sub { font-size: 18px; color: var(--bone); margin-top: 4px; max-width: 440px; }
.timer-wrap { display: flex; align-items: center; gap: 10px; margin-top: 4px; justify-content: center; }
.timer { font-family: var(--pix); font-size: 13px; color: var(--bone); min-width: 56px; }
.timer.urgent { color: #ff5a5f; animation: blink 0.5s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.timer-bar { width: 200px; height: 8px; background: #000; border: 1px solid var(--brass-dim); }
.timer-bar i { display: block; height: 100%; background: var(--brass); width: 100%; }

.mycard { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: start; }
.mycard-img { width: 76px; height: 106px; background-size: cover; background-position: center; cursor: pointer; border: 2px solid #000; box-shadow: 0 0 0 1px var(--brass-dim), 3px 3px 0 #000; transition: transform 0.15s; }
.mycard-img:hover { transform: translateY(-3px) rotate(-2deg); }
.role-name { font-family: var(--pix); font-size: 12px; margin: 8px 0 6px; line-height: 1.4; }
.role-hint { font-size: 17px; color: var(--dim); line-height: 1.05; }
.notes { grid-column: 1 / -1; font-size: 17px; }
.notes:empty { display: none; }
.notes .note { padding: 2px 0; }
.notes .bad { color: #ff6a6a; } .notes .good { color: #9fe0ff; }

.action-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: min(640px, calc(calc(100 * var(--vw)) - 660px)); min-width: 300px;
}
.action-text {
  font-size: 22px; text-align: center; background: rgba(8,4,4,0.82); padding: 10px 18px; clip-path: var(--notch);
  border: 2px solid var(--brass-dim); color: var(--bone); box-shadow: 0 0 0 2px #000;
}
.action-text:empty { display: none; }
.action-text b { color: var(--amber); font-weight: normal; }
.action-text .kill { color: #ff5a5f; } .action-text .inspect { color: var(--gold); } .action-text .save { color: var(--ice); }
.action-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.emotes { display: flex; gap: 6px; }
.emote { font-family: var(--pix); font-size: 8px; padding: 6px 8px; background: rgba(10,6,6,0.85); border: 1px solid var(--brass-dim); color: var(--dim); }
.emote:hover { color: var(--bone); border-color: var(--brass); }
.controls-hint { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); font-size: 15px; color: rgba(234,223,196,0.35); white-space: nowrap; pointer-events: none; animation: hintFade 28s forwards; padding: 2px 10px; }
@keyframes hintFade {
  0%, 75% { color: #f2d58a; background: rgba(0,0,0,0.75); text-shadow: 0 0 8px rgba(242,213,138,0.5); }
  100% { color: rgba(234,223,196,0.35); background: transparent; text-shadow: none; }
}
body.hud-hidden #hud .col-left, body.hud-hidden #hud .action-bar .emotes, body.hud-hidden .chat, body.hud-hidden .controls-hint { opacity: 0; pointer-events: none; }

.topbar { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; z-index: 6; }
.icon-btn {
  width: 38px; height: 38px; font-size: 18px; background: rgba(12,7,7,0.9); border: 2px solid var(--brass-dim); color: var(--brass);
  box-shadow: 3px 3px 0 #000; clip-path: var(--notch); padding: 0; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--brass); color: #140a06; }
.icon-btn.danger { color: #ff8a8a; border-color: #733; }
.room-tag { font-family: var(--pix); font-size: 8px; color: var(--dim); align-self: center; margin-right: 4px; letter-spacing: 1px; user-select: text; }
body.in-lobby .room-tag { display: none; }
.icon-btn.off { color: #666; }

/* ---------------------------------------------------------------- name tags */
#tags { position: fixed; inset: 0; pointer-events: none; z-index: 1; transition: opacity 1s; }
#tags.asleep { opacity: 0; }
.tag3d {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); text-align: center; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: default; will-change: transform;
}
.tag3d .plate {
  font-size: 19px; padding: 1px 8px 2px; background: rgba(6,3,3,0.78); border: 1px solid rgba(201,162,74,0.5);
  white-space: nowrap; display: flex; gap: 6px; align-items: center; color: var(--bone);
}
.tag3d.target { cursor: pointer; }
.tag3d.edge-l, .tag3d.edge-r { cursor: pointer; }
.tag3d.edge-l { flex-direction: row-reverse; align-items: center; gap: 8px; }
.tag3d.edge-r { flex-direction: row; align-items: center; gap: 8px; }
.tag3d.edge-l .bubble, .tag3d.edge-r .bubble { max-width: 200px; font-size: 17px; }
.tag3d.edge-l .plate::before { content: '◀'; color: var(--brass); font-size: 14px; }
.tag3d.edge-r .plate::after { content: '▶'; color: var(--brass); font-size: 14px; }
.tag3d.edge-l .plate, .tag3d.edge-r .plate { font-size: 17px; background: rgba(6,3,3,0.9); }
.tag3d.edge-l .bubble::after, .tag3d.edge-r .bubble::after { display: none; }
.tag3d.target .plate { border-color: #ff9a4a; }
.tag3d.sel .plate { background: rgba(120,10,16,0.9); border-color: #ff5a5f; box-shadow: 0 0 12px rgba(255,60,70,0.7); }
.tag3d.dead .plate { opacity: 0.55; text-decoration: line-through; }
.tag3d.off .plate { opacity: 0.5; }
.tag3d .vc { font-family: var(--pix); font-size: 9px; background: var(--red-deep); color: #fff; padding: 2px 4px; }
.tag3d .rc { font-family: var(--pix); font-size: 8px; }
.tag3d .bubble {
  max-width: 240px; background: #eadfc4; color: #140a06; padding: 5px 9px; font-size: 18px; line-height: 1.05;
  box-shadow: 3px 3px 0 #000; position: relative; white-space: normal; word-wrap: break-word; animation: pop 0.18s steps(3);
}
.tag3d .bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-top-color: #eadfc4; border-bottom: 0; }
.tag3d .bubble.mafia { background: #3a0a0e; color: #ffc0c0; border: 1px solid #a3222a; }
.tag3d .bubble.mafia::after { border-top-color: #3a0a0e; }
.tag3d .bubble.dead { background: #1a2640; color: #cfe0ff; }
.tag3d .bubble.dead::after { border-top-color: #1a2640; }
.tag3d .typing { font-family: var(--pix); font-size: 10px; background: #eadfc4; color: #140a06; padding: 3px 6px; box-shadow: 2px 2px 0 #000; }
.tag3d .emo { font-family: var(--pix); font-size: 8px; color: var(--amber); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

/* ---------------------------------------------------------------- overlays */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.86); display: grid; place-items: center; z-index: 20; }
.reveal-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 560px; padding: 20px; text-align: center; }
.reveal-title { font-family: var(--pix); font-size: 14px; color: var(--brass); letter-spacing: 3px; }
.flip-card { width: min(300px, calc(62 * var(--vw))); aspect-ratio: 5 / 7; perspective: 1200px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform 0.8s cubic-bezier(.3,1.4,.5,1); transform-style: preserve-3d; animation: float 3s ease-in-out infinite; }
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
@keyframes float { 50% { translate: 0 -6px; } }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 14px; background-size: cover; background-position: center; box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 0 2px #000; }
.flip-front { transform: rotateY(180deg); }
.flip-card:not(.flipped):hover .flip-inner { transform: rotateY(-12deg) rotateX(6deg); }
.reveal-hint { font-size: 20px; color: var(--dim); }
.reveal-role-name { font-family: var(--pix); font-size: 20px; margin-bottom: 10px; text-shadow: 3px 3px 0 #000; }
.reveal-role p { font-size: 22px; margin: 0; line-height: 1.15; }
.reveal-extra { margin-top: 10px; font-size: 20px; color: #ff8a8a; }
.reveal-btns { display: flex; gap: 10px; }

.announce {
  position: fixed; left: 50%; top: 50%; transform: translateX(-50%); z-index: 15; text-align: center;
  background: rgba(6,3,3,0.9); padding: 22px 34px; border: 2px solid var(--brass); clip-path: var(--notch);
  box-shadow: 0 0 0 3px #000; max-width: min(640px, calc(92 * var(--vw))); animation: annIn 0.4s steps(4); pointer-events: none;
}
@keyframes annIn { from { opacity: 0; transform: translate(-50%, -12px); } }
.announce-title { font-family: var(--pix); font-size: 24px; letter-spacing: 3px; color: var(--amber); text-shadow: 3px 3px 0 #000; margin-bottom: 12px; }
.announce-text { font-size: 26px; line-height: 1.1; }
.announce.death { border-color: #ff3b45; } .announce.death .announce-title { color: #ff3b45; }
.announce.saved { border-color: var(--ice); } .announce.saved .announce-title { color: var(--ice); }
.announce.night { border-color: #3a5a8a; } .announce.night .announce-title { color: var(--ice); }
.announce.accused { border-color: #ff3b45; } .announce.accused .announce-title { color: #ff3b45; }
.announce.win .announce-title { color: var(--gold); font-size: 28px; }

.sleep { position: fixed; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; pointer-events: none; }
.sleep-title { font-family: var(--pix); font-size: 22px; color: #7fa8e0; letter-spacing: 4px; text-shadow: 0 0 14px rgba(100,150,255,0.6); }
.sleep-text { font-size: 24px; color: #8fa0c0; }
.zzz { font-family: var(--pix); color: #7fa8e0; font-size: 22px; height: 60px; }
.zzz span { display: inline-block; animation: zz 2.4s infinite; opacity: 0; }
.zzz span:nth-child(2) { animation-delay: 0.6s; font-size: 16px; } .zzz span:nth-child(3) { animation-delay: 1.2s; font-size: 12px; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 10px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(14px, -30px); } }

.youdied { position: fixed; inset: 0; z-index: 18; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse, rgba(120,0,10,0.5), rgba(0,0,0,0.85)); pointer-events: none; animation: died 4.2s forwards; text-align: center; }
.youdied div { font-family: var(--pix); font-size: 22px; color: #ffb0b0; line-height: 1.6; }
.youdied b { font-size: 36px; color: #ff2a35; text-shadow: 0 0 20px rgba(255,0,20,0.8), 4px 4px 0 #000; font-weight: normal; }
.youdied p { font-size: 24px; color: var(--bone); max-width: 420px; }
@keyframes died { 0% { opacity: 0; } 10%, 75% { opacity: 1; } 100% { opacity: 0; } }

.gameover-box { width: min(760px, calc(94 * var(--vw))); max-height: calc(90 * var(--vh)); overflow-y: auto; text-align: center; padding: 26px; }
.gameover-title { font-family: var(--pix); font-size: 28px; letter-spacing: 3px; margin-bottom: 10px; text-shadow: 4px 4px 0 #000; }
.gameover-title.town { color: var(--gold); } .gameover-title.mafia { color: #ff3b45; }
.gameover-text { font-size: 24px; margin-bottom: 18px; }
.gameover-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 20px; }
.go-card { width: 96px; text-align: center; font-size: 18px; }
.go-card .im { width: 96px; height: 134px; background-size: cover; background-position: center; border-radius: 6px; box-shadow: 0 0 0 2px #000, 3px 3px 0 #000; margin-bottom: 5px; }
.go-card.dead .im { filter: grayscale(0.7) brightness(0.65); }
.go-card.win .im { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(242,193,78,0.6); }
.go-card .r { font-family: var(--pix); font-size: 8px; margin-top: 3px; }
.go-card .you { font-family: var(--pix); font-size: 7px; color: var(--dim); }
.gameover-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: grid; place-items: center; z-index: 30; }
.modal-box { width: min(560px, calc(94 * var(--vw))); max-height: calc(88 * var(--vh)); overflow-y: auto; padding: 22px; }
.modal-box h2 { font-family: var(--pix); font-size: 15px; color: var(--amber); margin: 0 0 16px; letter-spacing: 2px; text-shadow: 3px 3px 0 #000; }
.modal-box h3 { font-family: var(--pix); font-size: 10px; color: var(--brass); margin: 18px 0 8px; }
.modal-box p { margin: 6px 0; font-size: 21px; }
.modal-box .row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.modal-box .row .btn { flex: 1; }
.choice { display: grid; gap: 10px; }
.choice button { text-align: left; padding: 12px 14px; background: #120a09; border: 2px solid var(--brass-dim); clip-path: var(--notch); }
.choice button b { display: block; font-family: var(--pix); font-size: 10px; color: var(--brass); margin-bottom: 6px; font-weight: normal; }
.choice button span { font-size: 19px; color: var(--dim); }
.choice button.on { border-color: var(--brass); background: #2a1a0c; }
.choice button.on span { color: var(--bone); }
.friends { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fr-col { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: rgba(0,0,0,0.35); border: 1px solid rgba(201,162,74,0.25); }
.fr-col h3 { margin: 0 0 2px !important; }
.fr-col p { font-size: 18px !important; color: var(--dim); flex: 1; margin: 0 !important; }
.fr-col .btn { width: 100%; }
.fr-col .code-input { font-size: 22px !important; letter-spacing: 6px; padding: 8px 4px; }
.code-input { font-family: var(--pix) !important; font-size: 28px !important; letter-spacing: 10px; text-align: center; text-transform: uppercase; color: var(--amber) !important; }
.err { color: #ff6a6a; font-size: 20px; min-height: 22px; margin-top: 8px; }
.how-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin: 10px 0; }
.how-role { text-align: center; font-size: 17px; }
.how-role .im { width: 100%; aspect-ratio: 5 / 7; background-size: cover; background-position: center; border-radius: 6px; box-shadow: 0 0 0 2px #000; margin-bottom: 6px; }
.how-role b { display: block; font-family: var(--pix); font-size: 9px; margin-bottom: 4px; font-weight: normal; }
.opt-row { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 12px; margin: 10px 0; font-size: 20px; }
.qrow { display: flex; flex-wrap: wrap; gap: 6px; }
.qrow .btn { flex: 1 1 auto; padding: 8px 6px; }
.modal-box .hint { font-size: 17px; margin: -4px 0 8px; }
kbd { font-family: var(--pix); font-size: 9px; border: 1px solid var(--brass-dim); padding: 2px 5px; color: var(--brass); }

.toasts { position: fixed; left: 50%; top: 120px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1a0e0a; border: 2px solid var(--brass); padding: 8px 14px; font-size: 20px; box-shadow: 4px 4px 0 #000; animation: toast 3.4s forwards; }
.toast.bad { border-color: #ff5a5f; color: #ffb0b0; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.loading { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; font-family: var(--pix); font-size: 12px; color: var(--brass); }
.spinner { font-size: 42px; color: var(--red); animation: spin 1.2s steps(8) infinite; }
@keyframes spin { to { transform: rotateY(360deg); } }

/* ---------------------------------------------------------------- responsive */
@media (max-height: 800px) {
  .title-col { gap: 12px; }
  .logo-kicker { margin-bottom: 8px; font-size: 10px; }
  .logo-main { font-size: clamp(44px, calc(6.5 * var(--vw)), 70px); }
  .logo-suits { margin-top: 6px; font-size: 24px; }
  .menu { gap: 9px; padding: 14px 16px; }
  .menu .btn.big { padding: 12px 18px; }
}
@media (max-height: 720px) {
  .title-col { gap: 10px; }
  .logo-kicker { margin-bottom: 6px; font-size: 9px; }
  .logo-main { font-size: clamp(40px, calc(5 * var(--vw)), 58px); }
  .logo-suits { display: none; }
  .menu { gap: 7px; padding: 12px 14px; }
  .menu .btn.big { padding: 10px 16px; }
  .look-slot { width: 88px; height: 122px; }
  .who { gap: 12px; }
  .who-info { gap: 6px; }
  .menu-note { font-size: 15px; }
  .menu-row .btn { padding: 8px 6px; }
  .btn.kofi { padding: 8px; }
}
@media (max-height: 600px) {
  .logo-kicker { display: none; }
  .logo-main { font-size: 38px; }
  .look-slot { width: 72px; height: 100px; }
  .who-sum { display: none; }
  .menu .btn .rec, .menu .btn .sub { margin-top: 4px; }
}
@media (max-width: 1100px) {
  .col-left { width: 230px; }
  .col-right, .chat { width: 280px; }
  .action-bar { max-width: calc(calc(100 * var(--vw)) - 560px); min-width: 240px; }
  .controls-hint { display: none; }
}
@media (max-width: 820px) {
  body { font-size: 18px; }
  .col-left { position: absolute; left: 8px; right: 8px; top: auto; bottom: auto; width: auto; }
  #lobby .col-left { top: 8px; bottom: auto; max-height: calc(44 * var(--vh)); }
  #lobby .col-right { top: auto; bottom: 150px; left: 8px; right: 8px; width: auto; max-height: calc(34 * var(--vh)); overflow-y: auto; }
  #lobby .roomcard .code { font-size: 22px; }
  #hud .col-left { top: 104px; max-width: 240px; right: auto; }
  #hud .list-panel { display: none; }
  .mycard { grid-template-columns: 50px 1fr; padding: 8px 10px; }
  .mycard-img { width: 50px; height: 70px; }
  .chat { width: auto; left: 8px; right: 8px; height: 190px; bottom: 8px; }
  body.in-game .chat { top: auto; bottom: 8px; height: 170px; }
  .action-bar { bottom: 190px; max-width: calc(94 * var(--vw)); }
  .phase-banner { min-width: 0; width: calc(calc(100 * var(--vw)) - 150px); left: 8px; transform: none; padding: 8px 10px; }
  .phase-name { font-size: 13px; }
  .timer-bar { width: 100px; }
  .topbar { top: 8px; right: 8px; flex-direction: column; }
  .lobby-bottom { bottom: 214px; }
  .title-col { justify-content: flex-end; padding-bottom: 20px; }
  .logo-main { font-size: 48px; }
}

/* ---------------------------------------------------------------- wardrobe */
.wardrobe { z-index: 25; background: rgba(0,0,0,0.78); }
.wd-box { width: min(1040px, calc(96 * var(--vw))); height: min(680px, calc(92 * var(--vh))); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); gap: 18px; padding: 18px; }
.wd-stage {
  position: relative; min-height: 0; border: 2px solid var(--brass-dim); box-shadow: 0 0 0 2px #000, inset 0 0 60px rgba(0,0,0,0.8);
  background: radial-gradient(ellipse at 50% 35%, #4a2416 0%, #1c0d09 45%, #070303 80%);
}
.wd-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.wd-stage canvas.grab { cursor: grab; }
.wd-stage canvas.grabbing { cursor: grabbing; }
.wd-views { position: absolute; left: 10px; top: 10px; display: flex; gap: 4px; z-index: 1; }
.wd-views button { font-family: var(--pix); font-size: 8px; padding: 6px 8px; background: rgba(10,6,6,0.85); border: 1px solid var(--brass-dim); color: var(--dim); }
.wd-views button:hover { color: var(--bone); border-color: var(--brass); }
.wd-views button.on { background: var(--brass); color: #140a06; border-color: var(--brass); }
.wd-hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-family: var(--pix); font-size: 7px; color: rgba(234,223,196,0.45); pointer-events: none; letter-spacing: 1px; }
.wd-side { display: flex; flex-direction: column; min-height: 0; }
.wd-side h2 { font-family: var(--pix); font-size: 15px; color: var(--amber); margin: 4px 0 4px; letter-spacing: 2px; text-shadow: 3px 3px 0 #000; }
.wd-name { font-size: 18px; color: var(--dim); min-height: 20px; margin-bottom: 10px; }
.wd-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 10px; }
.wd-tabs button { font-family: var(--pix); font-size: 8px; padding: 10px 4px; background: #1a0e0a; border: 2px solid var(--brass-dim); color: var(--dim); }
.wd-tabs button:hover { color: var(--bone); border-color: var(--brass); }
.wd-tabs button.on { background: var(--brass); color: #140a06; border-color: var(--brass); }
.wd-rows { flex: 1; overflow-y: auto; min-height: 0; padding-right: 4px; }
.wd-rows::-webkit-scrollbar { width: 6px; }
.wd-rows::-webkit-scrollbar-thumb { background: var(--brass-dim); }
.wd-row { padding: 9px 0 10px; border-bottom: 1px dashed rgba(201,162,74,0.18); }
.wd-row:last-child { border-bottom: 0; }
.wd-row.off { opacity: 0.35; }
.wd-label { font-family: var(--pix); font-size: 9px; color: var(--brass); margin-bottom: 7px; }
.wd-pick { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 8px; }
.wd-val { text-align: center; font-size: 22px; color: var(--bone); display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.wd-swatches, .wd-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; justify-content: center; }
.wd-swatches button { width: 24px; height: 24px; padding: 0; border: 2px solid #000; box-shadow: 0 0 0 1px var(--brass-dim); }
.wd-swatches button:hover { box-shadow: 0 0 0 2px var(--brass); }
.wd-swatches button.on { box-shadow: 0 0 0 2px var(--amber), 0 0 10px rgba(255,179,71,0.6); transform: scale(1.12); }
.wd-dots button { width: 12px; height: 12px; padding: 0; background: #2a1a10; border: 1px solid var(--brass-dim); }
.wd-dots button:hover { background: var(--brass-dim); }
.wd-dots button.on { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 8px rgba(255,179,71,0.6); }
.wd-btns { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 12px; }
@media (max-width: 820px) {
  /* the lobby becomes one scrolling column above the chat, with the deal button pinned */
  #app > #lobby.screen { bottom: 262px; overflow-y: auto; overflow-x: hidden; pointer-events: auto; padding: 8px; }
  #lobby .col-left, #lobby .col-right { position: static; width: auto; max-height: none; overflow: visible; margin: 0 0 10px; pointer-events: auto; }
  #lobby .list-panel { max-height: none; overflow: visible; }
  #lobby .roster { overflow: visible; }
  #lobby .lobby-bottom { position: fixed; bottom: 206px; }
  body.in-lobby .chat { height: 190px; }
  .wd-box { grid-template-columns: 1fr; grid-template-rows: calc(42 * var(--vh)) 1fr; height: calc(94 * var(--vh)); padding: 10px; gap: 10px; }
  .friends { grid-template-columns: 1fr; }
  .who { gap: 10px; }
  .look-slot { width: 96px; height: 134px; }
}
@media (max-height: 800px) {
  .look-slot { width: 104px; height: 146px; }
  .who-sum { font-size: 16px; }
}

/* ---------------------------------------------------------------- phones & tablets: PC only */
body.pc-only #gl, body.pc-only #tags { display: none; }
.pc-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; pointer-events: auto; background: #000; overflow: auto; }
.pc-box { position: relative; width: min(460px, 100%); text-align: center; padding: 26px 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pc-box .logo-kicker { margin: 0; font-size: 9px; }
.pc-box .logo-main { font-size: clamp(44px, 14vw, 72px); }
.pc-box .logo-suits { margin: 0; font-size: 22px; }
.pc-box h2 { font-family: var(--pix); font-size: 13px; line-height: 1.6; color: var(--amber); margin: 10px 0 0; letter-spacing: 1px; text-shadow: 3px 3px 0 #000; }
.pc-box p { font-size: 22px; margin: 0; line-height: 1.15; }
.pc-box .btn { width: 100%; }
.pc-note { font-size: 17px; color: var(--dim); }
