/* ============================================================
   Last Card — styles (designed for landscape phones; portrait fallback at the end)
   ============================================================ */
:root {
  --text: #f5f7f6;
  --muted: #a9b8b0;
  --panel: rgba(10, 18, 15, 0.74);
  --panel-solid: #121c18;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #ffc83d;
  --accent-ink: #2b1d00;
  --red: #e5322d;
  --yellow: #f7c815;
  --green: #2fa84f;
  --blue: #1f6fd1;
  --danger: #e5484d;
  --ok: #4ade80;
  --cw: clamp(50px, min(17vh, 12vw), 88px);
  --ch: calc(var(--cw) * 1.5);
  --pile-w: clamp(52px, min(15.5vh, 11vw), 92px);
  --rail: 66px; /* right-hand control column in landscape */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text); background: #0b0f0d; overflow: hidden; user-select: none; -webkit-user-select: none;
}
/* A dim room with a warm lamp over the table. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 70% at 50% 30%, rgba(255, 214, 140, 0.10), transparent 70%),
    radial-gradient(ellipse at 50% 120%, #10261b 0%, transparent 60%),
    linear-gradient(180deg, #0d1512 0%, #0a0f0d 55%, #070a09 100%);
}
input, button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.center-row { justify-content: center; }

.screen {
  position: fixed; inset: 0; overflow-y: auto;
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); color: var(--text);
  padding: 10px 18px; border-radius: 14px; font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #ffd45e, #f2b308); color: var(--accent-ink); border-color: transparent; box-shadow: 0 6px 18px rgba(242, 179, 8, 0.25); }
.btn.warn { background: linear-gradient(180deg, #ff8a3d, #e5531a); border-color: transparent; }
.btn.danger { background: linear-gradient(180deg, #f0656a, #c9373c); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 7px 12px; font-size: 0.85rem; border-radius: 11px; }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 1.05rem; border-radius: 16px; }
.btn.live { background: linear-gradient(180deg, #ff6b6b, #d63a3a); border-color: transparent; }

.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); cursor: pointer; font-size: 1.05rem;
}
.icon-btn.small { width: 34px; height: 34px; font-size: 0.95rem; }
.icon-btn:active { transform: scale(0.94); }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 0.85rem; padding: 6px 0; cursor: pointer; justify-self: start; }

input:not([type=checkbox]) {
  width: 100%; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--text); outline: none; font-size: 1rem;
}
input:focus { border-color: var(--accent); }
.field { display: block; color: var(--muted); font-size: 0.8rem; }
.field input { margin-top: 6px; }
.code-input { text-transform: uppercase; letter-spacing: 0.25em; font-weight: 800; text-align: center; }
.code-input::placeholder { letter-spacing: 0.05em; font-weight: 500; text-transform: none; }

.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 800; display: grid; place-items: center;
}

/* ---------- avatars ---------- */
.avatar {
  position: relative; width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, #6d5dfc, #b23dff);
  background-size: cover; background-position: center; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18); transition: box-shadow 0.12s;
}
.avatar.pic { color: transparent; }
.speaking .avatar { box-shadow: 0 0 0 3px var(--ok), 0 0 16px 4px rgba(74, 222, 128, 0.6) !important; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--panel-solid); background: #6b7280; }
.online .avatar .dot { background: var(--ok); }

/* ============================================================
   HOME — two columns: play on the left, live tables on the right
   ============================================================ */
.screen.home {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  gap: 10px 26px; max-width: 980px; margin: 0 auto; overflow: hidden;
}
.home-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.profile-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: 999px; min-width: 0;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); cursor: pointer; text-align: left;
}
.profile-chip .avatar { width: 36px; height: 36px; }
.pc-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pc-text b { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
#myPoints { font-size: 0.74rem; font-weight: 800; color: var(--accent); }
.head-actions { display: flex; gap: 8px; }

.home-main { display: flex; flex-direction: column; justify-content: center; gap: 12px; min-height: 0; }
.hero { display: flex; align-items: center; gap: 14px; }
.hero-logo { width: clamp(56px, 16vh, 84px); height: clamp(56px, 16vh, 84px); filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6)); flex: none; }
.hero h1 {
  font-family: 'Arial Black', Roboto, sans-serif; font-weight: 900; font-style: italic; font-size: clamp(1.6rem, 6vh, 2.2rem);
  color: var(--accent); -webkit-text-stroke: 1.5px #3a1500; paint-order: stroke fill; text-shadow: 0 3px 0 #3a1500, 0 10px 24px rgba(0, 0, 0, 0.6);
}
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

.play-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.play-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; min-height: clamp(96px, 27vh, 130px);
  border-radius: 20px; border: 1px solid var(--line); cursor: pointer; text-align: left; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #1f2b26, #121a17); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.1s;
}
.play-tile:active { transform: scale(0.97); }
.play-tile b { font-size: 1.08rem; margin-top: auto; }
.play-tile small { color: var(--muted); font-size: 0.76rem; }
.play-tile .pt-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; font-weight: 900; background: rgba(255, 255, 255, 0.08); }
.play-tile.gold { background: linear-gradient(160deg, #ffd45e, #e9a300); color: var(--accent-ink); border-color: transparent; }
.play-tile.gold small { color: rgba(43, 29, 0, 0.7); }
.play-tile.gold .pt-icon { background: rgba(43, 29, 0, 0.12); }
.play-tile::after { content: ''; position: absolute; right: -18px; bottom: -26px; width: 70px; height: 100px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); transform: rotate(18deg); }

.join-row { display: flex; gap: 8px; }

section.live { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.section-head h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; overflow-y: auto; align-content: start; }
.room-list li { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.room-list li.empty { justify-content: center; color: var(--muted); font-size: 0.86rem; padding: 24px 12px; text-align: center; background: none; }
.room-icon { width: 36px; height: 36px; border-radius: 50%; flex: none; background: radial-gradient(circle at 50% 40%, #2fa364, #0f4d2a); box-shadow: inset 0 0 0 3px #6b3f1d, 0 2px 6px rgba(0, 0, 0, 0.5); }
.room-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-info span { font-size: 0.76rem; color: var(--muted); }
.room-info .playing { color: var(--accent); }

/* ============================================================
   BARS
   ============================================================ */
.bar { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 42px; }
.bar-title { display: flex; flex-direction: column; align-items: center; text-align: center; font-weight: 750; min-width: 0; line-height: 1.2; }
.bar-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.code-badge { padding: 7px 12px; border-radius: 12px; border: 1px dashed rgba(255, 200, 61, 0.6); background: rgba(0, 0, 0, 0.35); color: var(--accent); font-weight: 900; letter-spacing: 0.2em; cursor: pointer; }
.code-badge.big { font-size: 1.4rem; padding: 8px 18px; }

/* ============================================================
   LOBBY — players on the left, options on the right
   ============================================================ */
.screen.lobby { padding-right: calc(var(--rail) + 10px + var(--safe-right)); display: flex; flex-direction: column; }
.share-hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 2px 0 10px; }
.share-hint b { color: var(--accent); letter-spacing: 0.15em; }
.lobby-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; max-width: 900px; width: 100%; margin: 0 auto; }
.member-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; align-content: start; overflow-y: auto; }
.member-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.member-list li.offline { opacity: 0.5; }
.minfo { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mname { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpoints { font-size: 0.74rem; color: var(--muted); }
.vi { font-size: 0.85rem; }
.pmute { padding: 4px 6px !important; font-size: 0.9rem; }
.pmute.on { color: #ff8a8a; }
.friend-tag { font-size: 0.72rem; padding: 3px 8px; border-radius: 999px; background: rgba(74, 222, 128, 0.14); color: #86efac; }
.friend-tag.muted { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.lobby-side { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.lobby-options { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: grid; gap: 10px; }
.opt { display: grid; gap: 6px; }
.opt-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.lobby-options p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--text); font-weight: 700; font-size: 0.8rem; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip:disabled:not(.on) { opacity: 0.45; }
.chip:disabled { cursor: default; }
.lobby-hint { text-align: center; color: var(--muted); margin: 0; font-size: 0.88rem; }

/* ============================================================
   GAME — table fills the screen, hand along the bottom edge
   ============================================================ */
.screen.game { padding: 0; overflow: hidden; }
.game-bar { position: absolute; z-index: 6; top: calc(4px + var(--safe-top)); left: calc(10px + var(--safe-left)); right: calc(var(--rail) + 10px + var(--safe-right)); }
.game-clock { font-size: 0.76rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }
.game-clock.low { color: #ff6b6b; animation: pulse 0.8s infinite; }
.timer-pill { min-width: 52px; text-align: center; padding: 6px 10px; border-radius: 999px; font-weight: 800; font-size: 0.85rem; font-variant-numeric: tabular-nums; background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); }
.timer-pill:empty { visibility: hidden; }
.timer-pill.mine { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.timer-pill.low { background: var(--danger); color: #fff; animation: pulse 0.7s infinite; }

.leaders { position: absolute; z-index: 6; top: calc(48px + var(--safe-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; animation: popIn 0.35s ease-out; white-space: nowrap; }
.leader { padding: 4px 11px; border-radius: 999px; font-weight: 800; font-size: 0.74rem; background: linear-gradient(180deg, #ffd84d, #f2b705); color: var(--accent-ink); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5); }
.leader + .leader { background: linear-gradient(180deg, #f1f3f7, #b9c0cc); }
.leader.me { outline: 2px solid #fff; }

/* The table: wooden rim around green felt. */
.table-area {
  position: absolute; display: flex;
  top: calc(46px + var(--safe-top)); bottom: calc(6px + var(--safe-bottom));
  left: calc(8px + var(--safe-left)); right: calc(var(--rail) + 6px + var(--safe-right));
}
.table-rim {
  flex: 1; display: flex; padding: 10px; border-radius: 50% / 46%;
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.2), transparent 28%),
    linear-gradient(135deg, #8a5527 0%, #5a3216 35%, #7a4720 60%, #43240f 100%);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.75), inset 0 2px 1px rgba(255, 255, 255, 0.25), inset 0 -4px 8px rgba(0, 0, 0, 0.5);
}
.felt {
  position: relative; flex: 1; border-radius: 50% / 46%;
  background:
    url("img/felt-noise.svg"),
    radial-gradient(ellipse 70% 70% at 50% 42%, #34ad6a 0%, #208049 45%, #135e33 80%, #0c4425 100%);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 -10px 30px rgba(0, 0, 0, 0.35);
}
.felt::before { content: ''; position: absolute; left: 50%; top: 40%; height: 62%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.06); }

/* Opponent seats around the table edge (positioned by app.js). */
.seats { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; z-index: 2; }
.seat { position: absolute; transform: translate(-50%, -50%); width: 80px; display: flex; flex-direction: column; align-items: center; transition: left 0.3s, top 0.3s; }
.seat.offline { opacity: 0.5; }
.ring-wrap { position: relative; width: 44px; height: 44px; }
.ring-wrap .avatar { width: 44px; height: 44px; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.5); }
.turn-ring { position: absolute; left: -6px; top: -6px; width: 56px; height: 56px; transform: rotate(-90deg); pointer-events: none; }
.turn-ring circle { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.seat:not(.turn) .turn-ring { display: none; }
.seat.turn .avatar { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 0 18px rgba(255, 200, 61, 0.75); }
.seat .count { position: absolute; right: -9px; top: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; font-size: 0.72rem; font-weight: 900; background: #fff; color: #1a1a1a; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
.seat.last-one .count { background: var(--red); color: #fff; animation: pulse 0.8s infinite; }
.seat .oname { max-width: 80px; font-size: 0.7rem; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.5); margin-top: 4px; }
.seat .pmute { position: absolute !important; left: -12px; bottom: -5px; border: 0 !important; background: rgba(0, 0, 0, 0.6) !important; border-radius: 50% !important; font-size: 0.66rem !important; width: 22px; height: 22px; padding: 0 !important; display: grid; place-items: center; }
.seat .vi { position: absolute; right: -8px; bottom: -4px; font-size: 0.7rem; }
.seat.uno-flash .ring-wrap { animation: unoShake 0.5s 3; }
.mini-fan { position: relative; width: 56px; height: 22px; margin-top: 2px; }
.mini-fan img { position: absolute; left: 50%; bottom: 0; width: 14px; height: 21px; transform-origin: 50% 110%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }

/* Center: deck, discard pile, direction ring, status. */
.center { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); height: min(62%, 300px); aspect-ratio: 1; display: grid; place-items: center; z-index: 1; }
.dir-ring { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--accent); opacity: 0.6; animation: spin 16s linear infinite; }
.dir-ring path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 9; }
.dir-ring.ccw { animation-name: spinCcw; }
.piles { display: flex; gap: 20px; align-items: center; }
.deck-wrap { position: relative; }
.card { width: var(--cw); height: var(--ch); padding: 0; border: 0; background: none; flex: none; border-radius: calc(var(--cw) * 0.1); cursor: pointer; position: relative; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.55)); }
.card img { width: 100%; height: 100%; display: block; pointer-events: none; }
.piles .card { --cw: var(--pile-w); }
#deck { box-shadow: 2px 2px 0 #d8d8d8, 4px 4px 0 #bdbdbd, 6px 6px 0 #9e9e9e; }
.card.back em { position: absolute; top: -9px; right: -9px; min-width: 26px; padding: 2px 6px; border-radius: 999px; font-style: normal; font-size: 0.7rem; font-weight: 900; color: var(--accent-ink); background: var(--accent); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.card.back.glow { animation: glow 1.4s infinite; }
.card.back.must-draw { animation: mustDraw 0.9s ease-in-out infinite; }
.draw-hint { position: absolute; left: 50%; top: -28px; transform: translateX(-50%); white-space: nowrap; z-index: 2; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 0.68rem; padding: 4px 10px; border-radius: 999px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6); animation: hintBob 0.9s ease-in-out infinite; }
.draw-hint::after { content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--accent); border-bottom: 0; }
.discard { position: relative; width: var(--pile-w); height: calc(var(--pile-w) * 1.5); }
.discard .card { position: absolute; top: 0; left: 0; cursor: default; }
.discard::before { content: ''; position: absolute; inset: -22px; border-radius: 40%; background: radial-gradient(closest-side, var(--glow, transparent), transparent); opacity: 0.6; filter: blur(4px); transition: background 0.3s; }

.status-pill {
  position: absolute; left: 50%; top: calc(40% + min(31%, 150px) + 6px); transform: translateX(-50%); z-index: 2; max-width: 70%;
  display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 8px; border-radius: 16px; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px);
}
.status-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
#turnText { font-weight: 800; font-size: 0.86rem; white-space: nowrap; }
.my-turn .status-pill { background: var(--accent); color: var(--accent-ink); }
.color-dot { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); }
.color-dot.red { background: var(--red); } .color-dot.yellow { background: var(--yellow); }
.color-dot.green { background: var(--green); } .color-dot.blue { background: var(--blue); }
.log { list-style: none; margin: 0; padding: 0; font-size: 0.7rem; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log li { overflow: hidden; text-overflow: ellipsis; }

.actions { position: absolute; z-index: 5; right: calc(var(--rail) + 18px + var(--safe-right)); bottom: calc(var(--ch) * 0.55 + 14px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.draw-btn { animation: pulseGlow 1.2s infinite; }

/* Your hand, held in a fan along the bottom edge (cards positioned by app.js). */
.hand { position: absolute; z-index: 4; left: calc(70px + var(--safe-left)); right: calc(var(--rail) + 120px + var(--safe-right)); bottom: calc(-0.18 * var(--ch) + var(--safe-bottom)); height: calc(var(--ch) + 30px); }
.hand .card { position: absolute; bottom: 0; transform-origin: 50% 130%; transition: transform 0.18s ease, filter 0.15s; }
.hand .card.playable { filter: drop-shadow(0 0 7px rgba(255, 224, 102, 0.95)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.6)); }
.hand .card.dim { filter: brightness(0.6) drop-shadow(0 4px 5px rgba(0, 0, 0, 0.55)); }
.hand .card.drawn { outline: 3px solid #fff; outline-offset: 2px; }
.hand.one-left .card { filter: drop-shadow(0 0 10px #ff4d4d) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6)); }
.hand .card.dealt { animation: deal 0.45s cubic-bezier(.3,.8,.3,1) backwards; animation-delay: var(--d); }
.hand .card.incoming { animation: popIn 0.35s ease-out backwards; animation-delay: var(--d); }
.hand.scrollable { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.hand::-webkit-scrollbar { display: none; }

/* ---------- flying cards & UNO burst ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 45; overflow: hidden; }
.flying { position: absolute; left: 0; top: 0; filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.6)); will-change: transform; }
.uno-burst { position: absolute; transform: translate(-50%, -50%); text-align: center; animation: burst 1.9s ease-out forwards; }
.uno-burst b { display: block; font-family: 'Arial Black', Roboto, sans-serif; font-style: italic; font-weight: 900; font-size: 3.2rem; color: #ffd84d; -webkit-text-stroke: 3px #7a0b00; paint-order: stroke fill; text-shadow: 0 5px 0 #7a0b00, 0 0 30px #ff4d4d, 0 10px 24px rgba(0, 0, 0, 0.7); }
.uno-burst small { display: inline-block; margin-top: 4px; padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.75); color: #fff; font-weight: 700; font-size: 0.8rem; }

/* ============================================================
   CONTROL RAIL (voice, music, friends, chat) — right edge in landscape
   ============================================================ */
.roombar {
  position: fixed; z-index: 20; top: 0; bottom: 0; right: 0; width: calc(var(--rail) + var(--safe-right));
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom)) 10px;
  display: flex; flex-direction: column; gap: 10px; justify-content: center; align-items: center;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.55) 40%);
}
.roombar .btn { width: 46px; height: 46px; padding: 0; border-radius: 50%; display: grid; place-items: center; position: relative; font-size: 1.05rem; }
.roombar .voice .vb-label { display: none; }
.roombar .voice.live { box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.35); }
#sfxBtn.off { opacity: 0.45; text-decoration: line-through; }

/* ============================================================
   DRAWERS & SHEETS — side panels in landscape
   ============================================================ */
.drawer {
  position: fixed; z-index: 30; top: 0; bottom: 0; right: 0; width: min(400px, 92vw);
  display: flex; flex-direction: column; gap: 10px;
  padding: calc(14px + var(--safe-top)) calc(16px + var(--safe-right)) calc(14px + var(--safe-bottom)) 16px;
  background: var(--panel-solid); border-left: 1px solid var(--line); box-shadow: -16px 0 40px rgba(0, 0, 0, 0.7);
  animation: sheetIn 0.22s ease-out;
}
.drawer h3 { margin: 6px 0 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.drawer > .row.between:first-child, .sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-scroll { flex: 1; overflow-y: auto; display: grid; gap: 6px; align-content: start; padding-bottom: 8px; }
.sheet-section { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; display: grid; gap: 8px; }
.sheet-section h3 { margin: 0; }
.sheet-section p { margin: 0; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-weight: 600; cursor: pointer; }
.switch-row input { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 13px; background: #39423e; position: relative; cursor: pointer; transition: background 0.2s; margin: 0; }
.switch-row input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch-row input:checked { background: var(--green); }
.switch-row input:checked::after { transform: translateX(20px); }

.profile-row { display: flex; align-items: flex-end; gap: 12px; }
.profile-row .field { flex: 1; }
.avatar.profile-av { width: 58px; height: 58px; font-size: 1.4rem; border: 0; cursor: pointer; box-shadow: 0 0 0 3px var(--accent), 0 4px 12px rgba(0, 0, 0, 0.6); }
.avatar.profile-av::after { content: '📷'; position: absolute; right: -4px; bottom: -4px; font-size: 0.72rem; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.8); }

.account { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acct-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; flex: 1; }
.acct-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.small-av { width: 32px; height: 32px; font-size: 0.85rem; }
.google-btn { display: inline-flex; align-items: center; gap: 8px; background: #fff !important; color: #1f1f1f !important; border-color: #dadce0 !important; }

.chat-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; user-select: text; }
.chat-list li { background: rgba(255, 255, 255, 0.06); padding: 7px 11px; border-radius: 12px; align-self: flex-start; max-width: 85%; word-wrap: break-word; }
.chat-list li.mine { align-self: flex-end; background: rgba(255, 200, 61, 0.2); }
.chat-list li.system { align-self: center; background: none; color: var(--muted); font-size: 0.8rem; }
#chatForm, #addFriendForm { flex-wrap: nowrap; }

.my-code { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border-radius: 16px; background: rgba(255, 255, 255, 0.04); }
.friends-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.friend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); }
.friend-list li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.friend-list li.empty { background: none; color: var(--muted); }
.friend-list li.offline .avatar { filter: grayscale(0.7); opacity: 0.75; }
.finfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fname { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.fname strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpoints { flex: none; font-size: 0.72rem; font-weight: 800; color: var(--accent); }
.finfo .status { color: var(--muted); white-space: normal; line-height: 1.25; }
.finfo .status.on { color: #86efac; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.65); display: grid; place-items: center; padding: 12px; backdrop-filter: blur(3px); }
.modal-box { width: min(400px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7); animation: popIn 0.2s ease-out; }
.trophy { font-size: 2.6rem; }
.colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0; }
.swatch { height: 70px; border-radius: 18px; border: 3px solid #fff; cursor: pointer; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.5); }
.swatch.red { background: linear-gradient(145deg, #ff5a52, var(--red)); }
.swatch.yellow { background: linear-gradient(145deg, #ffe066, var(--yellow)); }
.swatch.green { background: linear-gradient(145deg, #5ad17a, var(--green)); }
.swatch.blue { background: linear-gradient(145deg, #4b95f0, var(--blue)); }

.avatar-box { width: min(560px, 100%); gap: 10px; }
.avatar.big-av { width: 84px; height: 84px; font-size: 2.2rem; align-self: center; box-shadow: 0 0 0 4px var(--accent), 0 8px 20px rgba(0, 0, 0, 0.6); }
.upload-btn { display: block; cursor: pointer; }
.preset-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.preset { aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; background-size: cover; background-position: center; cursor: pointer; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5); }
.preset.on { border-color: var(--accent); }

#winner .modal-box { width: min(460px, 100%); }
.results { list-style: none; margin: 2px 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.results li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); }
.results li.me { outline: 1px solid var(--accent); }
.results li:first-child { background: linear-gradient(90deg, rgba(255, 200, 61, 0.22), rgba(255, 255, 255, 0.05)); }
.results .medal { font-size: 1.3rem; width: 28px; text-align: center; }
.results .avatar { width: 32px; height: 32px; }
.rinfo { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rpoints { font-weight: 900; color: var(--accent); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); background: rgba(17, 17, 17, 0.92); color: #fff; padding: 10px 16px; border-radius: 14px; max-width: 80vw; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); font-size: 0.9rem; }
.game:not(.hidden) ~ .toast { bottom: calc(var(--ch) + 20px); }
.conn { position: fixed; z-index: 60; top: var(--safe-top); left: 0; right: 0; text-align: center; padding: 5px; font-size: 0.82rem; background: #c58b00; color: #1a1200; font-weight: 650; }
.conn.error { background: var(--danger); color: #fff; }

/* ============================================================
   PORTRAIT FALLBACK (browsers held upright)
   ============================================================ */
@media (orientation: portrait) {
  :root { --rail: 0px; --cw: clamp(56px, 17vw, 88px); --pile-w: clamp(66px, 20vw, 100px); }
  body { overflow: auto; }
  .screen { position: relative; min-height: 100%; }
  .screen.home { display: flex; flex-direction: column; gap: 14px; overflow: visible; max-width: 560px; }
  .hero { flex-direction: column; text-align: center; gap: 6px; padding-top: 8px; }
  section.live { min-height: 220px; }
  .screen.lobby { padding-right: 16px; padding-bottom: 90px; }
  .lobby-body { grid-template-columns: 1fr; }
  .screen.game { position: fixed; }
  .game-bar { right: 10px; }
  .table-area { right: 8px; bottom: calc(var(--ch) + 86px + var(--safe-bottom)); }
  .table-rim, .felt { border-radius: 40% / 30%; }
  .center { top: 50%; height: auto; width: min(76%, 300px); }
  .status-pill { top: auto; bottom: 22px; }
  .hand { left: 8px; right: 8px; bottom: calc(66px + var(--safe-bottom)); }
  .actions { right: 50%; transform: translateX(50%); flex-direction: row; bottom: calc(var(--ch) + 76px + var(--safe-bottom)); }
  .roombar { top: auto; left: 0; width: auto; height: auto; flex-direction: row; padding: 8px 12px calc(8px + var(--safe-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, 0.85) 45%); }
  .roombar .voice { width: auto; flex: 1; max-width: 200px; border-radius: 14px; padding: 0 14px; display: flex; gap: 6px; }
  .roombar .voice .vb-label { display: inline; }
  .drawer { top: auto; left: 0; width: auto; max-width: 560px; margin: 0 auto; height: min(80vh, 640px); border-left: 0; border-radius: 22px 22px 0 0; animation-name: sheetUp; }
  .preset-grid { grid-template-columns: repeat(4, 1fr); }
  .colors { grid-template-columns: 1fr 1fr; }
}

/* ---------- animations ---------- */
@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes glow { 50% { filter: drop-shadow(0 0 12px #ffe066) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.55)); } }
@keyframes mustDraw { 0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 10px #ffe066) drop-shadow(0 0 22px #ffc83d); } 50% { transform: translateY(-7px) scale(1.04); filter: drop-shadow(0 0 18px #fff3b0) drop-shadow(0 0 34px #ffc83d); } }
@keyframes hintBob { 50% { transform: translateX(-50%) translateY(-5px); } }
@keyframes pulseGlow { 50% { box-shadow: 0 0 0 6px rgba(255, 200, 61, 0.25), 0 0 24px rgba(255, 200, 61, 0.65); } }
@keyframes unoShake { 25% { transform: rotate(-8deg) scale(1.12); } 75% { transform: rotate(8deg) scale(1.12); } }
@keyframes deal { from { transform: translateY(-55vh) rotate(-30deg) scale(0.6); opacity: 0; } }
@keyframes popIn { from { transform: translateY(14px) scale(0.94); opacity: 0; } }
@keyframes sheetIn { from { transform: translateX(40px); opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinCcw { from { transform: scaleX(-1) rotate(0deg); } to { transform: scaleX(-1) rotate(360deg); } }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-12deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.25) rotate(-6deg); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1.05) rotate(-6deg); opacity: 0; }
}

/* hero: logo on the left, title and tagline stacked on the right */
.hero { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; }
.hero-logo { grid-row: span 2; }
.hero h1 { white-space: nowrap; align-self: end; }
.hero p { align-self: start; }
.room-list li.empty { display: block; }
@media (orientation: portrait) {
  .hero { grid-template-columns: 1fr; justify-items: center; }
  .hero-logo { grid-row: auto; }
}
@media (max-height: 440px) and (orientation: landscape) {
  .lobby-options p { display: none; }
  .lobby-options { padding: 10px 12px; gap: 8px; }
  .lobby-hint { font-size: 0.8rem; }
  .btn.big { padding: 11px; }
}

/* ---------- landscape table refinements ---------- */
:root { --pile-w: clamp(50px, min(14vh, 10.5vw), 90px); }
.game-bar { grid-template-columns: 46px minmax(0, 1fr) auto; }
.game-bar .status-pill {
  position: static; transform: none; justify-self: center; max-width: 100%; min-width: 0;
  display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 6px; border-radius: 16px;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line);
}
.game-bar .status-text { min-width: 0; }
.game-bar #turnText { overflow: hidden; text-overflow: ellipsis; }
.bar-right { display: flex; align-items: center; gap: 6px; }
.game-clock { padding: 5px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); font-size: 0.8rem; }
.game-clock.low { background: rgba(229, 72, 77, 0.25); }
.center { top: 47%; }
.felt::before { top: 47%; }
.leaders { top: auto; bottom: calc(var(--ch) * 0.82 + 8px + var(--safe-bottom)); left: calc(50% - var(--rail) / 2); }
/* Cards held beside the player's photo (towards the middle of the table). */
.seat .mini-fan { position: absolute; left: calc(50% + 16px); top: 20px; width: 40px; height: 24px; margin: 0; }
.seat.flip .mini-fan { left: auto; right: calc(50% + 16px); }
.seat .mini-fan img { width: 13px; height: 19px; }
.seat .pmute { left: -10px; top: -6px; bottom: auto; }
.seat .vi { right: auto; left: -8px; bottom: -4px; }
@media (orientation: portrait) {
  .game-bar .status-pill { padding-right: 10px; }
  .leaders { bottom: auto; top: calc(48px + var(--safe-top)); left: 50%; }
  .center { top: 50%; }
}
.my-turn .game-bar .status-pill { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ============================================================
   REALISTIC TABLE v2: room lighting, wood grain, leather rail, lit felt
   ============================================================ */
body::before {
  background:
    radial-gradient(ellipse 60% 55% at 50% 42%, rgba(255, 210, 140, 0.16), transparent 70%),
    radial-gradient(circle at 12% 18%, rgba(255, 190, 120, 0.06), transparent 30%),
    radial-gradient(circle at 88% 20%, rgba(255, 190, 120, 0.05), transparent 30%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #17110d 0%, #0e0b09 60%, #080706 100%);
}
.table-rim {
  position: relative; padding: 9px;
  background:
    linear-gradient(175deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 22%),
    repeating-linear-gradient(100deg, rgba(0, 0, 0, 0.18) 0 2px, rgba(0, 0, 0, 0) 2px 7px, rgba(255, 255, 255, 0.05) 7px 8px, rgba(0, 0, 0, 0) 8px 15px),
    linear-gradient(135deg, #9a6230 0%, #6b3c19 30%, #8a5426 55%, #4d2a10 80%, #6a3d1a 100%);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.6),
    inset 0 2px 1px rgba(255, 255, 255, 0.35), inset 0 -3px 6px rgba(0, 0, 0, 0.6);
}
/* Padded leather rail (the gradient border) around the felt. */
.felt {
  border: 11px solid transparent;
  background:
    url("img/felt-noise.svg") padding-box,
    radial-gradient(ellipse 55% 50% at 50% 44%, rgba(255, 245, 210, 0.22), rgba(255, 245, 210, 0) 70%) padding-box,
    radial-gradient(ellipse 85% 80% at 50% 46%, #2fa865 0%, #1f8048 40%, #155f35 72%, #0b3f22 100%) padding-box,
    linear-gradient(180deg, #4a2c1c 0%, #2a170d 45%, #1a0e07 100%) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 14px 26px rgba(0, 0, 0, 0.55), inset 0 -10px 24px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.7);
}
.felt::before { border: 2px solid rgba(255, 236, 170, 0.10); box-shadow: 0 0 0 10px rgba(255, 236, 170, 0.03); }
.felt::after { /* stitching just inside the leather rail */
  content: ''; position: absolute; inset: 4px; border-radius: inherit; pointer-events: none;
  border: 1.5px dashed rgba(255, 236, 170, 0.10);
}
.card { filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.45)) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35)); }
.discard .card:not(:last-child) { filter: brightness(0.92) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5)); }
.seat .oname { background: linear-gradient(180deg, rgba(20, 14, 10, 0.92), rgba(8, 6, 4, 0.92)); border: 1px solid rgba(255, 200, 61, 0.28); }
.ring-wrap .avatar { box-shadow: 0 0 0 2px rgba(255, 214, 140, 0.55), 0 6px 12px rgba(0, 0, 0, 0.6); }
.seat { cursor: pointer; }
.seat:active .ring-wrap { transform: scale(0.95); }

/* ---------- drawn card: Play it / Keep it ---------- */
.drawn-panel {
  position: absolute; z-index: 7; left: calc(50% - var(--rail) / 2); top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 16px;
  background: rgba(12, 18, 15, 0.92); border: 1px solid rgba(255, 200, 61, 0.45); border-radius: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7); backdrop-filter: blur(6px); animation: popIn 0.22s ease-out;
}
.dp-title { font-weight: 800; font-size: 0.85rem; color: var(--accent); }
.dp-row { display: flex; align-items: center; gap: 14px; }
.dp-card .card { --cw: clamp(52px, 13vh, 76px); cursor: default; }
.dp-actions { display: flex; flex-direction: column; gap: 8px; }
.dp-actions .btn { min-width: 120px; }

/* ---------- volume slider ---------- */
.volume-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-weight: 600; }
.volume-row input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; }
.menu-volume { justify-content: space-between; padding: 6px 4px; }

/* ---------- log in / create account ---------- */
.auth-box { width: min(380px, 100%); gap: 10px; }
.auth-logo { width: 64px; height: 64px; align-self: center; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6)); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.35); }
.auth-tab { border: 0; background: none; padding: 9px; border-radius: 10px; font-weight: 750; cursor: pointer; color: var(--muted); }
.auth-tab.on { background: var(--accent); color: var(--accent-ink); }
.auth-form { display: grid; gap: 8px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 1rem; padding: 6px; }
.auth-form p { margin: 0; text-align: left; }
.auth-error { color: #ff9b9b; font-size: 0.85rem; text-align: left; margin: 0; }
.acct-note { width: 100%; margin: 0; }

/* ---------- player card ---------- */
.player-box { position: relative; width: min(400px, 100%); gap: 8px; }
.pm-close { position: absolute; right: 10px; top: 10px; }
.avatar.pm-avatar { width: 72px; height: 72px; font-size: 1.8rem; align-self: center; box-shadow: 0 0 0 3px var(--accent), 0 6px 16px rgba(0, 0, 0, 0.6); }
.player-box p { margin: 0; }
.quick-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.quick { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); border-radius: 999px; padding: 7px 11px; cursor: pointer; font-weight: 650; font-size: 0.85rem; }
.quick:active { transform: scale(0.95); }
.pm-form { flex-wrap: nowrap; }
.talk-btn { user-select: none; -webkit-user-select: none; touch-action: none; }
.talk-btn.live { background: linear-gradient(180deg, #ff6b6b, #d63a3a); border-color: transparent; }
.member-list li.tappable .avatar, .member-list li.tappable .minfo { cursor: pointer; }

/* ---------- speech bubbles, private talk ---------- */
.speech-bubble {
  position: absolute; transform: translate(-50%, -100%); max-width: 200px; padding: 7px 12px; border-radius: 14px;
  background: #fff; color: #1a1a1a; font-weight: 700; font-size: 0.85rem; text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5); animation: bubbleIn 3.8s ease forwards;
}
.speech-bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
.whisper-pill {
  position: fixed; z-index: 55; top: calc(52px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px; background: linear-gradient(180deg, #8b5cf6, #6d28d9); color: #fff;
  font-weight: 800; font-size: 0.85rem; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); animation: pulse 1.2s infinite;
}
.chat-list li.dm { background: rgba(139, 92, 246, 0.2); cursor: pointer; }
.chat-list li.dm.mine { background: rgba(139, 92, 246, 0.32); }
@keyframes bubbleIn {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(0.7); }
  8% { opacity: 1; transform: translate(-50%, -100%) scale(1.05); }
  12% { transform: translate(-50%, -100%) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -115%); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .auth-box {
    width: min(660px, 100%); display: grid; column-gap: 20px; row-gap: 8px; align-items: center; text-align: center;
    grid-template-columns: 0.85fr 1.15fr;
    grid-template-areas: "logo form" "title form" "tabs form" "guest form";
  }
  .auth-logo { grid-area: logo; }
  #authTitle { grid-area: title; font-size: 1.1rem; }
  .auth-tabs { grid-area: tabs; }
  .auth-form { grid-area: form; }
  #authGuest { grid-area: guest; }
  .player-box { width: min(620px, 100%); display: grid; grid-template-columns: auto 1fr; column-gap: 16px; text-align: left; align-items: center;
    grid-template-areas: "av name" "av info" "quick quick" "form form" "talk talk" "btns btns"; }
  .pm-avatar { grid-area: av; }
  #pmName { grid-area: name; }
  #pmInfo { grid-area: info; }
  .quick-grid { grid-area: quick; }
  .pm-form { grid-area: form; }
  .talk-btn { grid-area: talk; }
  .player-box > .row { grid-area: btns; }
}

/* ============================================================
   CREATE ROOM / ROOM OPTIONS
   ============================================================ */
.room-box { width: min(760px, 100%); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); padding: 0; gap: 0; overflow: hidden; text-align: left;
  background: linear-gradient(180deg, #1d4f8f, #163e72); border: 2px solid #5b9cf0; }
.rm-head { display: flex; justify-content: center; position: relative; padding: 12px 16px 8px; }
.rm-head h2 { padding: 6px 26px; border-radius: 12px; background: linear-gradient(180deg, #7ed957, #3fae2a); color: #fff; text-shadow: 0 2px 0 #2a7a1a; font-weight: 900; letter-spacing: 0.04em; box-shadow: 0 4px 0 #2a7a1a; }
.rm-head .icon-btn { position: absolute; right: 12px; top: 10px; background: #3a7be0; border-color: #9cc4ff; }
.rm-scroll { overflow-y: auto; padding: 6px 18px 12px; display: grid; gap: 10px; }
.rm-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.rm-label { font-weight: 800; color: #ffe27a; font-size: 0.9rem; }
.room-box .chip { background: rgba(0, 0, 0, 0.25); border-color: rgba(255, 255, 255, 0.25); }
.room-box .chip.on { background: #ffd84d; color: #2b1d00; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper b { min-width: 28px; text-align: center; font-size: 1.15rem; }
.stepper .icon-btn { background: #3a7be0; }
.rm-section { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 0; color: #ffe27a; font-size: 1rem; text-transform: none; letter-spacing: 0; }
.help-btn { width: 24px; height: 24px; border-radius: 50%; border: 0; background: #4fc34a; color: #fff; font-weight: 900; cursor: pointer; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px 6px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, #7fc3ff, #4a95e6); border: 2px solid #a8d6ff; color: #0d2a52; font-weight: 800; font-size: 0.74rem; text-align: center;
  box-shadow: 0 4px 0 #2b6bb8; transition: transform 0.08s;
}
.tile:active { transform: translateY(2px); box-shadow: 0 2px 0 #2b6bb8; }
.tile.on { background: linear-gradient(180deg, #fff6dc, #ffe6a3); border-color: #ffc83d; box-shadow: 0 4px 0 #c99600; }
.tile.on::after { content: '✔'; position: absolute; right: -6px; bottom: -6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #4fc34a; color: #fff; font-size: 0.85rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
.tile-art { width: 46px; height: 58px; background-size: contain; background-repeat: no-repeat; background-position: center; display: grid; place-items: center; }
.tile-art.emoji { font-size: 1.5rem; line-height: 1; }
.tile-name { line-height: 1.15; }
.room-box > .btn.big { margin: 0 18px 14px; width: auto; background: linear-gradient(180deg, #7ed957, #3fae2a); color: #fff; text-shadow: 0 2px 0 #2a7a1a; box-shadow: 0 4px 0 #2a7a1a; font-weight: 900; font-size: 1.15rem; }
.help-box { width: min(520px, 100%); text-align: left; }
.help-body { display: grid; gap: 10px; max-height: 60vh; overflow-y: auto; }
.help-row { display: grid; gap: 2px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.help-row span { color: var(--muted); font-size: 0.88rem; }

/* ---------- lobby summary + teams ---------- */
.summary-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sum-chip { padding: 4px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: rgba(255, 255, 255, 0.07); }
.sum-chip.strong { background: var(--accent); color: var(--accent-ink); }
.sum-chip.rule { background: rgba(79, 195, 74, 0.2); color: #b4f0b0; }
.sum-chip.special { background: rgba(91, 156, 240, 0.22); color: #c4dcff; }
.team-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team { border-radius: 16px; padding: 10px; display: grid; gap: 6px; align-content: start; }
.team-a { background: rgba(229, 50, 45, 0.16); border: 1px solid rgba(229, 50, 45, 0.5); }
.team-b { background: rgba(31, 111, 209, 0.18); border: 1px solid rgba(31, 111, 209, 0.55); }
.team h3 { margin: 0; font-size: 0.85rem; }
.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-height: 34px; }
.team-list li { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 0.88rem; }

/* ---------- in game: teams, badges, UNO, challenge, swap, draft ---------- */
.seat.team-a .ring-wrap .avatar { box-shadow: 0 0 0 3px #e5322d, 0 6px 12px rgba(0, 0, 0, 0.6); }
.seat.team-b .ring-wrap .avatar { box-shadow: 0 0 0 3px #1f6fd1, 0 6px 12px rgba(0, 0, 0, 0.6); }
.challenge-btn { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); padding: 4px 9px !important; font-size: 0.72rem !important; animation: pulse 0.7s infinite; z-index: 3; }
.badges { position: absolute; z-index: 6; top: calc(48px + var(--safe-top)); left: calc(12px + var(--safe-left)); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; pointer-events: none; }
.badge-pill { padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line); }
.badge-pill.hot { background: rgba(229, 72, 77, 0.85); animation: pulse 0.8s infinite; }
.badge-pill.trick { background: rgba(139, 92, 246, 0.85); }
.badge-pill.balloon { background: rgba(247, 200, 21, 0.85); color: #2b1d00; }
.badge-pill.challenge { background: rgba(31, 111, 209, 0.85); }
.badge-pill.team-a { background: rgba(229, 50, 45, 0.85); }
.badge-pill.team-b { background: rgba(31, 111, 209, 0.85); }
.uno-btn {
  position: absolute; z-index: 8; left: calc(14px + var(--safe-left)); bottom: calc(var(--ch) * 0.55 + 18px + var(--safe-bottom));
  width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #ff7a6e, #e5322d 55%, #a51510); color: #ffd84d;
  font-family: 'Arial Black', Roboto, sans-serif; font-style: italic; font-weight: 900; font-size: 1.15rem;
  -webkit-text-stroke: 1px #5a0a00; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.6), 0 0 0 6px rgba(229, 50, 45, 0.35); animation: unoPulse 0.9s infinite;
}
@keyframes unoPulse { 50% { transform: scale(1.08); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.6), 0 0 0 12px rgba(229, 50, 45, 0.2); } }
.swap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.swap-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); text-align: left; }
.draft-panel {
  position: fixed; z-index: 35; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 20px; border-radius: 22px; background: rgba(10, 16, 13, 0.94); border: 1px solid rgba(255, 200, 61, 0.5); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75); animation: popIn 0.22s ease-out;
}
.draft-panel p { margin: 0; }
.draft-cards { display: flex; gap: 14px; margin-top: 4px; }
.draft-cards .card { --cw: clamp(62px, 18vh, 96px); transition: transform 0.15s; }
.draft-cards .card:hover, .draft-cards .card:active { transform: translateY(-8px) scale(1.05); }
@media (orientation: landscape) and (max-height: 520px) {
  .rm-scroll { padding: 4px 14px 8px; }
  .tile-grid { grid-template-columns: repeat(7, 1fr); }
  .tile-art { width: 38px; height: 48px; }
}
.auth-google { display: grid; gap: 8px; }
.google-btn.big-google { width: 100%; justify-content: center; padding: 11px; font-size: 0.95rem; border-radius: 14px; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.78rem; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--line); }
@media (orientation: landscape) and (max-height: 520px) {
  .auth-box { grid-template-areas: "logo form" "title form" "google form" "tabs form" "guest form"; }
  .auth-google { grid-area: google; }
}

/* Taps must reach the deck: the full-table seat layer and decorations let touches pass through. */
.seats { pointer-events: none; }
.seat { pointer-events: auto; }
.dir-ring, .felt::before, .felt::after, .discard::before { pointer-events: none; }

/* ============================================================
   DIRECTION RING v2, COLOR AURA, CARD EFFECTS, HAND HIGHLIGHTS
   ============================================================ */
@property --spin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.color-aura {
  position: absolute; inset: 6%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--dir-color, #ffc83d) 55%, transparent) 0%, transparent 68%);
  opacity: 0.55; animation: auraPulse 2.6s ease-in-out infinite; transition: background 0.4s;
}
.dir-ring {
  opacity: 1; animation: spin 7s linear infinite;
  filter: drop-shadow(0 0 4px var(--dir-color, #ffc83d)) drop-shadow(0 0 12px var(--dir-color, #ffc83d));
}
.dir-ring.ccw { animation: spinCcw 7s linear infinite; }
.dir-ring path { stroke-dasharray: none; }
.dir-ring .track { fill: none; stroke: rgba(0, 0, 0, 0.28); stroke-width: 13; }
.dir-ring .track-dots { fill: none; stroke: currentColor; stroke-opacity: 0.35; stroke-width: 2; stroke-dasharray: 1 7; stroke-linecap: round; }
.dir-ring .arc { fill: none; stroke: currentColor; stroke-width: 8; stroke-linecap: round; }
.dir-ring marker path { fill: currentColor; stroke: none; }
.dir-ring.flipping { animation: flipSpin 0.85s cubic-bezier(.3, .7, .3, 1); }
.dir-ring.ccw.flipping { animation: flipSpinCcw 0.85s cubic-bezier(.3, .7, .3, 1); }
@keyframes auraPulse { 50% { opacity: 0.85; transform: scale(1.05); } }
@keyframes flipSpin { 0% { transform: rotate(0deg) scale(1); } 45% { transform: rotate(250deg) scale(1.2); filter: brightness(1.8) drop-shadow(0 0 16px var(--dir-color)); } 100% { transform: rotate(360deg) scale(1); } }
@keyframes flipSpinCcw { 0% { transform: scaleX(-1) rotate(0deg) scale(1); } 45% { transform: scaleX(-1) rotate(250deg) scale(1.2); filter: brightness(1.8) drop-shadow(0 0 16px var(--dir-color)); } 100% { transform: scaleX(-1) rotate(360deg) scale(1); } }

/* Fire / sparkle canvas and banners */
.fire-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }
.fx-banner {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-family: 'Arial Black', Roboto, sans-serif; font-style: italic; font-weight: 900; font-size: clamp(1.6rem, 7vh, 2.6rem);
  color: #fff; -webkit-text-stroke: 2px rgba(0, 0, 0, 0.75); paint-order: stroke fill;
  text-shadow: 0 0 12px var(--c), 0 0 28px var(--c), 0 4px 0 rgba(0, 0, 0, 0.6);
  animation: bannerPop 1.6s cubic-bezier(.2, .9, .3, 1.2) forwards;
}
@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); opacity: 0; }
  14% { transform: translate(-50%, -50%) scale(1.18) rotate(-4deg); opacity: 1; }
  24% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); }
  78% { opacity: 1; }
  100% { transform: translate(-50%, -85%) scale(1.05) rotate(-4deg); opacity: 0; }
}
.color-wave {
  position: absolute; width: 60px; height: 60px; border-radius: 50%; pointer-events: none;
  border: 6px solid var(--c); box-shadow: 0 0 24px var(--c), inset 0 0 24px var(--c);
  transform: translate(-50%, -50%) scale(0.3); animation: colorWave 1.2s ease-out forwards;
}
@keyframes colorWave { 0% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(16); opacity: 0; border-width: 2px; } }

/* Hand highlights */
.hand .card.wildcard::before, .hand .card.power::before, .hand .card.special07::before {
  content: ''; position: absolute; inset: -3px; z-index: -1; border-radius: calc(var(--cw) * 0.12); pointer-events: none;
}
.hand .card.wildcard::before {
  background: conic-gradient(from var(--spin), #e5322d, #f7c815, #2fa84f, #1f6fd1, #e5322d);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35); animation: spinGrad 2.2s linear infinite;
}
.hand .card.power::before { background: linear-gradient(135deg, #ffe27a, #ff9a1f 55%, #ffe27a); opacity: 0.9; }
.hand .card.special07::before {
  background: conic-gradient(from var(--spin), #fff3b0, #ffc83d, #fff3b0, #ffb000, #fff3b0);
  animation: spinGrad 3s linear infinite; box-shadow: 0 0 12px rgba(255, 200, 61, 0.7);
}
.hand .card.special07::after {
  content: attr(data-tag); position: absolute; left: 50%; top: -9px; transform: translateX(-50%); white-space: nowrap;
  padding: 1px 6px; border-radius: 999px; background: #ffc83d; color: #2b1d00; font-size: 0.58rem; font-weight: 900; pointer-events: none;
}
@keyframes spinGrad { to { --spin: 360deg; } }

/* ---------- impact hits ---------- */
.table-rim.shake { animation: tableShake 0.55s cubic-bezier(.36, .07, .19, .97); }
.seat.shake { animation: seatShake 0.55s cubic-bezier(.36, .07, .19, .97); }
.seat.shake .avatar { box-shadow: 0 0 0 3px #ff3b2f, 0 0 22px #ff3b2f !important; }
@keyframes tableShake {
  10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-6px, 2px); } 40%, 60% { transform: translate(6px, -2px); }
}
@keyframes seatShake {
  0%, 100% { transform: translate(-50%, -50%); } 20% { transform: translate(calc(-50% - 7px), -50%) rotate(-6deg); }
  40% { transform: translate(calc(-50% + 7px), -50%) rotate(6deg); } 60% { transform: translate(calc(-50% - 5px), -50%) rotate(-4deg); }
  80% { transform: translate(calc(-50% + 4px), -50%) rotate(3deg); }
}
.hit-number {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  font-family: 'Arial Black', Roboto, sans-serif; font-style: italic; font-weight: 900; font-size: 2rem;
  color: #ff4d3a; -webkit-text-stroke: 2px #fff; paint-order: stroke fill; text-shadow: 0 0 14px #ff3b2f, 0 4px 0 rgba(0, 0, 0, 0.5);
  animation: hitRise 1.3s cubic-bezier(.2, .9, .3, 1.2) forwards;
}
.hit-number.big { font-size: 2.8rem; }
@keyframes hitRise {
  0% { transform: translate(-50%, -20%) scale(0.3); opacity: 0; }
  18% { transform: translate(-50%, -60%) scale(1.3); opacity: 1; }
  30% { transform: translate(-50%, -70%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -160%) scale(1); opacity: 0; }
}
.hit-flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 100%, rgba(255, 40, 30, 0.45), transparent 60%); animation: hitFlash 0.55s ease-out forwards; }
@keyframes hitFlash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- your turn ---------- */
.hand.turn-glow::after {
  content: ''; position: absolute; left: 10%; right: 10%; bottom: 0; height: 70%; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 200, 61, 0.55), transparent 70%); animation: turnGlow 1.4s ease-out forwards;
}
@keyframes turnGlow { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- victory ---------- */
#winner.victory .trophy { position: relative; z-index: 0; animation: trophyBounce 1.2s cubic-bezier(.2, .9, .3, 1.3); }
#winner.victory .trophy::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 260px; height: 260px; z-index: -1; pointer-events: none;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: repeating-conic-gradient(from var(--spin), rgba(255, 210, 80, 0.55) 0deg 10deg, transparent 10deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: spinGrad 6s linear infinite;
}
#winner.victory .modal-box { border-color: rgba(255, 200, 61, 0.7); box-shadow: 0 0 40px rgba(255, 200, 61, 0.35), 0 24px 60px rgba(0, 0, 0, 0.7); }
#winner.victory #winnerText { color: #ffd84d; text-shadow: 0 0 18px rgba(255, 200, 61, 0.8); }
@keyframes trophyBounce { 0% { transform: scale(0.2) rotate(-20deg); } 60% { transform: scale(1.25) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
