:root {
  --felt: #0f5132;
  --felt-dark: #072a1a;
  --gold: #e9c46a;
  --gold-2: #c99a2e;
  --red: #d64545;
  --ink: #f5efe0;
  --muted: #a9bfb2;
  --panel: rgba(9, 28, 20, 0.88);
  --panel-border: rgba(233, 196, 106, 0.35);
  --cw: 80px;
  --ch: 112px;
  --ease: cubic-bezier(0.22, 0.8, 0.22, 1);
  --fly: 520ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--felt-dark);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
input, button, select { font: inherit; }
html, body, button, input, select, .card, .plate, .panel, #topbar, .chat, .emote-bar, .modal { touch-action: manipulation; }
#topbar { padding-top: max(7px, env(safe-area-inset-top)); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(#24563f, #173b2b);
  color: var(--ink);
  padding: 0.6em 1.1em;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s, box-shadow 0.15s;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn.gold { background: linear-gradient(#f3d27e, #c99a2e); color: #2b1d02; border-color: #f8e3a6; }
.btn.red { background: linear-gradient(#e46060, #a52c2c); border-color: #f09090; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { padding: 0.8em 1.4em; font-size: 1.05rem; }
.btn.small { padding: 0.35em 0.7em; font-size: 0.85rem; }
.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.45); }
.icon-btn.small { width: 30px; height: 30px; font-size: 0.9rem; }
.badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- home ---------- */
.screen { position: fixed; inset: 0; }
#home {
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 255, 255, 0.08), transparent 60%),
    radial-gradient(ellipse at center, #16683f 0%, #0b3d25 60%, #052014 100%);
}
.home-wrap { max-width: 520px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.hero { text-align: center; padding-top: 8px; }
.hero h1 {
  font-family: Cinzel, Georgia, serif; font-weight: 800;
  font-size: clamp(2.8rem, 12vw, 4.4rem); letter-spacing: 0.18em; margin: 4px 0 0;
  background: linear-gradient(#fff3c4, #e9c46a 55%, #b8862a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
.tagline { margin: 4px 0 0; color: var(--muted); }
.hero-fan { position: relative; height: 150px; margin: 0 auto; width: 260px; }
.hero-fan .hcard {
  position: absolute; left: 50%; bottom: 0; width: 86px; height: 120px; margin-left: -43px;
  transform-origin: 50% 120%;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
  animation: heroIn 0.9s var(--ease) backwards;
}
.hero-fan .hcard svg { width: 100%; height: 100%; display: block; }
@keyframes heroIn { from { transform: rotate(0deg) translateY(60px); opacity: 0; } }
.home-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .join-row input, .chat-form input, select {
  background: rgba(0, 0, 0, 0.35); color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 10px; padding: 0.65em 0.8em; outline: none;
}
.field input:focus, .join-row input:focus, .chat-form input:focus { border-color: var(--gold); }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-picker button {
  width: 40px; height: 40px; font-size: 1.35rem; border-radius: 50%;
  border: 2px solid transparent; background: rgba(0, 0, 0, 0.3); cursor: pointer;
}
.avatar-picker button.on { border-color: var(--gold); background: rgba(233, 196, 106, 0.18); }
.home-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.home-actions > .btn { flex: 1 1 180px; }
.join-row { display: flex; gap: 6px; flex: 1 1 160px; }
.join-row input { width: 100%; text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; text-align: center; }
.create-opts summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.create-opts[open] summary { margin-bottom: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; cursor: pointer; }
.invite-box { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(233, 196, 106, 0.12); border: 1px solid var(--panel-border); text-align: center; }
.rooms-head { display: flex; justify-content: space-between; align-items: center; }
.rooms-head h2 { margin: 0; font-size: 1.05rem; font-family: Cinzel, serif; letter-spacing: 0.05em; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); cursor: pointer;
  border: 1px solid transparent;
}
.room-item:hover { border-color: var(--panel-border); }
.room-item .rn { font-weight: 700; }
.room-item .rs { font-size: 0.8rem; color: var(--muted); }
footer { text-align: center; }

/* ---------- game stage ---------- */
#game { background: var(--felt-dark); }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#felt {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.10), transparent 55%),
    radial-gradient(ellipse at 50% 50%, #19774a 0%, #0f5132 45%, #0a3a24 75%, #051c11 100%);
}
#felt::after {
  content: ''; position: absolute; inset: 0; opacity: 0.18; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
#tableGlow {
  position: absolute; border-radius: 28px; pointer-events: none;
  border: 2px dashed rgba(233, 196, 106, 0); transition: border-color 0.2s, background 0.2s;
}
#tableGlow.drop { border-color: rgba(233, 196, 106, 0.6); background: rgba(233, 196, 106, 0.06); }

#cards { position: absolute; inset: 0; pointer-events: none; perspective: 1400px; }
.card {
  position: absolute; left: 0; top: 0;
  width: var(--cw); height: var(--ch);
  margin-left: calc(var(--cw) / -2); margin-top: calc(var(--ch) / -2);
  transition: transform var(--fly) var(--ease), opacity 0.35s;
  will-change: transform;
  transform-style: preserve-3d;
}
.card .inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform var(--fly) var(--ease), translate 0.18s var(--ease);
}
.card.down .inner { transform: rotateY(180deg); }
.card .face {
  position: absolute; inset: 0; border-radius: calc(var(--cw) * 0.08);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 0 0 0.5px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transition: filter 0.2s, box-shadow 0.2s;
}
.card .face svg { width: 100%; height: 100%; display: block; }
.card .back { transform: rotateY(180deg); background: var(--back) center / 100% 100% no-repeat, #7d1424; }
.card.mine { pointer-events: auto; cursor: grab; }
@media (hover: hover) { .card.mine:hover .inner { translate: 0 -12%; } }
.card.mine.selected .inner { translate: 0 -22%; }
.card.mine.selected .front { box-shadow: 0 0 0 3px var(--gold), 0 10px 24px rgba(0, 0, 0, 0.5); }
.card.mine.playable .front { box-shadow: 0 0 0 2px rgba(233, 196, 106, 0.85), 0 4px 14px rgba(0, 0, 0, 0.45); }
.card.mine.dim .front { filter: brightness(0.62) saturate(0.7); }
.card.dragging { transition: none !important; cursor: grabbing; z-index: 2000 !important; }
.card.dragging .front { box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55) !important; }
.card.target { pointer-events: auto; cursor: pointer; }
.card.target .front { box-shadow: 0 0 0 3px #7cf0a0, 0 0 18px rgba(124, 240, 160, 0.7); animation: pulse 1s infinite alternate; }
.card.hot .front { box-shadow: 0 0 0 3px #7cf0a0, 0 0 26px rgba(124, 240, 160, 0.95); }
.card.trump-under .front { filter: brightness(0.95); }
@keyframes pulse { to { box-shadow: 0 0 0 3px #bff7d1, 0 0 26px rgba(124, 240, 160, 0.9); } }
.card.shake .inner { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }
.card.fade { opacity: 0; }

.pile-label {
  position: absolute; transform: translate(-50%, 0);
  font-size: 0.78rem; font-weight: 800; color: var(--gold);
  background: rgba(0, 0, 0, 0.45); padding: 2px 8px; border-radius: 9px; pointer-events: none;
  transition: opacity 0.3s; white-space: nowrap;
}
.trump-badge {
  position: absolute; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
  background: radial-gradient(#fffaf0, #e8dfc6); border: 2px solid var(--gold); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.trump-badge.red { color: #c0172b; }
.trump-badge.black { color: #16161d; }

/* ---------- attack arrows ---------- */
#arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#arrows .arrow { fill: none; stroke-linecap: round; }
#arrows .arrow.main { stroke: #f3d27e; stroke-width: 4; stroke-dasharray: 12 9; animation: march 0.9s linear infinite; filter: drop-shadow(0 0 6px rgba(243, 210, 126, 0.6)); }
#arrows .arrow.side { stroke: rgba(243, 210, 126, 0.5); stroke-width: 2.5; stroke-dasharray: 5 8; animation: march 1.4s linear infinite; }
#arrows .arrow.me { stroke: #ff6b6b; filter: drop-shadow(0 0 8px rgba(255, 90, 90, 0.8)); }
#arrows .arrow.main.me { stroke-width: 5; }
@keyframes march { to { stroke-dashoffset: -21; } }
#arrows .arrow.gone { opacity: 0; transition: opacity 0.2s; }
#arrows .arrow.fadein { animation: march 0.9s linear infinite, arrowIn 0.6s ease-out; }
@keyframes arrowIn { from { opacity: 0; } }
#arrows .sweep-arrow {
  fill: none; stroke: #ff8a5c; stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  filter: drop-shadow(0 0 10px rgba(255, 138, 92, 0.9));
  animation: sweepDraw 0.55s cubic-bezier(0.3, 0.7, 0.3, 1) forwards, sweepOut 0.5s 1s forwards;
}
@keyframes sweepDraw { to { stroke-dashoffset: 0; } }
@keyframes sweepOut { to { opacity: 0; } }
.card.sweep .front { box-shadow: 0 0 0 2px #ff8a5c, 0 0 22px rgba(255, 138, 92, 0.85); }
.card.sweep { transition-duration: 700ms !important; }
.plate.flash { animation: plateFlash 1.1s ease-out; }
@keyframes plateFlash { 0% { transform: translate(-50%, -50%) scale(1); } 25% { transform: translate(-50%, -50%) scale(1.18); box-shadow: 0 0 0 6px rgba(255, 138, 92, 0.6), 0 0 40px rgba(255, 138, 92, 0.8); } 100% { transform: translate(-50%, -50%) scale(1); } }

/* ---------- player plates ---------- */
#plates { position: absolute; inset: 0; pointer-events: none; }
.plate {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(6, 22, 15, 0.82); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px; padding: 4px 12px 4px 4px; min-width: 120px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: left 0.4s var(--ease), top 0.4s var(--ease), border-color 0.3s, box-shadow 0.3s, opacity 0.3s;
  pointer-events: auto;
  white-space: nowrap;
}
.plate.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233, 196, 106, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35); }
.plate.offline { opacity: 0.6; }
.plate.out { border-color: #7cf0a0; }
.plate.defender { border-color: #ff6b6b; animation: defPulse 1.4s ease-in-out infinite; }
.plate.attacker { border-color: var(--gold); }
@keyframes defPulse { 50% { box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.45), 0 0 26px rgba(255, 90, 90, 0.55); } }
.plate.durak { border-color: var(--red); box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.5); }
.plate .av {
  position: relative; width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 1.45rem;
  background: radial-gradient(circle at 35% 30%, #3b7f5d, #12392a);
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.plate .av .ring { position: absolute; inset: -5px; width: 50px; height: 50px; transform: rotate(-90deg); }
.plate .av .ring circle { fill: none; stroke: var(--gold); stroke-width: 3.5; stroke-linecap: round; }
.plate .av .ring.low circle { stroke: var(--red); }
.plate .av .clown { position: absolute; top: -16px; font-size: 1.2rem; animation: bob 1.2s infinite alternate; }
@keyframes bob { to { transform: translateY(-3px) rotate(8deg); } }
.plate .meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.plate .nm { font-weight: 700; font-size: 0.9rem; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.plate .sub { font-size: 0.72rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.plate .role { font-size: 0.68rem; font-weight: 800; padding: 1px 6px; border-radius: 6px; letter-spacing: 0.04em; }
.role.atk { background: #8a5a12; color: #ffe3a3; }
.role.def { background: #a52c2c; color: #ffe0e0; }
.role.atk2 { background: rgba(138, 90, 18, 0.55); color: #ffe3a3; }
.role.take { background: #8a1d1d; color: #ffd0d0; }
.role.pass { background: #3a4a42; color: #d7e6dc; }
.role.outr { background: #1d6a3e; color: #c9ffdc; }
.plate .count {
  position: absolute; right: -6px; top: -8px; background: var(--gold); color: #2b1d02; font-weight: 800;
  font-size: 0.72rem; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.plate .tools { display: flex; gap: 4px; margin-left: 4px; }
.plate .tools button { pointer-events: auto; }
.plate.empty { background: rgba(0, 0, 0, 0.25); border-style: dashed; color: var(--muted); }
.plate.empty .av { background: rgba(255, 255, 255, 0.06); border-style: dashed; }
.plate .host { font-size: 0.8rem; }
.bubble {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  background: #fffaf0; color: #1b1b1b; border-radius: 12px; padding: 6px 10px; font-size: 0.85rem; font-weight: 600;
  max-width: 220px; white-space: normal; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  animation: bubbleIn 0.25s var(--ease); pointer-events: none; z-index: 5;
}
.bubble.emote { font-size: 2rem; background: none; box-shadow: none; padding: 0; animation: emoteUp 2.2s var(--ease) forwards; }
.bubble::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: #fffaf0; }
.bubble.emote::after { display: none; }
@keyframes bubbleIn { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }
@keyframes emoteUp { 0% { transform: translateX(-50%) scale(0.3); opacity: 0; } 15% { transform: translateX(-50%) scale(1.3); opacity: 1; } 30% { transform: translateX(-50%) scale(1); } 100% { transform: translate(-50%, -50px); opacity: 0; } }

/* ---------- status + actions ---------- */
.status {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5); padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: 0.92rem; white-space: nowrap; pointer-events: none;
  transition: opacity 0.25s, background 0.25s; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis;
}
.status.you { background: rgba(201, 154, 46, 0.85); color: #2b1d02; }
.status.danger { background: rgba(165, 44, 44, 0.9); color: #fff; }
.status:empty { opacity: 0; }
.actions { position: absolute; display: flex; gap: 8px; transform: translate(-50%, -50%); }
.actions .btn { font-size: 1rem; padding: 0.6em 1.2em; animation: popIn 0.25s var(--ease); }
@keyframes popIn { from { transform: scale(0.6); opacity: 0; } }
.banner {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%) scale(0.6);
  font-family: Cinzel, serif; font-weight: 800; font-size: clamp(1.8rem, 7vw, 3.4rem);
  color: var(--gold); text-shadow: 0 4px 16px rgba(0, 0, 0, 0.7), 0 0 30px rgba(233, 196, 106, 0.4);
  opacity: 0; pointer-events: none; white-space: nowrap; letter-spacing: 0.08em; z-index: 3000;
}
.banner.show { animation: bannerIn 1.5s var(--ease) forwards; }
.banner.red { color: #ff8a8a; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  25% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ---------- top bar ---------- */
#topbar {
  position: absolute; left: 0; right: 0; top: 0; height: 52px; padding: 7px 10px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent); pointer-events: none; z-index: 4000;
}
#topbar > * { pointer-events: auto; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.tb-title #roomName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
.code-chip {
  background: rgba(233, 196, 106, 0.18); color: var(--gold); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 3px 8px; font-weight: 800; letter-spacing: 0.2em; cursor: pointer;
}
.conn {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 4500;
  background: #8a1d1d; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 0.85rem;
}

/* ---------- lobby panel ---------- */
.panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px;
  padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); z-index: 3500;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
  animation: panelIn 0.35s var(--ease);
}
@keyframes panelIn { from { transform: translate(-50%, -46%); opacity: 0; } }
.panel h2 { margin: 0; font-family: Cinzel, serif; letter-spacing: 0.05em; }
.big-code { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.35em; color: var(--gold); margin-left: 0.35em; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.opt-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; font-size: 0.92rem; }
.result-list { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.result-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.result-item.durak { background: rgba(214, 69, 69, 0.22); border: 1px solid rgba(214, 69, 69, 0.6); }
.result-item .place { width: 28px; text-align: center; font-weight: 800; font-size: 1.1rem; }
.result-item .sc { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.durak-hero { font-size: 3.2rem; line-height: 1; animation: bob 0.8s infinite alternate; }
.reveal-note { font-size: 0.8rem; color: var(--muted); }

/* ---------- transfer-or-beat popup ---------- */
.choice { position: absolute; inset: 0; z-index: 4600; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.choice-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: center; width: min(300px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); animation: popIn 0.22s var(--ease);
}
.choice-title { font-weight: 800; font-size: 1.05rem; }
.choice-preview { width: 70px; height: 98px; margin: 0 auto 4px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5)); }
.choice-preview svg { width: 100%; height: 100%; }

/* ---------- chat ---------- */
.chat {
  position: absolute; right: 10px; top: 60px; bottom: 10px; width: min(320px, calc(100vw - 20px));
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  display: flex; flex-direction: column; z-index: 4200; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: chatIn 0.25s var(--ease);
}
@keyframes chatIn { from { transform: translateX(30px); opacity: 0; } }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; user-select: text; -webkit-user-select: text; }
.chat-log .sys { color: var(--gold); font-style: italic; font-size: 0.82rem; }
.chat-log b { color: #bfe7cf; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.chat-form input { flex: 1; min-width: 0; }
.emote-bar {
  position: absolute; z-index: 3900; display: flex; gap: 2px; padding: 3px;
  background: rgba(0, 0, 0, 0.35); border-radius: 999px; transform: translate(-50%, -50%);
}
.emote-bar button { background: none; border: none; font-size: 1.15rem; cursor: pointer; padding: 3px 4px; border-radius: 50%; transition: transform 0.15s; }
.emote-bar button:hover { transform: scale(1.3); }

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 6000; pointer-events: none; }
.toast { background: rgba(10, 10, 10, 0.88); color: #fff; padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; animation: toastIn 0.25s var(--ease); max-width: 90vw; text-align: center; }
.toast.err { background: rgba(140, 25, 25, 0.95); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 7000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { position: relative; max-width: 560px; max-height: 90vh; overflow-y: auto; background: #0d2a1c; border: 1px solid var(--panel-border); border-radius: 16px; padding: 20px 22px; line-height: 1.5; user-select: text; }
.modal-card h2 { font-family: Cinzel, serif; margin-top: 0; color: var(--gold); }
.modal-card li { margin-bottom: 6px; }
.modal-x { position: absolute; right: 12px; top: 12px; }
#confetti { position: absolute; inset: 0; pointer-events: none; z-index: 3800; width: 100%; height: 100%; }

.plate.compact { flex-direction: column; border-radius: 16px; padding: 6px 6px 5px; gap: 2px; min-width: 0; max-width: 92px; text-align: center; white-space: normal; }
.plate.compact .role { font-size: 0.6rem; padding: 1px 4px; white-space: nowrap; }
.plate.compact .meta { align-items: center; }
.plate.compact .nm { max-width: 72px; font-size: 0.76rem; }
.plate.compact .sub { flex-wrap: wrap; justify-content: center; gap: 3px; }
.plate.compact .tools { margin: 2px 0 0; flex-direction: column; }
/* iOS zooms into any focused input under 16px; keep inputs at 16px on touch devices. */
@media (pointer: coarse) { input, select { font-size: 16px !important; } }
@media (max-width: 560px) {
  .plate { min-width: 0; padding-right: 8px; gap: 6px; }
  .plate .av { width: 34px; height: 34px; font-size: 1.2rem; }
  .plate .av .ring { inset: -5px; width: 44px; height: 44px; }
  .plate .nm { font-size: 0.8rem; max-width: 76px; }
  .status { font-size: 0.82rem; }
  .tb-title #roomName { display: none; }
}
