:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-soft: #e0f7f4;
  --border: #e5e7eb;
  --danger: #b91c1c;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  background: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08), transparent 25%),
    radial-gradient(circle at 90% 30%, rgba(14, 116, 144, 0.1), transparent 20%),
    var(--bg);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
}

main.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(15, 118, 110, 0.08);
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 600;
  display: grid;
  gap: 6px;
  color: var(--ink);
}

.admin-only {
  display: none;
}

.admin-only.visible {
  display: grid;
}

input, button {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 700;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.2);
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.secondary {
  background: #0f766e;
  color: #ecfeff;
}

button.danger {
  color: var(--danger);
  border-color: #fecaca;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

.hint {
  color: var(--muted);
  margin: 8px 0 0;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
  color: var(--muted);
}

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

.admin-header {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.06), transparent 55%);
  border-radius: 12px;
  padding: 18px;
  align-items: flex-start;
}

.admin-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, #0f766e, #0ea5e9);
  color: #ecfeff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 520px;
}

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

.status { 
  min-width: 120px; 
  text-align: right; 
  font-weight: 800; 
  color: var(--danger); 
}

.status.flag {
  color: #22c55e;
}

#logout-button {
  position: relative;
  z-index: 2000;
}

#dashboard.panel {
  position: relative;
  overflow: hidden;
}

#dashboard.panel.is-locked .board {
  filter: grayscale(0.9);
  opacity: 0.35;
}

.board-container {
  position: relative;
  width: min(100%, var(--board-size, 720px));
  margin: 16px auto 0;
  overflow: hidden;
  border-radius: 10px;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.cell {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fafb;
  color: var(--ink);
  font-weight: 700;
  display: grid;
  place-items: center;
  position: relative;
  text-align: center;
  overflow: hidden;
}

.cell.photo {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.cell.photo .label {
  display: none;
}

.cell.photo.photo--loading {
  background-image: linear-gradient(
    90deg,
    #f4f4f4 0%,
    #e5e7eb 50%,
    #f4f4f4 100%
  ) !important;
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.image-preview {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--preview-width, clamp(160px, 20vw, 280px));
  height: var(--preview-height, auto);
  max-width: min(92vw, 340px);
  max-height: var(--preview-max-height, 60vh);
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid #000;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  transform: translate(-9999px, -9999px);
  transition: transform 0.08s ease;
  pointer-events: none;
  z-index: 1200;
}

.image-preview img {
  width: 100%;
  height: 100%;
  max-height: calc(var(--preview-max-height, 60vh) - 20px);
  border-radius: 6px;
  display: block;
  object-fit: contain;
  background: #fff;
  border: 1px solid #000;
}

.cell.free {
  background: radial-gradient(circle at 30% 30%, rgba(14, 116, 144, 0.08), transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(16, 185, 129, 0.12), transparent 50%),
    var(--accent-soft);
  color: var(--accent);
  border: 2px dashed #0f766e;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.2);
}

.cell.free .label {
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.cell.marked {
  color: #fef2f2;
}

.cell.marked::after {
  content: '✖';
  font-size: 42px;
  font-weight: 900;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fef2f2;
  background: rgba(0, 0, 0, 0.55);
}

.boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.winner-limit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.winner-limit-inputs {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.winner-limit-inputs .stack {
  min-width: 180px;
}

.winner-limit-inputs input[type='number'] {
  max-width: 200px;
}

.winner-limit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.board-card {
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.board-card.bingo {
  background: linear-gradient(180deg, #ecfdf3, #d1fae5);
  border-color: #bbf7d0;
  box-shadow: 0 14px 32px rgba(34, 197, 94, 0.18);
}

.board-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.card-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.card-title {
  display: grid;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  width: fit-content;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.bingo-flag {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.bingo-flag[hidden] { display: none !important; }

.board-card .display-name {
  margin: 0;
  word-break: break-word;
}

.board-card .email {
  margin: 0;
  color: var(--muted);
  word-break: break-word;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #eef2ff;
  color: #312e81;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.12);
}

.status-dot.ready {
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.16);
}

.card-footer {
  display: flex;
  margin-top: auto;
}

.card-footer .view {
  width: 100%;
}

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

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay[hidden] {
  display: none;
}

.winner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: rgba(107, 114, 128, 0.74);
  color: #f8fafc;
  border-radius: 10px;
  box-shadow: none;
  z-index: 1500;
  pointer-events: auto;
  cursor: not-allowed;
}

.winner-overlay[hidden] {
  display: none;
}

.winner-overlay__content {
  max-width: 520px;
  padding: 26px 30px;
  background: rgba(15, 23, 42, 0.82);
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: auto;
  cursor: default;
}

.winner-overlay__title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 10px 0;
}

.winner-overlay__subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
}

.modal {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  max-width: 520px;
  width: min(95vw, 520px);
  box-shadow: 0 18px 48px rgba(15, 118, 110, 0.25);
  border: 1px solid var(--border);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fafb;
}

.admin-info {
  display: grid;
  gap: 4px;
}

.admin-name {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.admin-email {
  color: var(--muted);
  font-size: 14px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-actions button {
  white-space: nowrap;
}

.modal-actions {
  justify-content: flex-end;
}

.bingo-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.bingo-popup.visible {
  opacity: 1;
  pointer-events: auto;
}

.bingo-popup[hidden] {
  display: none;
}

.bingo-popup__content {
  background: var(--panel);
  border-radius: 16px;
  padding: 28px;
  max-width: 360px;
  width: min(90vw, 380px);
  text-align: center;
  box-shadow: 0 18px 48px rgba(15, 118, 110, 0.25);
  border: 1px solid var(--border);
}

.bingo-popup__title {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0.08em;
  color: #16a34a;
}

.bingo-popup__message {
  margin: 12px 0 20px;
  color: var(--muted);
}

dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  max-width: 520px;
}

.callout {
  background: #fef9c3;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 12px;
  border-radius: 10px;
  margin-top: 12px;
}

.actions {
  display: flex;
  gap: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
