/* =========================================================================
   UNO Online — premium dark gaming UI
   ========================================================================= */
:root {
  --bg: #090b16;
  --bg-2: #11142a;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f2f4ff;
  --muted: #9aa0c3;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --gold: #fbbf24;
  --danger: #f43f5e;
  --ok: #22c55e;

  --red: #e5323b;
  --yellow: #f6c515;
  --green: #22a95a;
  --blue: #1e6ee8;
  --wild: #15151d;

  --radius: 18px;
  --font-display: 'Lilita One', 'Arial Black', Impact, system-ui, sans-serif;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --hand-cw: clamp(66px, 7.4vw, 104px);
  --pile-cw: clamp(64px, 8.2vw, 108px);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1b1f45 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------- background */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-glow { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: 0.35; }
.bg-glow.g1 { background: var(--accent); left: -20vmax; top: -20vmax; animation: drift 18s ease-in-out infinite alternate; }
.bg-glow.g2 { background: var(--accent-2); right: -25vmax; bottom: -25vmax; animation: drift 22s ease-in-out infinite alternate-reverse; }
.bg-cards .card { position: absolute; opacity: 0.1; animation: float var(--d, 14s) ease-in-out infinite alternate; }
body[data-screen='game'] .bg-cards { display: none; }
@keyframes drift { to { transform: translate(8vmax, 6vmax) scale(1.1); } }
@keyframes float { from { transform: translateY(0) rotate(var(--r, 0deg)); } to { transform: translateY(-40px) rotate(calc(var(--r, 0deg) + 14deg)); } }

/* ------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; z-index: 1; display: none; overflow-y: auto; }
.screen.active { display: block; }
#screen-game.active { display: grid; }

/* ------------------------------------------------------------- buttons */
.btn {
  border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 800; letter-spacing: 0.2px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s var(--ease-out), box-shadow 0.2s, filter 0.2s, background 0.2s;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px rgba(236, 72, 153, 0.35); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 30px rgba(236, 72, 153, 0.5); }
.btn-secondary { background: linear-gradient(135deg, #2563eb, #06b6d4); box-shadow: 0 8px 22px rgba(6, 182, 212, 0.3); }
.btn-accent { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 8px 22px rgba(239, 68, 68, 0.3); }
.btn-ghost { background: rgba(255, 255, 255, 0.07); border: 1px solid var(--panel-border); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.btn-xl { font-size: 1.25rem; padding: 16px 24px; font-family: var(--font-display); letter-spacing: 1px; }
.btn-small { padding: 8px 14px; font-size: 0.9rem; border-radius: 11px; }
.btn-uno {
  font-family: var(--font-display); font-size: 1.2rem; letter-spacing: 1px;
  background: linear-gradient(135deg, #ef4444, #f59e0b); box-shadow: 0 8px 22px rgba(239, 68, 68, 0.35);
}
.btn-uno.hot { animation: unoPulse 0.9s ease-in-out infinite; }
@keyframes unoPulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.25), 0 10px 30px rgba(239, 68, 68, 0.6); } }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.07); display: inline-grid; place-items: center; font-size: 1.05rem;
  position: relative; transition: background 0.2s, transform 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.15); transform: translateY(-1px); }
.icon-btn.danger:hover { background: rgba(244, 63, 94, 0.3); }
.floating-sound { position: fixed; top: 14px; right: 14px; z-index: 5; }
body[data-screen='game'] .floating-sound { display: none; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent-2); font-size: 0.7rem; font-weight: 900; display: grid; place-items: center;
}

/* ------------------------------------------------------------- inputs & panels */
.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
  border: 1px solid var(--panel-border); border-radius: 24px; padding: 22px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.panel-title { font-weight: 900; margin-bottom: 10px; }
.input {
  width: 100%; padding: 13px 15px; border-radius: 13px; border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.3); outline: none; transition: border-color 0.2s, box-shadow 0.2s; font-weight: 700;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25); }
.field-label { display: block; font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 6px 0 8px; }
.eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); font-weight: 800; }

/* ------------------------------------------------------------- home */
.home {
  min-height: 100%; max-width: 1100px; margin: 0 auto; padding: 40px 16px;
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center;
}
.hero { text-align: center; }
.logo {
  display: inline-grid; place-items: center; width: 270px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff5a62, var(--red) 55%, #9d1219);
  transform: rotate(-12deg); border: 8px solid #fff8; box-shadow: 0 25px 60px rgba(229, 50, 59, 0.45), inset 0 -10px 30px rgba(0,0,0,.3);
  animation: logoIn 0.8s var(--ease-out) both, bob 4s ease-in-out 0.8s infinite;
}
.logo span {
  font-family: var(--font-display); font-size: 104px; color: var(--yellow); line-height: 1;
  text-shadow: 4px 4px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 6px 8px 0 rgba(0,0,0,.3);
  transform: skewX(-8deg);
}
.logo-sub { margin-top: 18px; font-family: var(--font-display); letter-spacing: 6px; color: #fff; opacity: 0.85; }
.tagline { color: var(--muted); font-size: 1.05rem; }
.tagline b { color: var(--text); }
@keyframes logoIn { from { transform: rotate(-30deg) scale(0.3); opacity: 0; } }
@keyframes bob { 50% { transform: rotate(-9deg) translateY(-8px); } }

.hero-fan { position: relative; height: 170px; margin-top: 18px; }
.hero-fan .card {
  --cw: 82px; position: absolute; left: 50%; bottom: 0; transform-origin: 50% 120%;
  transform: translateX(-50%) rotate(var(--r)); animation: fanIn 0.7s var(--ease-out) both; animation-delay: var(--delay);
  transition: transform 0.3s var(--ease-out);
}
.hero-fan:hover .card { transform: translateX(-50%) rotate(calc(var(--r) * 1.35)) translateY(-8px); }
@keyframes fanIn { from { transform: translateX(-50%) rotate(0deg) translateY(60px); opacity: 0; } }

.home-panel { display: flex; flex-direction: column; gap: 10px; }
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 8px; }
.avatar-option {
  aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; background: rgba(255, 255, 255, 0.06);
  font-size: 1.45rem; display: grid; place-items: center; transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.avatar-option:hover { transform: scale(1.1); background: rgba(255, 255, 255, 0.12); }
.avatar-option.selected { border-color: var(--gold); background: rgba(251, 191, 36, 0.18); box-shadow: 0 0 18px rgba(251, 191, 36, 0.35); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.82rem; margin: 6px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--panel-border); }
.join-row { display: flex; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-family: var(--font-display); font-size: 1.2rem; }

/* ------------------------------------------------------------- lobby */
.lobby {
  min-height: 100%; max-width: 1150px; margin: 0 auto; padding: 32px 16px;
  display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: stretch;
}
.lobby-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.room-code {
  font-family: var(--font-display); font-size: clamp(2.4rem, 7vw, 3.6rem); letter-spacing: 10px; line-height: 1;
  background: linear-gradient(135deg, #fff, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.code-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lobby-sub { color: var(--muted); margin: 10px 0 18px; }
.lobby-sub b { color: var(--text); }
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.player-slot {
  border-radius: 18px; padding: 16px 10px; text-align: center; position: relative;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-border);
  animation: popIn 0.35s var(--ease-out) both;
}
.player-slot.empty { background: transparent; border: 2px dashed rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.25); display: grid; place-items: center; min-height: 128px; animation: none; }
.player-slot.me { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2); }
.player-slot.offline { opacity: 0.5; }
.player-slot .p-avatar { font-size: 2.4rem; width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #312e81, #581c87); }
.player-slot .p-name { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-slot .p-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.player-slot .crown { position: absolute; top: 8px; left: 10px; font-size: 1.1rem; }
.tag { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 900; }
.tag.ready { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.tag.waiting { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.tag.host { background: rgba(251, 191, 36, 0.2); color: #fde68a; }
.lobby-status { margin: 20px 0 14px; padding: 12px 16px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); font-weight: 700; }
.lobby-status.ok { color: #86efac; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.lobby-actions .btn-ghost { margin-right: auto; }
#btn-ready.is-ready { background: linear-gradient(135deg, #16a34a, #22c55e); }
.lobby-chat { display: flex; flex-direction: column; min-height: 420px; max-height: calc(100dvh - 64px); }
.chat-slot { flex: 1; min-height: 0; display: flex; }
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } }

/* ------------------------------------------------------------- chat */
.chat { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; width: 100%; }
.chat-log { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.msg { max-width: 88%; padding: 7px 11px; border-radius: 14px 14px 14px 4px; background: rgba(255, 255, 255, 0.08); font-size: 0.9rem; word-wrap: break-word; animation: popIn 0.2s var(--ease-out); }
.msg .who { font-weight: 900; font-size: 0.75rem; color: #c4b5fd; display: block; }
.msg.mine { align-self: flex-end; background: linear-gradient(135deg, rgba(139, 92, 246, 0.5), rgba(236, 72, 153, 0.45)); border-radius: 14px 14px 4px 14px; }
.msg.system { align-self: center; background: none; color: var(--muted); font-size: 0.78rem; text-align: center; padding: 2px 6px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--panel-border); background: rgba(255, 255, 255, 0.06); border-radius: 999px; padding: 5px 10px; font-size: 0.8rem; font-weight: 800; transition: background 0.2s, transform 0.15s; }
.quick button:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }
.chat-form { display: flex; gap: 6px; }
.chat-form .input { padding: 10px 12px; }
.chat-form .btn { padding: 10px 14px; }

/* ------------------------------------------------------------- cards */
.card {
  --cw: 80px; --c: #333;
  position: relative; flex: none; width: var(--cw); height: calc(var(--cw) * 1.5);
  border-radius: calc(var(--cw) * 0.12); background: #fbfbfb;
  box-shadow: 0 calc(var(--cw) * 0.05) calc(var(--cw) * 0.14) rgba(0, 0, 0, 0.4);
  user-select: none; font-family: var(--font-display); color: #fff;
}
.card.red { --c: var(--red); }
.card.yellow { --c: var(--yellow); }
.card.green { --c: var(--green); }
.card.blue { --c: var(--blue); }
.card.wild { --c: var(--wild); }
.card .face {
  position: absolute; inset: calc(var(--cw) * 0.055); border-radius: calc(var(--cw) * 0.085); overflow: hidden;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 55%), var(--c);
}
.card .oval {
  position: absolute; left: 50%; top: 50%; width: 92%; height: 64%; border-radius: 50%; background: #fff;
  transform: translate(-50%, -50%) rotate(-58deg);
}
.card.wild .oval {
  background: conic-gradient(from 45deg, var(--red) 0 25%, var(--blue) 0 50%, var(--yellow) 0 75%, var(--green) 0);
}
.card .big {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * 0.52); line-height: 1;
  color: var(--c);
  text-shadow: calc(var(--cw) * 0.025) calc(var(--cw) * 0.025) 0 #111, calc(var(--cw) * -0.012) calc(var(--cw) * -0.012) 0 #111,
    calc(var(--cw) * 0.012) calc(var(--cw) * -0.012) 0 #111, calc(var(--cw) * -0.012) calc(var(--cw) * 0.012) 0 #111;
}
.card.wild .big { color: #fff; }
.card[data-value='6'] .big, .card[data-value='9'] .big { text-decoration: underline; text-decoration-thickness: calc(var(--cw) * 0.03); text-underline-offset: calc(var(--cw) * 0.04); }
.card[data-value='skip'] .big, .card[data-value='reverse'] .big { font-family: var(--font); font-weight: 900; }
.card .corner {
  position: absolute; font-size: calc(var(--cw) * 0.19); line-height: 1; color: #fff;
  text-shadow: 1px 1px 0 #111, -1px -1px 0 #111, 1px -1px 0 #111, -1px 1px 0 #111;
}
.card .tl { top: 6%; left: 9%; }
.card .br { bottom: 6%; right: 9%; transform: rotate(180deg); }

.card.back .face { background: radial-gradient(circle at 50% 40%, #2a2a33, #0c0c10); }
.card.back .oval { background: var(--red); }
.card.back .big {
  color: var(--yellow); font-size: calc(var(--cw) * 0.34); transform: rotate(-22deg);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

/* ------------------------------------------------------------- game layout */
#screen-game { grid-template-rows: auto minmax(0, 1fr) auto auto; height: 100dvh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; z-index: 3; }
.chip { padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--panel-border); font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.chip b { color: var(--text); letter-spacing: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.table-area { position: relative; min-height: 0; padding: 0 10px; }
.table { position: relative; width: 100%; height: 100%; min-height: 260px; --glow: rgba(139, 92, 246, 0.35); }
.table[data-color='red'] { --glow: rgba(229, 50, 59, 0.55); }
.table[data-color='yellow'] { --glow: rgba(246, 197, 21, 0.5); }
.table[data-color='green'] { --glow: rgba(34, 169, 90, 0.55); }
.table[data-color='blue'] { --glow: rgba(30, 110, 232, 0.6); }
.felt {
  position: absolute; inset: 9% 7%; border-radius: 50%;
  background: radial-gradient(ellipse at center, #232a66 0%, #161b45 55%, #0d1030 100%);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.65), 0 0 0 10px rgba(255, 255, 255, 0.025), 0 0 0 11px rgba(255, 255, 255, 0.06), 0 0 90px var(--glow);
  transition: box-shadow 0.6s ease;
}
.center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: clamp(16px, 3vw, 36px); align-items: center; }
.dir-ring {
  position: absolute; left: 50%; top: 50%; width: calc(var(--pile-cw) * 3.4); height: calc(var(--pile-cw) * 3.4);
  margin: calc(var(--pile-cw) * -1.7) 0 0 calc(var(--pile-cw) * -1.7);
  color: rgba(255, 255, 255, 0.18); pointer-events: none; animation: spin 14s linear infinite;
}
.dir-ring path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 4 7; }
.dir-ring.ccw { transform: scaleX(-1); animation-name: spinCcw; }
.dir-ring.flash { color: var(--gold); }
@keyframes spin { to { rotate: 360deg; } }
@keyframes spinCcw { to { rotate: -360deg; } }

.pile { position: relative; width: var(--pile-cw); height: calc(var(--pile-cw) * 1.5); border: 0; padding: 0; background: none; }
.pile .card { --cw: var(--pile-cw); position: absolute; left: 0; top: 0; }
.draw-pile .card:nth-child(2) { transform: translate(-3px, -3px); }
.draw-pile .card:nth-child(3) { transform: translate(-6px, -6px); }
.draw-pile.can-draw { animation: canDraw 1.4s ease-in-out infinite; border-radius: 12px; }
.draw-pile.can-draw:hover { transform: translateY(-4px); }
@keyframes canDraw { 50% { filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.8)); } }
.pile-count {
  position: absolute; z-index: 2; bottom: -10px; right: -10px; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px;
  background: #000c; border: 2px solid rgba(255, 255, 255, 0.25); font-weight: 900; font-size: 0.8rem; display: grid; place-items: center;
}
.discard-pile { filter: drop-shadow(0 0 22px var(--glow)); transition: filter 0.5s; }
.discard-pile .card { transform: rotate(var(--rot, 0deg)); }
/* waits for the flying card to arrive, then "lands" */
.discard-pile .card.landed { animation: land 0.3s var(--ease-out) 0.38s backwards; }
@keyframes land { from { opacity: 0; transform: rotate(var(--rot)) scale(1.25); } }

.status-line {
  position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); white-space: nowrap;
  padding: 7px 16px; border-radius: 999px; font-weight: 800; font-size: 0.92rem;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--panel-border);
}
.status-line.mine { background: linear-gradient(135deg, rgba(139, 92, 246, 0.8), rgba(236, 72, 153, 0.8)); }
.status-line.alert { background: linear-gradient(135deg, #b91c1c, #f59e0b); }
.feed { position: absolute; left: 12px; top: 6px; display: flex; flex-direction: column; gap: 4px; max-width: 46%; pointer-events: none; }
.feed div { font-size: 0.78rem; padding: 4px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.4); color: #dfe3ff; animation: feedIn 0.3s var(--ease-out); transition: opacity 0.5s; }
.feed div.old { opacity: 0.45; }
@keyframes feedIn { from { transform: translateX(-16px); opacity: 0; } }

/* ------------------------------------------------------------- seats */
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute; width: 112px; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: left 0.5s var(--ease-out), top 0.5s var(--ease-out);
}
.avatar-wrap { position: relative; width: 62px; height: 62px; }
.avatar {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; font-size: 32px;
  background: linear-gradient(135deg, #312e81, #581c87); border: 3px solid rgba(255, 255, 255, 0.18);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.seat.active .avatar, .me-info.active .avatar { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.25), 0 0 32px rgba(251, 191, 36, 0.65); transform: scale(1.08); }
.seat.offline { opacity: 0.45; filter: grayscale(0.7); }
.timer { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); transform: rotate(-90deg); pointer-events: none; }
.timer circle { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 100; animation: timerRun linear forwards; }
.timer.low circle { stroke: var(--danger); }
@keyframes timerRun { to { stroke-dashoffset: 100; } }
.seat .count {
  position: absolute; right: -8px; bottom: -4px; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 13px;
  background: #fff; color: #111; font-weight: 900; font-size: 0.82rem; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.seat .crown { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: 1rem; }
.seat .name { max-width: 100%; font-weight: 900; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.4); }
.seat .score { font-size: 0.7rem; color: var(--muted); }
.mini-hand { display: flex; height: 22px; }
.mini { width: 15px; height: 22px; border-radius: 3px; margin-left: -8px; background: linear-gradient(135deg, #1a1a22, #000); border: 1.5px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.4); position: relative; }
.mini:first-child { margin-left: 0; }
.mini::after { content: ''; position: absolute; inset: 4px 2px; border-radius: 50%; background: var(--red); }
.uno-flag { position: absolute; top: 4px; right: -2px; padding: 2px 7px; border-radius: 8px; background: linear-gradient(135deg, #ef4444, #f59e0b); font-family: var(--font-display); font-size: 0.75rem; transform: rotate(12deg); animation: popIn 0.3s var(--ease-out); }
.catch-btn {
  border: 0; border-radius: 10px; padding: 4px 10px; font-weight: 900; font-size: 0.78rem; color: #fff;
  background: linear-gradient(135deg, #dc2626, #f97316); animation: unoPulse 0.7s infinite;
}
.seat.shake, .me-info.shake { animation: shake 0.5s; }
@keyframes shake { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }
.bubble {
  position: fixed; transform: translate(-50%, -100%); max-width: 160px; z-index: 44; pointer-events: none;
  background: #fff; color: #111; font-weight: 800; font-size: 0.78rem; padding: 5px 10px; border-radius: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }

/* ------------------------------------------------------------- me + hand */
.me-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 16px 0; z-index: 2; }
.me-info { display: flex; align-items: center; gap: 10px; min-width: 0; position: relative; }
.me-info .avatar-wrap { width: 48px; height: 48px; }
.me-info .avatar { font-size: 25px; }
.me-info .me-name { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info .me-sub { font-size: 0.78rem; color: var(--muted); }
.me-info .secs { font-family: var(--font-display); color: var(--gold); }
.me-info .secs.low { color: var(--danger); }
.actions { display: flex; gap: 8px; }
.hand { overflow-x: auto; overflow-y: hidden; padding: 26px 12px calc(14px + env(safe-area-inset-bottom)); display: flex; scrollbar-width: thin; }
.hand-inner { display: flex; margin: 0 auto; padding: 0 8px; }
.hand .card {
  --cw: var(--hand-cw); cursor: pointer;
  transition: transform 0.18s var(--ease-out), filter 0.2s, margin 0.25s, box-shadow 0.2s;
}
.hand .card:hover { transform: translateY(-16px); z-index: 5; }
.hand.my-turn .card.playable { transform: translateY(-12px); box-shadow: 0 0 0 3px #fff, 0 0 26px rgba(255, 255, 255, 0.55); }
.hand.my-turn .card.playable:hover { transform: translateY(-24px) scale(1.04); }
.hand.my-turn .card:not(.playable) { filter: brightness(0.5) saturate(0.6); cursor: not-allowed; }
.hand .card.drawn { box-shadow: 0 0 0 3px var(--gold), 0 0 30px rgba(251, 191, 36, 0.8); }
.hand .card.new { animation: dealIn 0.45s var(--ease-out) both; animation-delay: var(--delay, 0ms); }
.hand .card.nope { animation: shake 0.4s; }
@keyframes dealIn { from { transform: translateY(70px) rotate(8deg); opacity: 0; } }

/* ------------------------------------------------------------- chat drawer */
.chat-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 30; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: rgba(14, 16, 36, 0.96); border-left: 1px solid var(--panel-border); box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
  transform: translateX(105%); transition: transform 0.3s var(--ease-out);
}
.chat-drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; }

/* ------------------------------------------------------------- modals */
.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 16px; background: rgba(5, 6, 15, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal.open { display: grid; }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: 88dvh; overflow-y: auto; padding: 26px; border-radius: 26px; text-align: center;
  background: linear-gradient(180deg, #1c2048, #12152f); border: 1px solid var(--panel-border); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.3s var(--ease-out);
}
.modal-card h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: 1px; margin: 4px 0 12px; font-size: 1.8rem; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
@keyframes modalIn { from { transform: translateY(30px) scale(0.95); opacity: 0; } }
.rules { text-align: left; }
.rules h2 { text-align: center; }
.rules li { margin-bottom: 9px; line-height: 1.5; color: #d7dbf5; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.color-btn { height: 92px; border: 0; border-radius: 18px; font-family: var(--font-display); font-size: 1.4rem; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.4); transition: transform 0.15s, box-shadow 0.2s; }
.color-btn:hover { transform: scale(1.05); }
.color-btn.red { background: var(--red); box-shadow: 0 10px 26px rgba(229, 50, 59, 0.45); }
.color-btn.yellow { background: var(--yellow); box-shadow: 0 10px 26px rgba(246, 197, 21, 0.4); }
.color-btn.green { background: var(--green); box-shadow: 0 10px 26px rgba(34, 169, 90, 0.45); }
.color-btn.blue { background: var(--blue); box-shadow: 0 10px 26px rgba(30, 110, 232, 0.45); }
.trophy { font-size: 4rem; animation: bob 2s ease-in-out infinite; }
.results-table { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; text-align: left; }
.res-row { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.06); }
.res-row.winner { background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(236, 72, 153, 0.2)); border: 1px solid rgba(251, 191, 36, 0.5); }
.res-row .r-av { font-size: 1.5rem; }
.res-row .r-name { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-row .r-cards { font-size: 0.8rem; color: var(--muted); }
.res-row .r-total { font-family: var(--font-display); color: var(--gold); min-width: 54px; text-align: right; }

/* ------------------------------------------------------------- overlays & fx */
.overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(5, 6, 15, 0.85); font-weight: 800; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent-2); animation: spin 0.9s linear infinite; }
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { padding: 10px 18px; border-radius: 14px; font-weight: 800; font-size: 0.92rem; background: rgba(20, 22, 48, 0.95); border: 1px solid var(--panel-border); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); animation: toastIn 0.3s var(--ease-out); transition: opacity 0.3s, transform 0.3s; text-align: center; }
.toast.error { border-color: rgba(244, 63, 94, 0.7); background: rgba(80, 14, 30, 0.95); }
.toast.warn { border-color: rgba(251, 191, 36, 0.7); background: rgba(70, 50, 8, 0.95); }
.toast.ok { border-color: rgba(34, 197, 94, 0.6); background: rgba(10, 60, 30, 0.95); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } }
.banner {
  position: fixed; left: 50%; top: 42%; z-index: 60; pointer-events: none; opacity: 0; white-space: nowrap;
  transform: translate(-50%, -50%) scale(0.6); font-family: var(--font-display); font-size: clamp(1.8rem, 6vw, 3.4rem); letter-spacing: 1px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 0 40px rgba(236, 72, 153, 0.8);
}
.banner.show { animation: bannerShow 1.4s var(--ease-out) forwards; }
@keyframes bannerShow { 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
.burst {
  position: fixed; z-index: 61; pointer-events: none; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-size: 3rem; color: var(--yellow);
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 0 30px rgba(239, 68, 68, 0.9);
  animation: burst 1.2s var(--ease-out) forwards;
}
.burst.small { font-size: 1.8rem; color: #fff; }
@keyframes burst { 0% { transform: translate(-50%, -50%) scale(0.2) rotate(-20deg); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.3) rotate(6deg); opacity: 1; } 35% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); } 80% { opacity: 1; } 100% { transform: translate(-50%, -90%) scale(1); opacity: 0; } }
.fly { position: fixed; z-index: 45; pointer-events: none; margin: 0; will-change: transform; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 65; pointer-events: none; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .home { grid-template-columns: 1fr; gap: 18px; padding-top: 28px; }
  .hero-fan { display: none; }
  .logo { width: 210px; height: 132px; }
  .logo span { font-size: 80px; }
  .lobby { grid-template-columns: 1fr; }
  .lobby-chat { min-height: 340px; }
}
@media (max-width: 640px) {
  :root { --hand-cw: 62px; --pile-cw: 58px; }
  .avatar-grid { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  .avatar-option { font-size: 1.15rem; border-radius: 9px; }
  .player-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .player-slot .p-avatar { width: 50px; height: 50px; font-size: 1.8rem; }
  .lobby-actions .btn { flex: 1; }
  .topbar { padding: 8px 10px; }
  .chip#game-round { display: none; }
  .seat { width: 76px; }
  .avatar-wrap { width: 44px; height: 44px; }
  .avatar { font-size: 22px; border-width: 2px; }
  .seat .name { font-size: 0.72rem; padding: 1px 5px; }
  .seat .score, .mini-hand { display: none; }
  .seat .count { min-width: 22px; height: 22px; font-size: 0.72rem; }
  .felt { inset: 6% 2%; }
  .feed { display: none; }
  .status-line { font-size: 0.8rem; bottom: 2%; }
  .me-bar { padding: 4px 10px 0; }
  .me-info .me-sub { display: none; }
  .actions .btn { padding: 10px 12px; font-size: 0.85rem; }
  .hand { padding-top: 20px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  :root { --hand-cw: 54px; --pile-cw: 52px; }
  .hand { padding-top: 16px; padding-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *:not(circle), *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
