/* ═══════════════════════════════════════════════════════════════
   Hand & Foot — Stylesheet
   Dark green felt table aesthetic
═══════════════════════════════════════════════════════════════ */

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

:root {
  --felt: #1a4a1a;
  --felt-dark: #0f2e0f;
  --felt-light: #245c24;
  --gold: #d4a843;
  --gold-light: #f0c866;
  --card-w: 52px;
  --card-h: 74px;
  --card-r: 5px;
  --red: #cc2222;
  --text: #f0e6c8;
  --text-muted: #a09070;
  --text-dim: #cdbf9c;
  --panel-bg: rgba(0,0,0,0.35);
  --border: rgba(255,255,255,0.12);
  --btn-h: 36px;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--felt);
  color: var(--text);
  font-size: 14px;
}

/* ── Views ──────────────────────────────────────────────────── */
.view { display: none; height: 100vh; }
.view.active { display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* ── Lobby ──────────────────────────────────────────────────── */
#view-lobby {
  background: var(--felt);
}

.lobby-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 36px;
  padding: 24px;
  overflow-y: auto;
}

.lobby-logo { text-align: center; animation: lobbyRise 0.6s ease-out both; }
.logo-suits {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 26px;
  margin-bottom: 14px;
}
.logo-suits span:nth-child(1), .logo-suits span:nth-child(3) { color: var(--gold-light); }
.logo-suits span:nth-child(2) { color: var(--red); }
.logo-suits span:nth-child(4) { color: var(--gold); }
.lobby-logo h1 {
  font-size: 54px;
  font-weight: normal;
  color: var(--gold-light);
  letter-spacing: 3px;
  text-shadow: 0 2px 18px rgba(0,0,0,0.7), 0 0 40px rgba(240,200,102,0.15);
}
.logo-rule {
  width: 120px;
  height: 2px;
  margin: 14px auto;
  background: linear-gradient(90deg, transparent, var(--gold) 50%, transparent);
}
.lobby-logo .subtitle {
  font-size: 16px;
  font-style: italic;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

.lobby-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  animation: lobbyRise 0.6s ease-out 0.1s both;
}

.lobby-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent 40%), var(--panel-bg);
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold);
  border-radius: 14px;
  padding: 26px 28px 28px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.lobby-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(0,0,0,0.45);
  border-top-color: var(--gold-light);
}

.lobby-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(212,168,67,0.12);
  border: 1px solid var(--border);
  border-radius: 50%;
  margin-bottom: 2px;
}

.lobby-card h2 { color: var(--gold-light); font-size: 20px; font-weight: normal; letter-spacing: 0.3px; }
.lobby-card p { font-size: 14px; color: var(--text-dim); line-height: 1.5; }

.lobby-hint { font-size: 12px; color: var(--text-dim); }

.btn-lobby-cta { margin-top: 4px; font-size: 15px; letter-spacing: 0.3px; }

.lobby-card-resume {
  width: auto;
  max-width: 636px; /* aligns with the two 300px cards + gap above */
  animation: lobbyRise 0.6s ease-out 0.2s both;
}
.lobby-resume-head { display: flex; align-items: center; gap: 14px; }
.lobby-resume-head h2 { margin-bottom: 2px; }
.lobby-resume-head p { margin: 0; }
.lobby-resume-body { display: flex; gap: 10px; }
.lobby-resume-body input { flex: 1; }
.lobby-resume-body .btn { flex-shrink: 0; }

.saves-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@keyframes lobbyRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .lobby-logo, .lobby-cards, .lobby-card-resume { animation: none; }
  .lobby-card { transition: none; }
}

@media (max-width: 480px) {
  .lobby-logo h1 { font-size: 38px; }
  .logo-suits { gap: 10px; font-size: 22px; }
  .lobby-card { width: 100%; max-width: 340px; }
  .lobby-resume-body { flex-direction: column; }
}

/* ── Shared elevated "panel card" (lobby, waiting room) ───────── */
.panel-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent 40%), var(--panel-bg);
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold);
  border-radius: 14px;
  padding: 22px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.panel-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-card-head h3 { color: var(--gold-light); font-size: 17px; font-weight: normal; letter-spacing: 0.3px; }

/* ── Waiting Room ───────────────────────────────────────────── */
#view-waiting {
  background: var(--felt);
}
.waiting-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 18px;
  padding: 24px;
  overflow-y: auto;
}
.waiting-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4px;
  animation: lobbyRise 0.6s ease-out both;
}
.waiting-header h2 { font-size: 32px; font-weight: normal; color: var(--gold-light); letter-spacing: 1px; }
.waiting-header .logo-rule { width: 90px; margin: 10px auto 14px; }

.room-info-card { width: 100%; max-width: 440px; text-align: center; animation: lobbyRise 0.6s ease-out 0.05s both; }
.room-info { display: flex; gap: 32px; justify-content: center; }
.info-block { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.info-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.info-value { font-size: 28px; font-weight: bold; color: var(--gold-light); letter-spacing: 4px; font-family: monospace; }

.share-link { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; }
.share-link a { color: var(--gold-light); overflow-wrap: anywhere; }

.player-list-card { width: 100%; max-width: 440px; animation: lobbyRise 0.6s ease-out 0.1s both; }
.player-list {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.player-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.player-entry:hover { background: rgba(255,255,255,0.05); }
.player-dot { width: 10px; height: 10px; border-radius: 50%; background: #4caf50; flex-shrink: 0; }
.player-dot.bot { background: var(--gold); }
.host-tag {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.3px;
  background: var(--gold);
  color: #24230f;
  border-radius: 10px;
  padding: 2px 8px;
}
.host-tag.tag-bot { background: #8b6914; color: var(--gold-light); }
.host-tag.tag-starts { background: #2c6e49; color: #d7f5e4; }
.seat-select {
  width: 40px;
  height: 24px;
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
}
.seat-badge {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
}

.waiting-actions {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: lobbyRise 0.6s ease-out 0.15s both;
}
.waiting-actions .info-block { align-items: flex-start; gap: 6px; }
.waiting-actions-buttons { display: flex; gap: 10px; margin-top: 4px; }
.waiting-actions-buttons .btn-lobby-cta { flex: 1; }

.guest-wait-note {
  width: 100%;
  max-width: 440px;
  text-align: center;
  animation: lobbyRise 0.6s ease-out 0.15s both;
}
.guest-wait-note .panel-card-head { justify-content: center; margin-bottom: 8px; }
.guest-wait-note p { font-size: 14px; color: var(--text-dim); }

@media (max-width: 480px) {
  .waiting-header h2 { font-size: 24px; }
  .room-info { gap: 20px; }
  .info-value { font-size: 22px; letter-spacing: 2px; }
}

/* ── Game Layout ────────────────────────────────────────────── */
#view-game { overflow: hidden; }

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--felt-dark);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.game-title { font-size: 16px; color: var(--gold); font-weight: bold; letter-spacing: 1px; }
.series-badge { background: rgba(212,168,67,0.2); border: 1px solid var(--gold); color: var(--gold); font-size: 11px; padding: 2px 8px; border-radius: 12px; }
.threshold-badge { font-size: 14px; color: var(--gold); font-weight: 600; }

.game-body {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

.left-col { width: 200px; flex-shrink: 0; overflow-y: auto; }
.center-col { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow: hidden; }
.right-col { width: 0; flex-shrink: 0; position: relative; }

/* ── Opponents Panel ────────────────────────────────────────── */
.opponents-panel { display: flex; flex-direction: column; gap: 8px; }

.opponent-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.opponent-card.active-turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,168,67,0.3); }
.opp-name { font-size: 17px; font-weight: bold; color: var(--gold-light); margin-bottom: 4px; }
.opp-stats { font-size: 18px; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.opp-mini-melds { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-size: 18px; }
.mini-meld {
  font-size: 18px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
}
.mini-meld.canasta { border-color: var(--gold); background: rgba(212,168,67,0.15); }
.mini-meld.clean { color: #ff6666; }
.mini-meld.dirty { color: #999; }
.mini-meld.wild { color: var(--gold); }

/* ── Table Area ─────────────────────────────────────────────── */
.table-area {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 8px;
}

.pile-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.card-back {
  width: var(--card-w);
  height: var(--card-h);
  background: repeating-linear-gradient(
    45deg, #8b0000, #8b0000 4px, #a00000 4px, #a00000 8px
  );
  border: 2px solid var(--gold);
  border-radius: var(--card-r);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  position: relative;
}
.card-back:hover { transform: scale(1.06); }

.discard-slot {
  width: var(--card-w);
  height: var(--card-h);
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: var(--card-r);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s;
}
.discard-slot:hover { border-color: var(--gold); }
.discard-slot .card { position: absolute; top: 0; left: 0; cursor: pointer; }

.pile-count {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  border-radius: 3px;
  padding: 1px 4px;
  font-family: monospace;
}

.frozen-tag { color: #ff4444; font-size: 10px; }

/* ── Action Bar ─────────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 4px 8px;
}

.btn-action {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 6px;
  font-family: inherit;
}
.btn-meld { background: rgba(76,175,80,0.3); border-color: #4caf50; color: #81c784; }
.btn-meld:hover { background: rgba(76,175,80,0.5); }
.btn-meld:disabled { background: rgba(76,175,80,0.1); border-color: rgba(76,175,80,0.3); color: rgba(129,199,132,0.4); }
.btn-add { background: rgba(33,150,243,0.3); border-color: #2196f3; color: #64b5f6; }
.btn-add:hover { background: rgba(33,150,243,0.5); }
.btn-add:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-discard { background: rgba(244,67,54,0.3); border-color: #f44336; color: #ef9a9a; }
.btn-discard:hover { background: rgba(244,67,54,0.5); }
.btn-discard:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-goout { background: rgba(212,168,67,0.3); border-color: var(--gold); color: var(--gold-light); }
.btn-goout:hover { background: rgba(212,168,67,0.5); }
.btn-goout:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-undo { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); color: var(--text-muted); }
.btn-undo:hover { background: rgba(255,255,255,0.15); }
.btn-undo:disabled { opacity: 0.4; cursor: not-allowed; }

.action-hint {
  text-align: center;
  font-size: 12px;
  color: var(--gold);
  min-height: 18px;
  padding: 0 8px;
}

/* ── My Melds Section ───────────────────────────────────────── */
.my-melds-section {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 4px;
}
.section-header {
  font-size: 12px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.basket-complete { color: #4caf50; font-size: 11px; }

.melds-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ── Canasta completed display (single card + info) ─────────── */
.canasta-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}
.canasta-display:hover { transform: translateY(-4px); }
.canasta-card {
  width: 68px;
  height: 96px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  position: relative;
  gap: 1px;
  padding: 4px 2px;
}
.canasta-card.clean { background: #fff; color: var(--red); border-color: #ff4444; }
.canasta-card.dirty { background: #fff; color: #111; border-color: #888; }
.canasta-card.wild { background: #fffbe6; color: #cc8800; border-color: var(--gold); }
.canasta-card.clean5 { background: #fff0f0; color: var(--red); border-color: #ff0000; }
.canasta-card.clean7 { background: #ffe8e8; color: #cc0000; border-color: #cc0000; }
.canasta-label { font-size: 11px; color: var(--gold); font-weight: bold; text-align: center; margin-top: 3px; }
.canasta-pts { font-size: 12px; color: var(--text-muted); text-align: center; }
.canasta-count { font-size: 10px; color: #888; }

/* ── Meld Display (incomplete melds) ───────────────────────── */
.meld-display {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-width: 180px;
  max-width: 100%;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.meld-cards-row { display: flex; gap: 4px; flex-wrap: wrap; overflow-x: auto; padding-bottom: 2px; }
.meld-display:hover { border-color: #2196f3; background: rgba(33,150,243,0.1); }
.meld-display.target-selected { border-color: #2196f3; background: rgba(33,150,243,0.2); box-shadow: 0 0 0 2px rgba(33,150,243,0.4); }

.meld-rank-label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.canasta-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}
.tag-clean { background: rgba(255,100,100,0.3); color: #ff8888; border: 1px solid #ff4444; }
.tag-dirty { background: rgba(150,150,150,0.2); color: #aaa; border: 1px solid #666; }
.tag-wild { background: rgba(212,168,67,0.3); color: var(--gold); border: 1px solid var(--gold); }
.tag-clean5 { background: rgba(255,50,50,0.4); color: #ff6666; border: 1px solid #ff2222; }
.tag-clean7 { background: rgba(255,0,0,0.5); color: #ff4444; border: 1px solid #ff0000; }

.meld-cards-row-old { display: flex; gap: 2px; flex-wrap: wrap; }
.meld-mini-card {
  width: 62px;
  height: 88px;
  background: #fff;
  border-radius: var(--card-r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  border: 1px solid #ccc;
  flex-shrink: 0;
}
.meld-mini-card.red { color: var(--red); }
.meld-mini-card.black { color: #111; }
.meld-mini-card.wild { background: #fffbe6; color: #cc8800; border-color: #f0c040; }
.meld-count { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Opponent canastas in their box ─────────────────────────── */
.opp-canastas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.opp-canasta-card {
  width: 36px;
  height: 50px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid;
}
.opp-canasta-card.clean { background: #fff; color: var(--red); border-color: #ff4444; }
.opp-canasta-card.dirty { background: #fff; color: #111; border-color: #888; }
.opp-canasta-card.wild { background: #fffbe6; color: #cc8800; border-color: var(--gold); }
.opp-canasta-card.clean5 { background: #fff0f0; color: var(--red); border-color: #ff0000; }
.opp-canasta-card.clean7 { background: #ffe8e8; color: #cc0000; border-color: #cc0000; }

/* ── Basket Status ──────────────────────────────────────────── */
.basket-panel {
  font-size: 11px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.basket-item {
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}
.basket-item.done { border-color: #4caf50; color: #81c784; background: rgba(76,175,80,0.1); }
.basket-item.missing { border-color: #f44336; color: #ef9a9a; background: rgba(244,67,54,0.1); }

/* ── Hand Area ──────────────────────────────────────────────── */
.hand-area {
  flex-shrink: 0;
  background: var(--felt-dark);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  max-height: 160px;
}
.hand-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
#hand-label { font-size: 15px; font-weight: 600; color: var(--gold-light); }
.set-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(212,168,67,0.2);
  border: 1px solid var(--gold);
  border-radius: 3px;
  color: var(--gold);
}
.hand-count { font-size: 14px; font-weight: 600; color: var(--gold-light); }
.hand-cards {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  background: #fff;
  border: 1px solid #ccc;
  border-radius: var(--card-r);
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}
.card:hover { transform: translateY(-6px); box-shadow: 0 8px 16px rgba(0,0,0,0.5); }
.card.selected {
  transform: translateY(-14px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.6);
  border: 2px solid #ffd700;
  z-index: 10;
}
.card.pickup-selected { border: 2px solid #2196f3; transform: translateY(-8px); }

.card .rank { font-size: 14px; font-weight: bold; }
.card .suit { font-size: 16px; line-height: 1; }
.card .corner-tl { position: absolute; top: 3px; left: 4px; font-size: 10px; line-height: 1.2; text-align: left; font-weight: bold; }
.card .corner-br { position: absolute; bottom: 3px; right: 4px; font-size: 10px; line-height: 1.2; text-align: right; font-weight: bold; transform: rotate(180deg); }

.card.red-card .rank, .card.red-card .suit, .card.red-card .corner-tl, .card.red-card .corner-br { color: var(--red); }
.card.black-card .rank, .card.black-card .suit, .card.black-card .corner-tl, .card.black-card .corner-br { color: #111; }
.card.wild-card { background: #fffbe6; border-color: #f0c040; }
.card.wild-card .rank, .card.wild-card .suit, .card.wild-card .corner-tl, .card.wild-card .corner-br { color: #cc8800; }
.card.red3-card { background: #fff0f0; }
.card.black3-card { background: #f5f5f5; }

/* ── Graveyard ───────────────────────────────────────────────── */
.graveyard-section {
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
}
.graveyard-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.graveyard-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.graveyard-canasta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s, transform 0.15s;
}
.graveyard-canasta:hover { opacity: 1; transform: translateY(-3px); }
.graveyard-canasta.dirty-yard { cursor: not-allowed; opacity: 0.5; }
.graveyard-canasta .canasta-card { width: 52px; height: 74px; font-size: 14px; }
.graveyard-canasta .canasta-label { font-size: 10px; }
.graveyard-canasta .canasta-pts { font-size: 10px; }

/* ── Log panel (draggable, collapsible) ──────────────────────── */
.log-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: absolute;
  top: 0;
  right: 0;
  width: 180px;
  max-height: 100%;
  cursor: default;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.log-panel.collapsed {
  height: auto !important;
}
.log-header {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  background: rgba(0,0,0,0.3);
  border-radius: 8px 8px 0 0;
}
.log-panel.collapsed .log-header {
  border-bottom: none;
  border-radius: 8px;
}
.log-header:hover { background: rgba(255,255,255,0.08); }
.log-toggle { font-size: 14px; color: var(--text-muted); }
.log-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 300px; }
.log-body.collapsed { display: none; }
.log-entry { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.log-entry.highlight { color: var(--gold-light); }
.log-entry.system { color: #888; border-top: 1px solid var(--border); padding-top: 4px; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: #1e3a1e;
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 28px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-box h2, .modal-box h3 { color: var(--gold); margin-bottom: 16px; }

.faq-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.faq-item:last-child { border-bottom: none; }
.faq-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--gold-light);
  margin-bottom: 4px;
}
.faq-cat {
  font-size: 10px;
  font-weight: normal;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 8px;
  vertical-align: middle;
}
.faq-a {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.score-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 12px 0; }
.score-table th { color: var(--gold); font-weight: normal; border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.score-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.score-table .total-row td { color: var(--gold-light); font-weight: bold; border-top: 1px solid var(--border); }
.score-table .neg { color: #ef9a9a; }
.score-table .pos { color: #81c784; }

#roundend-actions { display: flex; gap: 12px; margin-top: 20px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: var(--btn-h);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.15); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-primary { background: rgba(212,168,67,0.3); border-color: var(--gold); color: var(--gold-light); }
.btn-primary:hover { background: rgba(212,168,67,0.5); }
.btn-secondary { background: rgba(33,150,243,0.2); border-color: #2196f3; color: #64b5f6; }
.btn-secondary:hover { background: rgba(33,150,243,0.35); }
.btn-danger { background: rgba(244,67,54,0.2); border-color: #f44336; color: #ef9a9a; }
.btn-danger:hover { background: rgba(244,67,54,0.35); }

.btn-save { background: rgba(58,111,168,0.3); border-color: #3a6fa8; color: #90caf9; }
.btn-save:hover { background: rgba(58,111,168,0.5); }
.btn-save:disabled { opacity: 0.6; cursor: default; }

.btn-rosie { background: rgba(184,134,11,0.3); border-color: #b8860b; color: #ffe082; }
.btn-rosie:hover { background: rgba(184,134,11,0.5); }

.save-card-players .rosie-active { color: #ffd700; font-weight: bold; }
.btn-outline { background: transparent; border-color: rgba(255,255,255,0.3); }
.btn-small { padding: 0 10px; height: 28px; font-size: 12px; }
.btn-tiny { padding: 0 8px; height: 22px; font-size: 11px; }

/* ── Form inputs ─────────────────────────────────────────────── */
input[type=text] {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input[type=text]:focus { border-color: var(--gold); }
input[type=text]::placeholder { color: var(--text-muted); }

select {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 8px;
}
select:focus { border-color: var(--gold); }
select option { background: #2a2a2a; color: var(--text); }

.header-select {
  width: auto;
  height: 28px;
  padding: 0 8px;
  margin-bottom: 0;
  font-size: 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  cursor: pointer;
}

/* ── Error messages ──────────────────────────────────────────── */
.error-msg {
  background: rgba(244,67,54,0.15);
  border: 1px solid rgba(244,67,54,0.4);
  border-radius: 6px;
  color: #ef9a9a;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
}

/* ── Turn indicator ─────────────────────────────────────────── */
.your-turn-banner {
  text-align: center;
  font-size: 13px;
  color: var(--gold);
  font-weight: bold;
  padding: 2px 0;
  letter-spacing: 1px;
}

/* ── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .left-col { width: 150px; }
  .right-col { width: 140px; }
  :root { --card-w: 44px; --card-h: 62px; }
}
@media (max-width: 700px) {
  .left-col, .right-col { display: none; }
  .center-col { padding: 0; }
}

/* ── Add-to-meld mode ────────────────────────────────────────── */
body.add-meld-mode .meld-display { cursor: crosshair; }
body.add-meld-mode .action-hint { color: #2196f3; }

/* ── Voice Chat ──────────────────────────────────────────────── */
.voice-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}
.voice-btn { font-size: 12px; }
.voice-btn.active { background: rgba(76,175,80,0.4); border-color: #4caf50; color: #81c784; }
.voice-btn.muted { background: rgba(244,67,54,0.3); border-color: #f44336; color: #ef9a9a; }
.voice-peers {
  display: flex;
  gap: 6px;
  align-items: center;
}
.voice-peer {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted);
  transition: all 0.2s;
}
.voice-peer.speaking {
  background: rgba(76,175,80,0.25);
  border-color: #4caf50;
  color: #81c784;
}
.voice-peer.muted-peer {
  opacity: 0.5;
}
.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
}
.voice-peer.speaking .voice-dot {
  background: #4caf50;
  animation: pulse-dot 0.8s infinite;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

/* ── Basket / Graveyard Divider ───────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
}
.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148,0,211,0.5), transparent);
}
.divider-label {
  font-size: 13px;
  color: #da70d6;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(148,0,211,0.6);
}
.section-header {
  font-size: 13px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.graveyard-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* ── Live Score Tally ─────────────────────────────────────────── */
.live-tally {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.tally-player {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 180px;
  flex: 1;
  transition: min-width 0.2s;
}
.tally-player.collapsed-tally {
  min-width: 120px;
  flex: 0;
}
.tally-player.is-me {
  border-color: var(--gold);
  background: rgba(212,168,67,0.08);
}
.tally-player.is-leading {
  border-color: #4caf50;
}
.tally-name {
  font-size: 13px;
  font-weight: bold;
  color: var(--gold-light);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tally-total {
  font-size: 20px;
  font-weight: bold;
  color: var(--gold-light);
}
.tally-total.positive { color: #81c784; }
.tally-total.negative { color: #ef9a9a; }
.tally-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.tally-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tally-row .tally-val { font-family: monospace; }
.tally-row .tally-val.pos { color: #81c784; }
.tally-row .tally-val.neg { color: #ef9a9a; }
.tally-series {
  font-size: 10px;
  color: #888;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 3px;
}

/* ── Save Game Cards ──────────────────────────────────────────── */
.save-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.save-card:hover { border-color: var(--gold); background: rgba(212,168,67,0.08); }
.save-card.active-game { border-color: #4caf50; }
.save-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.save-card-room { font-size: 13px; font-weight: bold; color: var(--gold-light); font-family: monospace; }
.save-card-time { font-size: 11px; color: #888; }
.save-card-series { font-size: 11px; color: var(--text-muted); }
.save-card-players { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.save-card-players span { color: #81c784; }
.save-card-players .bot-cover { color: #ffd700; }
.save-card-players .online { color: #4caf50; }
.save-active-badge {
  font-size: 9px;
  background: rgba(76,175,80,0.2);
  border: 1px solid #4caf50;
  color: #81c784;
  border-radius: 3px;
  padding: 1px 5px;
}

/* ── Red 3 pulse animation ───────────────────────────────────── */
@keyframes pulse-red3 {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
}


.btn-camera { background:#5f4bb6; color:#fff; border:1px solid #4c3b92; }
.btn-camera:hover { background:#4c3b92; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}
.modal-card {
  background: #173617;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 18px;
  width: min(92vw, 560px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.modal-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }

.face-photo-wrap {
  width: 320px;
  height: 400px;
  margin: 0 auto;
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: 12px;
  overflow: hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,0.03);
}
.face-video, .face-canvas, .face-preview {
  width: 320px;
  height: 400px;
  object-fit: cover;
  display: block;
}
.face-placeholder { color: #a09070; font-size: 13px; text-align:center; padding: 12px; }
