/* ==========================================================================
   Justeen Miracle — Christmas Lucky Draw (v5 BETA Player Edition)
   Royal Navy (#001871), Ice Frost Blue (#38BDF8), Snow White, Champagne Gold
   ========================================================================== */

:root {
  --jm-navy: #001871;
  --jm-navy-deep: #000b3b;
  --jm-ice: #38bdf8;
  --jm-ice-soft: #bae6fd;
  --jm-gold: #f5c563;
  --jm-gold-bright: #ffe29a;
  --jm-gold-deep: #c98f22;
  --jm-green: #22c55e;
  --jm-text: #ffffff;
  --jm-muted: rgba(219, 234, 254, 0.8);
  --shadow-card: 0 18px 42px rgba(0, 8, 42, 0.48);
  --font-sans: 'Kantumruy Pro', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', 'Kantumruy Pro', Georgia, serif;
}

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

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--jm-text);
  background: radial-gradient(circle at 18% 12%, #1237b5 0%, #001871 42%, #000930 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.ambient-glow {
  position: fixed; pointer-events: none; border-radius: 50%; filter: blur(80px); z-index: 0; opacity: 0.45;
}
.glow-1 { width: 420px; height: 420px; top: -120px; left: -100px; background: radial-gradient(circle, rgba(56,189,248,0.42), transparent 70%); }
.glow-2 { width: 480px; height: 480px; bottom: -160px; right: -120px; background: radial-gradient(circle, rgba(245,197,99,0.3), transparent 70%); }

#snow-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

.app-shell {
  position: relative; z-index: 2; min-height: 100dvh; display: flex; flex-direction: column;
  max-width: 980px; margin: 0 auto; padding: 12px 14px 24px;
}

/* Top Bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }

.brand-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--jm-gold-bright), var(--jm-gold-deep));
  box-shadow: 0 0 12px var(--jm-gold);
}
.brand-pill-title { font-family: var(--font-display); font-weight: 700; font-size: 0.94rem; color: #fff; }
.beta-tag {
  font-size: 0.64rem; font-weight: 800; padding: 2px 7px; border-radius: 999px;
  background: rgba(245,197,99,0.22); border: 1px solid rgba(245,197,99,0.55); color: var(--jm-gold-bright);
  letter-spacing: 0.04em;
}

.topbar-controls { display: flex; align-items: center; gap: 7px; }

.btn-my-ticket-top {
  display: none; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px;
  border: 1.5px solid var(--jm-gold); background: rgba(245,197,99,0.2); color: var(--jm-gold-bright);
  font-family: var(--font-sans); font-size: 0.78rem; font-weight: 700; cursor: pointer;
  animation: softGlow 2.4s ease-in-out infinite;
}
.btn-my-ticket-top.show { display: inline-flex; }
@keyframes softGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,197,99,0.3); }
  50% { box-shadow: 0 0 16px 2px rgba(245,197,99,0.55); }
}

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.1); color: #fff; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; backdrop-filter: blur(10px);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.2); border-color: var(--jm-gold); }
.icon-btn.is-off { opacity: 0.55; color: var(--jm-ice-soft); }
.icon-btn svg { width: 18px; height: 18px; }

/* Screens */
.screen {
  flex: 1; display: none; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(14px); transition: opacity 0.36s ease, transform 0.36s ease;
}
.screen.active { display: flex; }
.screen.visible { opacity: 1; transform: translateY(0); }

/* Screen 1: Welcome */
.welcome-wrap {
  width: 100%; max-width: 680px; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 15px; padding: 4px 0 12px;
}

.festive-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 15px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(245,197,99,0.18), rgba(56,189,248,0.18));
  border: 1px solid rgba(245,197,99,0.45); color: var(--jm-gold-bright);
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em;
}

.hero-frame {
  position: relative; width: 100%; max-width: 600px; padding: 10px; border-radius: 26px;
  background: linear-gradient(145deg, rgba(255,255,255,0.24), rgba(186,230,253,0.12), rgba(245,197,99,0.28));
  box-shadow: 0 22px 58px rgba(0,7,40,0.55), 0 0 0 1px rgba(255,255,255,0.22) inset;
  animation: heroFloat 5.5s ease-in-out infinite;
}
@keyframes heroFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.hero-inner {
  width: 100%; aspect-ratio: 16 / 10; border-radius: 18px; background: #ffffff;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.hero-inner img, .hero-inner svg { width: 100%; height: 100%; object-fit: contain; display: block; }

.welcome-title {
  font-family: var(--font-display); font-size: clamp(1.6rem, 4.2vw, 2.45rem); font-weight: 800; line-height: 1.18;
  background: linear-gradient(180deg, #ffffff 15%, #dbeafe 65%, #f5c563 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.welcome-slogan { font-size: clamp(0.92rem, 2.2vw, 1.1rem); color: var(--jm-ice-soft); font-weight: 500; line-height: 1.55; max-width: 540px; }

.sub-brands-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; }
.sub-brand-chip {
  font-size: 0.74rem; font-weight: 600; color: rgba(255,255,255,0.92); padding: 4px 11px;
  border-radius: 999px; background: rgba(255,255,255,0.09); border: 1px solid rgba(186,230,253,0.24);
}

.welcome-actions {
  display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 360px;
}

/* Primary Buttons */
.btn-cta {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 38px; border-radius: 999px; border: 2px solid var(--jm-gold-bright);
  background: linear-gradient(135deg, #ffe29a 0%, #f5c563 48%, #d49622 100%);
  color: #00145c; font-family: var(--font-sans); font-size: 1.06rem; font-weight: 800;
  cursor: pointer; box-shadow: 0 14px 32px rgba(245,197,99,0.38), 0 0 0 4px rgba(245,197,99,0.14);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.22s ease;
  overflow: hidden;
}
.btn-cta::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 55%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
  transform: skewX(-22deg); animation: shimmerSweep 3.2s infinite;
}
@keyframes shimmerSweep { 0%, 60% { left: -100%; } 100% { left: 160%; } }
.btn-cta:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.btn-cta:active:not(:disabled) { transform: scale(0.97); }
.btn-cta:disabled { opacity: 0.65; cursor: not-allowed; }

.btn-spin-ready {
  background: linear-gradient(135deg, #86efac 0%, #22c55e 48%, #15803d 100%) !important;
  border-color: #dcfce7 !important;
  color: #052e16 !important;
  box-shadow: 0 14px 38px rgba(34,197,94,0.52), 0 0 0 6px rgba(34,197,94,0.22) !important;
  animation: pulseSpin 1.3s ease-in-out infinite;
}
@keyframes pulseSpin {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.08); color: #e0f2fe; font-family: var(--font-sans);
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: background 0.16s ease, border-color 0.16s ease;
}
.btn-ghost:hover { background: rgba(255,255,255,0.16); border-color: var(--jm-gold); color: #fff; }

.btn-recover-link {
  background: rgba(56,189,248,0.12); border: 1px dashed rgba(186,230,253,0.45);
  color: #e0f2fe; padding: 9px 16px; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; font-family: var(--font-sans); transition: all 0.18s ease;
}
.btn-recover-link:hover { background: rgba(56,189,248,0.22); border-color: var(--jm-gold); color: #fff; }

/* Screen 2: 3x3 Prize Grid */
.game-wrap { width: 100%; max-width: 780px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.game-header { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.game-heading-group { text-align: center; flex: 1; }
.game-title { font-family: var(--font-display); font-size: clamp(1.18rem, 3vw, 1.65rem); font-weight: 800; color: #fff; }
.game-subtitle { font-size: 0.8rem; color: var(--jm-ice-soft); margin-top: 2px; }

/* Verified Code Ready Banner */
.verified-banner {
  display: none; width: 100%; padding: 11px 16px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(34,197,94,0.22), rgba(56,189,248,0.16));
  border: 1.5px solid #4ade80; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; font-size: 0.86rem; color: #dcfce7;
}
.verified-banner.show { display: flex; }

.board-frame {
  width: 100%; padding: 12px; border-radius: 24px;
  background: linear-gradient(155deg, rgba(255,255,255,0.16), rgba(14,42,138,0.45), rgba(0,15,76,0.72));
  border: 1.5px solid rgba(245,197,99,0.36); box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.prize-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.prize-tile {
  position: relative; display: flex; flex-direction: column; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.97) 0%, #eef5ff 100%);
  border: 2px solid rgba(186,230,253,0.55); padding: 9px 7px 8px; color: var(--jm-navy);
  overflow: hidden; transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  box-shadow: 0 8px 18px rgba(0,12,66,0.24); user-select: none;
}
.prize-tile.grand-prize {
  background: linear-gradient(180deg, #fffdf5 0%, #fff4d2 100%);
  border: 2.5px solid var(--jm-gold);
}
.prize-tile.is-active {
  transform: scale(1.045); border-color: #ffe89e;
  box-shadow: 0 0 0 4px #f5c563, 0 0 32px rgba(245,197,99,0.95); z-index: 4;
}
.prize-tile.is-winner {
  transform: scale(1.06); border-color: #ffffff;
  box-shadow: 0 0 0 5px var(--jm-gold), 0 0 44px rgba(255,226,154,1); z-index: 5;
  animation: winnerPulse 0.65s ease-in-out infinite alternate;
}
@keyframes winnerPulse {
  from { box-shadow: 0 0 0 4px var(--jm-gold), 0 0 26px rgba(255,226,154,0.9); }
  to { box-shadow: 0 0 0 6px #fff, 0 0 48px rgba(245,197,99,1); }
}

.tile-badges { position: absolute; top: 5px; left: 5px; right: 5px; display: flex; justify-content: space-between; z-index: 2; pointer-events: none; }
.badge-grand {
  padding: 2px 6px; border-radius: 999px; background: linear-gradient(135deg, #001871, #1e3fa8);
  color: var(--jm-gold-bright); font-size: 0.6rem; font-weight: 800;
}
.badge-brand {
  padding: 2px 6px; border-radius: 999px; background: rgba(0,24,113,0.08); color: var(--jm-navy);
  font-size: 0.56rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 86%;
}

.tile-img-wrap {
  width: 100%; aspect-ratio: 4 / 3; margin-top: 15px; display: flex; align-items: center;
  justify-content: center; overflow: hidden; border-radius: 10px;
}
.tile-img-wrap img, .tile-img-wrap svg {
  max-width: 90%; max-height: 92%; width: auto; height: 100%; object-fit: contain; display: block;
}

.tile-name {
  margin-top: 6px; text-align: center; font-size: clamp(0.7rem, 1.8vw, 0.84rem); font-weight: 700;
  line-height: 1.25; color: var(--jm-navy); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; min-height: 2.3em;
}

.draw-action-bar { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.btn-draw { width: 100%; max-width: 360px; padding: 16px 28px; font-size: 1.06rem; }
.draw-hint { font-size: 0.78rem; color: var(--jm-muted); text-align: center; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,8,38,0.8); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); z-index: 50; display: none; align-items: center;
  justify-content: center; padding: 14px; opacity: 0; transition: opacity 0.22s ease;
}
.modal-backdrop.open { display: flex; }
.modal-backdrop.visible { opacity: 1; }

.modal-card {
  position: relative; width: 100%; max-width: 440px; max-height: 93dvh; overflow-y: auto;
  border-radius: 26px; background: linear-gradient(165deg, #0b2487 0%, #001871 55%, #000b3b 100%);
  border: 1.5px solid rgba(245,197,99,0.55); box-shadow: 0 28px 80px rgba(0,5,28,0.85);
  padding: 22px 20px; transform: translateY(14px) scale(0.96);
  transition: transform 0.26s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-backdrop.visible .modal-card { transform: translateY(0) scale(1); }

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-title { font-size: 1.15rem; font-weight: 800; color: var(--jm-gold-bright); line-height: 1.3; }
.modal-desc { font-size: 0.8rem; color: var(--jm-ice-soft); margin-top: 3px; line-height: 1.45; }

.form-field { margin-bottom: 12px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: #e0f2fe; margin-bottom: 5px; }
.form-input {
  width: 100%; padding: 12px 14px; border-radius: 13px; border: 1.5px solid rgba(186,230,253,0.3);
  background: rgba(0,10,48,0.78); color: #fff; font-family: var(--font-sans); font-size: 0.98rem;
  outline: none; transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.form-input:focus { border-color: var(--jm-gold); box-shadow: 0 0 0 3px rgba(245,197,99,0.22); }
.form-input.code-numeric {
  text-align: center; font-weight: 800; letter-spacing: 0.28em; font-size: 1.45rem;
  color: var(--jm-gold-bright); padding: 14px;
}
.form-input::placeholder { color: rgba(186,230,253,0.4); font-weight: 400; letter-spacing: normal; font-size: 0.92rem; }

.alert-box { display: none; padding: 11px 13px; border-radius: 13px; font-size: 0.82rem; line-height: 1.5; margin-bottom: 13px; }
.alert-box.show { display: block; }
.alert-box.error { background: rgba(239,68,68,0.18); border: 1px solid rgba(248,113,113,0.55); color: #fecaca; }
.alert-box.used { background: rgba(245,158,11,0.18); border: 1px solid rgba(251,191,36,0.55); color: #fef3c7; }

/* Winner Card */
.winner-card { text-align: center; border-width: 2px; border-color: var(--jm-gold); }
.winner-ribbon {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 15px; border-radius: 999px;
  background: linear-gradient(135deg, #ffe29a, #f5c563); color: #00145c; font-size: 0.74rem;
  font-weight: 800; margin-bottom: 8px;
}
.autosave-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px;
  background: rgba(34,197,94,0.2); border: 1px solid rgba(74,222,128,0.45); color: #86efac;
  font-size: 0.72rem; font-weight: 700; margin-bottom: 10px;
}
.winner-photo-stage {
  width: 156px; height: 156px; margin: 0 auto 12px; border-radius: 20px;
  background: radial-gradient(circle at center, #ffffff 55%, #e0f2fe 100%);
  border: 3px solid var(--jm-gold); display: flex; align-items: center; justify-content: center; padding: 10px;
}
.winner-photo-stage img, .winner-photo-stage svg { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }

.winner-brand-tag {
  display: inline-block; padding: 2px 11px; border-radius: 999px; background: rgba(56,189,248,0.2);
  color: var(--jm-ice-soft); font-size: 0.72rem; font-weight: 600; margin-bottom: 5px;
}
.winner-prize-name { font-size: 1.12rem; font-weight: 800; color: var(--jm-gold-bright); line-height: 1.32; margin-bottom: 12px; }

.prize-code-box {
  margin: 0 auto 12px; padding: 11px 14px; border-radius: 15px;
  background: linear-gradient(135deg, rgba(255,226,154,0.2), rgba(245,197,99,0.08));
  border: 2px solid var(--jm-gold);
}
.prize-code-label { font-size: 0.68rem; font-weight: 700; color: var(--jm-ice-soft); margin-bottom: 3px; }
.prize-code-value {
  font-family: 'Plus Jakarta Sans', monospace; font-size: clamp(1.18rem, 4.6vw, 1.52rem);
  font-weight: 800; letter-spacing: 0.08em; color: var(--jm-gold-bright); word-break: break-all;
}

.claim-ticket {
  text-align: left; padding: 10px 13px; border-radius: 14px; background: rgba(0,10,48,0.62);
  border: 1px dashed rgba(245,197,99,0.5); margin-bottom: 12px; font-size: 0.78rem; display: grid; gap: 4px;
}
.claim-row { display: flex; justify-content: space-between; gap: 10px; }
.claim-key { color: var(--jm-ice-soft); }
.claim-val { color: #fff; font-weight: 700; text-align: right; }

.pickup-card {
  text-align: left; padding: 10px 13px; border-radius: 14px;
  background: linear-gradient(145deg, rgba(56,189,248,0.14), rgba(245,197,99,0.1));
  border: 1px solid rgba(245,197,99,0.42); margin-bottom: 12px; font-size: 0.78rem; line-height: 1.5;
}
.pickup-title { font-weight: 700; color: var(--jm-gold-bright); margin-bottom: 4px; }

.btn-save-img {
  width: 100%; padding: 13px 18px; border-radius: 14px; border: 2px solid #86efac;
  background: linear-gradient(135deg, #22c55e, #15803d); color: #fff;
  font-family: var(--font-sans); font-size: 0.96rem; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 9px; box-shadow: 0 10px 24px rgba(34,197,94,0.34);
}
.btn-save-img:hover { filter: brightness(1.06); }

.winner-actions { display: flex; flex-direction: column; gap: 8px; }
.winner-actions .btn-cta { width: 100%; padding: 12px 18px; font-size: 0.92rem; }
.winner-actions .btn-ghost { width: 100%; }

.recover-item {
  padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.07);
  border: 1px solid rgba(245,197,99,0.4); margin-top: 10px; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer;
}
.recover-item:hover { border-color: var(--jm-gold-bright); background: rgba(255,255,255,0.12); }

.spinner {
  width: 18px; height: 18px; border: 2.5px solid rgba(0,20,92,0.25); border-top-color: #00145c;
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #001871; border: 1.5px solid var(--jm-gold); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 0.84rem; font-weight: 700; box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; z-index: 95; transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  .board-frame { padding: 8px; border-radius: 18px; }
  .prize-grid { gap: 7px; }
  .prize-tile { padding: 6px 4px; border-radius: 13px; }
  .tile-img-wrap { aspect-ratio: 1 / 1; margin-top: 13px; }
  .tile-name { font-size: 0.68rem; }
  .badge-brand { display: none; }
}
