@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Fraunces:opsz,wght@9..144,700;9..144,800&display=swap");

:root {
  --brand-primary: #199e70;
  --brand-secondary: #0d7a56;
  --brand-accent: #d4af37;
  --brand-bg: #0b1210;
  --brand-text: #f4f7f5;
  --brand-rim: #c9a227;
  --panel: #121a17;
  --muted: rgba(244, 247, 245, 0.62);
  --line: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--brand-text);
  background: var(--brand-bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  min-height: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(16px + var(--safe-top)) 20px calc(16px + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(25, 158, 112, 0.28), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 90%, rgba(212, 175, 55, 0.12), transparent 50%),
    radial-gradient(ellipse 40% 35% at 8% 70%, rgba(25, 158, 112, 0.1), transparent 45%),
    linear-gradient(165deg, #0a100e 0%, #0f1a16 45%, #0b1210 100%);
}

#app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  animation: rise 0.7s ease both;
}

.brand-block {
  max-width: min(720px, 100%);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brand-primary);
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  background: var(--brand-accent);
}

h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.8rem, 4.5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 10px 0 0;
  max-width: 36ch;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--brand-text);
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  box-shadow: 0 10px 28px rgba(25, 158, 112, 0.35);
  min-width: 180px;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  padding: 1rem 1.8rem;
}

.btn-primary.is-spinning {
  animation: pulse 1s ease-in-out infinite;
}

.btn-accent {
  background: linear-gradient(135deg, var(--brand-accent), #a8891f);
  color: #1a1a19;
  border: none;
}

.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--brand-text);
  font-size: 1.25rem;
  cursor: pointer;
}

.btn-icon.danger:hover {
  background: rgba(220, 60, 60, 0.2);
  border-color: rgba(220, 60, 60, 0.45);
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  animation: rise 0.85s 0.08s ease both;
}

.wheel-wrap {
  position: relative;
  width: min(72vh, 92vw, 560px);
  aspect-ratio: 1;
  filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.5));
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 34px solid var(--brand-accent);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
  z-index: 3;
}

.pointer::after {
  content: "";
  position: absolute;
  top: -34px;
  left: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff6c8;
  box-shadow: 0 0 12px rgba(255, 246, 200, 0.8);
}

.center-logo {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  height: 22%;
  border-radius: 50%;
  object-fit: cover;
  background: #101512;
  border: 3px solid var(--brand-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 2;
  pointer-events: none;
}

.footer-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: rise 0.9s 0.14s ease both;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.hint kbd {
  display: inline-block;
  padding: 0.1em 0.45em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8em;
}

/* Painel config */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}

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

.panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 0.3s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: calc(16px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
}

.panel.is-open {
  transform: translateX(0);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.panel-body {
  overflow: auto;
  flex: 1;
  padding-right: 4px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--brand-text);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.color-row input[type="color"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
  font-weight: 800;
}

.weight-sum {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-primary);
}

.weight-sum.warn {
  color: #ff7b7b;
}

.prize-row {
  display: grid;
  grid-template-columns: 42px 1fr 70px 42px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.prize-row input[type="color"] {
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  padding: 0;
}

.prize-row input[type="text"],
.prize-row input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--brand-text);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  font: inherit;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.panel-actions .btn {
  border-radius: 12px;
  width: 100%;
}

.panel-actions .wide {
  grid-column: 1 / -1;
}

/* Resultado */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 60;
  padding: 20px;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(440px, 100%);
  background:
    radial-gradient(circle at 50% 0%, rgba(25, 158, 112, 0.35), transparent 55%),
    #121a17;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateY(16px) scale(0.96);
  transition: transform 0.3s ease;
}

.modal.is-open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
}

.modal-card h2 {
  margin: 12px 0 22px;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  color: var(--brand-accent);
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 70;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall 2.4s var(--delay) ease-in forwards;
  transform: rotate(var(--rot));
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(calc(var(--rot) + 240deg));
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 10px 28px rgba(25, 158, 112, 0.35);
  }
  50% {
    box-shadow: 0 10px 36px rgba(212, 175, 55, 0.45);
  }
}

/* TV / desktop amplo */
@media (min-width: 1100px) {
  #app {
    padding: 28px 40px 32px;
  }

  .wheel-wrap {
    width: min(74vh, 640px);
  }

  .btn-primary {
    min-width: 220px;
    font-size: 1.35rem;
    padding: 1.15rem 2.2rem;
  }
}

/* Mobile */
@media (max-width: 700px) {
  #app {
    padding: calc(12px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  }

  .topbar {
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  h1 {
    font-size: 1.7rem;
  }

  .hint {
    display: none;
  }

  .wheel-wrap {
    width: min(78vw, 420px);
  }
}

/* Landscape phone / TV short */
@media (max-height: 520px) and (orientation: landscape) {
  #app {
    grid-template-columns: 1fr 1.1fr;
    grid-template-rows: 1fr;
    align-items: center;
    gap: 12px;
  }

  .topbar {
    grid-column: 1;
    flex-direction: column;
  }

  .stage {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .footer-actions {
    grid-column: 1;
  }

  .wheel-wrap {
    width: min(86vh, 420px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
