/* Modern Glassmorphism Bingo Styles */
:root {
  --bg-main: #0d1117;
  --bg-card: rgba(22, 27, 34, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.12);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #f59e0b;
  --accent-neon: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --ball-gold: radial-gradient(circle at 35% 35%, #fef08a, #eab308 60%, #a16207 100%);
  --daub-ink: radial-gradient(circle, rgba(239, 68, 68, 0.88) 0%, rgba(220, 38, 38, 0.95) 75%, rgba(185, 28, 28, 1) 100%);
  --daub-shadow: 0 0 16px rgba(239, 68, 68, 0.7);
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.18) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(245, 158, 11, 0.15) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
header.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.logo-badge .ball-icon {
  width: 34px;
  height: 34px;
  background: var(--ball-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e293b;
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(234, 179, 8, 0.4);
}

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

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.player-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
}

.player-tag .avatar-circle {
  font-size: 1.2rem;
}

/* Card Container Screen */
.screen {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--bg-card-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

/* JOIN / LOGIN SCREEN */
.join-header {
  text-align: center;
}

.join-header h1 {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #a5b4fc, #6366f1, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.join-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.input-pin {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 8px;
  text-align: center;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: var(--accent-neon);
  padding: 12px;
  transition: border-color 0.2s;
}

.input-pin:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.input-text {
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: var(--text-main);
  padding: 12px 16px;
  transition: border-color 0.2s;
}

.input-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

/* Avatar Selector */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .avatar-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.avatar-option {
  font-size: 1.6rem;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s ease;
  user-select: none;
}

.avatar-option:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.1);
}

.avatar-option.selected {
  border-color: var(--accent-neon);
  background: rgba(251, 191, 36, 0.2);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
  transform: scale(1.12);
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

/* LOBBY WAITING SCREEN */
.lobby-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

.room-pin-display {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--accent);
  padding: 12px 28px;
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.25);
}

.room-pin-label {
  font-size: 0.8rem;
  color: var(--accent-neon);
  font-weight: 700;
  letter-spacing: 1px;
}

.room-pin-code {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
}

.waiting-pulse {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  animation: pulseAnim 1.5s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px var(--success); }
  100% { transform: scale(0.8); opacity: 0.5; }
}

.lobby-players-box {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-players-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: left;
}

.lobby-player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.roster-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.roster-chip.you {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.25);
  font-weight: 700;
}

/* GAME SCREEN */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.round-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.95rem;
}

.round-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1e1b4b;
}

.round-badge.round2 {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #fff;
}

.stats-pill {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Caller Display */
.caller-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.15), rgba(0, 0, 0, 0.4));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  padding: 14px 18px;
}

.current-ball-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ball-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ball-gold);
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.8);
  animation: ballPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes ballPop {
  0% { transform: scale(0.3) rotate(-90deg); opacity: 0; }
  70% { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.caller-info h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.caller-info .last-call-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-neon);
}

.recent-balls-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px;
}

.ball-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* BINGO CARD (3 ROWS x 5 COLUMNS) */
.bingo-card-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid rgba(99, 102, 241, 0.4);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #a5b4fc;
}

.card-instruction {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bingo-grid {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
}

.bingo-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.bingo-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #fff;
  font-size: 1.45rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  overflow: hidden;
}

@media (max-width: 480px) {
  .bingo-cell {
    font-size: 1.2rem;
    border-radius: 10px;
  }
}

.bingo-cell:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.bingo-cell:active {
  transform: scale(0.95);
}

/* Stamped / Daubed Cell State */
.bingo-cell.marked {
  border-color: #ef4444;
  background: rgba(185, 28, 28, 0.3);
}

.bingo-cell.marked::after {
  content: '';
  position: absolute;
  width: 75%;
  height: 75%;
  background: var(--daub-ink);
  border-radius: 50%;
  opacity: 0.88;
  z-index: 1;
  box-shadow: var(--daub-shadow);
  animation: stampPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.4);
}

.bingo-cell .cell-number {
  position: relative;
  z-index: 2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.bingo-row.completed {
  animation: rowGlow 2s infinite alternate ease-in-out;
  border-radius: 14px;
}

@keyframes rowGlow {
  0% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
  100% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.8); }
}

@keyframes stampPop {
  0% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(1); opacity: 0.88; }
}

/* Card Footer with Progress */
.card-progress-bar-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  width: 0%;
  border-radius: 6px;
  transition: width 0.3s ease;
}

/* Drawn Numbers Drawer / Modal */
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* WINNER OVERLAYS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-box {
  background: linear-gradient(145deg, #1e1b4b, #0f172a);
  border: 2px solid var(--accent);
  box-shadow: 0 20px 50px rgba(245, 158, 11, 0.4);
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  animation: popModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-box.full-house {
  border-color: #ec4899;
  box-shadow: 0 20px 50px rgba(236, 72, 153, 0.5);
}

.winner-trophy {
  font-size: 4rem;
  animation: bounce 1s infinite alternate;
}

.winner-avatar-display {
  font-size: 3rem;
  background: rgba(255, 255, 255, 0.1);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--accent-neon);
}

.winner-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent-neon);
}

.winner-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.winner-desc {
  font-size: 1rem;
  color: var(--text-muted);
}

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

@keyframes popModal {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease, toastOut 0.3s 2.7s ease forwards;
}

.toast.error {
  border-color: var(--danger);
  background: rgba(127, 29, 29, 0.95);
}

.toast.success {
  border-color: var(--success);
  background: rgba(6, 78, 59, 0.95);
}

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateY(20px); opacity: 0; }
}
