:root {
  --bg: #1c1420;
  --bg-2: #2a1f30;
  --gold: #e8c15a;
  --cream: #f7f1e3;
  --muted: #b9aec4;
  --danger: #e06c75;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg), var(--bg-2));
  color: var(--cream);
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.game-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  text-align: center;
  color: var(--gold);
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.warning {
  background: rgba(224, 108, 117, 0.15);
  border: 1px solid var(--danger);
  color: #f0a8ae;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  text-align: center;
}

.field-label {
  margin-bottom: 8px;
  font-weight: 600;
}

.spin-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  flex: 1 1 calc(50% - 10px);
  min-width: 100px;
  padding: 10px;
  border: 2px solid rgba(232, 193, 90, 0.35);
  border-radius: 12px;
  background: transparent;
  color: var(--cream);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chip.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #241a08;
}

.total {
  text-align: center;
  font-size: 1.2rem;
}

.total strong {
  color: var(--gold);
  font-size: 1.5rem;
}

.pix-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#qr-code {
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  width: 180px;
  height: 180px;
  max-width: 45vw;
  max-height: 45vw;
}

.pix-label {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.pix-code-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

#pix-code {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--cream);
  font-size: 0.75rem;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
}

#btn-copy {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--cream);
}

.primary {
  background: var(--gold);
  color: #241a08;
  font-size: 1.05rem;
  padding: 16px;
}

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

.spins-left {
  text-align: center;
  color: var(--muted);
}

.spins-left strong {
  color: var(--gold);
  font-size: 1.3rem;
}

.wheel-wrap {
  position: relative;
  width: min(78vw, 340px);
  margin: 0 auto;
}

#wheel {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.12));
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 22px solid var(--gold);
  filter: drop-shadow(0 0 8px rgba(232, 193, 90, 0.65)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
  z-index: 2;
}

.result {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
  /* Espaço reservado para a imagem (96px) + texto, evitando
     que o layout "pule" quando o resultado aparece. */
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Quando oculto, mantém o espaço reservado (sem display:none)
   para não mover o botão "Girar" ao anunciar o item. */
#result.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.result-image {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px;
}

.out-of-spins {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.out-of-spins p {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Telas pequenas: compacta para caber tudo sem scroll */
@media (max-height: 720px) {
  .app { padding: 12px 16px 16px; }
  .screen { gap: 10px; }
  .game-title { font-size: 1.3rem; }
  #qr-code { width: 150px; height: 150px; max-width: 40vw; max-height: 40vw; padding: 6px; }
  .pix-label { font-size: 0.8rem; }
  .total { font-size: 1rem; }
  .total strong { font-size: 1.3rem; }
  .primary { padding: 12px; font-size: 1rem; }
  .chip { padding: 8px; font-size: 0.9rem; }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.modal-content {
  position: relative;
  background: var(--bg-2);
  border: 1px solid rgba(232, 193, 90, 0.25);
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
}

.surprise-carousel {
  width: min(70vw, 300px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  overflow: hidden;
}

#surprise-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.surprise-filename {
  margin: 0;
  padding: 4px 8px 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  word-break: break-word;
  min-height: 1.2em;
}

#surprise-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

#surprise-actions.hidden {
  display: none;
}
