/**
 * Mind Game - Main Application Styles
 * Luxury Poker Table Interface & Responsive Experience
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #082114;
  background-image: 
    radial-gradient(circle at 50% 40%, #154c30 0%, #0c3320 60%, #05160c 100%);
  color: #f1f5f9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* App Header */
.app-header {
  height: 60px;
  background: rgba(3, 16, 9, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffbe0b;
}

.brand span.card-glyph {
  font-size: 22px;
  color: #ff0055;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #ffb703, #fb8500);
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(251, 133, 0, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(251, 133, 0, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
}

.btn-gold {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #1e1e1e;
  font-weight: 800;
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
}

/* Room Pill Badge */
.room-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
}

/* Screens Wrapper */
.screen-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen-view.hidden {
  display: none !important;
}

/* ==========================================================================
   LOBBY SCREEN
   ========================================================================== */
.lobby-container {
  max-width: 680px;
  width: 92%;
  margin: 30px auto;
  background: rgba(10, 35, 22, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.lobby-title {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 20px;
  color: #ffbe0b;
}

.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}

.form-input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px 14px;
  color: #ffffff;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: #ffbe0b;
}

/* Avatar selector */
.avatar-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.avatar-choice {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.avatar-choice.active {
  border-color: #ffbe0b;
  background: rgba(255, 190, 11, 0.2);
  transform: scale(1.1);
}

/* Room Players List */
.players-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
  max-height: 280px;
  overflow-y: auto;
}

.player-item-row {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  font-size: 24px;
}

.player-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-name {
  font-weight: 700;
  font-size: 15px;
}

.badge-admin {
  background: #ffb703;
  color: #0f172a;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
}

.badge-you {
  background: #3b82f6;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
}

/* ==========================================================================
   GAME TABLE SCREEN
   ========================================================================== */
.poker-table-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding-bottom: 12px;
}

/* Opponents Grid / Circle */
.opponents-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 14px;
  flex-wrap: wrap;
  min-height: 140px;
  z-index: 10;
}

.opponent-seat {
  background: rgba(4, 25, 15, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
  min-width: 145px;
  position: relative;
}

.opponent-seat.active-turn {
  border-color: #ffbe0b;
  box-shadow: 0 0 20px rgba(255, 190, 11, 0.6);
  background: rgba(22, 60, 40, 0.85);
  transform: translateY(-3px);
}

.opponent-seat.active-turn::before {
  content: "TURN";
  position: absolute;
  top: -10px;
  background: #ffbe0b;
  color: #082114;
  font-size: 9px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 6px;
}

.seat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.seat-cards {
  display: flex;
  gap: 6px;
}

/* Center Play Area: Deck & Discard */
.table-center-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  position: relative;
}

.felt-circle {
  position: absolute;
  width: min(85vw, 620px);
  height: min(45vh, 320px);
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.piles-container {
  display: flex;
  align-items: center;
  gap: 40px;
  z-index: 5;
}

.pile-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.pile-title {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.5px;
}

.deck-count-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: #ffffff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Center announcement banner */
.center-announcement {
  background: rgba(3, 16, 9, 0.85);
  border: 1px solid rgba(255, 190, 11, 0.4);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #fef08a;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-width: 90%;
  z-index: 6;
}

/* Your Player Hand (Bottom) */
.player-hand-container {
  background: rgba(3, 16, 9, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 20;
}

.hand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 680px;
}

.player-status-badge {
  font-size: 13px;
  font-weight: 700;
  color: #a7f3d0;
}

.hand-cards-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
}

/* Player Action Bar */
.action-controls-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

/* Drawn Card Stage Area */
.drawn-card-stage {
  position: fixed;
  bottom: 180px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 35, 22, 0.95);
  border: 2px solid #ffbe0b;
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 80;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.drawn-card-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background: #0d2e1e;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-backdrop.active .modal-window {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffbe0b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
}
.modal-close:hover {
  color: #ffffff;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast-msg {
  background: rgba(15, 23, 42, 0.95);
  border-left: 4px solid #ffbe0b;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  pointer-events: auto;
  animation: fadeInRight 0.25s ease-out;
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Chat & Activity Drawer */
.chat-drawer {
  position: fixed;
  bottom: 12px;
  left: 12px;
  width: 320px;
  height: 280px;
  background: rgba(4, 20, 12, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.chat-drawer.collapsed {
  transform: translateY(calc(100% - 40px));
}

.chat-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.chat-tabs {
  display: flex;
  gap: 8px;
}
.chat-tab {
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  color: #94a3b8;
}
.chat-tab.active {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.chat-content {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-line {
  line-height: 1.35;
}
.chat-sender {
  font-weight: 700;
  color: #ffbe0b;
}

.chat-input-bar {
  display: flex;
  padding: 6px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.chat-input {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 12px;
  outline: none;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .app-header {
    padding: 0 10px;
  }
  .card-ui {
    width: 64px;
    height: 94px;
  }
  .card-ui.mini {
    width: 38px;
    height: 56px;
  }
  .chat-drawer {
    width: 260px;
    height: 240px;
  }
  .piles-container {
    gap: 20px;
  }
}

/* Variable hand sizes must fit narrow screens. */
.hand-cards-row, .seat-cards { flex-wrap: wrap; }
#stage-card-options { max-height: 55vh; overflow-y: auto; }
#showdown-results-table .player-item-row > div { flex-wrap: wrap; }
