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

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: #1a1a2e;
  background-color: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

/* ============================================================
   Page Container
   ============================================================ */
#app {
  width: 100%;
  max-width: 800px;
}

.page-container {
  width: 100%;
  max-width: 800px;
  padding: 1.5rem;
}

h1, h2, h3 {
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  margin-bottom: 0.75rem;
}

/* ============================================================
   Bingo Grid
   ============================================================ */
.bingo-grid {
  display: grid;
  gap: 6px;
  margin: 1rem 0;
}

.bingo-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background-color: #ffffff;
  border: 2px solid #d0d0e0;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: default;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  user-select: none;
}

.bingo-cell.drawn {
  background-color: #4f46e5;
  border-color: #4338ca;
  color: #ffffff;
}

.bingo-cell.complete {
  background-color: #1a1a2e;
  border-color: #111;
  color: #ffffff;
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.9);
  text-decoration-thickness: 3px;
}

/* ============================================================
   BINGO Overlay
   ============================================================ */
.bingo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.bingo-overlay-text {
  font-size: 3.5rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.1em;
  text-shadow: 0 0 20px rgba(0,0,0,0.9), 0 0 40px rgba(79,70,229,0.8), 0 4px 12px rgba(0,0,0,0.7);
  animation: bingo-pop 0.4s ease-out;
}

@keyframes bingo-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.bingo-card-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* ============================================================
   Countdown Timer
   ============================================================ */
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #6b7280;
  padding: 0.25rem 0.6rem;
  background-color: #f3f4f6;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
}

.countdown.warning {
  color: #b45309;
  background-color: #fef3c7;
  border-color: #fcd34d;
}

.countdown.danger {
  color: #dc2626;
  background-color: #fee2e2;
  border-color: #fca5a5;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

.modal-body {
  font-size: 0.95rem;
  color: #4b5563;
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background-color: #4338ca;
  border-color: #4338ca;
}

.btn-secondary {
  background-color: #ffffff;
  border-color: #d1d5db;
  color: #374151;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

.btn-danger {
  background-color: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
  border-color: #b91c1c;
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.form-input,
.form-select {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  background-color: #ffffff;
  color: #1a1a2e;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* ============================================================
   Player List
   ============================================================ */
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #374151;
}

.player-item.bingo-winner {
  border-color: #7c3aed;
  background-color: #f5f3ff;
  font-weight: 600;
  color: #5b21b6;
}

/* ============================================================
   Drawn Numbers List
   ============================================================ */
.drawn-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.drawn-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.4rem;
  background-color: #4f46e5;
  color: #ffffff;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.drawn-number.latest {
  background-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3);
}

/* ============================================================
   Error Message
   ============================================================ */
.error-message {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #991b1b;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

/* ============================================================
   QR Code Container
   ============================================================ */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  width: fit-content;
}

.qr-container canvas {
  display: block;
  border-radius: 4px;
}

.qr-label {
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}

/* ============================================================
   Utility / Layout Helpers
   ============================================================ */
.card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flex-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

/* ============================================================
   Responsive — Mobile
   ============================================================ */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }

  .page-container {
    padding: 1rem;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .bingo-cell {
    font-size: 0.85rem;
    border-radius: 4px;
  }

  .bingo-overlay-text {
    font-size: 2.5rem;
  }

  .modal {
    padding: 1rem;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
  }

  .drawn-number {
    min-width: 1.9rem;
    height: 1.9rem;
    font-size: 0.8rem;
  }
}

/* ============================================================
   Ad Container
   ============================================================ */
.ad-container {
  margin-top: 1rem;
  width: 100%;
  min-height: 100px;
  display: flex;
  justify-content: center;
}

.ad-container ins {
  display: block;
  width: 100%;
}
