/* ========== BUTTONS ========== */
.btn {
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  border: 2px solid var(--gold);
  background: rgba(0,0,0,0.4);
  color: var(--gold);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  min-height: 44px;
  min-width: 44px;
}

.btn:hover {
  background: rgba(218,165,32,0.2);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
  font-weight: bold;
}

.btn-primary:hover,
.btn-primary:active {
  background: #c4941d;
}

/* ========== TOOLBAR SOUND & 4-COLOR BUTTONS ========== */
.toolbar-sound-btn,
.toolbar-4color-btn {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  margin-left: 6px;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 44px;
  min-width: 44px;
}

.toolbar-sound-btn:hover,
.toolbar-4color-btn:hover {
  background: rgba(218, 165, 32, 0.2);
}

.toolbar-4color-btn.active {
  background: var(--gold);
  color: #111;
  font-weight: bold;
}

.toolbar-save {
  border-color: rgba(91, 206, 200, 0.45);
  color: #5bcec8;
}

.toolbar-save:hover {
  background: rgba(91, 206, 200, 0.2);
}

/* ========== TOASTS / ERRORS ========== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  font-weight: 500;
  text-align: center;
  pointer-events: none;
}

.toast.toast-success {
  background: #1b5e20;
  border: 1px solid #4caf50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 10px rgba(76,175,80,0.4);
}

.toast.toast-error {
  background: #b71c1c;
  border: 1px solid #e53935;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 10px rgba(229,57,53,0.4);
}

.toast.toast-info {
  background: #0d47a1;
  border: 1px solid #2196f3;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 10px rgba(33,150,243,0.4);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ========== RECONNECTING BANNER ========== */
.reconnecting-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ffc107;
  color: #333;
  text-align: center;
  padding: 0.5rem;
  font-weight: bold;
  z-index: 1001;
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* ========== TEACH ME PANEL ========== */
.teach-panel {
  position: fixed;
  right: 0;
  top: 50px;
  width: 280px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(0,0,0,0.85);
  border-left: 2px solid var(--gold);
  padding: 16px;
  z-index: 200;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text);
}

.teach-panel h3 {
  color: var(--gold);
  margin-top: 0;
}

.teach-panel ul {
  padding-left: 16px;
}

.teach-panel li {
  margin-bottom: 4px;
}

.teach-panel p {
  margin-bottom: 6px;
}

.teach-panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
  padding: 0;
  min-width: auto;
  min-height: auto;
}

.teach-panel-close:hover,
.teach-panel-close:active {
  opacity: 1;
}

/* ========== MELD CHEAT SHEET MODAL ========== */
.meld-guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overscroll-behavior: contain;
}

.meld-guide-content {
  background: #1a472a;
  border: 2px solid var(--gold);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  padding: 16px;
}

.meld-guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(218, 165, 32, 0.3);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.meld-guide-header h3 {
  margin: 0;
  color: var(--gold);
  font-size: 1.1rem;
}

.meld-guide-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.7;
}

.meld-guide-close:hover {
  opacity: 1;
}

.meld-guide-section {
  margin-bottom: 14px;
}

.meld-guide-section h4 {
  margin: 0 0 6px 0;
  color: #e8a830;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meld-guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.meld-guide-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.meld-guide-table td:last-child {
  text-align: right;
  color: var(--gold);
  white-space: nowrap;
}

/* ========== GAME OVER ========== */
.game-over {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  flex: 1;
  justify-content: center;
}

.game-over h1 {
  font-size: 2.5rem;
  color: var(--gold);
}

.final-scores {
  font-size: 1.5rem;
}

.final-scores .score-ns,
.final-scores .score-ew {
  display: inline;
}

/* Celebration screen */
.celebration-screen {
  text-align: center;
  max-width: 600px;
}

.celebration-screen .confetti {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  animation: confetti-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes confetti-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.celebration-screen .congrats-msg {
  font-size: 1.3rem;
  color: var(--gold);
  margin: 0.5rem 0;
}

.celebration-screen .final-scores-celebration {
  font-size: 1.5rem;
  margin: 1rem 0;
}

.celebration-screen .winner-score {
  color: #ffd700;
  font-weight: bold;
}

.celebration-screen .versus {
  margin: 0 1rem;
  opacity: 0.6;
}

.celebration-screen .loser-score {
  color: #999;
}

.celebration-screen .taunt {
  font-style: italic;
  color: #aaa;
  margin: 0.5rem 0;
  font-size: 1rem;
}

/* ========== REDUCED MOTION (F-M7) ========== */
/* Disable all infinite pulses/bounces for users who prefer reduced motion.
   Target the consuming selectors (not just keyframes) and use !important so
   the inline animation style on .trick-complete-indicator (render.js) is
   overridden without a JS change. */
@media (prefers-reduced-motion: reduce) {
  .player-zone.current-player,      /* current-turn-glow */
  .player-turn-indicator,           /* prompt-pulse */
  .table-swap-hint,                 /* prompt-pulse */
  .table-seat.table-seat-selected,  /* pulse-seat */
  .celebration-screen .confetti,    /* confetti-bounce */
  .reconnecting-banner,             /* pulse */
  .trick-complete-indicator         /* pulse (inline style) */ {
    animation: none !important;
  }
}

/* ========== TAP HIGHLIGHT & FOCUS VISIBILITY (F-M11) ========== */
button,
a,
.card,
.table-seat,
.toolbar-btn,
.chat-floater,
.table-talk-send-btn,
.toolbar-sound-btn,
.toolbar-4color-btn,
.teach-toggle,
.trick-history-toggle,
.btn-sub-bot,
.btn-leave-lobby {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ========== MOBILE RESPONSIVE (extracted per-component from the style.css mega-block) ========== */
@media (max-width: 768px), (min-width: 769px) and (max-width: 1024px) and (pointer: coarse) {
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
    width: 100%;
  }

  .game-over h1 {
    font-size: 1.8rem;
  }

  /* Teach Me panel — mobile: full-width at bottom above hand */
  .teach-panel {
    position: fixed;
    right: 0;
    left: 0;
    top: auto;
    /* Clear the ~119px fixed hand bar plus the home indicator. */
    bottom: calc(119px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 2px solid var(--gold);
    border-radius: 0;
    z-index: 199;
  }
}
