:root {
  --pink: #D4537E;
  --pink-deep: #B03A64;
  --cream: #FBF3EE;
  --black: #1A1A1A;
  --gray: #6E666E;
  --white: #FFFFFF;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, sans-serif;
  background: linear-gradient(160deg, var(--pink) 0%, #f3b8c8 35%, var(--cream) 100%);
  min-height: 100vh;
  color: var(--black);
}

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 20px 60px; }

.topbar {
  position: relative;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 18px 40px;
  width: 100%;
}
.logo-img { height: 56px; width: auto; justify-self: start; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25)); }

.main-nav { display: flex; gap: 32px; justify-self: center; }
.main-nav a {
  color: var(--black); text-decoration: none; font-weight: 600; font-size: 15px;
  opacity: 0.85; transition: opacity 0.15s;
}
.main-nav a:hover { opacity: 1; text-decoration: underline; }

.user-chip { justify-self: end; }

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr; justify-items: center; padding: 16px 20px; gap: 12px; }
  .logo-img { justify-self: center; height: 44px; }
  .user-chip { position: absolute; top: 16px; right: 20px; }
}

.user-chip { display: flex; align-items: center; gap: 10px; position: relative; }
.user-chip.hidden { display: none; }
.balance-chip {
  background: var(--black); color: var(--cream); font-weight: 700; font-size: 14px;
  padding: 8px 14px; border-radius: 999px;
}
.user-icon-btn {
  width: 42px; height: 42px; border-radius: 50%; background: white; border: none;
  display: flex; align-items: center; justify-content: center; color: var(--pink-deep);
  cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
.user-dropdown {
  position: absolute; top: 46px; right: 0; background: white; border-radius: 14px;
  padding: 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); display: flex;
  flex-direction: column; gap: 8px; min-width: 180px; z-index: 10;
}
.user-dropdown span { font-size: 12.5px; color: var(--gray); word-break: break-all; }

.link-btn {
  background: none; border: none; color: var(--pink-deep); font-family: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; padding: 4px; text-align: left;
}

.card {
  background: var(--white); border-radius: 22px; padding: 32px 26px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
}
.login-card h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; }
.sub { font-size: 14px; color: var(--gray); margin: 0 0 22px; }
.sub.small { font-size: 13px; margin-bottom: 16px; }

input[type="email"], input[type="text"] {
  width: 100%; font-family: inherit; font-size: 16px; padding: 13px 14px;
  border-radius: 12px; border: 1.5px solid #eee; outline: none; margin-bottom: 12px;
  background: #fafafa; color: var(--black);
}
input:focus { border-color: var(--pink); background: white; }
#code-input { text-align: center; letter-spacing: 8px; font-weight: 700; font-size: 22px; }

.btn-primary {
  width: 100%; background: var(--black); color: var(--cream); border: none;
  padding: 14px; border-radius: 999px; font-family: inherit; font-size: 15px;
  font-weight: 600; cursor: pointer;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error {
  color: #c0392b; font-size: 13px; margin-top: 12px; background: #fdecea;
  padding: 10px 12px; border-radius: 10px;
}

/* --- menu de maquinas --- */
.menu-title { font-size: 24px; font-weight: 700; margin: 6px 0 20px; }
.machines-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.machine-card {
  background: white; border-radius: 18px; padding: 14px; text-align: center;
  box-shadow: 0 10px 24px rgba(0,0,0,0.10); cursor: pointer; border: none; font-family: inherit;
}
.machine-card img {
  width: 100%; height: 120px; object-fit: contain; margin-bottom: 10px;
}
.machine-card .m-name { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.machine-card .m-cost { font-size: 13px; color: var(--pink-deep); font-weight: 700; }
.machine-card:disabled { opacity: 0.45; cursor: not-allowed; }
.machine-card .m-soldout { font-size: 11.5px; color: var(--gray); margin-top: 4px; }

/* --- pantalla de juego --- */
.back-link { margin-bottom: 14px; display: inline-block; }
.play-header { text-align: center; margin-bottom: 20px; }
.play-image { width: 160px; height: 160px; object-fit: contain; margin-bottom: 10px; }
.play-header h2 { margin: 0 0 8px; font-size: 22px; }
.cost-pill {
  display: inline-block; background: var(--black); color: var(--cream);
  padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
}

.prizes-preview {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 18px;
}
.prize-chip {
  flex: 0 0 auto; width: 72px; text-align: center; font-size: 11px; color: var(--gray);
}
.prize-chip img {
  width: 64px; height: 64px; object-fit: contain; background: white; border-radius: 12px;
  padding: 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.08); margin-bottom: 4px;
}
.prize-chip.agotado { opacity: 0.4; }

.btn-pull {
  display: block; width: 100%; background: var(--pink-deep); color: white; border: none;
  padding: 16px; border-radius: 999px; font-family: inherit; font-size: 16px; font-weight: 700;
  cursor: pointer; box-shadow: 0 10px 24px rgba(176,58,100,0.35);
}
.btn-pull:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-pull.shaking { animation: shake 0.5s infinite; }
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-1.5deg); }
  75% { transform: rotate(1.5deg); }
}

.prize-reveal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.prize-reveal-card { background: white; border-radius: 24px; padding: 36px 28px; text-align: center; max-width: 340px; }
.prize-reveal-emoji { font-size: 44px; }
.prize-reveal-card h2 { margin: 6px 0 14px; font-size: 24px; }
.prize-name { font-size: 20px; font-weight: 700; color: var(--pink-deep); margin: 0 0 10px; }
.prize-note { font-size: 13px; color: var(--gray); margin-bottom: 22px; }

.history-block { margin-top: 30px; }
.history-block h3 { font-size: 14px; color: var(--gray); margin-bottom: 10px; font-weight: 600; }
.history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li {
  background: white; border-radius: 12px; padding: 12px 14px; font-size: 13.5px;
  display: flex; justify-content: space-between; box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.history-list .hist-status {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; background: #fdf1f4; color: var(--pink-deep);
  font-weight: 600; text-transform: uppercase;
}
