/* ---------- HUD ---------- */
#game { padding-top: var(--safe-t); }
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; min-height: 52px;
}
.score { display: flex; align-items: center; gap: 6px; font-weight: 900; }
.team { display: flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 12px; font-size: 14px; }
.team b { font-size: 22px; line-height: 1; }
.team.us { background: rgba(25, 184, 166, .22); color: #9ff3e8; }
.team.them { background: rgba(255, 138, 61, .22); color: #ffd0ad; }
.vs { color: var(--muted); font-size: 12px; }
.hud-mid { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.trump-badge {
  background: var(--cream); color: var(--ink); border-radius: 12px; padding: 3px 10px; font-weight: 900;
  font-size: 14px; box-shadow: 0 0 0 2px var(--gold);
}
.trump-badge.red .sym { color: var(--red); }
.trump-badge .sym { font-size: 18px; }
.trick-badge { font-size: 12.5px; color: var(--muted); background: rgba(0, 0, 0, .25); padding: 3px 8px; border-radius: 10px; }
.hud-btns { display: flex; gap: 6px; }

/* ---------- table & carpet ---------- */
.table { position: relative; flex: 1; min-height: 0; margin: 0 6px; }
.carpet {
  position: absolute; inset: 0; border-radius: 22px;
  background:
    radial-gradient(circle at 50% 50%, rgba(244, 194, 91, .25) 0 8%, transparent 9%),
    radial-gradient(circle at 0 0, rgba(28, 35, 70, .55) 0 7%, transparent 8%),
    radial-gradient(circle at 100% 0, rgba(28, 35, 70, .55) 0 7%, transparent 8%),
    radial-gradient(circle at 0 100%, rgba(28, 35, 70, .55) 0 7%, transparent 8%),
    radial-gradient(circle at 100% 100%, rgba(28, 35, 70, .55) 0 7%, transparent 8%),
    repeating-linear-gradient(45deg, rgba(244, 194, 91, .07) 0 6px, transparent 6px 22px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, .12) 0 6px, transparent 6px 22px),
    var(--carpet);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, auto, auto, auto;
  border: 7px solid var(--navy);
  box-shadow:
    inset 0 0 0 3px var(--gold), inset 0 0 0 9px var(--carpet-dark), inset 0 0 0 11px rgba(244, 194, 91, .6),
    inset 0 0 60px rgba(0, 0, 0, .55), 0 10px 30px rgba(0, 0, 0, .5);
}
.sofreh {
  position: absolute; left: 23%; right: 23%; top: 21%; bottom: 19%;
  background:
    radial-gradient(ellipse at center, #fff8e6 0%, var(--cream) 60%, #e6d3a8 100%);
  border-radius: 26px;
  box-shadow: 0 0 0 5px #c9a35a, 0 0 0 9px var(--cream), 0 0 0 11px #b88a3b, 0 12px 26px rgba(0, 0, 0, .45);
  transition: inset .35s;
}
.table.lobby .sofreh { left: 25%; right: 25%; top: 26%; bottom: 24%; }
.deco { position: absolute; font-size: 20px; opacity: .85; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.deco.d1 { top: 6px; left: 8px; }
.deco.d2 { bottom: 6px; right: 8px; }
.deco.d3 { top: 6px; right: 10px; font-size: 16px; }
.center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--ink); padding: 10px; gap: 8px; overflow-y: auto; z-index: 2;
}
.center:empty { pointer-events: none; }
.center .wait { font-weight: 800; font-size: 15px; line-height: 1.7; }
.center .wait .think { display: inline-block; animation: think 1s ease-in-out infinite alternate; }
@keyframes think { to { transform: rotate(-15deg) scale(1.15); } }
.trick { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.trick .card { left: 50%; top: 50%; }

/* ---------- lobby: code on the sofreh, controls in the bottom panel ---------- */
.lobby-mini { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #6b4b3a; font-weight: 800; }
.lobby-mini .lbl { font-size: 12px; }
.code-big { font-size: clamp(28px, 9vw, 40px); letter-spacing: 3px; color: var(--carpet); line-height: 1.15; font-weight: 900; }
.lobby-mini small { font-size: 11px; font-weight: 700; }
.panel {
  margin: 4px 8px calc(6px + var(--safe-b)); padding: 10px; border-radius: 18px; max-height: 38vh; overflow-y: auto;
  background: linear-gradient(180deg, #fff9ea, #f1e1bd); color: var(--ink); box-shadow: 0 0 0 3px var(--gold), 0 8px 24px rgba(0, 0, 0, .4);
}
#game.with-panel .hand { display: none; }
.panel .overlay-card { box-shadow: none; background: none; padding: 0; max-width: none; text-align: center; }
.lobby-panel { display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: 100%; }
.invite { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.inv {
  border: 0; border-radius: 12px; padding: 6px 2px; background: rgba(94, 16, 32, .1); color: var(--ink);
  font-size: 11.5px; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.inv b { font-size: 20px; line-height: 1.2; }
.inv:active { background: var(--gold); }
.settings { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
.set { display: flex; align-items: center; gap: 4px; }
.lobby-panel .btn { background: rgba(94, 16, 32, .1); box-shadow: inset 0 0 0 1px rgba(94, 16, 32, .25); color: var(--ink); }
.lobby-panel .btn.small { padding: 4px 9px; min-width: 32px; }
.lobby-panel .btn.on { background: var(--carpet); color: #fff; }
.lobby-panel .btn.gold { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #3a1d06; box-shadow: 0 4px 0 #8f5410; }
.lobby-panel .btn.start { font-size: 18px; padding: 10px; }
.lobby-panel .lbl { font-size: 12px; font-weight: 800; color: #6b4b3a; }
.lobby-panel .wait { text-align: center; font-weight: 800; }
.lobby-panel .hint { font-size: 11.5px; color: #7a5a48; line-height: 1.7; margin: 0; text-align: center; }

/* ---------- seats ---------- */
.seat {
  --av: 52px;
  position: absolute; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 80px; transition: opacity .3s;
}
.seat .nm { display: flex; align-items: center; gap: 3px; }
.seat .nm-t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.seat .meta { display: flex; align-items: center; gap: 4px; }
.seat .meta:has(.rage[hidden]):has(.backs[hidden]) { display: none; }
.seat .seat-acts { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.seat.pos-t, .seat.pos-b { width: auto; min-width: 80px; max-width: 200px; }
.seat.pos-t .nm, .seat.pos-b .nm { max-width: 170px; }
.seat.pos-t .seat-acts, .seat.pos-b .seat-acts { flex-direction: row; }
.seat.pos-t .seat-acts { position: absolute; top: 2px; right: calc(100% + 4px); flex-direction: column; }
.seat.pos-t { top: 4px; left: 50%; transform: translateX(-50%); }
.seat.pos-l { left: 0; top: 40%; transform: translateY(-50%); }
.seat.pos-r { right: 0; top: 40%; transform: translateY(-50%); }
.seat.pos-b { bottom: 2px; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }
.seat.offline { opacity: .5; }
.av-wrap { position: relative; width: var(--av); height: var(--av); }
.ring {
  position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--t, 0) * 360deg), transparent 0);
  opacity: 0; transition: opacity .2s;
}
.seat.turn .ring { opacity: 1; }
.av {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: calc(var(--av) * .62); line-height: 1; background: radial-gradient(circle at 35% 30%, #fff6e2, #e9d3a8);
  border: 3px solid var(--them); box-shadow: 0 4px 10px rgba(0, 0, 0, .4);
}
.seat.us .av { border-color: var(--us); }
.seat.me .av { border-color: var(--gold); }
.seat.empty .av { background: rgba(0, 0, 0, .25); border: 2px dashed rgba(255, 255, 255, .35); font-size: 22px; }
.face {
  position: absolute; top: -10px; right: -12px; font-size: 24px; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); animation: facePop .25s ease-out;
}
@keyframes facePop { from { transform: scale(0) rotate(-30deg); } }
.badge-crown { position: absolute; top: -16px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 20px; }
.badge-bruise { position: absolute; bottom: -4px; left: -8px; font-size: 15px; letter-spacing: -6px; }
.badge-eyes { position: absolute; bottom: -6px; right: -10px; font-size: 22px; animation: eyes .5s ease-in-out infinite alternate; }
@keyframes eyes { to { transform: translateX(-4px); } }
.nm {
  max-width: 100%; font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(0, 0, 0, .45); padding: 1px 7px; border-radius: 8px;
}
.tags { font-size: 10px; color: var(--muted); display: flex; gap: 2px; align-items: center; flex: none; }
.tags:empty { display: none; }
.tags .t-us { color: #8ff0e2; }
.tags .t-them { color: #ffc49b; }
.rage { width: 40px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.rage i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd34d, #ff7a1a, #e8112d); transition: width .4s; }
.rage.full i { animation: rageFull .5s ease-in-out infinite alternate; }
@keyframes rageFull { to { filter: brightness(1.6); } }
.backs { font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.backs .mini-back {
  width: 12px; height: 17px; border-radius: 2px; border: 1px solid #c9a35a;
  background: repeating-linear-gradient(45deg, #23305f 0 2px, #1c2346 2px 4px);
}
.revealed { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; max-width: 120px; }
.revealed .card { --cw: 22px; position: relative; }
.seat-act { font-size: 11px; padding: 3px 8px; border-radius: 9px; border: 0; background: rgba(255, 255, 255, .15); font-weight: 700; }
.seat-act.gold { background: var(--gold); color: #3a1d06; }
.table.aiming .seat.target .av { animation: aim .6s ease-in-out infinite alternate; border-color: #ff3b3b; }
.table.aiming .seat.target .av::after { content: '🎯'; position: absolute; font-size: 18px; top: -8px; left: -8px; }
@keyframes aim { to { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(255, 59, 59, .45); } }

/* speech bubbles */
.bubble {
  position: absolute; z-index: 20; max-width: 170px; width: max-content; background: #fffaf0; color: var(--ink);
  padding: 6px 10px; border-radius: 14px; font-size: 12.5px; font-weight: 700; line-height: 1.5;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35); animation: bubbleIn .2s ease-out; pointer-events: none;
}
.bubble.wink { background: #ffe4f1; }
.bubble.chat { background: #e8f6ff; }
.pos-t .bubble { top: calc(var(--av) + 6px); }
.pos-b .bubble { bottom: calc(var(--av) + 8px); }
.pos-l .bubble { left: 82px; top: 0; }
.pos-r .bubble { right: 82px; top: 0; }
@keyframes bubbleIn { from { transform: scale(.6); opacity: 0; } }

.feed {
  height: 24px; margin: 0 8px 3px; pointer-events: none; display: flex; justify-content: center; align-items: center;
}
.feed div {
  background: rgba(0, 0, 0, .35); padding: 2px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 700;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: toastIn .25s ease-out;
}
.feed div.out { animation: toastOut .4s ease-in forwards; }

/* ---------- cards ---------- */
.card {
  --cw: 56px;
  position: absolute; width: var(--cw); height: calc(var(--cw) * 1.42); border-radius: calc(var(--cw) * .12);
  background: linear-gradient(160deg, #fffefa, #f5ecd8); color: #17172b; border: 1px solid #cdbb94;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35); font-weight: 900; overflow: hidden;
}
.card.red { color: var(--red); }
.card .ix {
  position: absolute; top: 3%; left: 6%; display: flex; flex-direction: column; align-items: center;
  line-height: 1; font-size: calc(var(--cw) * .32);
}
.card .ix i { font-style: normal; font-size: calc(var(--cw) * .27); }
.card .mid { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 22%; padding-left: 18%; font-size: calc(var(--cw) * .5); }
.card .mid.face-card { font-size: calc(var(--cw) * .48); }
.card.back {
  background:
    radial-gradient(circle, rgba(244, 194, 91, .9) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, #2b3a74 0 4px, #1c2346 4px 8px);
  border: 2px solid #c9a35a;
}
.card.back::after { content: '🩴'; position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .32); }

/* ---------- hand ---------- */
.hand {
  --cw: clamp(50px, 14.5vw, 78px);
  position: relative; height: calc(var(--cw) * 1.42 + 30px); margin: 0 8px calc(4px + var(--safe-b));
}
.hand .card { --cw: inherit; bottom: 4px; transition: transform .18s, filter .2s, box-shadow .2s; cursor: pointer; transform-origin: 50% 120%; }
.hand.myturn .card.legal { box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(244, 194, 91, .5); }
.hand.myturn .card.illegal { filter: brightness(.55) saturate(.5); }
.hand .card.sel { box-shadow: 0 0 0 3px #fff, 0 0 18px var(--gold); }
.hand-note {
  position: absolute; left: 50%; top: -6px; transform: translateX(-50%); font-size: 12.5px; font-weight: 800;
  background: var(--gold); color: #3a1d06; padding: 2px 10px; border-radius: 10px; white-space: nowrap; z-index: 30;
  animation: notePulse .8s ease-in-out infinite alternate;
}
@keyframes notePulse { to { transform: translateX(-50%) scale(1.07); } }

/* ---------- dock ---------- */
.dock { padding: 4px 8px 2px; display: flex; flex-direction: column; gap: 4px; }
.items { display: flex; gap: 4px; justify-content: center; overflow-x: auto; scrollbar-width: none; }
.items::-webkit-scrollbar { display: none; }
.item {
  position: relative; flex: 0 0 auto; width: 43px; height: 46px; border-radius: 12px; border: 2px solid transparent;
  background: rgba(255, 255, 255, .09); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 21px; line-height: 1.05; padding: 0;
}
.item small { font-size: 8.5px; color: var(--muted); white-space: nowrap; }
.item.sel { border-color: var(--gold); background: rgba(244, 194, 91, .22); }
.item.locked { opacity: .38; }
.item.ready-ult { animation: ult .6s ease-in-out infinite alternate; border-color: #ff4d4d; }
@keyframes ult { to { transform: scale(1.12); box-shadow: 0 0 14px #ff4d4d; } }
.item .cdm { position: absolute; inset: 0; border-radius: 10px; background: conic-gradient(rgba(0, 0, 0, .62) calc(var(--p, 0) * 360deg), transparent 0); pointer-events: none; }
.dock-row2 { display: flex; align-items: center; gap: 8px; }
.my-rage { flex: 1; position: relative; height: 18px; border-radius: 9px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.my-rage i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #ffd34d, #ff7a1a, #e8112d); transition: width .4s; }
.my-rage span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 900; text-shadow: 0 1px 2px #000; }
.my-rage.full i { animation: rageFull .4s ease-in-out infinite alternate; }
.actions { display: flex; gap: 4px; }
.act {
  border: 0; width: 46px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, .1);
  font-size: 18px; line-height: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.act small { font-size: 9px; color: var(--muted); }
.act.used { opacity: .4; }
.act.rec { background: #e8112d; animation: ult .5s ease-in-out infinite alternate; }

/* spectators */
#game.spectator .hand { display: none; }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  .seat { --av: 66px; width: 120px; }
  .pos-l .bubble { left: 124px; }
  .pos-r .bubble { right: 124px; }
  .dock { flex-direction: row; justify-content: center; align-items: center; }
  .dock-row2 { flex: 0 1 420px; }
  .item { width: 50px; height: 52px; font-size: 24px; }
  .hand { --cw: 74px; max-width: 900px; margin-inline: auto; width: 100%; }
  #game { max-width: 1100px; margin: 0 auto; width: 100%; }
}
@media (max-height: 640px) {
  .seat { --av: 44px; }
  .hand { --cw: clamp(44px, 12vw, 60px); }
}
