:root {
  --creme: #fff8f5;
  --rosa: #f8e8ee;
  --rosa-forte: #d4849a;
  --chocolate: #5c4033;
  --chocolate-escuro: #3e2a22;
  --livre-bg: #eef8f0;
  --livre-border: #6bbf7a;
  --livre-text: #2d6a3e;
  --reservado-bg: #fff4e0;
  --reservado-border: #e8a838;
  --reservado-text: #8a5a10;
  --pago-bg: #f0eaea;
  --pago-border: #8a6e6e;
  --pago-text: #5a4040;
  --selecionado-bg: #d4849a;
  --selecionado-border: #5c4033;
  --shadow: 0 12px 40px rgba(92, 64, 51, 0.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --bar-height: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", sans-serif;
  color: var(--chocolate);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #f8e8ee 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #f3e6dc 0%, transparent 50%),
    linear-gradient(180deg, var(--creme) 0%, #f5ebe6 100%);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

body.has-selection {
  padding-bottom: calc(7.5rem + var(--safe-bottom));
}

.font-display {
  font-family: "Fraunces", Georgia, serif;
}

img,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Hero ---------- */
.hero-banner {
  position: relative;
  min-height: clamp(220px, 42vw, 320px);
  background:
    linear-gradient(135deg, rgba(92, 64, 51, 0.55), rgba(212, 132, 154, 0.45)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='400' viewBox='0 0 800 400'%3E%3Crect fill='%23f3e0d8' width='800' height='400'/%3E%3Ccircle cx='400' cy='210' r='110' fill='%23e8b4a0'/%3E%3Cellipse cx='400' cy='150' rx='120' ry='40' fill='%23f5d0c8'/%3E%3Ccircle cx='360' cy='130' r='10' fill='%23d4849a'/%3E%3Ccircle cx='400' cy='120' r='12' fill='%23c96b84'/%3E%3Ccircle cx='440' cy='132' r='9' fill='%23d4849a'/%3E%3Crect x='290' y='250' width='220' height='40' rx='8' fill='%23c4a484'/%3E%3C/svg%3E")
      center / cover no-repeat;
  display: flex;
  align-items: flex-end;
  padding-top: var(--safe-top);
}

.hero-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(62, 42, 34, 0.78) 0%, transparent 58%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 1.5rem 1rem 1.35rem;
  color: #fff;
}

.hero-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fce7f0;
  margin: 0 0 0.5rem;
  opacity: 0.95;
}

.hero-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.75rem, 7vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5rem;
  word-wrap: break-word;
}

.hero-desc {
  font-size: clamp(0.9rem, 3.5vw, 1.125rem);
  line-height: 1.45;
  margin: 0;
  max-width: 36rem;
  color: #fff5f8;
  opacity: 0.95;
}

/* ---------- Layout ---------- */
.page-main {
  width: 100%;
  max-width: 64rem;
  margin: -1.25rem auto 0;
  padding: 0 0.875rem;
  position: relative;
  z-index: 10;
}

@media (min-width: 640px) {
  .page-main {
    margin-top: -1.5rem;
    padding: 0 1rem;
  }
}

.card-soft {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(232, 216, 208, 0.8);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}

.winner-banner {
  background: linear-gradient(135deg, #2d6a3e 0%, #3d8b52 55%, #c96b84 100%);
  color: #fff;
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.winner-eyebrow {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.9;
}

.winner-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  margin: 0.4rem 0 0.25rem;
  line-height: 1.2;
}

.winner-name {
  margin: 0;
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 700;
  opacity: 0.95;
  word-break: break-word;
}

.winner-meta {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  opacity: 0.9;
  line-height: 1.4;
}

.winner-meta a {
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
}

.premio-sabores {
  list-style: none;
  margin: 0 0 1.15rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .premio-sabores {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

.premio-sabores li {
  background: var(--rosa);
  color: var(--chocolate);
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 132, 154, 0.35);
  text-align: center;
}

.premio-info-grid {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .premio-info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

.premio-info-item {
  background: #faf4f0;
  border: 1px solid #e8d8d0;
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
}

.premio-info-label {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rosa-forte);
}

.premio-info-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: rgba(92, 64, 51, 0.9);
}

.prova-box {
  background: #f7f0ec;
  border: 1px solid #e8d8d0;
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 0.75rem;
  word-break: break-all;
  line-height: 1.45;
}

.prova-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 700;
}

.prova-fail {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 700;
}

@media (min-width: 640px) {
  .card-soft {
    border-radius: 1.25rem;
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.35rem;
  }
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #eadfd8;
  overflow: hidden;
}

@media (min-width: 640px) {
  .progress-track {
    height: 12px;
  }
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rosa-forte), #c96b84);
  transition: width 0.6s ease;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.stats-side {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.stat-chip {
  background: var(--rosa);
  border-radius: 0.75rem;
  padding: 0.4rem 0.65rem;
  line-height: 1.2;
}

.valor-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .valor-block {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.8125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 2px solid;
  display: inline-block;
  flex-shrink: 0;
}

/* ---------- Grade de números (touch-first) ---------- */
.numeros-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  width: 100%;
}

.numero-btn {
  aspect-ratio: 1;
  width: 100%;
  min-height: 0;
  min-width: 0;
  border-radius: 0.65rem;
  border: 2px solid;
  font-weight: 800;
  font-size: clamp(0.7rem, 3.2vw, 0.95rem);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 0;
  line-height: 1;
}

.numero-btn.livre {
  background: var(--livre-bg);
  border-color: var(--livre-border);
  color: var(--livre-text);
}

.numero-btn.reservado {
  background: var(--reservado-bg);
  border-color: var(--reservado-border);
  color: var(--reservado-text);
  cursor: not-allowed;
  opacity: 0.92;
}

.numero-btn.pago {
  background: var(--pago-bg);
  border-color: var(--pago-border);
  color: var(--pago-text);
  cursor: not-allowed;
  opacity: 0.88;
}

.numero-btn.selecionado {
  background: var(--selecionado-bg);
  border-color: var(--selecionado-border);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(212, 132, 154, 0.4);
  transform: scale(1.04);
}

@media (hover: hover) and (pointer: fine) {
  .numero-btn.livre:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(107, 191, 122, 0.35);
  }
}

@media (min-width: 380px) {
  .numeros-grid {
    gap: 0.45rem;
  }
}

@media (min-width: 480px) {
  .numeros-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .numero-btn {
    border-radius: 0.75rem;
  }
}

@media (min-width: 768px) {
  .numeros-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .numero-btn {
    font-size: 0.95rem;
    border-radius: 0.85rem;
  }
}

/* Telas muito estreitas: ainda 5 colunas, alvos tocáveis */
@media (max-width: 360px) {
  .numeros-grid {
    gap: 0.3rem;
  }

  .numero-btn {
    border-width: 1.5px;
    border-radius: 0.5rem;
    font-size: 0.68rem;
  }

  .card-soft {
    padding: 0.85rem;
    border-radius: 0.85rem;
  }

  .page-main {
    padding: 0 0.65rem;
  }
}

/* ---------- Botões e formulário ---------- */
.btn-primary {
  background: linear-gradient(135deg, #d4849a, #c96b84);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.9rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  width: 100%;
  font-size: 1rem;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(201, 107, 132, 0.4);
  }
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--chocolate);
  border: 2px solid #e0d0c8;
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover {
    background: var(--rosa);
  }
}

.btn-close-modal {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f5ebe6;
  border-radius: 12px;
  color: var(--chocolate);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.input-field {
  width: 100%;
  border: 2px solid #e8d8d0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  /* 16px evita zoom automático no iOS */
  font-size: 16px;
  color: var(--chocolate);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.input-field:focus {
  border-color: var(--rosa-forte);
}

/* ---------- Barra flutuante ---------- */
.floating-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 248, 245, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #e8d8d0;
  padding: 0.75rem 0.875rem calc(0.75rem + var(--safe-bottom));
  z-index: 40;
  transform: translateY(110%);
  transition: transform 0.25s ease;
  box-shadow: 0 -8px 28px rgba(92, 64, 51, 0.1);
}

.floating-bar.visible {
  transform: translateY(0);
}

.floating-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.floating-info {
  font-size: 0.875rem;
  min-width: 0;
}

.floating-info .selected-nums {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  color: rgba(92, 64, 51, 0.7);
  margin: 0.15rem 0 0;
  line-height: 1.35;
}

@media (min-width: 640px) {
  .floating-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .floating-bar .btn-primary {
    width: auto;
    min-width: 200px;
  }
}

/* ---------- Modal (sheet no mobile) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(62, 42, 34, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  z-index: 50;
  overscroll-behavior: contain;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: #fff;
  border-radius: 1.25rem 1.25rem 0 0;
  width: 100%;
  max-width: 480px;
  max-height: min(92dvh, 92vh);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow);
  animation: sheetUp 0.28s ease;
  padding: 1.15rem 1rem calc(1.15rem + var(--safe-bottom));
}

.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #e0d0c8;
  margin: 0 auto 0.85rem;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }

  .modal-box {
    border-radius: 1.25rem;
    max-height: 90vh;
    padding: 1.5rem;
    animation: slideUp 0.25s ease;
  }

  .modal-handle {
    display: none;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.pix-code {
  word-break: break-all;
  overflow-wrap: anywhere;
  font-size: 0.7rem;
  line-height: 1.4;
  background: #f7f0ec;
  border-radius: 10px;
  padding: 0.75rem;
  border: 1px dashed #d4b8b0;
  max-height: 88px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#qrcode {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.35rem;
}

#qrcode canvas,
#qrcode img {
  border-radius: 12px;
  max-width: min(220px, 70vw) !important;
  height: auto !important;
}

.pix-numeros-wrap {
  word-break: break-word;
  line-height: 1.4;
}

.site-footer {
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(92, 64, 51, 0.5);
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  line-height: 1.5;
}

.site-footer-brand {
  color: rgba(92, 64, 51, 0.65);
}

.site-footer-meta a {
  color: rgba(92, 64, 51, 0.7);
  font-weight: 600;
  text-decoration: underline;
}

.site-footer a {
  color: rgba(92, 64, 51, 0.65);
}

/* ---------- Admin mobile ---------- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
}

@media (min-width: 480px) {
  .admin-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.35rem;
  }
}

@media (min-width: 768px) {
  .admin-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 0.4rem;
  }
}

.admin-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid;
  font-size: clamp(0.6rem, 2.5vw, 0.75rem);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  margin: 0;
  font-family: inherit;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.admin-cell.livre { background: #eef8f0; border-color: #6bbf7a; color: #2d6a3e; }
.admin-cell.reservado { background: #fff4e0; border-color: #e8a838; color: #8a5a10; }
.admin-cell.pago { background: #f0eaea; border-color: #8a6e6e; color: #5a4040; }

.admin-cell.selecionavel {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.admin-cell.selecionavel:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(107, 191, 122, 0.35);
}

.admin-cell.selecionavel.selecionado {
  background: #d4849a;
  border-color: #5c4033;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(212, 132, 154, 0.45);
  transform: scale(1.06);
}

.admin-cell:disabled,
.admin-cell[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.9;
}

.pendente-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pendente-card {
  border: 1px solid #e8d8d0;
  border-radius: 14px;
  padding: 0.9rem;
  background: #fff;
}

.pendente-card .acoes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.pendente-card .acoes button {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.8125rem;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-confirmar {
  background: #16a34a;
  color: #fff;
}

.btn-cancelar-reserva {
  background: #fee2e2;
  color: #991b1b;
}

.tabela-desktop {
  display: none;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  min-width: 0;
}

@media (min-width: 768px) {
  .pendente-cards {
    display: none;
  }

  .tabela-desktop {
    display: table;
  }

  .pendente-card .acoes {
    flex-direction: row;
  }
}

.admin-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  font-size: 0.8125rem;
}

@media (max-width: 479px) {
  .admin-stats {
    grid-template-columns: 1fr !important;
  }
}

/* Reduz motion se o usuário preferir */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
