:root {
  --night: #07050b;
  --night-2: #140a17;
  --pink: #f03ea0;
  --pink-soft: #ff7cc4;
  --gold: #e8c98a;
  --gold-hi: #fff1d2;
  --gold-lo: #a8854a;
  --glass: rgba(14, 8, 18, .72);
  --line: rgba(232, 201, 138, .55);
  /* Flayer de la noche: se pone aquí, p. ej. url("fondo.jpg"). */
  --bg-photo: none;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  background-color: var(--night);
  background-image:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(240, 62, 160, .28), transparent 70%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(120, 30, 110, .35), transparent 70%),
    var(--bg-photo);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Velo oscuro sobre el flayer para que la ruleta resalte, y dos luces suaves que se mueven. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 48%, rgba(7, 5, 11, .55) 0%, rgba(7, 5, 11, .25) 45%, rgba(7, 5, 11, .75) 100%);
  z-index: -1;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(circle at 20% 30%, rgba(240, 62, 160, .16), transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(232, 201, 138, .10), transparent 35%);
  animation: haze 18s ease-in-out infinite alternate;
  z-index: -1;
  pointer-events: none;
}
@keyframes haze {
  to { transform: translate(6%, -5%) rotate(8deg); }
}
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
}

button { font: inherit; cursor: pointer; }

/* ---------- Cabecera ---------- */
.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) 16px 4px;
}
h1 {
  margin: 0;
  padding: 0 120px;
  text-align: center;
  font-family: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Noto Serif", serif;
  font-size: clamp(24px, 5vmin, 58px);
  font-weight: 400;
  letter-spacing: .22em;
  text-transform: uppercase;
  line-height: 1.15;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(240, 62, 160, .45));
}
h1::after {
  content: "";
  display: block;
  width: 40%;
  height: 1px;
  margin: .35em auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.top-actions {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
}
.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .35);
  color: rgba(255, 255, 255, .7);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.icon-btn:active { background: rgba(255, 255, 255, .15); }
body.spinning .top-actions { opacity: .2; pointer-events: none; }

/* ---------- Ruleta ---------- */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#wheelWrap { position: relative; }
#wheel { display: block; touch-action: none; }
#hub {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: radial-gradient(circle at 35% 28%, #3a2a36, #120b14 60%, #050307);
  color: var(--gold-hi);
  font-weight: 600;
  letter-spacing: .18em;
  text-indent: .18em;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .55), 0 0 24px rgba(240, 62, 160, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
  padding: 0;
}
#hub:active:not(:disabled) { transform: translate(-50%, -50%) scale(.95); }
#hub:disabled { cursor: default; }

/* ---------- Botón principal ---------- */
.bottom {
  padding: 8px 16px max(22px, env(safe-area-inset-bottom));
  text-align: center;
}
.spin-btn {
  position: relative;
  font-size: clamp(20px, 3.8vmin, 38px);
  font-weight: 600;
  letter-spacing: .32em;
  text-indent: .32em;
  text-transform: uppercase;
  padding: .7em 2.6em;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, rgba(240, 62, 160, .95), #b81d74);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .45), 0 0 28px rgba(240, 62, 160, .65), inset 0 1px 0 rgba(255, 255, 255, .35);
  animation: glow 2.6s ease-in-out infinite;
  transition: transform .1s, filter .2s;
}
@keyframes glow {
  50% { box-shadow: 0 0 0 4px rgba(0, 0, 0, .45), 0 0 46px rgba(240, 62, 160, .9), inset 0 1px 0 rgba(255, 255, 255, .35); }
}
.spin-btn:active:not(:disabled) { transform: scale(.97); }
.spin-btn:disabled { filter: grayscale(.8) brightness(.6); animation: none; cursor: default; }
.spin-btn.small { font-size: clamp(16px, 2.8vmin, 24px); padding: .8em 2em; animation: none; }
#hint {
  margin: 14px 0 0;
  font-size: clamp(11px, 1.7vmin, 15px);
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .7;
}
body.spinning #hint { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .spin-btn { animation: none; }
}

/* ---------- Brillos y avisos ---------- */
#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--glass);
  border: 1px solid var(--line);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 17px;
  letter-spacing: .04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Modales ---------- */
.hidden { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 3, 8, .7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.card {
  --seg: var(--pink);
  position: relative;
  width: min(640px, 100%);
  background: linear-gradient(180deg, rgba(30, 16, 32, .92), rgba(10, 6, 12, .95));
  color: #fff;
  border-radius: 28px;
  border: 1px solid var(--line);
  padding: clamp(28px, 6vmin, 64px) clamp(22px, 4.5vmin, 52px);
  text-align: center;
  box-shadow: 0 0 0 6px rgba(0, 0, 0, .35), 0 0 60px rgba(240, 62, 160, .4), 0 30px 80px rgba(0, 0, 0, .6);
  box-shadow: 0 0 0 6px rgba(0, 0, 0, .35), 0 0 60px color-mix(in srgb, var(--seg) 45%, transparent), 0 30px 80px rgba(0, 0, 0, .6);
  animation: rise .55s cubic-bezier(.2, .9, .3, 1) .1s both;
}
@keyframes rise {
  from { transform: translateY(24px) scale(.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.result-head {
  font-size: clamp(13px, 2.2vmin, 20px);
  font-weight: 600;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--gold);
}
.result-head::after {
  content: "";
  display: block;
  width: 64px;
  height: 1px;
  margin: .9em auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.result-label {
  font-family: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Noto Serif", serif;
  font-size: clamp(36px, 8.5vmin, 88px);
  font-weight: 400;
  line-height: 1.08;
  margin: .4em 0 .6em;
  overflow-wrap: anywhere;
  color: #fff;
  text-shadow: 0 0 28px color-mix(in srgb, var(--seg) 70%, transparent);
}
.result-ticket {
  display: inline-block;
  margin: -.2em 0 1.4em;
  padding: .55em 1.2em;
  border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
  border-radius: 999px;
  font-size: clamp(15px, 2.6vmin, 24px);
  letter-spacing: .04em;
  color: var(--gold);
}
.err { color: #ff8fb1; min-height: 1.2em; margin: 8px 0; font-size: 15px; }

/* ---------- Inicio de sesión y sesión ---------- */
.modal.solid { background: rgba(5, 3, 8, .9); z-index: 45; }
.form-card { width: min(460px, 100%); text-align: left; }
.form-card .result-head { text-align: center; }
.form-sub { text-align: center; color: rgba(255, 255, 255, .6); margin: 14px 0 22px; font-size: 16px; overflow-wrap: anywhere; }
.form-field {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}
.form-field input {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-size: 20px;
  letter-spacing: normal;
  text-transform: none;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  user-select: text;
  -webkit-user-select: text;
}
.form-field input:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px rgba(240, 62, 160, .25); }
.form-card .spin-btn { display: block; width: 100%; padding: .85em 1em; }
.form-card .row { justify-content: flex-end; }

.btn {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .08em;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: transparent;
  color: #fff;
}
.btn:active { background: rgba(255, 255, 255, .08); }
.btn:disabled { opacity: .5; }
.btn.danger-solid { background: #b3123f; border-color: #b3123f; color: #fff; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Estado ---------- */
.net-badge {
  align-self: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(179, 18, 63, .9);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  white-space: nowrap;
}
.closed-msg {
  display: none;
  margin: 0;
  padding: .5em 1.2em;
  font-size: clamp(14px, 2.4vmin, 22px);
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold);
}
body.closed .closed-msg { display: block; }
body.closed #btnSpin, body.closed #hint { display: none; }
body.closed #hub { pointer-events: none; filter: grayscale(.6); }

@media (max-width: 600px) {
  h1 { padding: 0; text-align: left; margin-right: 120px; letter-spacing: .12em; }
  h1::after { margin-left: 0; }
  .top { justify-content: flex-start; }
}
