/* ============================================================
   UNO — Complete UI Stylesheet
   ============================================================ */

:root {
  --red:    #e53935;
  --blue:   #1e88e5;
  --green:  #43a047;
  --yellow: #fdd835;
  --wild:   #212121;

  --tg-bg:       #17212b;
  --tg-bg2:      #232e3c;
  --tg-text:     #f5f5f5;
  --tg-hint:     #708499;
  --tg-btn:      #2b5278;
  --tg-btn-text: #ffffff;
  --tg-accent:   #5288c1;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0d1117;
  color: var(--tg-text);
  overflow: hidden;
  height: 100vh; width: 100vw;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ── Canvas (decorative 3D) ── */
#pc-canvas {
  position: fixed; inset: 0;
  width: 100vw !important; height: 100vh !important;
  z-index: 0; display: none;
}

/* ── UI Layer ── */
#ui-layer {
  position: fixed; inset: 0; z-index: 10;
  pointer-events: none;
}
#ui-layer .screen,
#ui-layer .overlay,
#ui-layer .uno-btn,
#ui-layer .hand-container,
#ui-layer .hud-player,
#ui-layer #turn-bar,
#ui-layer #color-dot,
#ui-layer #game-center,
#ui-layer #notifications {
  pointer-events: auto;
}

/* ── Screens ── */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes fadeIn   { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(0.85) } to { opacity: 1; transform: scale(1) } }
@keyframes bounceIn {
  0%   { transform: scale(0) }
  55%  { transform: scale(1.15) }
  100% { transform: scale(1) }
}
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-60px) scale(0.6) rotate(-15deg); }
  to   { opacity: 1; transform: translateY(0) scale(1) rotate(var(--card-rot, 0deg)); }
}
@keyframes dotBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes pulseShadow {
  0%,100% { box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 12px rgba(255,214,0,0.3); }
  50%      { box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 28px rgba(255,214,0,0.6); }
}
@keyframes glowPulse {
  0%,100% { box-shadow: 0 0 8px rgba(255,214,0,0.3); }
  50%      { box-shadow: 0 0 22px rgba(255,214,0,0.8), 0 0 44px rgba(255,214,0,0.2); }
}
@keyframes spinCW  { from { transform: translate(-50%,-50%) rotate(0deg);   } to { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes spinCCW { from { transform: translate(-50%,-50%) rotate(0deg);   } to { transform: translate(-50%,-50%) rotate(-360deg); } }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -60%) scale(0.85); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes confettiFall {
  0%   { transform: translateY(-10px) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes mmSpin {
  0%,100% { transform: rotate(-8deg) scale(1); }
  50%      { transform: rotate(8deg) scale(1.1); }
}
@keyframes drawPulse {
  0%,100% { transform: scale(1); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
  50%      { transform: scale(1.04); box-shadow: 0 6px 28px rgba(0,0,0,0.5), 0 0 16px rgba(255,255,255,0.08); }
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */
.tg-input {
  width: 100%; padding: 14px 18px;
  border-radius: 12px; border: 1.5px solid rgba(255,255,255,0.1);
  background: var(--tg-bg2); color: var(--tg-text);
  font-size: 16px; outline: none; transition: border-color 0.2s;
  -webkit-appearance: none;
}
.tg-input:focus { border-color: var(--tg-accent); }
.tg-input::placeholder { color: var(--tg-hint); }

.tg-btn {
  width: 100%; padding: 14px 24px; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tg-btn:active { transform: scale(0.96); }
.tg-btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--tg-btn); color: var(--tg-btn-text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.btn-ghost {
  background: transparent; color: var(--tg-accent);
  border: 1.5px solid rgba(255,255,255,0.12);
}

.hidden { display: none !important; }

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
#screen-lobby {
  background: linear-gradient(180deg, var(--tg-bg) 0%, var(--tg-bg2) 100%);
  align-items: center; justify-content: center; padding: 0 24px 32px;
}
.lobby-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 0; width: 100%; max-width: 340px; animation: fadeUp 0.5s ease-out;
}
.lobby-logo-wrap {
  display: flex; flex-direction: column; align-items: center; margin-bottom: 36px;
}
.logo-cards {
  display: flex; align-items: flex-end; margin-bottom: 16px; height: 80px;
}
.logo-card {
  width: 50px; height: 72px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: white;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.lc-red    { background: linear-gradient(145deg,#ff5252,#c62828); transform: rotate(-15deg) translateX(6px); }
.lc-blue   { background: linear-gradient(145deg,#42a5f5,#1565c0); transform: rotate(-5deg); z-index:1; }
.lc-green  { background: linear-gradient(145deg,#66bb6a,#2e7d32); transform: rotate(5deg); z-index:1; }
.lc-yellow { background: linear-gradient(145deg,#fff176,#f9a825); color:#333; transform: rotate(15deg) translateX(-6px); }

.logo-text {
  font-size: 54px; font-weight: 900; font-style: italic; letter-spacing: 4px;
  background: linear-gradient(135deg, #ff5252, #ffd600, #69f0ae, #40c4ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1; margin-bottom: 6px;
}
.logo-sub { color: var(--tg-hint); font-size: 14px; font-weight: 500; }

.lobby-form {
  display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%;
}

/* ============================================================
   MODE SELECTION
   ============================================================ */
#screen-modes {
  background: linear-gradient(180deg, var(--tg-bg) 0%, var(--tg-bg2) 100%);
  align-items: center; justify-content: center; padding: 24px;
}
.modes-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 18px; width: 100%; max-width: 340px; animation: fadeUp 0.4s ease-out;
}
.modes-title { font-size: 22px; font-weight: 800; color: var(--tg-text); margin-bottom: 4px; }

.mode-card {
  width: 100%; border-radius: 20px; overflow: hidden; cursor: pointer;
  position: relative; height: 130px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:active { transform: scale(0.97); box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.mode-card-bg { position: absolute; inset: 0; }
.mode-card-inner {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  justify-content: center; padding: 20px 24px; height: 100%;
}
.mode-icon { font-size: 34px; margin-bottom: 6px; line-height: 1; }
.mode-label {
  font-size: 20px; font-weight: 900; font-style: italic;
  color: white; text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  letter-spacing: 1px; line-height: 1.15;
}
.mode-desc { font-size: 12px; color: rgba(255,255,255,0.72); margin-top: 4px; }

/* ============================================================
   MATCHMAKING SCREEN
   ============================================================ */
#screen-matchmaking {
  background: linear-gradient(180deg, var(--tg-bg) 0%, var(--tg-bg2) 100%);
  align-items: center; justify-content: center; padding: 24px;
}
.matchmaking-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; animation: fadeUp 0.4s ease-out; width: 100%; max-width: 340px;
}
.mm-spinner { font-size: 64px; animation: mmSpin 2.5s ease-in-out infinite; }
.mm-title { font-size: 24px; font-weight: 800; color: var(--tg-text); }
.mm-sub { font-size: 14px; color: var(--tg-hint); text-align: center; }

/* Player count buttons */
.mm-count-opts {
  display: flex; gap: 12px; width: 100%; justify-content: center; margin-top: 8px;
}
.mm-count-btn {
  flex: 1; padding: 16px 8px; border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.12);
  background: var(--tg-bg2); color: var(--tg-text);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.mm-count-btn:active { transform: scale(0.94); }
.mm-count-btn:hover  { border-color: var(--tg-accent); background: rgba(82,136,193,0.1); }
.mco-num   { font-size: 32px; font-weight: 900; font-style: italic;
             background: linear-gradient(135deg, #ff5252, #ffd600);
             -webkit-background-clip: text; -webkit-text-fill-color: transparent;
             background-clip: text; line-height: 1; }
.mco-label { font-size: 12px; font-weight: 600; color: var(--tg-hint); }

/* Waiting state */
.mm-players {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px;
}
.mm-player-badge {
  background: var(--tg-bg2); border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 40px; padding: 8px 16px; font-size: 14px; font-weight: 700;
  color: var(--tg-text); display: flex; align-items: center; gap: 8px;
  animation: scaleIn 0.3s ease-out;
}
.mm-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}

/* ============================================================
   FRIENDS SCREEN
   ============================================================ */
#screen-friends {
  background: linear-gradient(180deg, var(--tg-bg) 0%, var(--tg-bg2) 100%);
  align-items: center; justify-content: center; padding: 24px;
}
.friends-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; width: 100%; max-width: 340px; animation: fadeUp 0.4s ease-out;
}
.friends-title { font-size: 22px; font-weight: 800; color: var(--tg-text); }

.timer-selector { display: flex; align-items: center; gap: 12px; width: 100%; padding: 4px 0; }
.timer-label-txt { font-size: 14px; color: var(--tg-hint); white-space: nowrap; font-weight: 600; }
.timer-options { display: flex; gap: 8px; }
.timer-opt {
  padding: 7px 16px; border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: transparent; color: var(--tg-hint);
  font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.18s;
}
.timer-opt.active { background: var(--tg-accent); border-color: var(--tg-accent); color: white; }
.timer-opt:active { transform: scale(0.93); }

.stake-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.stake-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: var(--tg-text);
  font-size: 15px;
  font-weight: 800;
  outline: none;
}

.friends-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.friends-card {
  background: var(--tg-bg2); border: 1.5px solid rgba(255,255,255,0.09);
  border-radius: 18px; padding: 20px 14px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; transition: transform 0.15s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.friends-card:not(.join-card):active { transform: scale(0.96); background: rgba(255,255,255,0.06); }
.fc-icon { font-size: 34px; line-height: 1; }
.fc-label { font-size: 15px; font-weight: 800; color: var(--tg-text); text-align: center; }
.fc-desc  { font-size: 11px; color: var(--tg-hint); text-align: center; }
.join-card { cursor: default; gap: 8px; }
.room-code-input {
  width: 100%; padding: 10px 8px; border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05); color: var(--tg-text);
  font-size: 16px; font-weight: 800; letter-spacing: 3px;
  text-align: center; outline: none; margin-top: 4px;
}
.room-code-input:focus { border-color: var(--tg-accent); }
.room-code-input::placeholder { color: var(--tg-hint); font-weight: 400; letter-spacing: 1px; font-size: 12px; }
.fc-join-btn { width: 100%; padding: 10px 8px !important; font-size: 14px !important; border-radius: 10px !important; margin-top: 2px; }

/* ============================================================
   ROOM SCREEN
   ============================================================ */
#screen-room {
  background: linear-gradient(180deg, var(--tg-bg) 0%, var(--tg-bg2) 100%);
  align-items: center; padding: 32px 24px 28px; gap: 0; overflow-y: auto;
}
.room-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; width: 100%; max-width: 340px;
}
.room-top { text-align: center; }
.room-label { color: var(--tg-hint); font-size: 13px; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; }
.room-code-display {
  font-size: 36px; font-weight: 900; letter-spacing: 8px;
  color: var(--tg-accent); font-variant-numeric: tabular-nums; margin-bottom: 6px;
}
.room-hint { color: var(--tg-hint); font-size: 13px; margin-bottom: 14px; }
.share-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px;
  background: rgba(255,255,255,0.07); border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 24px; color: var(--tg-text); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
.share-btn:active { background: rgba(255,255,255,0.12); }
.waiting-label { color: var(--tg-hint); font-size: 14px; font-weight: 600; }
.dot-anim { animation: dotBlink 1.2s infinite; }

.player-slots { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.player-slot {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--tg-bg2); border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.07); animation: fadeUp 0.3s ease-out;
}
.player-slot.empty { opacity: 0.35; border-style: dashed; }
.slot-avatar {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.slot-name { flex: 1; font-weight: 600; font-size: 15px; color: var(--tg-text); }
.slot-badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 700; }
.badge-host  { background: var(--tg-btn); color: white; }
.badge-ready { background: rgba(67,160,71,0.25); color: #69f0ae; }
.room-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

/* ============================================================
   GAME SCREEN — flex column layout
   ============================================================ */
#screen-game {
  /* .screen gives: position:absolute; inset:0; display:flex; flex-direction:column */
  background: radial-gradient(ellipse 140% 90% at 50% 30%,
    #1e4020 0%, #102210 50%, #060d06 100%);
  pointer-events: none;
}

/* Turn bar — top flex item */
.turn-bar {
  flex-shrink: 0;
  z-index: 20;
  overflow: hidden;
  position: relative;
}
.turn-bar-text {
  padding: 8px 16px; text-align: center; font-size: 13px; font-weight: 600;
  color: var(--tg-hint); background: rgba(0,0,0,0.65);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: color 0.3s, background 0.3s; display: block;
}
.turn-bar.your-turn .turn-bar-text { color: #ffd600; background: rgba(255,214,0,0.12); }
.timer-track { height: 4px; width: 100%; background: rgba(255,255,255,0.08); }
.timer-fill  { height: 100%; width: 100%; transform-origin: left; transition: background 0.5s; }
.timer-fill.urgent { background: #ff5252 !important; }
.timer-label {
  position: absolute; right: 12px; top: 50%; transform: translateY(-75%);
  font-size: 12px; font-weight: 800; color: rgba(255,255,255,0.5);
  font-variant-numeric: tabular-nums;
}
.timer-label.urgent { color: #ff5252; }

/* Play area — fills remaining space, centers the table */
.game-play-area {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ── Opponent HUD panels (absolute within .game-play-area) ── */
.hud-player { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hud-top    { position: absolute; top: 8px;  left: 50%; transform: translateX(-50%); pointer-events: auto; }
.hud-left   { position: absolute; left: 6px; top:  50%; transform: translateY(-50%); pointer-events: auto; }
.hud-right  { position: absolute; right: 6px;top:  50%; transform: translateY(-50%); pointer-events: auto; }

/* Bottom hand area — bottom flex item */
.hud-bottom {
  flex-shrink: 0;
  flex-direction: column;
  padding-bottom: 10px;
  pointer-events: auto;
}

.hud-badge {
  display: flex; align-items: center; gap: 6px; padding: 5px 11px;
  background: rgba(0,0,0,0.65); border-radius: 24px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,0.08); transition: border-color 0.3s, background 0.3s;
}
.hud-badge.active-turn {
  background: rgba(255,214,0,0.14);
  border-color: rgba(255,214,0,0.6);
  animation: glowPulse 1.5s ease-in-out infinite;
}
.hud-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; border: 2px solid rgba(255,255,255,0.2);
}
.hud-name  { font-size: 12px; font-weight: 700; color: var(--tg-text); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-count { font-size: 11px; font-weight: 800; color: var(--tg-hint); background: rgba(255,255,255,0.1); padding: 2px 7px; border-radius: 10px; }

/* Mini opponent cards */
.opp-mini-cards { display: flex; }
.opp-mini-cards .mc {
  width: 20px; height: 30px; border-radius: 4px;
  background: linear-gradient(145deg, #c62828, #7b0000);
  border: 1.5px solid rgba(0,0,0,0.5); margin: 0 -4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.opp-mini-cards.vertical { flex-direction: column; }
.opp-mini-cards.vertical .mc { margin: -5px 0; }

/* ── Center Game Table (flex item — naturally centered) ── */
.game-center {
  position: relative;
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-mat {
  width: min(82vw, 340px);
  height: min(44vh, 200px);
  background: radial-gradient(ellipse at 40% 35%, #2e6b2e 0%, #1c4a1c 55%, #102510 100%);
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.09);
  box-shadow:
    0 16px 60px rgba(0,0,0,0.8),
    inset 0 2px 10px rgba(255,255,255,0.04),
    0 0 0 6px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}

/* Direction ring */
.direction-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 140px; height: 140px;
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: 50%;
  pointer-events: none;
}
.direction-ring.cw  { animation: spinCW  8s linear infinite; }
.direction-ring.ccw { animation: spinCCW 8s linear infinite; }
.direction-ring::after {
  content: '▶';
  position: absolute; top: -10px; left: 50%;
  transform: translateX(-50%);
  font-size: 14px; color: rgba(255,255,255,0.2);
}

/* Center piles */
.center-piles {
  display: flex; gap: 24px; align-items: center; z-index: 1; position: relative;
}
.pile-area { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* Draw pile */
.draw-pile-area {
  cursor: pointer; pointer-events: auto;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.draw-pile-area:active { transform: scale(0.9); }
.draw-pile-area.can-draw {
  animation: none;
  filter: drop-shadow(0 0 12px rgba(255, 235, 74, 0.7));
}

.pile-stack { position: relative; width: 52px; height: 74px; }
.back-card {
  position: absolute; width: 52px; height: 74px; border-radius: 8px;
  background: linear-gradient(145deg, #d32f2f, #7b1a1a);
  border: 2px solid rgba(0,0,0,0.6);
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
}
.bc2 { top: 4px; left: 2px; transform: rotate(3deg); }
.bc1 { top: 2px; left: 1px; transform: rotate(1.5deg); }
.bc0 { top: 0; left: 0; transform: rotate(-1deg); }
.uno-back-text {
  font-size: 10px; font-weight: 900; font-style: italic;
  color: #ffd600; transform: rotate(-20deg); letter-spacing: -0.5px;
}

/* Discard pile */
.discard-pile-area { pointer-events: none; }
.discard-top {
  width: 52px; height: 74px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  position: relative; font-size: 22px; font-weight: 900; color: white;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.25);
  text-shadow: 1px 2px 4px rgba(0,0,0,0.4);
  transform: rotate(-5deg);
  border: 2px solid rgba(255,255,255,0.5);
}
.discard-top .dt-oval {
  position: absolute; inset: 12% 8%;
  background: rgba(255,255,255,0.15); border-radius: 50%;
  transform: rotate(-20deg); pointer-events: none;
}
.discard-top .dt-val { z-index: 1; }
.dt-red    { background: linear-gradient(145deg, #ff5252, #c62828); }
.dt-blue   { background: linear-gradient(145deg, #42a5f5, #1565c0); }
.dt-green  { background: linear-gradient(145deg, #66bb6a, #2e7d32); }
.dt-yellow { background: linear-gradient(145deg, #fff176, #f9a825); color: #2c2c2c; text-shadow: none; }
.dt-wild   { background: linear-gradient(145deg, #616161, #212121); }

.pile-info { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.pile-count { font-size: 13px; font-weight: 800; color: var(--tg-text); }
.pile-label { font-size: 9px; font-weight: 700; color: rgba(255,255,255,0.4); letter-spacing: 1px; text-transform: uppercase; }

/* Color dot — below the table within play area */
.color-dot {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4); z-index: 12; transition: background 0.3s;
}
.dot-red    { background: var(--red); }
.dot-blue   { background: var(--blue); }
.dot-green  { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-wild   { background: conic-gradient(var(--red) 0% 25%, var(--blue) 25% 50%, var(--green) 50% 75%, var(--yellow) 75%); }

/* ── Hand ── */
.hand-container {
  width: 100%; overflow-x: auto; overflow-y: visible;
  padding: 12px 16px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.hand-container::-webkit-scrollbar { display: none; }
.hand {
  display: flex; justify-content: center; align-items: flex-end;
  min-height: 110px; padding-bottom: 4px; position: relative;
}

/* HTML cards */
.hcard {
  width: 58px; height: 86px; border-radius: 10px;
  position: relative; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 26px; color: white;
  text-shadow: 1px 2px 3px rgba(0,0,0,0.3);
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  border: 2.5px solid rgba(255,255,255,0.75);
  cursor: pointer; margin: 0 -9px; flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  will-change: transform; -webkit-tap-highlight-color: transparent;
  transform-origin: bottom center;
}
.hcard .oval {
  position: absolute; inset: 10% 8%;
  background: rgba(255,255,255,0.13); border-radius: 50%;
  transform: rotate(-20deg); pointer-events: none;
}
.hcard .cn { position: absolute; font-size: 11px; font-weight: 800; line-height: 1; }
.hcard .cn.tl { top: 5px; left: 6px; }
.hcard .cn.br { bottom: 5px; right: 6px; transform: rotate(180deg); }
.hcard .cv { z-index: 1; }

.hcard.c-red    { background: linear-gradient(145deg, #ff5252, #c62828); }
.hcard.c-blue   { background: linear-gradient(145deg, #42a5f5, #1565c0); }
.hcard.c-green  { background: linear-gradient(145deg, #66bb6a, #2e7d32); }
.hcard.c-yellow { background: linear-gradient(145deg, #fff176, #f9a825); color: #2c2c2c; text-shadow: none; }
.hcard.c-yellow .cn { color: #2c2c2c; }
.hcard.c-wild   { background: linear-gradient(145deg, #616161, #212121); border-color: rgba(255,255,255,0.5); }
.hcard.c-wild::after {
  content: ''; position: absolute; inset: 0; border-radius: 8px;
  background: conic-gradient(from 180deg, #ff5252 0%, #ffd600 25%, #69f0ae 50%, #40c4ff 75%, #ff5252 100%);
  opacity: 0.2; pointer-events: none;
}

.hcard.playable { border-color: #ffd600; box-shadow: 0 6px 16px rgba(0,0,0,0.4), 0 0 20px rgba(255,214,0,0.5); }
.hcard.not-playable { filter: brightness(0.4) saturate(0.5); cursor: not-allowed; }
.hcard.playable:active, .hcard.playable.lifted {
  transform: translateY(-28px) scale(1.1) !important; z-index: 100;
  box-shadow: 0 16px 36px rgba(0,0,0,0.5), 0 0 28px rgba(255,214,0,0.55);
}
.hcard.deal-anim { animation: dealIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both; }

.motion-card {
  position: fixed;
  width: 78px;
  height: 116px;
  border-radius: 8px;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 1px 2px 3px rgba(0,0,0,0.3);
  border: 4px solid rgba(255,255,255,0.92);
  box-shadow: 0 16px 28px rgba(32, 58, 24, 0.36);
  transform-origin: center;
}

.motion-card .oval {
  position: absolute;
  inset: 10% 8%;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transform: rotate(-20deg);
}

.motion-card .cv {
  position: relative;
  z-index: 1;
}

.motion-card.c-red { background: linear-gradient(145deg, #ff5252, #c62828); }
.motion-card.c-blue { background: linear-gradient(145deg, #42a5f5, #1565c0); }
.motion-card.c-green { background: linear-gradient(145deg, #66bb6a, #2e7d32); }
.motion-card.c-yellow { background: linear-gradient(145deg, #fff176, #f9a825); color: #2c2c2c; text-shadow: none; }
.motion-card.c-wild { background: linear-gradient(145deg, #616161, #212121); }
.motion-card.card-back {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.88), transparent 24%),
    url('../../assets/back.png') center / cover no-repeat;
}

.card-particle {
  position: fixed;
  width: 10px;
  height: 10px;
  left: 0;
  top: 0;
  z-index: 999;
  pointer-events: none;
  border-radius: 50%;
  background: #fff15a;
  box-shadow: 0 0 12px currentColor;
  animation: particleBurst 720ms cubic-bezier(.14,.72,.2,1) var(--delay, 0ms) forwards;
}

.card-particle.tiny {
  width: 6px;
  height: 6px;
  opacity: 0.8;
  animation-duration: 460ms;
}

.card-particle.p-red { background: #ff5252; color: #ff5252; }
.card-particle.p-blue { background: #42a5f5; color: #42a5f5; }
.card-particle.p-green { background: #66bb6a; color: #66bb6a; }
.card-particle.p-yellow { background: #fff176; color: #fff176; }
.card-particle.p-wild {
  background: conic-gradient(#ff5252, #fff176, #66bb6a, #42a5f5, #ff5252);
  color: #ffffff;
}

.special-pop {
  animation: specialPop 480ms ease-out;
}

@keyframes particleBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.1);
  }
}

@keyframes specialPop {
  0% { filter: brightness(1); transform: translate(-50%, -50%) scale(1); }
  36% { filter: brightness(1.22) saturate(1.25); transform: translate(-50%, -50%) scale(1.04); }
  100% { filter: brightness(1); transform: translate(-50%, -50%) scale(1); }
}

.pile-stack.shuffling .back-card {
  animation: shuffleWobble 0.55s ease-in-out 2;
}

@keyframes shuffleWobble {
  0%, 100% { transform: translateX(0) rotate(var(--base-rot, 0deg)); }
  25% { transform: translateX(-8px) rotate(calc(var(--base-rot, 0deg) - 7deg)); }
  50% { transform: translateX(7px) rotate(calc(var(--base-rot, 0deg) + 8deg)); }
  75% { transform: translateX(-4px) rotate(calc(var(--base-rot, 0deg) - 4deg)); }
}

/* UNO button — absolute within #screen-game */
.uno-btn {
  position: absolute; bottom: 110px; right: 14px;
  width: 68px; height: 68px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff5252, #c62828);
  border: 3px solid #ffd600; color: white;
  font-size: 14px; font-weight: 900; font-style: italic;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 20px rgba(255,214,0,0.3);
  z-index: 50; display: none; align-items: center; justify-content: center;
  text-align: center; line-height: 1.2;
  animation: pulseShadow 1.2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
.uno-btn.visible { display: flex; }

/* Notifications */
#notifications { position: absolute; inset: 0; pointer-events: none; z-index: 100; }
.notif-toast {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.82); color: white;
  padding: 10px 22px; border-radius: 22px;
  font-size: 15px; font-weight: 700; white-space: nowrap;
  backdrop-filter: blur(8px); animation: toastIn 0.25s ease-out;
}
.speech-bubble {
  position: absolute; background: rgba(0,0,0,0.8);
  border: 1px solid rgba(255,255,255,0.15); color: white;
  padding: 7px 13px; border-radius: 14px;
  font-size: 13px; font-weight: 700; max-width: 150px; text-align: center;
  animation: fadeUp 0.3s ease-out; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

/* ============================================================
   OVERLAYS
   ============================================================ */
.overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.25s;
}
.overlay.hidden { display: none; }

/* Color picker */
.picker-box {
  background: var(--tg-bg2); border-radius: 20px; padding: 28px;
  border: 1px solid rgba(255,255,255,0.1); width: min(320px, 90vw);
  animation: scaleIn 0.25s ease-out;
}
.picker-box h3 { text-align: center; font-size: 18px; margin-bottom: 20px; color: var(--tg-text); }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cpick {
  padding: 16px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.3);
  font-size: 15px; font-weight: 700; color: white; cursor: pointer;
  transition: transform 0.15s; -webkit-tap-highlight-color: transparent;
}
.cpick:active { transform: scale(0.92); }
.cpick.red    { background: var(--red); }
.cpick.blue   { background: var(--blue); }
.cpick.green  { background: var(--green); }
.cpick.yellow { background: var(--yellow); color: #2c2c2c; }

/* Win overlay */
.win-box {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: scaleIn 0.4s ease-out; width: min(300px, 85vw);
}
#win-trophy { font-size: 64px; animation: bounceIn 0.6s ease-out; }
.win-title {
  font-size: 60px; font-weight: 900; font-style: italic;
  background: linear-gradient(135deg, #ffd600, #ff9100);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1; animation: bounceIn 0.7s ease-out 0.1s both;
}
.win-sub { color: var(--tg-hint); font-size: 16px; animation: fadeUp 0.5s ease-out 0.3s both; }

/* Wallet / admin panels */
.wallet-box,
.admin-box {
  width: min(860px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: rgba(22, 32, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.45);
  animation: scaleIn 0.22s ease-out;
}

.admin-box {
  width: min(720px, 94vw);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 21px;
  line-height: 1.1;
}

.panel-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: rgba(255,255,255,0.1);
  font-size: 24px;
  cursor: pointer;
}

.wallet-balance {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 8px;
  padding: 14px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255,214,0,0.16), rgba(64,196,255,0.12));
}

.wallet-balance strong {
  font-size: 40px;
  line-height: 1;
  color: #ffd600;
}

.wallet-balance small {
  grid-column: 1 / -1;
  color: var(--tg-hint);
  font-weight: 700;
  margin-top: 4px;
}

.wallet-grid,
.profile-picker {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 0.95fr);
  gap: 18px;
  margin-bottom: 12px;
}

.wallet-grid label,
.profile-picker label {
  display: grid;
  gap: 6px;
  color: var(--tg-hint);
  font-size: 12px;
  font-weight: 800;
}

.avatar-preview-panel {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  min-height: 318px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(18, 80, 136, 0.26);
  border: 1px solid rgba(255,255,255,0.14);
}

.avatar-preview-panel p {
  max-width: 230px;
  text-align: center;
  color: #fff;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

.avatar-preview-panel img {
  width: 132px;
  height: 132px;
  object-fit: cover;
  object-position: center center;
  border-radius: 8px;
  border: 3px solid rgba(255, 214, 0, 0.88);
  background: #72bd37;
  box-shadow: 0 4px 0 rgba(0,0,0,0.28);
}

.avatar-preview-panel label,
.avatar-preview-panel .tg-input {
  width: 100%;
}

.mini-green-btn {
  height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  background: linear-gradient(180deg, #8ee124, #43a61e);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.28), 0 3px 0 rgba(22, 80, 12, 0.72);
  cursor: pointer;
}

.confirm-profile {
  width: min(160px, 100%);
}

.profile-avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  grid-auto-rows: 112px;
  align-content: start;
  gap: 14px;
  max-height: 412px;
  overflow-y: auto;
  padding: 14px;
  margin: 0;
  border-radius: 8px;
  background: rgba(46, 143, 218, 0.28);
  border: 2px solid rgba(178, 224, 255, 0.26);
}

.avatar-choice {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 8px;
  border: 3px solid rgba(18, 67, 102, 0.75);
  background: #43bfd2;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.22);
}

.avatar-choice.selected {
  border-color: #ffd600;
  box-shadow: 0 0 0 3px rgba(255,214,0,0.3), 0 3px 0 rgba(0,0,0,0.25);
}

.avatar-choice.selected::after {
  content: "✓";
  position: absolute;
  right: 6px;
  bottom: 5px;
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #77d529;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(0,0,0,0.35);
}

.avatar-choice img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
}

@media (max-width: 680px) {
  .wallet-box {
    width: 94vw;
  }

  .profile-picker {
    grid-template-columns: 1fr;
  }

  .profile-avatar-grid {
    grid-template-columns: repeat(3, minmax(68px, 1fr));
    grid-auto-rows: 104px;
    max-height: 280px;
  }

  .avatar-preview-panel {
    min-height: 0;
  }
}

.market-actions,
.admin-grant {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.wallet-note {
  margin-top: 12px;
  color: var(--tg-hint);
  font-size: 12px;
  line-height: 1.35;
}

.admin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.admin-summary span {
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: var(--tg-text);
  font-size: 12px;
}

.admin-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}

.admin-row small {
  color: var(--tg-hint);
  word-break: break-all;
}

.admin-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.admin-row-actions button {
  border: 0;
  border-radius: 8px;
  padding: 7px 9px;
  color: white;
  background: var(--tg-btn);
  font-weight: 800;
  cursor: pointer;
}

/* Toast */
#toast {
  position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.88); color: white; padding: 10px 24px;
  border-radius: 22px; font-size: 14px; font-weight: 600;
  z-index: 600; white-space: nowrap; backdrop-filter: blur(8px); animation: toastIn 0.25s;
}
#toast.hidden { display: none; }

/* Confetti */
.confetti-bit {
  position: absolute; width: 8px; height: 8px; border-radius: 2px;
  animation: confettiFall 3s ease-in forwards; pointer-events: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-height: 680px) {
  .table-mat { width: min(72vw, 280px); height: min(34vh, 150px); }
  .pile-stack, .discard-top { width: 44px; height: 62px; }
  .back-card  { width: 44px; height: 62px; }
  .hcard { width: 50px; height: 76px; font-size: 22px; }
}
@media (max-width: 380px) {
  .hcard { width: 46px; height: 68px; margin: 0 -10px; }
}

/* ============================================================
   REFERENCE-STYLE GAME TABLE
   ============================================================ */
#screen-game {
  background: url('../../assets/backgrounds/table_scene.png') center / cover no-repeat;
  border-radius: 0 0 34px 34px;
  overflow: hidden;
  isolation: isolate;
}

#screen-game::before {
  content: none;
}

#screen-game::after {
  content: none;
}

.round-tool-btn {
  position: absolute;
  top: 18px;
  right: 88px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  z-index: 40;
  color: #5a3b00;
  font-size: 26px;
  font-weight: 900;
  background: radial-gradient(circle at 34% 30%, #fff36a 0 18%, #f2bd23 42%, #bd7d0f 100%);
  box-shadow: 0 3px 0 #7a4b07, 0 8px 14px rgba(40, 58, 18, 0.28);
  cursor: pointer;
}

.turn-bar {
  align-self: center;
  width: min(420px, calc(100vw - 28px));
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(42, 90, 45, 0.55);
  box-shadow: 0 4px 12px rgba(12, 47, 23, 0.18);
  opacity: 0.96;
}

.turn-bar-text {
  padding: 6px 44px 6px 18px;
  color: #fff0a8;
  background: transparent;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(28, 62, 24, 0.65);
}

.turn-bar.your-turn .turn-bar-text {
  color: #fff565;
  background: rgba(255, 219, 50, 0.12);
}

.timer-track {
  height: 3px;
  background: rgba(12, 64, 31, 0.34);
}

.game-play-area {
  align-items: stretch;
  justify-content: stretch;
  z-index: 2;
}

.hud-player {
  z-index: 24;
}

.hud-top {
  top: 54px;
}

.hud-left {
  left: clamp(10px, 7vw, 160px);
  top: 52%;
}

.hud-right {
  right: clamp(10px, 8vw, 150px);
  top: 50%;
}

.opp-wrap {
  position: relative;
  min-width: 152px;
  min-height: 118px;
}

.opp-wrap.top {
  min-width: 180px;
  min-height: 122px;
}

.opp-wrap.left,
.opp-wrap.right {
  min-width: 165px;
}

.hud-badge {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  box-shadow: none;
}

.hud-badge.active-turn,
.opp-wrap.active-turn .hud-badge {
  background: transparent;
  border: 0;
  animation: none;
}

.hud-avatar,
.hud-avatar-img {
  width: 78px;
  height: 78px;
  border-radius: 13px;
  object-fit: cover;
  object-position: top center;
  background: linear-gradient(180deg, #f9d75d, #78bc64);
  border: 2px solid rgba(45, 101, 51, 0.55);
  box-shadow: 0 4px 0 rgba(34, 85, 37, 0.42), 0 10px 15px rgba(32, 75, 35, 0.26);
}

.opp-wrap.active-turn .hud-avatar-img {
  border-color: #ffef4f;
  box-shadow: 0 0 0 4px rgba(255, 238, 72, 0.36), 0 5px 0 rgba(120, 96, 7, 0.35);
}

.hud-name {
  max-width: 108px;
  min-width: 108px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #f7e86d;
  background: rgba(51, 93, 47, 0.84);
  border: 1px solid rgba(131, 169, 78, 0.42);
  font-size: 16px;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 1px rgba(40, 56, 22, 0.76);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

.hud-count {
  position: absolute;
  top: 60px;
  right: 12px;
  min-width: 26px;
  padding: 3px 6px;
  color: #315222;
  background: #ffe359;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(28, 54, 18, 0.24);
}

.uno-tag {
  position: absolute;
  top: 4px;
  right: -18px;
  padding: 3px 7px;
  color: #ffffff;
  background: #e02b25;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(35, 28, 16, 0.28);
}

.opp-mini-cards {
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

.opp-wrap.top .opp-mini-cards {
  top: 8px;
  left: -42px;
  transform: rotate(-2deg);
}

.opp-wrap.left .opp-mini-cards {
  top: 54px;
  right: 108px;
  transform: rotate(-22deg);
}

.opp-wrap.right .opp-mini-cards {
  top: 54px;
  left: 108px;
  transform: rotate(22deg);
}

.opp-mini-cards.vertical {
  flex-direction: row;
}

.opp-mini-cards .mc,
.opp-mini-cards.vertical .mc {
  width: 45px;
  height: 66px;
  margin: 0 -13px;
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.82), transparent 28%),
    url('../../assets/back.png') center / cover no-repeat;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 5px 8px rgba(29, 64, 32, 0.34);
  transform: rotate(calc((var(--i) - (var(--total) - 1) / 2) * 10deg));
}

.game-center {
  position: absolute;
  left: 50%;
  top: 51%;
  transform: translate(-50%, -50%);
  z-index: 9;
  pointer-events: none;
}

.table-mat {
  width: min(44vw, 420px);
  height: min(40vh, 280px);
  background: transparent;
  border: 0;
  box-shadow: none;
  pointer-events: none;
}

.table-mat::before {
  content: none;
}

.direction-ring {
  display: none !important;
}

.direction-ring::after {
  content: none;
}

.center-piles {
  gap: 26px;
  transform: translateY(8px);
  pointer-events: none;
}

.pile-stack,
.discard-top,
.back-card {
  width: 92px;
  height: 128px;
  border-radius: 9px;
}

.draw-pile-area {
  position: relative;
  z-index: 20;
  pointer-events: auto;
}

.back-card {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.88), transparent 24%),
    url('../../assets/back.png') center / cover no-repeat;
  border: 3px solid rgba(255,255,255,0.92);
}

.bc2 { top: 8px; left: 10px; transform: rotate(14deg); }
.bc1 { top: 4px; left: 5px; transform: rotate(7deg); }
.bc0 { top: 0; left: 0; transform: rotate(-5deg); }
.bc2 { --base-rot: 14deg; }
.bc1 { --base-rot: 7deg; }
.bc0 { --base-rot: -5deg; }

.uno-back-text {
  display: none;
}

.discard-top {
  font-size: 48px;
  border: 5px solid rgba(255,255,255,0.86);
  box-shadow: 0 14px 18px rgba(55, 64, 27, 0.28), 0 0 0 3px rgba(255,255,255,0.22);
  transform: rotate(0deg);
}

.discard-top .dt-oval {
  inset: 11% 10%;
  background: rgba(255,255,255,0.54);
  transform: rotate(-18deg);
}

.pile-info {
  display: none;
}

.color-dot {
  bottom: 21%;
  width: 22px;
  height: 22px;
  border-width: 3px;
  z-index: 35;
}

.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 182px;
  align-items: center;
  justify-content: flex-end;
  z-index: 30;
  pointer-events: none;
}

.me-panel {
  position: absolute;
  left: clamp(190px, 22vw, 300px);
  bottom: 22px;
  width: 150px;
  height: 136px;
  z-index: 7;
  pointer-events: none;
}

.me-avatar-frame {
  width: 116px;
  height: 116px;
  margin: 0 auto;
  padding: 5px;
  border-radius: 19px;
  background: linear-gradient(145deg, #fff56a, #a8d943 54%, #6fad2d);
  box-shadow: 0 0 0 3px rgba(255, 239, 74, 0.45), 0 0 22px rgba(241, 235, 40, 0.56), 0 10px 18px rgba(55, 92, 31, 0.3);
}

.me-avatar-frame.active-turn {
  animation: pulseShadow 1.4s ease-in-out infinite;
}

.me-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  border-radius: 14px;
  display: block;
}

.me-name-plate {
  width: 152px;
  margin-top: -2px;
  padding: 7px 30px 7px 18px;
  border-radius: 999px;
  color: #fff16d;
  background: rgba(72, 124, 57, 0.9);
  border: 1px solid rgba(155, 190, 83, 0.48);
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 1px rgba(46, 63, 25, 0.78);
  position: relative;
}

.me-name-plate strong {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 24px;
  color: #35541f;
  background: #ffe45b;
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 5px;
  text-shadow: none;
}

.chat-launch {
  position: absolute;
  left: clamp(110px, 12vw, 210px);
  bottom: 95px;
  z-index: 8;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 2px 2px rgba(28, 67, 24, 0.7);
  pointer-events: auto;
  cursor: pointer;
}

.chat-face {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto 2px;
  border-radius: 50%;
  color: #3d5b1b;
  font-size: 31px;
  line-height: 1;
  background: #ffe14a;
  box-shadow: 0 3px 0 rgba(91, 116, 30, 0.45), 0 6px 12px rgba(47, 76, 23, 0.22);
}

.hand-container {
  width: min(470px, 60vw);
  margin: 0 auto;
  padding: 22px 16px 8px;
  overflow: visible;
  pointer-events: auto;
}

.hand {
  min-height: 148px;
  justify-content: center;
}

.hcard {
  width: 78px;
  height: 116px;
  border-radius: 8px;
  margin: 0 -18px;
  font-size: 34px;
  border: 4px solid rgba(255,255,255,0.9);
  box-shadow: 0 10px 18px rgba(46, 68, 32, 0.32);
}

.hcard .cn {
  font-size: 15px;
}

.hcard.playable {
  border-color: #fff15a;
  box-shadow: 0 10px 18px rgba(46, 68, 32, 0.32), 0 0 18px rgba(255, 241, 90, 0.72);
}

.uno-btn {
  bottom: 136px;
  right: clamp(24px, 22vw, 330px);
}

#notifications {
  z-index: 90;
  pointer-events: none !important;
}

#toast {
  bottom: 160px;
}

@media (max-width: 760px) {
  /* Force portrait column layout for the game screen */
  #screen-game {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden;
  }

  #screen-game::after {
    width: min(84vw, 520px);
    height: min(37vh, 300px);
  }

  .round-tool-btn {
    right: 14px;
    top: 14px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  /* Turn bar — full width pill at top */
  .turn-bar {
    width: calc(100vw - 20px);
    margin: 8px auto 0;
    border-radius: 20px;
    flex-shrink: 0;
  }

  .turn-bar-text {
    font-size: 12px;
    padding: 5px 36px 5px 12px;
  }

  /* Play area fills remaining vertical space */
  .game-play-area {
    flex: 1;
    min-height: 0;
    position: relative;
  }

  /* Opponent top HUD — centred at top of play area */
  .hud-top {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Side HUDs — scaled down, hugging edges */
  .hud-left {
    left: 4px;
    top: 44%;
    transform: translateY(-50%) scale(0.78);
    transform-origin: left center;
  }

  .hud-right {
    right: 4px;
    top: 44%;
    transform: translateY(-50%) scale(0.78);
    transform-origin: right center;
  }

  .hud-avatar-img {
    width: 48px;
    height: 48px;
  }

  .hud-name {
    min-width: 64px;
    max-width: 64px;
    font-size: 10px;
  }

  .hud-count { font-size: 12px; }

  .opp-wrap {
    min-width: 90px;
    min-height: 80px;
  }

  .opp-wrap.top { min-width: 120px; }

  .opp-mini-cards .mc,
  .opp-mini-cards.vertical .mc {
    width: 24px;
    height: 34px;
    margin: 0 -8px;
  }

  /* Center table — compact square */
  .table-mat {
    width: min(190px, 48vw);
    height: min(190px, 48vw);
  }

  .pile-stack,
  .discard-top,
  .back-card {
    width: 58px;
    height: 82px;
  }

  .discard-top {
    font-size: 28px;
    border-width: 3px;
  }

  .center-piles { gap: 10px; }
  .pile-count   { font-size: 10px; }
  .pile-label   { font-size: 8px; }

  /* Me panel bottom-left */
  .me-panel {
    left: 12px;
    bottom: 8px;
    transform: scale(0.76);
    transform-origin: bottom left;
  }

  .chat-launch {
    left: 12px;
    bottom: 96px;
    transform: scale(0.76);
    transform-origin: bottom left;
  }

  /* Hand strip — fixed height, full width, scrollable */
  .hud-bottom {
    flex-shrink: 0;
    min-height: 108px;
    max-height: 130px;
  }

  .hand-container {
    width: 100vw;
    padding: 4px 56px 10px 108px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .hand {
    min-height: 90px;
    justify-content: flex-start;
  }

  .hcard {
    width: 50px;
    height: 74px;
    margin: 0 -10px;
    font-size: 20px;
    border-width: 2.5px;
  }

  .uno-btn {
    right: 10px;
    bottom: 108px;
    width: 52px;
    height: 52px;
    font-size: 9px;
  }

  #color-dot {
    bottom: 136px;
    left: 50%;
    transform: translateX(-50%);
  }

  #notifications {
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
  }
}

/* Extra-narrow phones (iPhone SE, width ≤ 390px) */
@media (max-width: 390px) {
  .hud-left {
    left: 2px;
    transform: translateY(-50%) scale(0.68);
  }
  .hud-right {
    right: 2px;
    transform: translateY(-50%) scale(0.68);
  }
  .hcard {
    width: 44px;
    height: 64px;
    margin: 0 -11px;
    font-size: 17px;
  }
  .hand-container {
    padding: 4px 52px 10px 100px;
  }
  .pile-stack,
  .discard-top,
  .back-card {
    width: 50px;
    height: 72px;
  }
  .discard-top { font-size: 24px; }
  .table-mat {
    width: min(160px, 44vw);
    height: min(160px, 44vw);
  }
  .hud-bottom {
    min-height: 96px;
    max-height: 116px;
  }
}

/* ── Admin dashboard ─────────────────────────────────────────────────────── */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.admin-stat {
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-stat span {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}
.admin-stat small {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.admin-tab {
  flex: 1;
  padding: 8px 0;
  background: rgba(255,255,255,0.07);
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .03em;
  transition: background .15s, color .15s;
}
.admin-tab.active {
  background: #3a7bd5;
  color: #fff;
}
.admin-tab-pane { }
.admin-tab-pane.hidden { display: none; }
.admin-search-row { margin-bottom: 8px; }
.admin-grant {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  margin-bottom: 6px;
}
.admin-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.admin-row-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.admin-row-info { min-width: 0; }
.admin-row-info strong {
  display: block;
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-row-info small {
  color: rgba(255,255,255,0.4);
  font-size: 0.7rem;
}
.admin-row-coins {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffd54f;
  white-space: nowrap;
}
.admin-row-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.admin-row-actions button {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.admin-row-actions .btn-approve { background: #2e7d32; color: #fff; }
.admin-row-actions .btn-reject  { background: #c62828; color: #fff; }
.admin-row-actions .btn-end     { background: #e65100; color: #fff; }
.admin-row-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-pending  { background: #e65100; color: #fff; }
.badge-approved { background: #2e7d32; color: #fff; }
.badge-rejected { background: #555; color: #fff; }
.badge-playing  { background: #1565c0; color: #fff; }
.badge-waiting  { background: #555; color: #fff; }
.admin-game-players { font-size: 0.72rem; color: rgba(255,255,255,0.5); margin-top: 2px; }

/* ── Loading screen ──────────────────────────────────────────────────────── */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  background: linear-gradient(180deg, #1a1f2e 0%, #0d1117 100%);
}
.loading-logo-cards {
  display: flex;
  gap: -8px;
  margin-bottom: 4px;
}
.loading-logo-cards .logo-card {
  width: 52px;
  height: 72px;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin: 0 -4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.loading-bar-wrap {
  width: min(260px, 70vw);
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  overflow: hidden;
}
.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #fdd835, #ff6f00);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.loading-hint {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: .05em;
}
