@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Poppins:wght@400;600;700&display=swap');

:root {
  --bg-dark: #1a1a2e;
  --bg-card: rgba(30, 30, 50, 0.9);
  --primary: #6366f1;
  --gold: #f59e0b;
  --letter-b: #ef4444;
  --letter-i: #f97316;
  --letter-n: #eab308;
  --letter-g: #22c55e;
  --letter-o: #3b82f6;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --success: #10b981;
}

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

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

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

.game-wrapper {
  position: relative;
  min-height: 100vh;
}

/* Background Pattern */
.bg-pattern {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(245, 158, 11, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(239, 68, 68, 0.08) 0%, transparent 70%);
  z-index: 0;
}

/* Header */
.b-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.b-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px;
}

.b-header .b-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

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

.brand-icon {
  font-size: 1.8rem;
}

.brand h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--gold), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badge {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.b-room {
  display: flex;
  gap: 8px;
}

.room-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.chip-icon { font-size: 0.9rem; }
.chip-text { font-weight: 600; font-size: 0.85rem; }

.room-chip.players .chip-text { color: var(--success); }

/* Main */
.b-main {
  position: relative;
  z-index: 1;
  padding-top: 20px;
  padding-bottom: 40px;
}

/* Card */
.b-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Lobby */
.lobby-card {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.lobby-hero {
  margin-bottom: 24px;
}

.hero-balls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 -3px 10px rgba(0, 0, 0, 0.2);
  animation: bounce 2s ease-in-out infinite;
}

.ball-b { background: linear-gradient(135deg, var(--letter-b), #dc2626); animation-delay: 0s; }
.ball-i { background: linear-gradient(135deg, var(--letter-i), #ea580c); animation-delay: 0.1s; }
.ball-n { background: linear-gradient(135deg, var(--letter-n), #ca8a04); animation-delay: 0.2s; }
.ball-g { background: linear-gradient(135deg, var(--letter-g), #16a34a); animation-delay: 0.3s; }
.ball-o { background: linear-gradient(135deg, var(--letter-o), #2563eb); animation-delay: 0.4s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.lobby-hero h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.lobby-subtitle {
  color: var(--text-muted);
}

/* Actions */
.b-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.b-btn {
  padding: 14px 24px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.b-btn:hover { background: rgba(255, 255, 255, 0.1); }
.b-btn:active { transform: scale(0.98); }
.b-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.b-primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border: none;
}

.b-primary:hover {
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

.b-gold {
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  border: none;
  color: #1a1a2e;
}

.btn-glow {
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 5px 20px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 5px 40px rgba(99, 102, 241, 0.6); }
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.b-join {
  display: flex;
  gap: 10px;
}

.b-join input {
  flex: 1;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 3px;
}

.b-join input:focus {
  outline: none;
  border-color: var(--primary);
}

.b-msg {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Game Layout */
.b-game {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

/* Panel */
.b-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.b-call, .b-called, .b-status {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.current-number {
  font-family: 'Fredoka One', cursive;
  font-size: 4rem;
  text-align: center;
  background: linear-gradient(135deg, var(--gold), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 10px 0 15px;
}

.called-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 100px;
  overflow-y: auto;
}

.called-list span {
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-text {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.status-icon { font-size: 1.2rem; }

.b-claims {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.claim-btn {
  padding: 10px;
  font-size: 0.85rem;
}

/* Board */
.b-board {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.b-title {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.b-title span {
  text-align: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.5rem;
  padding: 8px;
  border-radius: 10px;
}

.letter-b { color: var(--letter-b); background: rgba(239, 68, 68, 0.15); }
.letter-i { color: var(--letter-i); background: rgba(249, 115, 22, 0.15); }
.letter-n { color: var(--letter-n); background: rgba(234, 179, 8, 0.15); }
.letter-g { color: var(--letter-g); background: rgba(34, 197, 94, 0.15); }
.letter-o { color: var(--letter-o); background: rgba(59, 130, 246, 0.15); }

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

.b-cell {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.b-cell:hover { background: rgba(255, 255, 255, 0.1); }
.b-cell:active { transform: scale(0.95); }

.b-cell.free {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border: none;
  font-size: 1.5rem;
}

.b-cell.marked {
  background: linear-gradient(135deg, var(--success), #059669);
  border-color: var(--success);
  color: white;
  animation: markPop 0.3s ease;
}

@keyframes markPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Mobile */
@media (max-width: 768px) {
  .b-game {
    grid-template-columns: 1fr;
  }
  .b-panel {
    order: 2;
  }
  .b-board {
    order: 1;
  }
  .brand h1 { font-size: 1.3rem; }
  .ball { width: 40px; height: 40px; font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .b-container { padding: 10px; }
  .b-card { padding: 16px; border-radius: 16px; }
  .lobby-hero h2 { font-size: 1.4rem; }
  .ball { width: 36px; height: 36px; font-size: 1rem; }
  .b-btn { padding: 12px 16px; }
  .b-join { flex-direction: column; }
  .b-grid { gap: 5px; }
  .b-cell { font-size: 1rem; border-radius: 8px; }
  .b-title span { font-size: 1.2rem; }
  .current-number { font-size: 3rem; }
  .b-claims { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .hero-balls { gap: 4px; }
  .ball { width: 32px; height: 32px; font-size: 0.9rem; }
  .b-cell { font-size: 0.9rem; }
}
