/* style.css — SABSARACARDS Mobile Game UI */

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

:root {
  --felt: #1a3a2a;
  --felt-light: #214d37;
  --felt-dark: #0f2219;
  --felt-rim: #0a1a10;
  --gold: #d4a843;
  --gold-dim: #8a6a20;
  --cream: #f5ead8;
  --red-card: #c0392b;
  --ink: #0d1a13;
  --smoke: rgba(255,255,255,0.07);
  --smoke2: rgba(255,255,255,0.12);
  --border: rgba(212,168,67,0.22);
  --border-bright: rgba(212,168,67,0.55);
  --r: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --card-w: 44px;
  --card-h: 64px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--felt-dark);
  color: var(--cream);
  font-family: 'Space Grotesk', sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* Prevent iOS Safari pull-to-refresh / rubber-band scrolling that can
     shuffle the layout during play. */
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  width: 100%;
}

/* ── LAYOUT SHELL ──────────────────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ── TOP BAR ───────────────────────────────────────────────────────────────── */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--felt-dark);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  flex-shrink: 0;
}

#topbar .room-code {
  font-family: 'Bebas Neue', cursive;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--gold);
}

#topbar .game-badge {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(245,234,216,0.4);
  background: rgba(0,0,0,0.3);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

#topbar .top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--smoke);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active { background: var(--smoke2); }
.icon-btn.active { border-color: var(--gold); background: rgba(212,168,67,0.15); }

/* ── TABLE AREA ────────────────────────────────────────────────────────────── */

#table-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%);
}

/* Felt texture overlay */
#table-area::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 3px, rgba(0,0,0,0.04) 3px, rgba(0,0,0,0.04) 6px
  );
  pointer-events: none;
}

/* Table rim */
#table-rim {
  position: absolute;
  inset: 8px;
  border: 3px solid rgba(100,60,20,0.4);
  border-radius: 50%;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.3),
    0 0 0 6px rgba(80,40,10,0.2);
  pointer-events: none;
  z-index: 1;
}

/* Center trick/pile area */
#center-pile {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#center-pile .pile-cards {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ── PLAYER SEATS ──────────────────────────────────────────────────────────── */

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 40;
}

/* Positioning for 4-player Call Break */
.seat[data-pos="bottom"] { bottom: 8px; left: 50%; transform: translateX(-50%); }
.seat[data-pos="top"]    { top: 8px;    left: 50%; transform: translateX(-50%); }
.seat[data-pos="left"]   { left: 8px;   top: 50%;  transform: translateY(-50%); }
.seat[data-pos="right"]  { right: 8px;  top: 50%;  transform: translateY(-50%); }

/* Dynamic positioning for Donkey (3–8 players) handled in JS */

.avatar-wrap {
  position: relative;
  width: 54px;
  height: 54px;
  pointer-events: none;
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--felt-light), var(--felt-dark));
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.avatar.active-turn {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(212,168,67,0.5);
}

.avatar.high-card {
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--gold);
}

.high-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--ink);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 5;
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 12px rgba(212,168,67,0.4); }
  50% { box-shadow: 0 0 24px rgba(212,168,67,0.7); }
}

.avatar.me {
  border-color: rgba(100,200,120,0.6);
}

.speaking-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid #4ade80;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1;
  pointer-events: none;
}

.speaking-ring.active {
  opacity: 1;
  animation: speaking-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes speaking-pulse {
  from { transform: scale(1); opacity: 0.7; }
  to   { transform: scale(1.12); opacity: 1; }
}

.player-name {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  max-width: 70px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cream);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border-radius: 4px;
}

.bid-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--gold);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 20px;
  text-align: center;
  z-index: 5;
}

.tricks-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #2ecc71;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 20px;
  text-align: center;
  z-index: 5;
}

.hand-count {
  position: absolute;
  bottom: -6px;
  left: -6px;
  background: rgba(0,0,0,0.7);
  color: var(--cream);
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 5px;
  z-index: 5;
}

/* Cards fanned behind opponent avatar */
.opp-cards {
  display: flex;
  margin-top: 2px;
  pointer-events: none;
}

.opp-card-back {
  width: 16px;
  height: 24px;
  border-radius: 3px;
  background: linear-gradient(135deg, #1a3a8a 30%, #0f2060);
  border: 1px solid rgba(255,255,255,0.2);
  margin-left: -6px;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* ── MY HAND (BOTTOM) ──────────────────────────────────────────────────────── */

#my-hand-area {
  position: absolute;
  bottom: calc(70px + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0 12px;
  z-index: 30;
  min-height: 90px;
  transition: bottom 0.3s ease;
}

#my-hand-area.bid-active {
  bottom: calc(280px + var(--safe-bottom));
}

#my-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
}

.playing-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  background: white;
  border: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 4px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.4);
  margin-left: var(--hand-overlap, -10px);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.playing-card:first-child { margin-left: 0; }

.playing-card:hover,
.playing-card.selected {
  transform: translateY(-16px);
  box-shadow: 2px 8px 16px rgba(0,0,0,0.5);
  z-index: 5;
}

.playing-card.valid-play {
  box-shadow: 0 0 12px rgba(46,204,113,0.6), 2px 3px 8px rgba(0,0,0,0.4);
}

.playing-card.invalid-play {
  opacity: 0.45;
  cursor: not-allowed;
}

.playing-card.sortable {
  cursor: grab;
}

.playing-card.dragging {
  opacity: 0.4;
  transform: translateY(-24px);
  z-index: 20;
}

.playing-card.drop-target {
  box-shadow: 0 0 0 3px var(--gold), 2px 3px 8px rgba(0,0,0,0.4);
  transform: translateY(-10px);
}

.card-rank {
  font-size: calc(var(--card-w) * 0.30);
  font-weight: 700;
  line-height: 1;
  font-family: 'Space Grotesk', sans-serif;
}

.card-suit {
  font-size: calc(var(--card-w) * 0.26);
  line-height: 1;
  align-self: flex-start;
}

.card-center-suit {
  font-size: calc(var(--card-w) * 0.45);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.suit-S, .suit-C { color: #1a1a1a; }
.suit-H, .suit-D { color: var(--red-card); }

.card-back {
  background: linear-gradient(135deg, #1a3a8a 20%, #0f2060 80%);
  border: 1px solid rgba(255,255,255,0.15);
}

.card-back::after {
  content: '🂠';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 0.3;
}

/* ── BOTTOM ACTION BAR ─────────────────────────────────────────────────────── */

#action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--felt-dark);
  border-top: 1px solid var(--border);
  z-index: 50;
  flex-shrink: 0;
  gap: 8px;
}

#status-text {
  flex: 1;
  font-size: 12px;
  color: rgba(245,234,216,0.6);
  text-align: center;
  font-weight: 500;
}

.action-btn {
  padding: 9px 18px;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: rgba(212,168,67,0.15);
  color: var(--gold);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.action-btn:active { background: rgba(212,168,67,0.3); }
.action-btn.primary {
  background: linear-gradient(135deg, var(--gold) 0%, #b8912a 100%);
  color: var(--ink);
  border-color: transparent;
}

/* ── TRICK CARD IN CENTER ──────────────────────────────────────────────────── */

.trick-card {
  position: absolute;
  width: 36px;
  height: 52px;
  border-radius: 5px;
  background: white;
  border: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  padding: 2px 3px;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.4);
}

@keyframes card-fly-in {
  from { transform: scale(0.5) rotate(10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ── BIDDING PANEL ─────────────────────────────────────────────────────────── */

#bid-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, var(--felt-dark) 0%, rgba(15,34,25,0.95) 100%);
  border-top: 1px solid var(--border);
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  z-index: 60;
  display: none;
}

#bid-panel.visible { display: block; }

#bid-panel h3 {
  text-align: center;
  font-size: 13px;
  color: rgba(245,234,216,0.6);
  margin-bottom: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Bid range slider */
#bid-slider {
  width: 100%;
  margin: 14px 0 6px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--gold) 0%, var(--gold) var(--fill, 7%), var(--smoke2) var(--fill, 7%), var(--smoke2) 100%);
  outline: none;
  cursor: pointer;
}

#bid-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--cream);
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  cursor: pointer;
}

#bid-slider::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--cream);
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  cursor: pointer;
}

#bid-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--smoke2);
}

.bid-value {
  text-align: center;
  font-size: 44px;
  font-weight: 700;
  font-family: 'Bebas Neue', cursive;
  color: var(--gold);
  line-height: 1;
  margin: 8px 0 4px;
  letter-spacing: 2px;
}

.bid-value small {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  color: rgba(245,234,216,0.4);
  font-weight: 400;
  letter-spacing: 1px;
}

#bid-confirm.slider-play-btn {
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 10px 36px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#bid-confirm.slider-play-btn:active { transform: scale(0.95); }

/* ── SCORE PANEL ───────────────────────────────────────────────────────────── */

#score-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#score-panel.visible { display: flex; }

.score-card {
  background: var(--felt-dark);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  max-height: 80vh;
  overflow-y: auto;
}

.score-card h2 {
  font-family: 'Bebas Neue', cursive;
  font-size: 28px;
  letter-spacing: 3px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 16px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.score-row:last-child { border-bottom: none; }

.score-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--smoke);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.score-rank.first { background: var(--gold); color: var(--ink); }
.score-rank.second { background: #aaa; color: var(--ink); }
.score-rank.third { background: #c07b4a; color: #fff; }

.score-name { flex: 1; font-size: 14px; font-weight: 600; }
.score-bid  { font-size: 12px; color: rgba(245,234,216,0.45); min-width: 30px; text-align: center; }
.score-pts  { font-size: 16px; font-weight: 700; color: var(--gold); min-width: 40px; text-align: right; }

/* ── CHAT PANEL ────────────────────────────────────────────────────────────── */

#chat-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60vh;
  background: rgba(10,26,16,0.97);
  border-top: 1px solid var(--border);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

#chat-panel.open { transform: translateY(0); }

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-header span { font-size: 13px; font-weight: 600; color: var(--gold); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-msg .sender {
  font-size: 10px;
  color: rgba(245,234,216,0.4);
  font-weight: 600;
}

.chat-msg .text {
  font-size: 13px;
  color: var(--cream);
  background: var(--smoke);
  border-radius: 8px 8px 8px 2px;
  padding: 6px 10px;
  display: inline-block;
  max-width: 85%;
}

.chat-msg.mine .text {
  background: rgba(212,168,67,0.15);
  border-radius: 8px 8px 2px 8px;
  align-self: flex-end;
}

.chat-msg.mine { align-items: flex-end; }

.chat-msg.system .text {
  background: transparent;
  color: rgba(245,234,216,0.4);
  font-size: 11px;
  font-style: italic;
  padding: 0;
}

.throw-msg {
  text-align: center;
  font-size: 12px;
  color: rgba(245,234,216,0.5);
  padding: 4px 0;
}

#chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--cream);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  outline: none;
}

#chat-send {
  padding: 10px 16px;
  background: var(--gold);
  border: none;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* ── RADIAL ACTION MENU ────────────────────────────────────────────────────── */

#action-menu {
  position: fixed;
  z-index: 200;
  display: none;
  pointer-events: none;
}

#action-menu.visible {
  display: block;
  pointer-events: all;
}

.action-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: -1;
}

.radial-ring {
  position: absolute;
  width: 180px;
  height: 180px;
  transform: translate(-50%, -50%);
}

.radial-item {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--felt-dark);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%) scale(0);
  animation: radial-pop 0.2s ease forwards;
}

.radial-item:nth-child(1) { animation-delay: 0.00s; }
.radial-item:nth-child(2) { animation-delay: 0.04s; }
.radial-item:nth-child(3) { animation-delay: 0.08s; }
.radial-item:nth-child(4) { animation-delay: 0.12s; }
.radial-item:nth-child(5) { animation-delay: 0.16s; }
.radial-item:nth-child(6) { animation-delay: 0.20s; }

@keyframes radial-pop {
  to { transform: translate(-50%, -50%) scale(1); }
}

.radial-item:active { background: rgba(212,168,67,0.2); transform: translate(-50%, -50%) scale(1.1); }

/* ── THROWABLE ANIMATION ───────────────────────────────────────────────────── */

.throwable {
  position: fixed;
  font-size: 36px;
  z-index: 300;
  pointer-events: none;
  animation: throw-fly 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  transform-origin: center;
}

@keyframes throw-fly {
  0%   { opacity: 1; transform: scale(0.5) rotate(0deg); }
  60%  { opacity: 1; transform: scale(1.3) rotate(180deg); }
  100% { opacity: 0; transform: scale(0.8) rotate(360deg); }
}

/* ── DONKEY HUMILIATION ─────────────────────────────────────────────────────── */

#humiliation-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

#humiliation-screen.visible { display: flex; }

.donkey-banner {
  font-family: 'Bebas Neue', cursive;
  font-size: 72px;
  color: #e74c3c;
  letter-spacing: 6px;
  text-shadow:
    0 0 20px rgba(231,76,60,0.8),
    0 0 60px rgba(231,76,60,0.4);
  animation: donkey-shake 0.5s ease-in-out infinite alternate;
}

@keyframes donkey-shake {
  from { transform: rotate(-2deg) scale(1); }
  to   { transform: rotate(2deg) scale(1.04); }
}

.donkey-avatar-wrap {
  position: relative;
  width: 120px;
  height: 120px;
}

.donkey-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a1a1a, #1a0a0a);
  border: 3px solid #e74c3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  box-shadow: 0 0 40px rgba(231,76,60,0.5);
}

.donkey-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--cream);
  text-align: center;
}

/* ── CONFETTI / WINNER ─────────────────────────────────────────────────────── */

#winner-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.88);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

#winner-screen.visible { display: flex; }

.trophy { font-size: 80px; animation: trophy-bounce 0.6s ease-in-out infinite alternate; }

@keyframes trophy-bounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-10px) scale(1.05); }
}

.winner-name {
  font-family: 'Bebas Neue', cursive;
  font-size: 40px;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(212,168,67,0.7);
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  pointer-events: none;
  z-index: 401;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.firework-particle {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 401;
  animation: firework-burst 0.7s ease-out forwards;
}

@keyframes firework-burst {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ── LOBBY SCREEN ──────────────────────────────────────────────────────────── */

#lobby-screen {
  position: absolute;
  inset: 0;
  background: var(--felt-dark);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 20px;
}

.lobby-code {
  font-family: 'Bebas Neue', cursive;
  font-size: 64px;
  letter-spacing: 10px;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(212,168,67,0.5);
}

.lobby-label {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(245,234,216,0.4);
  text-align: center;
}

.lobby-share {
  background: var(--smoke);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 12px;
  color: rgba(245,234,216,0.55);
  word-break: break-all;
  text-align: center;
  max-width: 300px;
}

.player-list {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--smoke);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.player-row .emoji { font-size: 22px; }
.player-row .pname { flex: 1; font-size: 14px; font-weight: 600; }
.player-row .host-tag {
  font-size: 10px;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 2px 6px;
}

/* ── MIC BAR ───────────────────────────────────────────────────────────────── */

#mic-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mic-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  flex-shrink: 0;
}

.mic-indicator.on { background: #2ecc71; animation: mic-blink 1s infinite; }

@keyframes mic-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── DONKEY DRAW UI ────────────────────────────────────────────────────────── */

.draw-indicator {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  animation: bounce-in 0.3s ease;
}

.avatar.draw-target {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,168,67,0.9);
  animation: pulse-gold 0.8s infinite;
}

.avatar.exited {
  opacity: 0.45;
  filter: grayscale(0.7);
}

.exit-badge {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #2e7d32;
  color: #eafff0;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  white-space: nowrap;
}

.exit-badge.rank-1 { background: linear-gradient(135deg, #d4a843, #b8942e); color: #1a1200; font-size: 10px; }
.exit-badge.rank-2 { background: linear-gradient(135deg, #b0b0b0, #8a8a8a); color: #1a1a1a; font-size: 10px; }
.exit-badge.rank-3 { background: linear-gradient(135deg, #cd7f32, #a0622a); color: #1a1200; font-size: 10px; }

.gadhaa-badge {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(231,76,60,0.6);
}

.avatar.gadhaa-loser {
  border-color: #e74c3c;
  box-shadow: 0 0 16px rgba(231,76,60,0.6);
  animation: gadhaa-pulse 1.5s infinite;
}

@keyframes gadhaa-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(231,76,60,0.5); }
  50%      { box-shadow: 0 0 24px rgba(231,76,60,0.9); }
}

.player-name.gadhaa-name {
  color: #e74c3c;
  font-weight: 900;
  font-size: 13px;
  text-shadow: 0 0 8px rgba(231,76,60,0.5);
}

.gadhaa-label {
  font-family: 'Bebas Neue', cursive;
  font-size: 28px;
  letter-spacing: 6px;
  color: #e74c3c;
  text-shadow: 0 0 20px rgba(231,76,60,0.7);
  text-align: center;
}

.gadhaa-stats {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--gold);
  font-weight: 700;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 1px 5px;
  vertical-align: middle;
}

.dealer-badge {
  display: inline-block;
  background: linear-gradient(135deg, #7b3ff2, #4f2bbf);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ── DONKEY TRADE DIALOG ───────────────────────────────────────────────────── */

.trade-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}
.trade-dialog.visible { display: flex; }

.trade-panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  max-width: 340px;
  width: 88%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.trade-panel h3 {
  color: var(--gold);
  margin: 0 0 6px;
  font-size: 16px;
}

.trade-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
  min-height: 64px;
}
.trade-cards .playing-card { cursor: pointer; }
.trade-cards .playing-card.selected {
  outline: 2px solid var(--gold);
  transform: translateY(-6px);
}

.trade-select {
  width: 100%;
  margin-top: 6px;
  background: var(--ink);
  color: var(--gold);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}


@keyframes bounce-in {
  0%   { transform: translateX(-50%) scale(0); }
  70%  { transform: translateX(-50%) scale(1.1); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ── ROUND RESULT TOAST ────────────────────────────────────────────────────── */

#round-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(10,26,16,0.97);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 24px 32px;
  text-align: center;
  z-index: 150;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
}

#round-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#round-toast .rt-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(245,234,216,0.4);
  margin-bottom: 4px;
}

#round-toast .rt-winner {
  font-family: 'Bebas Neue', cursive;
  font-size: 32px;
  color: var(--gold);
  letter-spacing: 3px;
}

#round-toast .rt-msg {
  font-size: 13px;
  color: rgba(245,234,216,0.6);
  margin-top: 4px;
}

/* ── UTILITIES ─────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
.gold   { color: var(--gold); }
.red    { color: var(--red-card); }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

/* ── WAITING FOR PLAYERS ───────────────────────────────────────────────────── */

.waiting-msg {
  text-align: center;
  color: rgba(245,234,216,0.4);
  font-size: 13px;
  font-style: italic;
  padding: 20px;
}

/* Landscape hint */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --card-h: 52px; --card-w: 36px; }
  #my-hand-area { bottom: 50px; }
  .lobby-code { font-size: 48px; }
}
