/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a15;
  --surface: #13131f;
  --surface-2: #1d1d2b;
  --border: #2a2a42;
  --text: #f0f0f5;
  --text-dim: #9999b0;
  --accent: #ff5e8a;
  --accent-2: #ffd700;
  --accent-3: #6bcb77;
  --drink-1: #a8e6a1;
  --drink-2: #ffd700;
  --drink-3: #ff5e8a;
  --bingo: #00d9ff;
  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ──────────────────────────────────────────────────── */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  text-align: center;
  padding: 32px 0 24px;
}

.header h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header p {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--accent-2);
  letter-spacing: -0.01em;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover { transform: translateY(-2px); filter: brightness(1.12); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent-2); }
.btn-success { background: var(--accent-3); color: #0a0a15; }
.btn-warning { background: var(--accent-2); color: #0a0a15; }
.btn-danger { background: #e63946; color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; filter: none !important; box-shadow: none !important; }

/* ── Inputs ──────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

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

label { display: block; color: var(--text-dim); font-size: 0.875rem; font-weight: 500; margin-bottom: 8px; }

.input-group { margin-bottom: 16px; }

.input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.input-row .input-group { flex: 1; margin-bottom: 0; }

/* ── Bingo Board ─────────────────────────────────────────────── */
.bingo-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 600px;
  margin: 0 auto;
}

.bingo-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.2;
}

.bingo-cell:hover:not(.marked) {
  border-color: var(--accent-2);
  background: var(--surface);
  transform: scale(1.02);
}

.bingo-cell:active:not(.marked) {
  transform: scale(0.97);
}

.bingo-cell .cell-text {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
}

.bingo-cell .drink-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 55%;
  height: 55%;
  border-radius: 50%;
  font-size: 1.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0a15;
  opacity: 0.55;
  animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-pop {
  from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 0.55; }
}

.drink-1 { background: var(--drink-1); }
.drink-2 { background: var(--drink-2); }
.drink-3 { background: var(--drink-3); }

.bingo-cell.marked {
  background: var(--surface);
  border-color: var(--accent-3);
  opacity: 0.85;
}

.bingo-cell.marked .cell-text {
  text-decoration: line-through;
  color: var(--text-dim);
  opacity: 0.6;
}

.bingo-cell.free {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #0a0a15;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
}

.bingo-cell.free:hover {
  transform: scale(1.02);
  box-shadow: 0 0 15px rgba(255, 94, 138, 0.3);
}

.bingo-cell.bingo-line {
  border-color: var(--bingo) !important;
  border-width: 3px;
  box-shadow: 0 0 20px rgba(0, 217, 255, 0.6);
  animation: bingo-pulse 0.8s ease-in-out infinite;
}

@keyframes bingo-pulse {
  0%, 100% { box-shadow: 0 0 15px rgba(0, 217, 255, 0.4); }
  50% { box-shadow: 0 0 30px rgba(0, 217, 255, 0.8); }
}

/* ── Leaderboard ─────────────────────────────────────────────── */
.leaderboard {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.leaderboard th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.leaderboard td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.leaderboard tr.has-bingo td {
  color: var(--bingo);
  font-weight: 700;
}

.leaderboard tr.is-me td { color: var(--accent-2); font-weight: 600; }

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
}

.progress-bar-fill.bingo {
  background: linear-gradient(90deg, var(--bingo), #0088ff);
}

/* ── Prompt List (Host) ──────────────────────────────────────── */
.prompt-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 12px 0;
}

.prompt-list::-webkit-scrollbar { width: 8px; }
.prompt-list::-webkit-scrollbar-track { background: var(--surface); }
.prompt-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.prompt-list::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.prompt-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
  transition: background 0.15s ease;
}

.prompt-item:hover { background: #222238; }

.prompt-item .prompt-text { flex: 1; font-size: 0.9rem; }
.prompt-item .prompt-drinks {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #0a0a15;
  flex-shrink: 0;
}

.prompt-item .remove-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 4px;
  transition: color 0.15s ease;
}

.prompt-item .remove-btn:hover { color: var(--accent); }

/* ── Toast / Drink Notification ──────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  padding: 16px 28px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.2rem;
  animation: toast-slide-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), toast-slide-out 0.3s ease 2.7s forwards;
  text-align: center;
  min-width: 200px;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast-drink {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #0a0a15;
}

.toast-bingo {
  background: linear-gradient(135deg, var(--bingo), #0088ff);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
}

.toast-info {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-slide-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* ── Game Over Overlay ───────────────────────────────────────── */
.game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: overlay-fade 0.4s ease;
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.game-over-card {
  background: var(--surface);
  border: 2px solid var(--accent-2);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: card-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes card-pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.game-over-card h2 {
  font-family: 'Poppins', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-list {
  text-align: left;
  margin: 24px 0;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.result-row:hover { background: var(--surface-2); }

.result-row .rank { font-weight: 800; font-size: 1.3rem; margin-right: 16px; }
.result-row .rank-1 { color: var(--accent-2); }
.result-row .rank-2 { color: #c0c0c0; }
.result-row .rank-3 { color: #cd7f32; }
.result-row .penalty { color: var(--accent); font-weight: 700; }

/* ── Share Link ──────────────────────────────────────────────── */
.share-box {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-2);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 16px 0;
  border: 1px solid var(--border);
}

.share-box input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.9rem;
  padding: 0;
}

.share-box input:focus { box-shadow: none; }

/* ── Player Chips ────────────────────────────────────────────── */
.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.player-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.15s ease;
}

.player-chip:hover { border-color: var(--accent-2); }

/* ── Waiting Screen ──────────────────────────────────────────── */
.waiting {
  text-align: center;
  padding: 48px;
}

.waiting h2 { color: var(--text); font-size: 1.2rem; font-weight: 600; }

.waiting .spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
  margin: 24px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Home Page Cards ─────────────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 32px;
}

/* ── Mobile: Player view optimized for phones ────────────────── */
@media (max-width: 600px) {
  .home-grid { grid-template-columns: 1fr; }

  .container { padding: 12px; }
  .header { padding: 20px 0 12px; }
  .header h1 { font-size: 2rem; }
  .header p { font-size: 0.85rem; }

  .input-row { flex-direction: column; }
  .card { padding: 16px; margin-bottom: 16px; }

  /* Board fills the screen, cells are easy tap targets */
  .bingo-board { gap: 6px; max-width: 100%; }
  .bingo-cell {
    font-size: 0.65rem;
    padding: 6px;
    border-radius: 6px;
    -webkit-tap-highlight-color: rgba(255, 215, 0, 0.15);
    touch-action: manipulation;
  }
  .bingo-cell.marked .drink-badge { font-size: 1.2rem; }
  .bingo-cell.free { font-size: 0.8rem; }

  /* Leaderboard compact */
  .leaderboard th { padding: 6px 8px; font-size: 0.7rem; }
  .leaderboard td { padding: 8px; font-size: 0.85rem; }

  /* Toasts bigger and more visible on mobile */
  .toast-container { top: 12px; width: 90%; left: 5%; transform: none; }
  .toast { font-size: 1.1rem; padding: 14px 20px; min-width: unset; width: 100%; }
  .toast-bingo { font-size: 1.3rem; }

  /* Game over overlay mobile friendly */
  .game-over-card { padding: 28px 16px; }
  .game-over-card h2 { font-size: 1.5rem; }
  .result-row { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; }
  .result-row .rank { font-size: 1.1rem; }

  /* Buttons min height for tap targets */
  .btn { min-height: 44px; }
}

/* ── Misc ────────────────────────────────────────────────────── */
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.count-badge {
  display: inline-block;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 2px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
}

.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.mt-10 { margin-top: 12px; }
.mt-20 { margin-top: 24px; }
.mb-10 { margin-bottom: 12px; }
.hidden { display: none !important; }
