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

:root{
  --bg:#0D0E11;
  --card:#1A1C22;
  --red:#E8251A;
  --green:#00A264;
  --green2:#00C278;
  --gold:#F5C518;
  --text:#FFFFFF;
  --muted:#9AA0AC;
}

html,body{
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  min-height:100vh;
  overflow-x:hidden;
}

/* HEADER */
.site-header{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  border-bottom:1px solid rgba(255,255,255,0.07);
}
.logo-img{height:36px;width:auto;object-fit:contain}

/* MAIN */
.main{
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:32px 20px 48px;
  max-width:560px;
  margin:0 auto;
  text-align:center;
}

.title{
  font-size:clamp(26px,7vw,38px);
  font-weight:800;
  line-height:1.2;
  margin-bottom:12px;
}
.gold{color:var(--gold)}

.subtitle{
  font-size:15px;
  color:var(--muted);
  line-height:1.5;
  max-width:360px;
  margin-bottom:28px;
}
.subtitle strong{color:var(--text)}

/* ATTEMPTS */
.attempts-row{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:6px;
}
.gem{
  width:14px;height:14px;
  border-radius:50%;
  background:rgba(255,255,255,0.15);
  border:2px solid rgba(255,255,255,0.2);
  transition:background .3s, border-color .3s;
}
.gem.used{background:var(--red);border-color:var(--red)}
.gem-line{width:48px;height:2px;background:rgba(255,255,255,0.12);border-radius:1px}
.attempts-text{font-size:13px;color:var(--muted);margin-bottom:24px}
.attempts-text strong{color:var(--text)}

/* CHESTS GRID */
.chests-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
  width:100%;
  max-width:480px;
  margin-bottom:20px;
}

.chest-card{
  aspect-ratio:1;
  background:var(--card);
  border-radius:14px;
  border:2px solid rgba(255,255,255,0.08);
  cursor:pointer;
  position:relative;
  perspective:600px;
  transition:border-color .2s, transform .15s;
  animation:float 3.5s ease-in-out infinite;
}
.chest-card:nth-child(2){animation-delay:-.6s}
.chest-card:nth-child(3){animation-delay:-1.2s}
.chest-card:nth-child(4){animation-delay:-1.8s}
.chest-card:nth-child(5){animation-delay:-.4s}
.chest-card:nth-child(6){animation-delay:-1.0s}
.chest-card:nth-child(7){animation-delay:-2.1s}
.chest-card:nth-child(8){animation-delay:-2.8s}

@keyframes float{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-5px)}
}

.chest-card:hover:not(.opened):not(.chest-locked){
  border-color:var(--red);
  transform:translateY(-4px) scale(1.03);
  animation:none;
}
.chest-card.chest-locked{opacity:.35;cursor:default}

.chest-inner{
  width:100%;height:100%;
  position:relative;
  transform-style:preserve-3d;
  transition:transform .55s cubic-bezier(.4,0,.2,1);
  border-radius:12px;
}
.chest-card.opened .chest-inner{transform:rotateY(180deg)}

.chest-front,.chest-back{
  position:absolute;inset:0;
  display:flex;align-items:center;justify-content:center;
  backface-visibility:hidden;
  border-radius:12px;
  padding:8px;
}
.chest-back{transform:rotateY(180deg)}
.chest-front img,.chest-back img{width:100%;height:100%;object-fit:contain}

.chest-card.chest-winner{border-color:var(--gold);box-shadow:0 0 20px rgba(245,197,24,.35)}

/* HINT */
.hint{
  font-size:13px;
  color:var(--muted);
  margin-bottom:32px;
}

/* CTA */
.btn-cta{
  display:block;
  width:100%;
  max-width:380px;
  background:linear-gradient(135deg,var(--green),var(--green2));
  color:#fff;
  text-decoration:none;
  font-size:16px;
  font-weight:700;
  padding:16px 24px;
  border-radius:12px;
  margin-bottom:12px;
  transition:transform .15s,box-shadow .15s;
  box-shadow:0 4px 20px rgba(0,162,100,.35);
}
.btn-cta:hover{transform:translateY(-2px);box-shadow:0 8px 28px rgba(0,162,100,.5)}
.btn-cta:active{transform:scale(.97)}

.fine{font-size:11px;color:var(--muted)}

/* WIN OVERLAY */
.win-overlay{
  display:none;
  position:fixed;inset:0;
  background:rgba(0,0,0,.82);
  z-index:100;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.win-overlay.active{display:flex}

.win-card{
  background:#1A1C22;
  border:2px solid var(--gold);
  border-radius:20px;
  padding:32px 24px;
  text-align:center;
  max-width:340px;
  width:100%;
  position:relative;
  box-shadow:0 0 40px rgba(245,197,24,.2);
}
.win-confetti{position:absolute;inset:0;overflow:hidden;border-radius:20px;pointer-events:none}
.win-icon{font-size:48px;margin-bottom:8px}
.win-title{font-size:28px;font-weight:800;margin-bottom:16px}

.win-chest-img{
  width:120px;height:120px;
  object-fit:contain;
  margin:0 auto 12px;
  display:block;
}
.win-amount{
  font-size:32px;font-weight:900;
  color:var(--gold);
  margin-bottom:8px;
}
.win-desc{font-size:14px;color:var(--muted);margin-bottom:20px;line-height:1.5}

.win-timer-wrap{margin-bottom:20px}
.win-timer-label{font-size:12px;color:var(--muted);margin-bottom:4px}
.win-timer{font-size:28px;font-weight:800;color:var(--red);letter-spacing:2px}

.btn-resgatar{
  display:block;
  background:linear-gradient(135deg,var(--green),var(--green2));
  color:#fff;
  text-decoration:none;
  font-size:16px;font-weight:700;
  padding:15px 24px;
  border-radius:12px;
  transition:transform .15s;
  box-shadow:0 4px 20px rgba(0,162,100,.4);
}
.btn-resgatar:hover{transform:translateY(-2px)}

/* CONFETTI */
.confetti-p{
  position:absolute;
  animation:confetti-fall 1.1s ease-in forwards;
}
@keyframes confetti-fall{
  0%{transform:translateY(0) rotate(0);opacity:1}
  100%{transform:translateY(200px) rotate(360deg);opacity:0}
}

/* TOASTS */
#toast-container{
  position:fixed;bottom:20px;left:50%;transform:translateX(-50%);
  width:calc(100% - 32px);max-width:360px;
  z-index:200;display:flex;flex-direction:column;gap:8px;align-items:center;
}
.toast-notif{
  background:#1E2129;
  border:1px solid rgba(255,255,255,0.1);
  border-left:3px solid var(--red);
  border-radius:10px;
  padding:10px 14px;
  display:flex;align-items:center;gap:10px;
  width:100%;
  box-shadow:0 4px 16px rgba(0,0,0,.4);
  animation:toast-in .3s ease;
}
.toast-notif.hiding{animation:toast-out .3s ease forwards}
@keyframes toast-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
@keyframes toast-out{to{opacity:0;transform:translateY(10px)}}
.toast-avatar{
  width:32px;height:32px;border-radius:50%;
  background:linear-gradient(135deg,var(--red),#c0392b);
  display:flex;align-items:center;justify-content:center;
  font-size:11px;font-weight:700;flex-shrink:0;
}
.toast-body{flex:1;min-width:0}
.toast-name{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.toast-action{font-size:11px;color:var(--muted)}
.toast-action em{color:var(--green2);font-style:normal}
.toast-time{font-size:10px;color:var(--muted);flex-shrink:0}
