/* ═══════════════════════════════════════════════════════════
   game_cards.css — Shared CSS for all card games
   (Ba Cây, UNO, and future games: blackjack, poker, tiến lên)
   ═══════════════════════════════════════════════════════════ */

/* ── Theme variables ───────────────────────────────────────── */
:root {
  --gc-bg-dark: #0a1e3a;
  --gc-bg-mid: #1e5a8a;
  --gc-bg-deep: #0d2035;
  --gc-surface: rgba(15, 23, 42, 0.85);
  --gc-surface-hover: rgba(20, 30, 55, 0.9);
  --gc-border: rgba(255, 255, 255, 0.12);
  --gc-border-accent: rgba(255, 255, 255, 0.18);
  --gc-text: #c8ddf0;
  --gc-text-bright: #e8f0fa;
  --gc-muted: #6b8fb5;
  --gc-gold: #FFD700;
  --gc-gold-soft: #f59e0b;
  --gc-green: #4ade80;
  --gc-red: #ef4444;
  --gc-blue: #3b82f6;
  --gc-cyan: #22d3ee;
  --gc-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --gc-shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
  --font-head: "Bungee", cursive;
  --font-body: "Be Vietnam Pro", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  /* Backward compat aliases (bc-* still works) */
  --bc-bg-dark: var(--gc-bg-dark);
  --bc-bg-mid: var(--gc-bg-mid);
  --bc-bg-deep: var(--gc-bg-deep);
  --bc-surface: var(--gc-surface);
  --bc-surface-hover: var(--gc-surface-hover);
  --bc-border: var(--gc-border);
  --bc-border-accent: var(--gc-border-accent);
  --bc-text: var(--gc-text);
  --bc-text-bright: var(--gc-text-bright);
  --bc-muted: var(--gc-muted);
  --bc-gold: var(--gc-gold);
  --bc-gold-soft: var(--gc-gold-soft);
  --bc-green: var(--gc-green);
  --bc-red: var(--gc-red);
  --bc-blue: var(--gc-blue);
  --bc-cyan: var(--gc-cyan);
  --bc-shadow: var(--gc-shadow);
  --bc-shadow-sm: var(--gc-shadow-sm);
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--gc-bg-dark);
  font-family: var(--font-body);
  color: var(--gc-text);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

/* ── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.chat-fab { display: none !important; }

/* ── Sidebar ───────────────────────────────────────────────── */
.bc-sidebar {
  width: 280px; height: 100vh;
  display: flex; flex-direction: column;
  background: rgba(10, 25, 50, 0.92);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--gc-border);
  overflow: hidden; flex-shrink: 0;
}

.bc-sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gc-border);
}

.bc-sidebar-room {
  padding: 14px 12px;
  border-bottom: 1px solid var(--gc-border);
}

.bc-sidebar-chat {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; padding: 10px 12px 12px;
}

/* ── Sidebar elements ──────────────────────────────────────── */
.bc-panel-title {
  font-family: var(--font-head); font-size: 15px;
  line-height: 1.4; color: var(--gc-text-bright);
}

.bc-panel-sub {
  margin-top: 4px; color: var(--gc-muted); font-size: 12px;
}

.bc-room-stats { display: grid; gap: 6px; margin-top: 12px; }

.bc-room-stats div {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12px; color: var(--gc-muted);
}

.bc-room-stats strong {
  font-family: var(--font-mono); color: var(--gc-cyan);
}

.bc-timer {
  font-family: var(--font-head); font-size: 24px; color: var(--gc-cyan);
}

.bc-action-stack { display: grid; gap: 8px; margin-top: 12px; }

/* ── Buttons ───────────────────────────────────────────────── */
.bc-btn {
  border: none; border-radius: 8px; padding: 9px 16px;
  font-weight: 700; font-size: 13px; cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
  font-family: var(--font-body);
}

.bc-btn:active { transform: scale(0.96); }

.bc-btn-primary { background: var(--gc-blue); color: #fff; }
.bc-btn-primary:hover { background: #2563eb; }

.bc-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--gc-text); border: 1px solid var(--gc-border);
}
.bc-btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

.bc-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--gc-border); background: rgba(255, 255, 255, 0.06);
  color: var(--gc-text); font-size: 16px; cursor: pointer;
  transition: background 0.15s ease; flex-shrink: 0;
}
.bc-btn-icon:hover { background: rgba(255, 255, 255, 0.12); }

.bc-btn-icon-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--gc-border); background: rgba(255, 255, 255, 0.06);
  color: var(--gc-muted); font-size: 14px; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.bc-btn-icon-close:hover { background: rgba(255, 255, 255, 0.12); }

.bc-btn-chat-send {
  padding: 0 14px; min-height: 36px; border-radius: 8px; border: none;
  background: var(--gc-blue); color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: background 0.15s ease;
}
.bc-btn-chat-send:hover { background: #2563eb; }

/* ── Profile chip ──────────────────────────────────────────── */
.bc-profile-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; min-height: 36px; border-radius: 8px;
  border: 1px solid var(--gc-border); background: rgba(255, 255, 255, 0.06);
  cursor: pointer; transition: background 0.15s ease;
  text-align: left; margin-left: auto;
}
.bc-profile-chip:hover { background: rgba(255, 255, 255, 0.1); }
.bc-profile-chip strong { font-size: 12px; color: var(--gc-text-bright); }
.bc-profile-chip span { font-size: 11px; color: var(--gc-cyan); font-family: var(--font-mono); }

/* ── Chat ──────────────────────────────────────────────────── */
.bc-chat-title {
  font-family: var(--font-head); font-size: 13px;
  color: var(--gc-muted); margin-bottom: 8px;
}

.bacay-chat-list {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; min-height: 0; padding-right: 4px;
}


.bacay-chat-empty {
  color: var(--gc-muted); font-size: 12px; text-align: center;
  padding: 18px 8px; font-family: var(--font-mono);
}

.bacay-chat-item {
  border-radius: 8px; padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto; width: 100%; min-height: 0;
}
.bacay-chat-item.me {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.15);
}

.bacay-chat-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 4px;
}

.bacay-chat-author { font-weight: 600; font-size: 11px; color: var(--gc-gold-soft); }
.bacay-chat-elo { margin-left: 4px; color: var(--gc-cyan); font-family: var(--font-mono); font-size: 10px; }
.bacay-chat-time { color: var(--gc-muted); font-size: 10px; font-family: var(--font-mono); white-space: nowrap; }

.bacay-chat-msg {
  color: var(--gc-text); font-size: 12px; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}

.bacay-chat-compose {
  margin-top: auto; display: flex; gap: 6px; flex-shrink: 0;
  padding-top: 8px;
}

.bacay-chat-input {
  flex: 1; min-width: 0; min-height: 36px; border-radius: 8px;
  border: 1px solid var(--gc-border); background: var(--gc-bg-deep);
  color: #fff; padding: 0 10px; font-size: 12px;
}
.bacay-chat-input:focus {
  outline: none; border-color: var(--gc-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.bacay-chat-input::placeholder { color: var(--gc-muted); }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); z-index: 300;
}
.modal-overlay.show { display: flex; }

.modal-card {
  width: min(100%, 460px); border-radius: 14px;
  border: 1px solid var(--gc-border-accent);
  background: rgba(13, 32, 53, 0.97);
  box-shadow: var(--gc-shadow); padding: 24px;
}
.modal-card h3 {
  margin: 0 0 8px; font-family: var(--font-head);
  font-size: 18px; color: var(--gc-text-bright);
}
.modal-card p { margin: 0 0 16px; color: var(--gc-muted); font-size: 13px; }

.modal-grid { display: grid; gap: 14px; }
.modal-grid label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--gc-muted); }
.modal-grid input,
.modal-grid select {
  min-height: 40px; border-radius: 8px;
  border: 1px solid var(--gc-border); background: var(--gc-bg-deep);
  color: #fff; padding: 0 12px; font-size: 14px;
}
.modal-grid input:focus,
.modal-grid select:focus { outline: none; border-color: var(--gc-blue); }

.modal-field-label { font-size: 13px; font-weight: 600; color: var(--gc-muted); }

.modal-radio-group { display: flex; gap: 8px; }
.modal-radio-group.disabled-group { opacity: 0.4; pointer-events: none; }
.modal-radio { flex: 1; display: flex !important; align-items: center; justify-content: center; gap: 0; }
.modal-radio input[type="radio"] { display: none; }
.modal-radio span {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 40px; border-radius: 8px;
  border: 1px solid var(--gc-border); background: var(--gc-bg-deep);
  color: var(--gc-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.modal-radio input[type="radio"]:checked + span {
  border-color: var(--gc-blue); background: rgba(99, 102, 241, 0.15); color: #fff;
}

.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--gc-border);
}
.modal-header h3 { margin: 0; flex: 1; }

/* ── Rules modal ───────────────────────────────────────────── */
.rules-modal-card {
  width: min(100%, 640px); max-height: 85vh;
  display: flex; flex-direction: column;
}
.rules-content { flex: 1; overflow-y: auto; padding-right: 8px; margin-bottom: 14px; }


.rules-section {
  margin-bottom: 14px; padding: 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.rules-section h4 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--gc-text-bright); }
.rules-section ul { margin: 0; padding-left: 20px; list-style: disc; }
.rules-section li { margin-bottom: 6px; font-size: 13px; color: var(--gc-text); line-height: 1.5; }
.rules-section li strong { color: var(--gc-cyan); font-weight: 600; }
.rules-section p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--gc-text); }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; left: 16px; bottom: 16px; z-index: 600;
  display: flex; flex-direction: column; gap: 6px;
  width: min(320px, calc(100vw - 32px));
}

.toast {
  padding: 8px 18px; border-radius: 8px;
  background: rgba(20, 60, 100, 0.92);
  border: 1px solid var(--gc-border);
  font-size: 13px; color: var(--gc-text);
  animation: gcToastIn 0.3s ease;
}
@keyframes gcToastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.success { border-color: rgba(74, 222, 128, 0.15); }
.toast.error { border-color: rgba(239, 68, 68, 0.18); }

/* ── Orientation lock ──────────────────────────────────────── */
.orientation-lock {
  position: fixed; inset: 0; z-index: 120;
  display: none; align-items: center; justify-content: center; padding: 24px;
  background: rgba(10, 30, 58, 0.97); backdrop-filter: blur(10px);
}
.orientation-lock.show { display: flex; }

body.orientation-locked { overflow: hidden; }
body.mobile-fullscreen { overflow: hidden; }

.orientation-lock-card {
  width: min(360px, 100%); border-radius: 14px;
  border: 1px solid var(--gc-border);
  background: rgba(13, 32, 53, 0.95);
  box-shadow: var(--gc-shadow); padding: 24px; text-align: center;
}
.orientation-lock-icon { font-size: 32px; line-height: 1; }
.orientation-lock-title {
  margin-top: 12px; font-family: var(--font-head);
  font-size: 18px; color: var(--gc-text-bright);
}
.orientation-lock-sub { margin-top: 10px; color: var(--gc-muted); font-size: 13px; }

/* ── Password error ────────────────────────────────────────── */
.pw-error { color: #f87171; font-size: 13px; margin-top: 6px; min-height: 0; }
.pw-error:empty { display: none; }

/* ── Mobile sidebar drawer (shared) ───────────────────────── */
/* On mobile (≤900px), the sidebar transforms into a bottom bar
   with a toggle to expand into a drawer showing room info + chat.
   Reusable across all card games. */

.bc-sidebar-toggle {
  display: none;
}

@media (max-width: 900px) {
  .bc-sidebar {
    width: 100%;
    height: 48px;
    border-left: none;
    border-bottom: 1px solid var(--gc-border);
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: height .3s ease;
    order: -1;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .bc-sidebar.expanded {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    z-index: 200;
  }

  .bc-sidebar-header {
    border-bottom: none;
    padding: 8px 12px;
    flex-shrink: 0;
    width: 100%;
  }

  .bc-sidebar.expanded .bc-sidebar-header {
    border-bottom: 1px solid var(--gc-border);
  }

  .bc-sidebar-room {
    display: none;
  }

  .bc-sidebar.expanded .bc-sidebar-room {
    display: block;
    padding: 10px 12px;
  }

  .bc-sidebar:not(.expanded) .bc-sidebar-chat {
    display: none;
  }

  .bc-sidebar.expanded .bc-sidebar-chat {
    min-height: 160px;
    padding: 8px 12px 10px;
  }

  .bc-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(200, 221, 240, 0.08);
    border: 1px solid var(--gc-border);
    color: var(--gc-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform .3s;
    flex-shrink: 0;
  }

  .bc-sidebar.expanded .bc-sidebar-toggle {
    transform: rotate(180deg);
  }

  .toast-stack {
    bottom: 16px;
  }
}
