:root {
  --bg: #eef1f6;
  --bg-grad: radial-gradient(circle at 50% 25%, #ffffff 0%, #dfe5f0 100%);
  --card: #ffffff;
  --card-2: #f1f4f9;
  --ink: #171c26;
  --ink-2: #4b5565;
  --ink-3: #7d8798;
  --rule: rgba(23, 28, 38, 0.11);
  --rule-2: rgba(23, 28, 38, 0.22);
  --felt: radial-gradient(ellipse at center, #20523d 0%, #143728 72%, #0e261c 100%);
  --felt-border: #5a3c24;
  --primary: #e53935;
  --primary-ink: #ffffff;
  --danger: #d92b2b;
  --uno-red: #e53935;
  --uno-yellow: #f9b915;
  --uno-green: #2fa85a;
  --uno-blue: #2374e1;
  --sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: 0 18px 46px rgba(14, 20, 34, 0.16);
}

:root[data-theme="dark"] {
  --bg: #0f131b;
  --bg-grad: radial-gradient(circle at 50% 20%, #1c2434 0%, #0d1118 100%);
  --card: #181f2c;
  --card-2: #222b3d;
  --ink: #f2f5fa;
  --ink-2: #b4bfd2;
  --ink-3: #7f8ca3;
  --rule: rgba(255, 255, 255, 0.1);
  --rule-2: rgba(255, 255, 255, 0.22);
  --felt: radial-gradient(ellipse at center, #1b4232 0%, #102a1f 72%, #0a1b14 100%);
  --felt-border: #402a19;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.52);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 var(--sans);
  background: var(--bg-grad);
  color: var(--ink);
  overflow-x: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-3); }
.ic { width: 1.2em; height: 1.2em; display: block; }

/* Loader */
.loader {
  position: fixed; inset: 0; z-index: 999; display: grid; place-items: center;
  background: #0f131b;
}
.uno-logo-pill {
  display: inline-block; padding: 10px 26px; border-radius: 999px;
  background: linear-gradient(135deg, #e53935, #c62828);
  color: #ffd524; font-weight: 900; font-size: 28px; letter-spacing: .08em;
  transform: rotate(-7deg); border: 4px solid #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,.38); text-shadow: 2px 3px 0 #111;
}
.uno-logo-pill.big { font-size: 40px; padding: 12px 34px; }

/* Card base & bottoni */
.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: 18px;
  box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--rule-2);
  background: var(--card-2); font-weight: 700; cursor: pointer;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.ghost.danger { color: var(--danger); border-color: rgba(217, 43, 43, .45); }
.btn.big { width: 100%; padding: 13px 18px; font-size: 16px; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.solo { background: linear-gradient(135deg, #2374e1, #1956b0); color: #fff; border-color: transparent; }
.icon-btn {
  position: relative; width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid var(--rule); background: var(--card); cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.icon-btn:hover { background: var(--card-2); transform: translateY(-1px); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 9px; }
.btn-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--uno-red); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--rule-2);
  background: var(--card-2); color: var(--ink); font-size: 15px; font-weight: 600;
}
.field.compact { margin-bottom: 10px; }

/* Screens */
.screen { min-height: 100%; display: grid; place-items: center; padding: 20px; }

/* Home */
.home-card { width: min(440px, 100%); overflow: hidden; }
.home-hero {
  padding: 28px 24px 20px; text-align: center;
  background: linear-gradient(160deg, rgba(229,57,53,.14), rgba(35,116,225,.12));
  border-bottom: 1px solid var(--rule);
}
.hero-cards { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.hero-cards .hc {
  width: 34px; height: 48px; border-radius: 7px; border: 2px solid #fff;
  display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 15px;
  box-shadow: 0 6px 14px rgba(0,0,0,.22);
}
.hc.r { background: var(--uno-red); transform: rotate(-12deg) translateY(3px); }
.hc.y { background: var(--uno-yellow); color: #222; transform: translateY(-2px); }
.hc.b { background: var(--uno-blue); transform: rotate(12deg) translateY(3px); }
.tagline { margin: 14px 0 0; color: var(--ink-2); font-size: 14px; }
.home-body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 10px; }
.join-box { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--rule); }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: .16em; text-align: center; font-family: var(--mono); }
.fineprint { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); text-align: center; }
.lang-switch { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.lang-switch button {
  padding: 6px 12px; border-radius: 99px; border: 1px solid var(--rule); background: var(--card-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }

/* Lobby */
.lobby-card { width: min(980px, 100%); overflow: hidden; }
.lobby-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--rule); background: var(--card-2);
}
.ticket-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }
.code { font-size: 30px; font-weight: 800; letter-spacing: .18em; color: var(--uno-red); }
.lobby-share { display: flex; flex-wrap: wrap; gap: 8px; }
.lobby-body { display: grid; grid-template-columns: 1.05fr .95fr 1.15fr; gap: 20px; padding: 22px; }
.lobby-col h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }
.count { font-size: 13px; color: var(--ink-3); font-weight: 700; }
.lobby-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; max-height: 310px; overflow: auto; }
.lobby-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 12px; background: var(--card-2); border: 1px solid var(--rule);
}
.lp-av {
  width: 30px; height: 30px; border-radius: 99px; color: #fff; flex: none;
  display: grid; place-items: center; box-shadow: inset 0 -2px 0 rgba(0,0,0,.22);
}
.lp-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-badges { display: flex; gap: 4px; }
.b { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 99px; background: var(--rule); }
.b.host { background: rgba(249,185,21,.22); color: #d89600; }
.b.bot { background: rgba(35,116,225,.2); color: #5aa3ff; }
.b.you { background: rgba(47,168,90,.2); color: #36c469; }
.b.off { background: rgba(217,43,43,.2); color: #f66; }
.btn-kick { border: none; background: transparent; color: var(--ink-3); cursor: pointer; padding: 4px; border-radius: 6px; }
.btn-kick:hover { color: var(--danger); background: rgba(217,43,43,.12); }
.bot-actions { display: flex; gap: 8px; }

.avatar-picker, .color-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.av-opt, .col-opt {
  height: 38px; border-radius: 10px; border: 2px solid transparent; cursor: pointer;
  display: grid; place-items: center; transition: transform .1s ease;
}
.av-opt { background: var(--card-2); color: var(--ink-2); border-color: var(--rule); }
.av-opt.active { border-color: var(--primary); color: var(--primary); background: rgba(229,57,53,.1); transform: scale(1.06); }
.col-opt.active { border-color: #fff; box-shadow: 0 0 0 2px var(--ink); transform: scale(1.08); }

.host-note { margin: 0 0 10px; font-size: 12px; color: var(--ink-3); }
.rules-sub { margin: 12px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.toggle {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; cursor: pointer; font-size: 13px;
}
.toggle input { display: none; }
.toggle > span {
  width: 36px; height: 20px; border-radius: 99px; background: var(--rule-2); flex: none;
  position: relative; margin-top: 2px; transition: background .18s ease;
}
.toggle > span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 99px; background: #fff; transition: transform .18s ease;
}
.toggle input:checked + span { background: var(--uno-green); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:disabled + span { opacity: .5; }
.toggle .tl { font-weight: 700; line-height: 1.3; }
.toggle .tl small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.lobby-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px; border-top: 1px solid var(--rule); background: var(--card-2);
}
.lobby-foot .btn.big { width: auto; min-width: 190px; }
.hint { font-size: 13px; color: var(--ink-2); font-weight: 600; }

/* HUD e Tavolo CSS 3D */
#hud {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  position: relative;
}
#hud-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; z-index: 20;
}
.top-left, .hud-tools { display: flex; align-items: center; gap: 8px; }
.pill-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--rule); font-weight: 800; font-size: 13px;
}
.color-dot { width: 12px; height: 12px; border-radius: 99px; display: inline-block; box-shadow: 0 0 8px currentColor; }
.color-dot.c-red { background: var(--uno-red); color: var(--uno-red); }
.color-dot.c-yellow { background: var(--uno-yellow); color: var(--uno-yellow); }
.color-dot.c-green { background: var(--uno-green); color: var(--uno-green); }
.color-dot.c-blue { background: var(--uno-blue); color: var(--uno-blue); }

.turn-banner {
  padding: 6px 16px; border-radius: 99px; font-weight: 800; font-size: 14px;
  background: var(--card); border: 1px solid var(--rule); text-align: center;
}
.turn-banner.mine {
  background: linear-gradient(135deg, #2fa85a, #1d7f41); color: #fff; border-color: transparent;
  box-shadow: 0 0 18px rgba(47, 168, 90, .45);
}
.turn-banner.spectator { background: rgba(35,116,225,.18); color: #67adff; }

#table-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 4px 14px 10px; position: relative; min-height: 0; perspective: 1100px;
}

/* Avversari */
.opponents {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  width: min(1040px, 100%); z-index: 10;
}
.opponent-seat {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .2s ease;
}
.opp-card {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 14px; background: var(--card); border: 2px solid var(--rule);
  min-width: 126px; max-width: 175px; box-shadow: 0 8px 18px rgba(0,0,0,.15);
}
.opponent-seat.active .opp-card {
  border-color: #ffd524; box-shadow: 0 0 22px rgba(255, 213, 36, .38); transform: translateY(-2px);
}
.opponent-seat.offline { opacity: .6; }
.opp-avatar {
  width: 28px; height: 28px; border-radius: 99px; color: #fff; flex: none;
  display: grid; place-items: center;
}
.opp-meta { min-width: 0; flex: 1; }
.opp-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.opp-tag { font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 6px; }
.opp-tag.bot { background: rgba(35,116,225,.2); color: #67adff; }
.opp-tag.off { background: rgba(217,43,43,.2); color: #f66; }
.opp-sub { display: flex; gap: 6px; font-size: 11px; color: var(--ink-3); font-weight: 700; }
.opp-score { color: var(--uno-yellow); }
.opp-fan { display: flex; justify-content: center; height: 18px; margin-top: -2px; }
.mini-card-back {
  width: 14px; height: 20px; border-radius: 3px; background: #19191f; border: 1.5px solid #fff;
  margin-left: -6px; transform: rotate(calc(var(--i) * 5deg)); box-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.mini-card-back:first-child { margin-left: 0; }
.uno-pill {
  position: absolute; top: -8px; right: -8px; background: var(--uno-red); color: #ffd524;
  font-size: 10px; font-weight: 900; padding: 2px 6px; border-radius: 99px; border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(229,57,53,.5);
}
.catch-pill {
  position: absolute; top: -10px; right: -10px; background: #ff9800; color: #111; border: 2px solid #fff;
  font-size: 11px; font-weight: 900; padding: 3px 8px; border-radius: 99px; cursor: pointer;
  animation: pulseUno .9s infinite alternate;
}
.opp-timer { width: 90%; height: 4px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.opp-timer span { display: block; height: 100%; background: #ffd524; transition: width .14s linear; }

.seat-emote, .my-emote-slot {
  position: absolute; bottom: -46px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 4px;
  box-shadow: var(--shadow); pointer-events: none; animation: popIn .2s ease;
}
.seat-emote img, .my-emote-slot img { width: 52px; height: 52px; display: block; }
.my-emote-slot { bottom: 168px; }

/* Tappeto ovale centrale */
.table-felt {
  position: relative; width: min(620px, 92vw); height: min(275px, 34vh); min-height: 195px;
  border-radius: 999px; background: var(--felt); border: 10px solid var(--felt-border);
  box-shadow: inset 0 0 40px rgba(0,0,0,.5), 0 22px 44px rgba(0,0,0,.35);
  display: grid; place-items: center; transform: rotateX(9deg); transition: box-shadow .35s ease;
}
#table-stage[data-active-color="red"] .table-felt { box-shadow: inset 0 0 45px rgba(229,57,53,.38), 0 0 38px rgba(229,57,53,.28), 0 22px 44px rgba(0,0,0,.35); }
#table-stage[data-active-color="yellow"] .table-felt { box-shadow: inset 0 0 45px rgba(249,185,21,.34), 0 0 38px rgba(249,185,21,.28), 0 22px 44px rgba(0,0,0,.35); }
#table-stage[data-active-color="green"] .table-felt { box-shadow: inset 0 0 45px rgba(47,168,90,.35), 0 0 38px rgba(47,168,90,.28), 0 22px 44px rgba(0,0,0,.35); }
#table-stage[data-active-color="blue"] .table-felt { box-shadow: inset 0 0 45px rgba(35,116,225,.38), 0 0 38px rgba(35,116,225,.28), 0 22px 44px rgba(0,0,0,.35); }

.direction-ring {
  position: absolute; width: 250px; height: 250px; color: rgba(255,255,255,.72); pointer-events: none;
}
.direction-ring.cw svg { animation: spinCW 18s linear infinite; }
.direction-ring.ccw svg { animation: spinCCW 18s linear infinite; transform: scaleX(-1); }

.piles-row { position: relative; display: flex; align-items: center; gap: 34px; z-index: 5; }
.pile-draw {
  position: relative; background: none; border: none; padding: 0; cursor: pointer;
  border-radius: 14px; transition: transform .15s ease, filter .15s ease;
  box-shadow: 0 6px 0 #0e0e12, 0 12px 24px rgba(0,0,0,.45);
}
.pile-draw:not(.clickable) { cursor: default; }
.pile-draw.clickable:hover { transform: translateY(-4px) scale(1.03); }
.pile-draw.clickable { box-shadow: 0 6px 0 #0e0e12, 0 0 24px rgba(255,255,255,.38); }
.pile-draw.must-draw { box-shadow: 0 6px 0 #0e0e12, 0 0 28px rgba(229,57,53,.9); animation: pulseUno .9s infinite alternate; }
.draw-count {
  position: absolute; bottom: -10px; right: -10px; min-width: 28px; height: 24px; padding: 0 7px;
  border-radius: 99px; background: var(--card); border: 2px solid var(--rule-2);
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
}

.pile-discard { position: relative; width: 90px; height: 132px; }
.discard-layer {
  position: absolute; inset: 0; transform: rotate(var(--rot, 0deg));
  transition: transform .22s ease;
}
.stack-badge {
  position: absolute; bottom: 12px; z-index: 12; padding: 4px 12px; border-radius: 99px;
  background: var(--uno-red); color: #ffd524; font-weight: 900; font-size: 13px; border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.35); animation: pulseUno .8s infinite alternate;
}

/* Carte UNO vettoriali */
.uno-card {
  width: 90px; height: 132px; border-radius: 13px; padding: 5px; background: #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,.32); position: relative; color: #fff;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease, opacity .16s ease;
}
.uno-card-inner {
  width: 100%; height: 100%; border-radius: 9px; position: relative; overflow: hidden;
  display: grid; place-items: center;
  background: #1c1e26;
}
.uno-card.c-red .uno-card-inner { background: radial-gradient(circle at 30% 25%, #f45b58, #c8211f); }
.uno-card.c-yellow .uno-card-inner { background: radial-gradient(circle at 30% 25%, #ffd344, #dfa006); }
.uno-card.c-green .uno-card-inner { background: radial-gradient(circle at 30% 25%, #46c873, #1e8744); }
.uno-card.c-blue .uno-card-inner { background: radial-gradient(circle at 30% 25%, #4294ff, #1657b8); }
.uno-card.c-wild .uno-card-inner { background: radial-gradient(circle at 35% 30%, #343948, #14161e); }
.uno-card.chosen-red { box-shadow: 0 0 0 4px var(--uno-red), 0 8px 20px rgba(0,0,0,.45); }
.uno-card.chosen-yellow { box-shadow: 0 0 0 4px var(--uno-yellow), 0 8px 20px rgba(0,0,0,.45); }
.uno-card.chosen-green { box-shadow: 0 0 0 4px var(--uno-green), 0 8px 20px rgba(0,0,0,.45); }
.uno-card.chosen-blue { box-shadow: 0 0 0 4px var(--uno-blue), 0 8px 20px rgba(0,0,0,.45); }

.uno-oval {
  position: absolute; width: 78%; height: 84%; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.88); transform: rotate(-24deg); pointer-events: none;
}
.uno-card.back .uno-card-inner { background: radial-gradient(circle at 30% 30%, #2b2e3a, #121319); }
.back-oval {
  background: #d92b2b; border: none; display: grid; place-items: center;
}
.back-oval span {
  color: #ffd524; font-weight: 900; font-size: 20px; letter-spacing: .04em;
  text-shadow: 2px 2px 0 #111; transform: rotate(8deg);
}
.uno-corner {
  position: absolute; font-weight: 900; font-size: 15px; line-height: 1;
  text-shadow: 1.5px 1.5px 0 rgba(0,0,0,.45); z-index: 2;
}
.uno-corner.tl { top: 6px; left: 7px; }
.uno-corner.br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.uno-center { position: relative; z-index: 2; display: grid; place-items: center; }
.uno-num {
  font-size: 46px; font-weight: 900; line-height: 1;
  text-shadow: 3px 3px 0 rgba(0,0,0,.42);
}
.uno-num.underline { text-decoration: underline; text-underline-offset: 4px; }
.uno-sym { width: 44px; height: 44px; filter: drop-shadow(2px 3px 0 rgba(0,0,0,.38)); }

.uno-mini-stack { position: relative; width: 38px; height: 44px; }
.uno-mini-stack span {
  position: absolute; width: 24px; height: 32px; border-radius: 5px;
  border: 2px solid #fff; background: rgba(255,255,255,.25); box-shadow: 2px 3px 0 rgba(0,0,0,.3);
}
.uno-mini-stack .m1 { top: 0; right: 0; }
.uno-mini-stack .m2 { bottom: 0; left: 0; }

.uno-wild-oval {
  width: 50px; height: 66px; border-radius: 50%; transform: rotate(-20deg);
  overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; border: 2px solid #fff;
}
.uno-wild-oval span:nth-child(1) { background: var(--uno-red); }
.uno-wild-oval span:nth-child(2) { background: var(--uno-blue); }
.uno-wild-oval span:nth-child(3) { background: var(--uno-yellow); }
.uno-wild-oval span:nth-child(4) { background: var(--uno-green); }

.uno-wild4-fan { position: relative; width: 48px; height: 46px; }
.uno-wild4-fan .wc {
  position: absolute; width: 17px; height: 24px; border-radius: 3px; border: 1.5px solid #fff;
  box-shadow: 1px 2px 0 rgba(0,0,0,.4);
}
.wc.r { background: var(--uno-red); top: 2px; left: 4px; transform: rotate(-10deg); }
.wc.b { background: var(--uno-blue); top: 0; left: 17px; }
.wc.y { background: var(--uno-yellow); top: 14px; left: 10px; transform: rotate(-5deg); }
.wc.g { background: var(--uno-green); top: 12px; left: 24px; transform: rotate(8deg); }

.uno-card.mini { width: 42px; height: 62px; padding: 3px; border-radius: 7px; }
.uno-card.mini .uno-num { font-size: 21px; }
.uno-card.mini .uno-corner { font-size: 8px; }
.uno-card.mini .uno-sym { width: 22px; height: 22px; }
.uno-card.mini .uno-wild-oval { width: 24px; height: 32px; }
.uno-card.mini .uno-mini-stack, .uno-card.mini .uno-wild4-fan { transform: scale(0.5); }

/* Mano del giocatore */
.my-hand {
  display: flex; justify-content: center; align-items: flex-end; height: 152px; width: 100%;
  padding-bottom: 6px; position: relative; z-index: 15;
}
.hand-slot {
  position: relative; width: 90px; margin-left: calc(var(--step, 52px) - 90px);
  transform: translateY(var(--drop, 0px)) rotate(var(--ang, 0deg));
  transform-origin: bottom center; transition: transform .16s ease;
}
.hand-slot:first-child { margin-left: 0; }
.uno-card.playable { cursor: pointer; transform: translateY(-14px); box-shadow: 0 12px 24px rgba(0,0,0,.42), 0 0 0 2px rgba(255,255,255,.75); }
.uno-card.playable:hover { transform: translateY(-28px) scale(1.07); z-index: 50; }
.uno-card.jumpable { cursor: pointer; transform: translateY(-14px); box-shadow: 0 0 22px #42d4ff, 0 0 0 3px #42d4ff; }
.uno-card.jumpable:hover { transform: translateY(-28px) scale(1.07); }
.uno-card.dimmed { filter: brightness(.72) saturate(.8); }
.jump-tag {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  background: #42d4ff; color: #0b1420; font-size: 10px; font-weight: 900;
  padding: 1px 6px; border-radius: 99px; pointer-events: none;
}

/* Action strip */
.action-strip {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; z-index: 18;
}
.action-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 99px; background: var(--card); border: 1px solid var(--rule-2); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700;
}
.action-pill.warn { border-color: #ff9800; }
.uno-callout-btn {
  padding: 10px 24px; border-radius: 99px; border: 3px solid #fff;
  background: linear-gradient(135deg, #e53935, #b71c1c); color: #ffd524;
  font-weight: 900; font-size: 18px; letter-spacing: .06em; cursor: pointer;
  box-shadow: 0 8px 24px rgba(229,57,53,.45);
}
.uno-callout-btn.urgent { animation: pulseUno .65s infinite alternate; }
.uno-callout-btn.armed { background: linear-gradient(135deg, #2fa85a, #1d7f41); color: #fff; }
.uno-callout-btn:disabled { opacity: .45; cursor: default; }

/* Cassetto laterale */
.side-panel {
  position: fixed; top: 60px; right: 12px; bottom: 12px; width: min(340px, calc(100vw - 24px));
  z-index: 40; display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(calc(100% + 24px)); transition: transform .22s ease;
}
.side-panel.open { transform: translateX(0); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: none; background: transparent; padding: 6px 10px; border-radius: 9px;
  font-weight: 700; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.tabs button.active { background: var(--card-2); color: var(--ink); }
.tab-pane { flex: 1; overflow-y: auto; padding: 12px; }
.goal-pill { font-size: 12px; font-weight: 800; color: var(--ink-2); margin-bottom: 10px; }
.score-list { display: flex; flex-direction: column; gap: 6px; }
.score-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 10px;
  background: var(--card-2); font-size: 13px;
}
.score-row.cur { outline: 2px solid #ffd524; }
.sr-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-cards { color: var(--ink-3); font-size: 12px; }
.sr-pts { font-weight: 800; color: var(--uno-yellow); }
.log-entry { padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.chat-pane { display: flex; flex-direction: column; padding: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { font-size: 13px; line-height: 1.35; word-break: break-word; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--rule); }
.chat-form input { flex: 1; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--rule-2); background: var(--card-2); }

/* Popover e Modali */
.popover {
  position: fixed; top: 58px; right: 14px; z-index: 45; width: min(350px, calc(100vw - 24px));
  padding: 12px; max-height: 75vh; overflow: auto;
}
.compact-pop { width: 270px; }
.compact-pop h4, .pop-head h4 { margin: 0 0 10px; font-size: 14px; }
.pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.seg-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.seg-row button {
  padding: 6px; border-radius: 8px; border: 1px solid var(--rule); background: var(--card-2);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.seg-row button.active { border-color: var(--primary); color: var(--primary); }
.slider-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-bottom: 10px; }
.emote-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.emote-tabs button {
  flex: 1; padding: 4px; border-radius: 8px; border: 1px solid var(--rule); background: var(--card-2); cursor: pointer;
}
.emote-tabs button.active { border-color: var(--primary); }
.emote-tabs img { width: 24px; height: 24px; display: block; margin: auto; }
.emote-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-height: 250px; overflow-y: auto; }
.emote-btn {
  padding: 4px; border-radius: 9px; border: 1px solid transparent; background: var(--card-2); cursor: pointer;
}
.emote-btn:hover { border-color: var(--primary); transform: scale(1.06); }
.emote-btn img { width: 100%; aspect-ratio: 1; display: block; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(7, 10, 18, .68);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px;
}
.modal { width: min(440px, 100%); padding: 22px; text-align: center; }
.modal h3 { margin: 0 0 12px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }

.color-wheel {
  width: 210px; height: 210px; margin: 16px auto; border-radius: 50%; overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; background: var(--card-2);
  box-shadow: 0 10px 26px rgba(0,0,0,.28);
}
.cw-btn { border: none; cursor: pointer; transition: transform .12s ease, filter .12s ease; }
.cw-btn:hover { transform: scale(1.05); filter: brightness(1.1); }
.cw-btn.red { background: var(--uno-red); border-top-left-radius: 100%; }
.cw-btn.yellow { background: var(--uno-yellow); border-top-right-radius: 100%; }
.cw-btn.green { background: var(--uno-green); border-bottom-left-radius: 100%; }
.cw-btn.blue { background: var(--uno-blue); border-bottom-right-radius: 100%; }

.swap-targets { display: flex; flex-direction: column; gap: 8px; }
.swap-target-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--rule-2); background: var(--card-2); cursor: pointer; font-weight: 700;
}
.swap-target-btn:hover { border-color: var(--primary); }
.swap-target-btn .st-name { flex: 1; text-align: left; }
.swap-target-btn .st-cards { font-size: 13px; color: var(--ink-3); }

.end-card { width: min(560px, 100%); max-height: 88vh; overflow-y: auto; }
.end-kicker { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--uno-yellow); }
.end-card h2 { margin: 6px 0 4px; }
.end-standings { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; text-align: left; }
.end-row { padding: 10px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--rule); }
.end-row.win { border-color: var(--uno-green); }
.end-row-top { display: flex; align-items: center; gap: 8px; }
.end-score { margin-left: auto; font-weight: 800; color: var(--uno-yellow); }
.end-cards { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.end-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.rules-card { width: min(560px, 100%); text-align: left; max-height: 84vh; overflow-y: auto; }
.rules-body ul { padding-left: 18px; }
.rules-body li { margin-bottom: 6px; }

/* Volo carte, coriandoli e toast */
.flying-card { position: fixed; z-index: 90; pointer-events: none; }
.confetti-burst { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confetti-burst i {
  position: absolute; top: -16px; width: 10px; height: 16px; border-radius: 2px;
  animation: confettiDrop var(--dur, 2s) linear forwards;
}
.toasts {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 120;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
  padding: 9px 16px; border-radius: 99px; background: #1d2433; color: #fff; font-weight: 700;
  font-size: 13px; box-shadow: var(--shadow); transition: opacity .25s ease, transform .25s ease;
}
.toast.error { background: var(--uno-red); }
.toast.ok { background: var(--uno-green); }
.toast.out { opacity: 0; transform: translateY(8px); }

@keyframes pulseUno { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes popIn { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes spinCW { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes spinCCW { from { transform: rotate(0deg) scaleX(-1); } to { transform: rotate(-360deg) scaleX(-1); } }
@keyframes confettiDrop {
  to { transform: translate(var(--dx, 0px), 105vh) rotate(540deg); opacity: .2; }
}

@media (max-width: 820px) {
  .lobby-body { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .uno-card { width: 68px; height: 100px; border-radius: 10px; padding: 4px; }
  .uno-num { font-size: 32px; }
  .uno-corner { font-size: 11px; }
  .uno-sym { width: 32px; height: 32px; }
  .uno-wild-oval { width: 38px; height: 50px; }
  .pile-discard { width: 68px; height: 100px; }
  .piles-row { gap: 18px; }
  .hand-slot { width: 68px; margin-left: calc(var(--step, 40px) - 68px); }
  .my-hand { height: 118px; }
  .opp-card { min-width: 104px; padding: 5px 8px; }
  .turn-banner { display: none; }
}
