* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #08080d;
  --surface: rgba(255, 255, 255, 0.045);
  --glass: rgba(14, 16, 26, 0.62);
  --stroke: rgba(255, 255, 255, 0.09);
  --text: #f0f2f7;
  --muted: rgba(240, 242, 247, 0.55);
  --accent: #8b7cf6;
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #8b7cf6 10%, #22d3ee 90%);
  --ok: #34d399;
  --danger: #f43f5e;
  --felt: #10281c;
  --card-w: clamp(48px, 7vw, 84px);
  --card-h: calc(var(--card-w) * 1.4);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

html, body { height: 100%; }
body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;              /* no double-tap zoom on iOS */
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
input { -webkit-user-select: text; user-select: text; font-family: inherit; }

.hidden { display: none !important; }
.screen { position: fixed; inset: 0; height: 100dvh; }

/* soft ambient glow behind the entry screens */
.center-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(560px 380px at 30% 18%, rgba(139, 124, 246, 0.14), transparent 65%),
    radial-gradient(520px 400px at 72% 80%, rgba(34, 211, 238, 0.10), transparent 65%);
}

/* ---------- intro ---------- */
.intro {
  z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
}
#introCanvas { filter: drop-shadow(0 18px 44px rgba(0, 0, 0, 0.55)); }
.intro-wm { font-size: clamp(1.6rem, 6vw, 2.2rem); }
.dedication {
  color: var(--muted); font-size: 0.85rem; font-weight: 300; letter-spacing: 0.14em;
  text-transform: uppercase;
}
.dedication::first-letter { letter-spacing: 0.14em; }
.auth-dedication {
  position: absolute; bottom: calc(16px + var(--sab)); left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}

/* ---------- shared ---------- */
.center-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; padding: 24px calc(16px + var(--sal)) calc(24px + var(--sab));
}
.wordmark {
  font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 800; letter-spacing: -0.035em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; position: relative;
}
.tagline { color: var(--muted); font-weight: 300; letter-spacing: 0.02em; position: relative; }
.panel {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.3); backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--stroke); border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 26px;
  width: min(370px, 92vw);
  display: flex; flex-direction: column; gap: 13px;
}
.panel h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.panel input {
  font-size: 1rem; border-radius: 14px; border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28); color: var(--text); padding: 13px 16px;
  transition: border-color 0.15s ease;
}
.panel input::placeholder { color: rgba(240, 242, 247, 0.35); }
.panel input:focus { outline: none; border-color: rgba(139, 124, 246, 0.55); }
button { font-family: inherit; cursor: pointer; }
button.big {
  font-size: 1.02rem; padding: 14px 22px; border: 0; border-radius: 999px;
  background: var(--grad); color: #0a0c12; font-weight: 700; letter-spacing: 0.01em;
  min-height: 48px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
button.big:hover { filter: brightness(1.12); }
button.big:active { transform: scale(0.985); }
button.big.solo {
  background: var(--surface); color: var(--text); border: 1px solid var(--stroke);
}
button.big.solo:hover { background: rgba(255, 255, 255, 0.08); }
button.linkish {
  background: none; border: 0; color: var(--muted);
  font-size: 0.92rem; padding: 10px; min-height: 44px; letter-spacing: 0.01em;
}
button.linkish:hover { color: var(--text); }
.or { color: var(--muted); font-size: 0.85rem; font-weight: 300; }
.hint, .status { color: var(--muted); font-size: 0.88rem; min-height: 1.2em; }
.status.err { color: #fda4af; }
.join-row { display: flex; gap: 8px; }
.join-row input {
  /* flex items refuse to shrink below their intrinsic width without min-width:0,
     which pushed the Join button off-screen on iPhone */
  flex: 1; width: 0; min-width: 0;
  text-align: center; font-size: 1.2rem; letter-spacing: 5px; text-transform: uppercase;
}
.join-row button { flex-shrink: 0; }
.seg {
  display: inline-flex; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--stroke); background: rgba(0, 0, 0, 0.25);
}
.seg.wide { width: 100%; }
.seg.wide button { flex: 1; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font-size: 0.95rem;
  font-weight: 600; padding: 10px 20px; min-height: 44px; transition: color 0.15s ease;
}
.seg button.on { background: var(--grad); color: #0a0c12; }
.size-row { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }

/* ---------- google + friends ---------- */
.gmark {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; color: #4285f4; font-weight: 800; font-size: 0.9rem;
  margin-right: 6px;
}
.friends { gap: 10px; }
.friends-head { display: flex; align-items: center; justify-content: space-between; }
.code-pill {
  border: 1px dashed var(--stroke); background: rgba(0, 0, 0, 0.25); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; letter-spacing: 3px; font-size: 0.9rem;
}
.code-pill:hover { border-color: var(--accent); }
.friends-list, .requests { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.friend-row, .request-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--stroke);
  border-radius: 14px; padding: 9px 12px;
}
.friend-row .dot {
  width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); flex-shrink: 0;
}
.friend-row.online .dot { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
.friend-row .fname, .request-row .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row button, .request-row button {
  border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 0.85rem;
}
.friend-row .call-btn { background: var(--grad); color: #0a0c12; }
.friend-row .call-btn:disabled { opacity: 0.35; }
.request-row .ok-btn { background: var(--ok); color: #06241a; }
.request-row .no-btn { background: var(--surface); color: var(--muted); border: 1px solid var(--stroke); }

/* ---------- incoming ring ---------- */
.modal.ring { z-index: 60; }
.ring-box { align-items: center; text-align: center; }
.ring-pulse { font-size: 2.6rem; animation: ringshake 1.1s ease-in-out infinite; }
@keyframes ringshake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg) scale(1.06); }
  40% { transform: rotate(12deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(6deg); }
}
.ring-text { font-size: 1.15rem; font-weight: 700; }
.ring-actions { display: flex; flex-direction: column; gap: 6px; width: 100%; }

/* ---------- call screen ---------- */
.video-grid { position: absolute; inset: 0; display: grid; background: var(--bg); }
.video-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.video-grid[data-count="3"] { grid-template-columns: 1fr 1fr 1fr; }
.video-grid video { width: 100%; height: 100%; object-fit: cover; }
.video-grid .table-bg {
  display: grid; place-items: center; font-size: 5rem; opacity: 0.22;
  background: radial-gradient(ellipse at center, var(--felt), var(--bg) 78%);
}
.mirror { transform: scaleX(-1); }

.tile-strip {
  position: absolute; top: calc(14px + var(--sat)); right: calc(14px + var(--sar));
  display: flex; flex-direction: column; gap: 8px; z-index: 5;
}
.tile-strip video {
  width: clamp(96px, 18vw, 220px); aspect-ratio: 4/3; border-radius: 16px;
  object-fit: cover; border: 1px solid var(--stroke);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

/* frosted pill shared by floating labels */
.code-banner, .opp-chip, .pile-label, .turn-banner, .spot-label {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--stroke); border-radius: 999px;
}

.code-banner {
  position: absolute; top: calc(14px + var(--sat)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; z-index: 5;
  padding: 8px 16px; font-size: 0.95rem;
}
.code-banner b { letter-spacing: 4px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.code-banner button { background: none; border: 0; color: var(--text); font-size: 1rem; padding: 4px; }
.code-banner span:last-child { color: var(--muted); }

.call-controls {
  position: absolute; left: calc(10px + var(--sal)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 7;
}
.call-controls button, .leave-game {
  border: 1px solid var(--stroke);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  color: #fff; transition: background 0.15s ease, transform 0.1s ease;
}
.call-controls button {
  width: 52px; height: 52px; border-radius: 50%; font-size: 1.25rem;
}
.call-controls button:hover { background: rgba(255, 255, 255, 0.10); }
.call-controls button:active { transform: scale(0.94); }
.call-controls button.off { background: rgba(244, 63, 94, 0.55); border-color: transparent; }
.call-controls button.danger { background: var(--danger); border-color: transparent; transform: rotate(135deg); }

.leave-game {
  position: absolute; top: calc(14px + var(--sat)); left: calc(14px + var(--sal));
  z-index: 8; width: 44px; height: 44px; border-radius: 50%; font-size: 1.05rem;
}
.leave-game:hover { background: rgba(255, 255, 255, 0.10); }
.ctrl-toggle { top: calc(66px + var(--sat)); }
.ctrl-toggle.touch-on { background: rgba(139, 124, 246, 0.5); border-color: transparent; }
.table-toggle { top: calc(118px + var(--sat)); }
.table-toggle.on { background: rgba(52, 211, 153, 0.45); border-color: transparent; }

/* ---------- table mode ---------- */
.video-park {
  position: absolute; bottom: 0; right: 0; width: 4px; height: 4px;
  overflow: hidden; opacity: 0.01; pointer-events: none; z-index: 0;
}
.video-park video { width: 4px; height: 4px; }
.table-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
/* spots replace the chip bar and tile strip whenever a game is up */
.gaming .opp-bar, .gaming .tile-strip { display: none; }
.player-spot {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 2;
}
.player-spot canvas {
  width: clamp(84px, 13vw, 150px); aspect-ratio: 1; border-radius: 50%;
  background: rgba(0, 0, 0, 0.3); border: 2px solid var(--stroke);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.player-spot.self {
  /* centered directly above the your-turn banner */
  left: 50%; top: auto; bottom: calc(292px + var(--sab));
  transform: translateX(-50%);
}
.player-spot.self canvas { width: clamp(60px, 8vw, 96px); }
.player-spot.turn canvas {
  border-color: var(--ok); box-shadow: 0 0 26px rgba(52, 211, 153, 0.5);
}
.spot-label { padding: 4px 13px; font-size: 0.85rem; white-space: nowrap; }
.spot-label .cnt { font-weight: 800; color: var(--accent-2); }

/* opponents' hands, face down under their video circle */
.mini-cards { display: flex; margin-top: 2px; }
.back-card {
  width: clamp(13px, 1.6vw, 18px); aspect-ratio: 5/7; border-radius: 3px;
  margin-left: calc(clamp(13px, 1.6vw, 18px) * -0.55);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.16) 0 18%, transparent 20%),
    linear-gradient(150deg, #6d5cd9, #3b2f8f);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}
.back-card:first-child { margin-left: 0; }

.modal {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(4, 5, 9, 0.6);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}

/* ---------- game overlay ---------- */
.opp-bar {
  position: absolute; top: calc(14px + var(--sat)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 5; flex-wrap: wrap; justify-content: center;
  max-width: min(70vw, 600px);
}
.opp-chip { padding: 8px 16px; font-size: 0.92rem; transition: box-shadow 0.15s ease; }
.opp-chip .cnt { font-weight: 800; color: var(--accent-2); }
.opp-chip.turn { box-shadow: 0 0 0 1.5px var(--ok); }
.opp-chip.ai::before { content: '🤖 '; }

.pile-area {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 4;
}
.pile-label { padding: 5px 15px; font-size: 0.88rem; color: var(--muted); }
.pile-cards { display: flex; gap: 6px; position: relative; }
.pile-cards .card { z-index: 1; }

/* ---------- play animations ---------- */
/* cards slam down from above with a settle */
@keyframes cardLand {
  0%   { transform: translateY(-90px) scale(1.5) rotate(-4deg); opacity: 0; }
  55%  { transform: translateY(5px) scale(0.97); opacity: 1; }
  75%  { transform: translateY(-3px) scale(1.02); }
  100% { transform: none; opacity: 1; }
}
.pile-cards .card.land { animation: cardLand 0.4s cubic-bezier(0.2, 0.8, 0.3, 1) both; }

/* flight from the owner's stack: real pile card hides until its flyer lands */
.pile-cards .card.await-flight { opacity: 0; }
.fly-card { position: fixed; margin: 0; z-index: 45; pointer-events: none; }
@keyframes landPop {
  0%   { transform: scale(1.18); }
  55%  { transform: scale(0.96); }
  100% { transform: none; }
}
.pile-cards .card.land-pop { animation: landPop 0.22s ease-out both; }

.pass-bubble {
  position: fixed; z-index: 46; pointer-events: none; transform: translate(-50%, -50%);
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 999px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  padding: 7px 16px; font-weight: 800; font-size: 0.95rem; letter-spacing: 0.06em;
  animation: bubbleUp 1.25s ease-out both;
}
@keyframes bubbleUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  18%  { opacity: 1; transform: translate(-50%, -70%) scale(1.05); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.95); }
}

/* four of a kind: earthquake */
@keyframes quake {
  0%, 100% { transform: none; }
  15% { transform: translate(-7px, 4px) rotate(-0.5deg); }
  30% { transform: translate(6px, -5px) rotate(0.4deg); }
  45% { transform: translate(-5px, -3px) rotate(-0.3deg); }
  60% { transform: translate(4px, 4px) rotate(0.3deg); }
  75% { transform: translate(-3px, 2px); }
  90% { transform: translate(2px, -1px); }
}
#gameLayer.quake { animation: quake 0.65s ease-out; }

/* straight flush: rainbow shimmer sweeping across the pile */
.rainbow-sweep {
  position: absolute; inset: -18px; z-index: 3; pointer-events: none;
  border-radius: 14px; mix-blend-mode: screen;
  background: linear-gradient(105deg,
    transparent 15%, rgba(255, 80, 80, 0.55) 30%, rgba(255, 214, 110, 0.55) 40%,
    rgba(90, 255, 140, 0.55) 50%, rgba(90, 190, 255, 0.55) 60%,
    rgba(190, 120, 255, 0.55) 70%, transparent 85%);
  background-size: 320% 100%;
  animation: rainbowSweep 1.4s ease-in-out both;
}
@keyframes rainbowSweep {
  0%   { background-position: 110% 0; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { background-position: -60% 0; opacity: 0; }
}

.confetti {
  position: fixed; z-index: 55; pointer-events: none;
  width: 9px; height: 13px; transform-origin: center;
}

/* the table shudders under the impact — heavier for 5-card hands */
@keyframes thump {
  0%, 100% { transform: none; }
  40% { transform: translateY(3px); }
  65% { transform: translateY(-2px); }
}
@keyframes thumpBig {
  0%, 100% { transform: none; }
  25% { transform: translateY(7px) scale(1.02); }
  45% { transform: translateY(-4px); }
  65% { transform: translateY(3px); }
  82% { transform: translateY(-1px); }
}
.pile-cards.thump { animation: thump 0.32s ease-out 0.28s; }
.pile-cards.thump-big { animation: thumpBig 0.55s ease-out 0.3s; }

/* the 2♦ arrives with golden god-rays */
.sunrays {
  position: absolute; left: 50%; top: 50%; width: min(400px, 90vw); aspect-ratio: 1;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 0;
  background: repeating-conic-gradient(from 0deg,
    rgba(255, 214, 110, 0.55) 0deg 6deg, transparent 6deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 8%, transparent 68%);
  mask: radial-gradient(circle, #000 8%, transparent 68%);
  animation: sunrays 1.8s ease-out forwards;
}
@keyframes sunrays {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.25) rotate(0deg); }
  22%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2) rotate(38deg); }
}
/* pulse lives on ::after so it never fights the land/flight animations */
.pile-cards .card.golden {
  box-shadow: 0 0 0 2px #ffd778, 0 0 24px rgba(255, 199, 88, 0.8), 0 3px 12px rgba(0, 0, 0, 0.5);
}
.pile-cards .card.golden::after {
  content: ''; position: absolute; inset: -7px; border-radius: 13px; pointer-events: none;
  box-shadow: 0 0 38px rgba(255, 214, 110, 0.95);
  opacity: 0; animation: goldenPulse 1.2s ease-in-out 0.45s 3;
}
@keyframes goldenPulse { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

.card {
  width: var(--card-w); height: var(--card-h);
  background: linear-gradient(160deg, #ffffff, #eef0ef);
  border-radius: 10px; color: #16181d;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 6px; font-weight: 700; user-select: none; -webkit-user-select: none;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.card .corner { font-size: calc(var(--card-w) * 0.26); line-height: 1.05; }
.card .corner.bottom { align-self: flex-end; transform: rotate(180deg); }
.card .pip-glyph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--card-w) * 0.5); opacity: 0.85;
}
.card.red { color: #d02b3e; }
.card.selected {
  transform: translateY(-26px);
  box-shadow: 0 0 0 2px var(--accent), 0 0 22px rgba(139, 124, 246, 0.45), 0 12px 20px rgba(0, 0, 0, 0.5);
}
.card.hover { transform: translateY(-12px); }
.card.selected.hover { transform: translateY(-30px); }

.hand-area {
  position: absolute; bottom: calc(86px + var(--sab)); left: 50%; transform: translateX(-50%);
  display: flex; z-index: 6; max-width: 96vw;
}
.hand-area .card { margin-left: calc(var(--card-w) * -0.42); flex-shrink: 0; }
.hand-area .card:first-child { margin-left: 0; }

.actions {
  position: absolute; bottom: calc(12px + var(--sab)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; z-index: 6;
}
button.action {
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 12px 30px; border: 0; border-radius: 999px;
  position: relative; min-height: 48px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
button.action:hover:not(:disabled) { filter: brightness(1.1); }
button.action:active:not(:disabled) { transform: scale(0.98); }
button.action:disabled { opacity: 0.3; cursor: default; }
.action.play { background: var(--grad); color: #0a0c12; }
.action.pass { background: rgba(244, 63, 94, 0.85); color: #fff; }
.action.sort {
  background: var(--glass); color: var(--text); border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  font-size: 0.85rem;
}
.pass-ring {
  position: absolute; inset: -4px; border-radius: 999px; pointer-events: none;
  background: conic-gradient(rgba(255,255,255,0.9) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 3px;
}

.turn-banner {
  position: absolute; bottom: calc(240px + var(--sab)); left: 50%; transform: translateX(-50%);
  padding: 6px 18px; font-weight: 700; letter-spacing: 0.01em; z-index: 5;
}
.turn-banner.yours { color: var(--ok); }
.turn-banner:empty { display: none; }

.toast {
  position: absolute; top: 20%; left: 50%; transform: translateX(-50%);
  background: rgba(244, 63, 94, 0.9);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  padding: 10px 22px; border-radius: 999px;
  font-weight: 600; z-index: 40; max-width: 90vw;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.cursor { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -50%); }
.cursor-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--accent); background: rgba(139, 124, 246, 0.22);
  box-shadow: 0 0 14px rgba(139, 124, 246, 0.5);
  transition: transform 0.08s ease;
}
.cursor.pinching .cursor-dot { transform: scale(0.55); background: var(--accent); }

.game-over {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(4, 5, 9, 0.65);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.game-over-box {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border: 1px solid var(--stroke); border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 34px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em;
}

/* ---------- phones (portrait) ---------- */
@media (max-width: 700px) and (orientation: portrait) {
  :root { --card-w: clamp(44px, 12vw, 60px); }
  .hand-area { bottom: calc(96px + var(--sab)); }
  .hand-area .card { margin-left: calc(var(--card-w) * -0.55); } /* tighter fan */
  .call-controls {
    left: 50%; top: auto; bottom: calc(12px + var(--sab));
    transform: translateX(-50%); flex-direction: row;
  }
  /* game buttons move up so they don't collide with call controls */
  .gaming .call-controls { display: none; }
  .call-controls button { width: 48px; height: 48px; }
  .pile-area { transform: translate(-50%, -80%); }
  .turn-banner { bottom: auto; top: calc(64px + var(--sat)); }
  .opp-bar { top: calc(14px + var(--sat)); max-width: 96vw; gap: 6px; }
  .opp-chip { padding: 5px 11px; font-size: 0.78rem; }

  /* 3-4 person calls: stack feeds in rows instead of skinny columns */
  .video-grid[data-count="2"] { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .video-grid[data-count="3"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
  .video-grid[data-count="3"] video:last-child { grid-column: 1 / -1; }

  /* tiles become a horizontal row so they can't stack down over the cards */
  .tile-strip {
    flex-direction: row; left: 8px; right: 8px; top: calc(56px + var(--sat));
    justify-content: flex-end; gap: 6px;
  }
  .tile-strip video { width: clamp(68px, 21vw, 110px); }
  .code-banner { font-size: 0.85rem; padding: 6px 12px; max-width: 94vw; }
  .actions { gap: 8px; }
  button.action { padding: 10px 18px; font-size: 0.95rem; min-height: 44px; }
  .action.sort { font-size: 0.78rem; }

  /* banner is at the top on phones; keep the self avatar above the hand fan */
  .player-spot.self { bottom: calc(225px + var(--sab)); }
}

/* small landscape phones: shrink cards a bit */
@media (max-height: 450px) {
  :root { --card-w: clamp(40px, 9vh, 56px); }
  .hand-area { bottom: calc(64px + var(--sab)); }
  .actions { bottom: calc(8px + var(--sab)); }
  button.action { padding: 8px 18px; min-height: 40px; }
  .turn-banner { bottom: auto; top: calc(10px + var(--sat)); }
}
