/* =====================================================
   Gratta e Vinci — CBDWorld
   ===================================================== */

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #0d1f14;
  min-height: 100vh;
}

/* ---- Sfondo pagina ---- */
.page-bg {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(45, 138, 78, .25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(26, 92, 54, .3) 0%, transparent 55%),
    linear-gradient(160deg, #0a1a0f 0%, #142a1c 50%, #0d1f14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

/* ---- Card principale ---- */
.card {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.06),
    0 24px 60px rgba(0, 0, 0, .55),
    0 8px 20px rgba(0, 0, 0, .35);
}

/* ---- Header ---- */
.card-header {
  background: linear-gradient(135deg, #1a5c36 0%, #2d8a4e 60%, #1e7040 100%);
  padding: 22px 24px 18px;
  text-align: center;
  position: relative;
}

.logo-link {
  display: inline-block;
  font-size: 12px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.card-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .5px;
  text-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.demo-badge {
  display: inline-block;
  margin-top: 8px;
  background: #f59e0b;
  color: #000;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---- Body ---- */
.card-body {
  padding: 24px 24px 20px;
}

/* ---- Campagna chiusa ---- */
.closed-msg {
  text-align: center;
  padding: 40px 24px;
}
.closed-icon { font-size: 48px; margin-bottom: 14px; }
.closed-msg p { font-size: 16px; color: #444; margin-bottom: 20px; }

/* ---- Form ---- */
.intro-text {
  font-size: 15px;
  color: #444;
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}
.form-group input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
  color: #111;
  transition: border-color .2s;
  outline: none;
}
.form-group input[type="email"]:focus { border-color: #2d8a4e; }

.consent-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  color: #555;
  line-height: 1.5;
  margin-bottom: 18px;
  cursor: pointer;
}
.consent-label input[type="checkbox"] {
  margin-top: 2px;
  accent-color: #1a5c36;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.consent-label a { color: #1a5c36; }

.form-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---- Pulsante GIOCA ---- */
.btn-play {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #1a5c36, #2d8a4e);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(26, 92, 54, .45);
}
.btn-play:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(26, 92, 54, .5); }
.btn-play:active { transform: translateY(0); }
.btn-play:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Pulsante shop ---- */
.btn-shop {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(135deg, #1a5c36, #2d8a4e);
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  transition: opacity .2s;
}
.btn-shop:hover { opacity: .88; }

/* ---- Scratch card area ---- */
.scratch-hint {
  text-align: center;
  font-size: 14px;
  color: #444;
  margin-bottom: 16px;
  line-height: 1.5;
}

.scratch-outer {
  position: relative;
  width: 100%;
  max-width: 340px;
  height: 210px;
  margin: 0 auto 18px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 2px #d1d5db,
    0 8px 24px rgba(0,0,0,.18);
  user-select: none;
}

/* ---- Prize reveal (layer sotto) ---- */
.prize-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #14532d 0%, #166534 40%, #15803d 100%);
}

/* Colori dinamici applicati via JS in base alla % */
.prize-reveal.color-teal   { background: linear-gradient(135deg, #134e4a, #0f766e); }
.prize-reveal.color-blue   { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); }
.prize-reveal.color-purple { background: linear-gradient(135deg, #4c1d95, #6d28d9); }
.prize-reveal.color-orange { background: linear-gradient(135deg, #9a3412, #ea580c); }
.prize-reveal.color-red    { background: linear-gradient(135deg, #7f1d1d, #dc2626); }
.prize-reveal.color-gold   { background: linear-gradient(135deg, #78350f, #d97706); }

.prize-inner {
  text-align: center;
  color: #fff;
  padding: 12px;
}

.prize-emoji { font-size: 32px; margin-bottom: 4px; }

.prize-won-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255,255,255,.75);
  margin-bottom: 2px;
}

.prize-percent {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.prize-off-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255,255,255,.8);
  margin-top: 2px;
}

.prize-code-box {
  margin-top: 8px;
  background: rgba(255,255,255,.15);
  border: 1px dashed rgba(255,255,255,.5);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.prize-code-label { color: rgba(255,255,255,.7); font-size: 11px; letter-spacing: 1px; display: block; }
.prize-code-value { font-size: 16px; font-weight: 700; letter-spacing: 3px; color: #fff; }

/* ---- Canvas scratch ---- */
#scratchCanvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
  transition: opacity .6s ease;
}

/* ---- Messaggio risultato ---- */
.scratch-message {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  color: #14532d;
  text-align: center;
  line-height: 1.5;
}
.scratch-message.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* ---- Info post-vincita (scadenza + disclaimer) ---- */
.scratch-info {
  text-align: center;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.7;
  margin-top: 8px;
  padding: 10px 14px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.scratch-info strong { color: #374151; }

/* ---- Già giocato ---- */
.already-icon { font-size: 48px; text-align: center; margin-bottom: 12px; }
#stepAlready { text-align: center; }
#stepAlready p { font-size: 15px; color: #444; margin-bottom: 20px; line-height: 1.5; }

/* ---- Win confetti animation ---- */
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(60px) rotate(720deg); opacity: 0; }
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confetti-fall .8s ease-out forwards;
  pointer-events: none;
}

/* ---- Footer ---- */
.card-footer {
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  padding: 10px 24px;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
}
.card-footer a { color: #6b7280; text-decoration: none; }

/* ---- Utility ---- */
.hidden { display: none !important; }

/* ---- Mobile ---- */
@media (max-width: 440px) {
  .card { border-radius: 16px; }
  .card-header { padding: 18px 16px 14px; }
  .card-header h1 { font-size: 19px; }
  .card-body { padding: 20px 16px 16px; }
  .scratch-outer { height: 190px; }
  .prize-percent { font-size: 44px; }
}
