:root {
  --green-950: #062a15;
  --green-900: #0a3d1f;
  --green-800: #0d552b;
  --green-600: #16a044;
  --green-500: #20c65a;
  --green-300: #8de8a7;
  --gold-500: #f6bd16;
  --gold-400: #ffd958;
  --text: #fffaf0;
  --muted: #b9d2bd;
  --border: rgba(255, 255, 255, 0.18);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Inter", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(32, 198, 90, 0.26), transparent 32rem),
    radial-gradient(circle at 85% 20%, rgba(246, 189, 22, 0.16), transparent 24rem),
    linear-gradient(145deg, var(--green-950), var(--green-900) 48%, #073117);
}

button {
  font: inherit;
}

.app-shell {
  width: min(980px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero {
  position: relative;
  width: 100%;
  min-height: min(760px, calc(100vh - 64px));
  padding: clamp(24px, 5vw, 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(5, 55, 25, 0.62);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.admin-button {
  position: absolute;
  top: 18px;
  right: 18px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(141, 232, 167, 0.45);
  border-radius: 999px;
  color: var(--green-300);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.brand-mark {
  position: relative;
  width: clamp(48px, 8vw, 72px);
  aspect-ratio: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.28));
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10%;
  width: 9%;
  height: 42%;
  border-radius: 999px;
  background: linear-gradient(#52dc84, #196234);
  transform: translateX(-50%) rotate(-32deg);
  transform-origin: top;
}

.brand-mark span {
  position: absolute;
  width: 43%;
  aspect-ratio: 1;
  border-radius: 70% 70% 42% 70%;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.55), transparent 26%),
    linear-gradient(145deg, #79f3a3, #17a84c 74%);
}

.brand-mark span:nth-child(1) {
  left: 28%;
  top: 3%;
  transform: rotate(45deg);
}

.brand-mark span:nth-child(2) {
  right: 4%;
  top: 28%;
  transform: rotate(135deg);
}

.brand-mark span:nth-child(3) {
  left: 28%;
  bottom: 4%;
  transform: rotate(225deg);
}

.brand-mark span:nth-child(4) {
  left: 4%;
  top: 28%;
  transform: rotate(315deg);
}

.title-box {
  width: min(760px, 100%);
  padding: 10px 18px 14px;
  border: 2px solid #8b5cf6;
  background: rgba(8, 78, 38, 0.9);
}

h1 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(246, 189, 22, 0.18);
}

.subtitle {
  width: min(690px, 100%);
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: clamp(1rem, 2.6vw, 1.35rem);
  font-weight: 700;
  line-height: 1.35;
}

.base-status {
  margin: 0 0 30px;
  color: var(--green-300);
  font-size: 0.94rem;
  font-weight: 800;
}

.number-panel {
  width: min(760px, 100%);
}

.controls-row {
  width: min(690px, 100%);
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(210px, 1.25fr) minmax(210px, 1.25fr);
  gap: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 8px;
  text-align: left;
}

.field.full {
  width: 100%;
}

.field span {
  color: var(--green-300);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  color: var(--text);
  background: rgba(3, 29, 14, 0.52);
  font-size: 1.15rem;
  font-weight: 800;
  outline: none;
}

.field select {
  cursor: pointer;
}

.field input:focus,
.field select:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 4px rgba(246, 189, 22, 0.12);
}

.numbers-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(74px, 1fr));
  gap: clamp(12px, 2.4vw, 24px);
  justify-items: center;
  align-items: center;
}

.ball {
  width: clamp(72px, 9vw, 98px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2rem, 5vw, 3.15rem);
  font-weight: 800;
  line-height: 1;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.28), transparent 24%),
    linear-gradient(160deg, #35d76b, #0da23f 72%);
  box-shadow:
    inset 0 -10px 18px rgba(0, 0, 0, 0.12),
    0 16px 24px rgba(0, 0, 0, 0.22);
  transform: translateY(0);
}

.ball.pop {
  animation: pop 420ms ease both;
}

.generate-button {
  min-width: min(340px, 100%);
  min-height: 74px;
  margin-top: 0;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #123018;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.generate-button.compact {
  min-width: 0;
  min-height: 52px;
  padding: 0 22px;
  font-size: 1rem;
}

.generate-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 22px 34px rgba(0, 0, 0, 0.3);
}

.generate-button:active {
  transform: translateY(1px);
}

.button-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #f2e9ff;
  background: linear-gradient(135deg, #6d55a8, #261445);
  font-size: 0.85rem;
}

.result-note {
  min-height: 24px;
  margin: 0;
  color: var(--green-300);
  font-size: 0.95rem;
  font-weight: 600;
}

.tickets {
  width: min(760px, 100%);
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

.ticket-card {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(3, 29, 14, 0.36);
}

.ticket-title {
  margin-bottom: 12px;
  color: var(--green-300);
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-numbers {
  display: grid;
  grid-template-columns: repeat(var(--ticket-columns, 6), 1fr);
  gap: 10px;
  justify-items: center;
}

.small-ball {
  width: clamp(48px, 9vw, 74px);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.actions-row {
  width: min(690px, 100%);
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.summary-card {
  width: min(760px, 100%);
  margin-top: 16px;
  padding: 0;
  border: 1px solid rgba(246, 189, 22, 0.28);
  border-radius: 16px;
  background: rgba(246, 189, 22, 0.09);
  overflow: hidden;
}

.summary-card.hidden {
  display: none;
}

.summary-title {
  padding: 16px 16px 10px;
  color: var(--gold-400);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.summary-line,
.summary-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.summary-line {
  min-height: 28px;
  padding: 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.summary-line span,
.summary-total span,
.summary-line strong,
.summary-total strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary-line span,
.summary-total span {
  text-align: left;
}

.summary-line strong,
.summary-total strong {
  text-align: right;
}

.summary-total {
  margin-top: 10px;
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(246, 189, 22, 0.28);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
}

.secondary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid rgba(246, 189, 22, 0.5);
  color: #123018;
  background: var(--gold-400);
}

.secondary-button.outline {
  color: var(--gold-400);
  background: rgba(246, 189, 22, 0.08);
}

.secondary-button.compact,
.ghost-button {
  min-height: 42px;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  position: relative;
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(9, 69, 34, 0.98), rgba(4, 34, 17, 0.98));
  box-shadow: var(--shadow);
}

.small-modal {
  width: min(430px, 100%);
}

.modal-card h2 {
  margin-bottom: 10px;
}

.modal-text {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.4;
}

.modal-heading,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  font-weight: 900;
  cursor: pointer;
}

.error-text {
  min-height: 20px;
  margin: 10px 0;
  color: #ffd4d4;
  font-size: 0.92rem;
  font-weight: 700;
}

.table-wrap {
  margin: 18px 0;
  overflow: auto;
}

.admin-section-title {
  margin-top: 20px;
  color: var(--gold-400);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.base-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.base-table th {
  padding: 0 10px 4px;
  color: var(--green-300);
  text-align: left;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.base-table td {
  padding: 8px;
  background: rgba(3, 29, 14, 0.4);
}

.base-table td:first-child {
  border-radius: 12px 0 0 12px;
}

.base-table td:last-child {
  border-radius: 0 12px 12px 0;
}

.base-table input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  font-weight: 800;
}

.base-table input:disabled {
  color: var(--green-300);
  opacity: 1;
}

.remove-row {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(190, 38, 38, 0.8);
  font-weight: 800;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-300);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h2 {
  margin: 0 0 18px;
  font-size: 1.45rem;
  line-height: 1.15;
}

@keyframes pop {
  0% {
    opacity: 0.3;
    transform: translateY(16px) scale(0.82);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 940px) {
  .app-shell {
    align-items: start;
  }

  .hero {
    min-height: auto;
  }

}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px;
  }

  .hero,
  .modal-card {
    border-radius: 20px;
  }

  .admin-button {
    position: static;
    align-self: flex-end;
    margin-bottom: 14px;
  }

  .controls-row {
    grid-template-columns: 1fr;
  }

  .ticket-numbers {
    grid-template-columns: repeat(3, 1fr);
  }

  .generate-button {
    min-height: 64px;
    margin-top: 34px;
  }
}

@media (max-width: 390px) {
  .hero {
    padding: 22px 14px;
  }

  .numbers-grid {
    gap: 10px;
  }

  .ball {
    width: 68px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }

  @page receipt {
    size: 80mm auto;
    margin: 4mm;
  }

  @page sheet {
    size: A4;
    margin: 14mm;
  }

  body {
    min-height: auto;
    color: #000;
    background: #fff;
  }

  body.print-80mm {
    page: receipt;
  }

  body.print-a4 {
    page: sheet;
  }

  .brand-mark,
  .title-box,
  .subtitle,
  .base-status,
  .controls-row,
  .actions-row,
  .admin-button,
  .modal-backdrop {
    display: none !important;
  }

  .app-shell,
  .hero {
    width: 100%;
    min-height: auto;
    padding: 0;
    margin: 0;
    display: block;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }

  .tickets {
    width: calc(100% - 2mm);
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4mm;
    padding-right: 1mm;
  }

  .ticket-card {
    break-inside: avoid;
    width: 100%;
    min-width: 0;
    padding: 4mm;
    border: 0;
    outline: 1px solid #000;
    outline-offset: -1px;
    border-radius: 2mm;
    background: #fff;
  }

  .ticket-title {
    margin-bottom: 2mm;
    color: #000;
    font-size: 11pt;
    text-align: center;
  }

  .ticket-numbers {
    grid-template-columns: repeat(6, 1fr);
    gap: 2.5mm;
  }

  .ball,
  .small-ball {
    width: 9mm;
    color: #000;
    border: 1px solid #000;
    background: #fff;
    box-shadow: none;
    font-family: Arial, sans-serif;
    font-size: 10pt;
  }

  .summary-card {
    width: calc(100% - 2mm);
    margin-top: 6mm;
    padding: 0;
    border: 1px solid #000;
    outline: 0;
    border-radius: 2mm;
    background: #fff;
    color: #000;
    overflow: hidden;
  }

  .summary-title,
  .summary-line,
  .summary-total {
    color: #000;
  }

  .summary-title {
    padding: 5mm 5mm 2mm;
    font-size: 11pt;
    text-align: center;
  }

  .summary-line,
  .summary-total {
    min-height: 6mm;
    font-size: 10pt;
    grid-template-columns: minmax(0, 1fr) minmax(24mm, auto);
    gap: 3mm;
  }

  .summary-line {
    padding: 0 5mm;
  }

  .summary-total {
    border-top: 1px solid #000;
    border-bottom: 0;
    padding: 3mm 5mm 4mm;
    font-size: 12pt;
  }

  body.print-80mm .app-shell,
  body.print-80mm .hero {
    width: 72mm;
  }

  body.print-80mm .tickets {
    width: 72mm;
    grid-template-columns: 1fr;
    gap: 3mm;
    padding-right: 0;
  }

  body.print-80mm .ticket-card {
    padding: 3mm 0;
    border: 0;
    outline: 0;
    border-bottom: 1px dashed #000;
    border-radius: 0;
  }

  body.print-80mm .ticket-numbers {
    gap: 1.5mm;
  }

  body.print-80mm .summary-card {
    width: 72mm;
    margin-top: 3mm;
    padding: 0;
    border: 0;
    outline: 0;
    border-radius: 0;
  }

  body.print-80mm .summary-title {
    padding: 3mm 0 1mm;
    text-align: center;
  }

  body.print-80mm .summary-line,
  body.print-80mm .summary-total {
    grid-template-columns: minmax(0, 1fr);
    gap: 1mm;
    min-height: auto;
    padding: 1mm 0;
    text-align: center;
  }

  body.print-80mm .summary-line strong,
  body.print-80mm .summary-total strong {
    text-align: center;
  }

  body.print-80mm .summary-total {
    margin-top: 2mm;
    padding-top: 2mm;
    font-size: 11pt;
  }

  body.print-a4::before {
    content: "Simulador Mega-Sena";
    display: block;
    margin-bottom: 6mm;
    color: #000;
    font-family: Arial, sans-serif;
    font-size: 18pt;
    font-weight: 900;
    text-align: center;
  }
}
