/* =================================================
   THAI BLESSING COOKING CHALLENGE
   Design system + components + screens
   Edit color tokens in :root to retheme the entire app.
   ================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  /* ---- Brand tokens ---- */
  --chili:   #E53935;
  --lemon:   #FFD600;
  --lime:    #00C853;
  --bg:      #121212;
  --bg-2:    #1c1414;
  --ink:     #fff8e7;
  --ink-dim: #c9bfa9;

  /* glow shadows for neon */
  --glow-red:   0 0 24px rgba(229,57,53,.55), 0 0 48px rgba(229,57,53,.35);
  --glow-yel:   0 0 24px rgba(255,214,0,.55), 0 0 48px rgba(255,214,0,.35);
  --glow-grn:   0 0 24px rgba(0,200,83,.55), 0 0 48px rgba(0,200,83,.35);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-display: "Baloo 2", "Fredoka", system-ui, sans-serif;
  --font-body:    "Fredoka", system-ui, sans-serif;
}

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  font-weight: 500;
  user-select: none;
  -webkit-user-select: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input  { font-family: inherit; }

/* ===== Animated night-market backdrop ===== */
.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, #2a0e0e 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, #1a2a14 0%, transparent 50%),
    var(--bg);
}
.bg-blob {
  position: absolute;
  width: 60vmin; height: 60vmin;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
  animation: float 12s ease-in-out infinite;
}
.bg-blob-1 { background: var(--chili); top: -20%; left: -15%; }
.bg-blob-2 { background: var(--lemon); bottom: -25%; right: -10%; animation-delay: -4s; }
.bg-blob-3 { background: var(--lime);  top: 40%;   left: 50%;   animation-delay: -8s; opacity:.22; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(20px,-30px) scale(1.1); }
}

.lantern {
  position: absolute;
  font-size: 32px;
  filter: drop-shadow(0 0 10px var(--chili));
  animation: sway 3.5s ease-in-out infinite;
}
.lantern-1 { top: 8%;  left: 8%;  }
.lantern-2 { top: 6%;  right:10%; animation-delay: -.7s; }
.lantern-3 { top: 22%; left: 78%; animation-delay: -1.2s; font-size:24px; }
.lantern-4 { top: 18%; left: 22%; animation-delay: -2s;   font-size:22px; }
@keyframes sway {
  0%,100% { transform: rotate(-6deg); }
  50%     { transform: rotate(6deg); }
}

/* ===== App container ===== */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  overflow: hidden;
}

/* ===== Screens ===== */
.screen {
  position: absolute; inset: 0;
  padding: 20px 22px env(safe-area-inset-bottom) 22px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* =====================================================
   1. HOME SCREEN
   ===================================================== */
.home-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 20px;
}
.brand-row {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 8px;
}
.brand-tag {
  background: var(--chili);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--glow-red);
}
.brand-tag-en {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  font-weight: 700;
}

.title-big {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(36px, 11vw, 52px);
  line-height: .95;
  margin-top: 10px;
  text-align: center;
}
.title-big .t-fire { display:block; font-size:.6em; }
.title-big .t-main {
  display: block;
  color: var(--lemon);
  text-shadow: 0 0 18px rgba(255,214,0,.6), 4px 4px 0 #b48a00;
  letter-spacing: .5px;
}
.title-big .t-shadow {
  color: var(--chili);
  text-shadow: 0 0 18px rgba(229,57,53,.7), 4px 4px 0 #7a1a18;
}

.subtitle {
  margin-top: 12px;
  font-size: 17px;
  color: var(--ink);
  font-weight: 600;
}
.subtitle strong { color: var(--lime); text-shadow: var(--glow-grn); }

/* mascot wrap shared */
.mascot-wrap {
  width: 180px; height: 180px;
  margin: 14px 0 6px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.5));
}
.mascot-wrap svg { width:100%; height:100%; }
.mascot-bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce {
  0%,100% { transform: translateY(0) rotate(-1deg); }
  50%     { transform: translateY(-10px) rotate(1deg); }
}

/* ===== Buttons ===== */
.cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  padding: 18px 22px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .5px;
  background: linear-gradient(180deg, #ff6b67 0%, var(--chili) 60%, #b71c1c 100%);
  color: #fff;
  box-shadow: var(--glow-red), inset 0 -4px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3);
  transition: transform .12s ease, box-shadow .2s ease;
  margin-top: 12px;
}
.cta-btn:active { transform: scale(.96); }
.cta-arrow { font-size: 16px; opacity: .85; }
.cta-pulse { animation: pulseGlow 1.6s ease-in-out infinite; }
@keyframes pulseGlow {
  0%,100% { box-shadow: var(--glow-red), inset 0 -4px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3); }
  50%     { box-shadow: 0 0 32px rgba(229,57,53,.9), 0 0 64px rgba(229,57,53,.5),
                        inset 0 -4px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3); }
}

.cta-claim {
  background: linear-gradient(180deg, #4ce884 0%, var(--lime) 60%, #00913c 100%);
  box-shadow: var(--glow-grn), inset 0 -4px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3);
}
.cta-claim.cta-pulse { animation: pulseClaim 1.4s ease-in-out infinite; }
@keyframes pulseClaim {
  0%,100% { box-shadow: var(--glow-grn), inset 0 -4px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3); }
  50%     { box-shadow: 0 0 32px rgba(0,200,83,.9), 0 0 64px rgba(0,200,83,.5),
                        inset 0 -4px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3); }
}

.ghost-btn {
  width: 100%; max-width: 320px;
  padding: 12px 18px;
  margin-top: 10px;
  border-radius: 999px;
  font-weight: 700; font-size: 15px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.18);
  color: var(--ink);
  transition: background .2s;
}
.ghost-btn:active { background: rgba(255,255,255,.14); }

.text-btn {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-dim);
  text-decoration: underline;
}

/* ===== Reward teaser ===== */
.reward-teaser {
  margin-top: 14px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,214,0,.12);
  border: 1.5px dashed var(--lemon);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 320px;
}
.reward-badge {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(255,214,0,.8));
}
.reward-text { text-align: left; }
.reward-title { font-size: 14px; font-weight: 700; }
.reward-title strong { color: var(--lemon); }
.reward-sub { font-size: 11px; color: var(--ink-dim); }

.live-counter {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-dim);
  display: flex; align-items: center; gap: 6px;
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; }
  50%     { opacity: .35; }
}

/* =====================================================
   2. GAME SCREEN
   ===================================================== */
.game-topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.hud-pill {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1.5px solid rgba(255,255,255,.12);
  font-weight: 700; font-size: 17px;
}
.hud-icon { font-size: 18px; }
.hud-timer { color: var(--lemon); }
.hud-timer.danger { color: var(--chili); animation: shake .4s infinite; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-2px); }
  75%     { transform: translateX(2px); }
}
.hud-score { color: var(--lime); }

.timer-track {
  height: 8px;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}
.timer-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--lime), var(--lemon), var(--chili));
  transition: width .2s linear;
}

.task-prompt {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 14px;
  min-height: 28px;
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
}

.game-stage {
  flex: 1;
  position: relative;
  background: rgba(255,255,255,.04);
  border: 2px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* feedback toast */
.fb-toast {
  position: absolute;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%) scale(.6);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 56px;
  pointer-events: none;
  opacity: 0;
  transition: none;
  z-index: 5;
  text-shadow: 0 4px 0 rgba(0,0,0,.5);
}
.fb-toast.show {
  animation: pop 0.6s ease forwards;
}
@keyframes pop {
  0%   { transform: translate(-50%,-50%) scale(.4); opacity: 0; }
  30%  { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
  60%  { transform: translate(-50%,-50%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%,-80%) scale(1.0); opacity: 0; }
}
.fb-perfect { color: var(--lime); }
.fb-good    { color: var(--lemon); }
.fb-wrong   { color: var(--chili); }

.game-mascot {
  position: absolute;
  bottom: 12px; right: 12px;
  width: 64px; height: 64px;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.5));
}
.game-mascot svg { width:100%; height:100%; }

/* ----- TASK: chili swipe ----- */
.chili-target {
  position: absolute;
  width: 70%;
  display: flex; align-items: center; justify-content: center;
  font-size: 92px;
  transform: translate(-50%,-50%);
  left: 50%; top: 50%;
  filter: drop-shadow(0 0 16px rgba(229,57,53,.6));
  transition: transform .15s ease, opacity .15s ease;
}
.chili-target.cut {
  transform: translate(-50%,-50%) rotate(20deg);
  opacity: 0;
}
.cut-line {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 2px;
  background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(255,255,255,.6) 6px 14px);
  transform: translateY(-50%);
  pointer-events: none;
}
.cut-flash {
  position: absolute; left:0; top:0; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  transform: translateX(-100%);
  pointer-events: none;
}
.cut-flash.fire { animation: slash .35s ease forwards; }
@keyframes slash { to { transform: translateX(100%); } }

/* ----- TASK: tap correct ingredient ----- */
.ing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px;
  width: 100%;
}
.ing-item {
  aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: var(--radius-md);
  transition: transform .12s, background .2s;
  cursor: pointer;
}
.ing-item:active { transform: scale(.92); }
.ing-item.correct { background: rgba(0,200,83,.3); border-color: var(--lime); }
.ing-item.wrong   { background: rgba(229,57,53,.3); border-color: var(--chili); }

/* ----- TASK: drag to stir ----- */
.stir-pot {
  position: relative;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #5a3a1a 0%, #3a2410 70%, #1a1208 100%);
  border: 6px solid #2a1808;
  box-shadow: 0 12px 24px rgba(0,0,0,.5), inset 0 8px 16px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.stir-spoon {
  width: 14px; height: 130px;
  background: linear-gradient(180deg, #d49a5a, #8a5a2a);
  border-radius: 8px;
  transform-origin: 50% 100%;
  position: absolute; bottom: 50%;
  left: 50%; margin-left: -7px;
  pointer-events: none;
}
.stir-progress {
  position: absolute;
  bottom: -32px;
  left: 0; right: 0;
  height: 8px;
  background: rgba(255,255,255,.1);
  border-radius: 999px;
  overflow: hidden;
}
.stir-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--lemon), var(--lime));
  transition: width .15s ease;
}

/* ----- TASK: timing tap to plate ----- */
.timing-bar {
  position: relative;
  width: 92%; height: 60px;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.timing-zone {
  position: absolute; top: 0; bottom: 0;
  width: 28%;
  left: 36%;
  background: linear-gradient(180deg, rgba(0,200,83,.4), rgba(0,200,83,.2));
  border-left: 2px solid var(--lime);
  border-right: 2px solid var(--lime);
}
.timing-zone-perfect {
  position: absolute; top: 0; bottom: 0;
  width: 8%;
  left: 46%;
  background: rgba(255,214,0,.4);
  border-left: 2px solid var(--lemon);
  border-right: 2px solid var(--lemon);
}
.timing-marker {
  position: absolute; top: -4px; bottom: -4px;
  width: 6px;
  background: var(--chili);
  box-shadow: var(--glow-red);
  border-radius: 4px;
  left: 0;
  transition: none;
}
.timing-tap-btn {
  display:block; margin: 22px auto 0;
  padding: 14px 28px;
  background: var(--lemon);
  color: #2a1d00;
  font-weight: 800;
  border-radius: 999px;
  font-size: 18px;
  box-shadow: var(--glow-yel);
}
.timing-tap-btn:active { transform: scale(.95); }

/* =====================================================
   3. RESULT SCREEN
   ===================================================== */
.result-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 10px;
}
.rank-emoji {
  font-size: 72px;
  margin: -10px 0 0;
  filter: drop-shadow(0 0 16px rgba(255,214,0,.6));
  animation: bounce 1.5s ease-in-out infinite;
}
.rank-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  color: var(--lemon);
  text-shadow: var(--glow-yel), 3px 3px 0 #4d4100;
  margin-top: 6px;
}
.score-block {
  margin: 14px 0 12px;
  padding: 18px 28px;
  background: rgba(0,0,0,.35);
  border: 2px solid rgba(255,214,0,.3);
  border-radius: var(--radius-lg);
}
.score-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 56px;
  color: var(--lime);
  text-shadow: var(--glow-grn);
  line-height: 1;
}
.score-label {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--ink-dim);
  margin-top: 4px;
}
.percentile-pill {
  background: linear-gradient(90deg, var(--chili), #ff6b67);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 14px;
  box-shadow: var(--glow-red);
  animation: pulseGlow 1.6s ease-in-out infinite;
}
.percentile-pill strong { color: var(--lemon); font-size: 22px; }

/* =====================================================
   4. LEAD CAPTURE OVERLAY
   ===================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  padding: 20px;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.lead-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #1f1818 0%, #14100e 100%);
  border: 2px solid rgba(255,214,0,.3);
  border-radius: var(--radius-lg);
  padding: 26px 22px 22px;
  text-align: center;
  transform: scale(.85);
  transition: transform .35s cubic-bezier(.18,.89,.32,1.28);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), var(--glow-yel);
}
.overlay.show .lead-card { transform: scale(1); }
.close-x {
  position: absolute; top: 10px; right: 14px;
  font-size: 22px; color: var(--ink-dim);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.close-x:active { background: rgba(255,255,255,.1); }
.lead-emoji { font-size: 48px; }
.lead-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin-top: 4px;
  color: var(--lemon);
  text-shadow: var(--glow-yel);
}
.lead-sub {
  margin: 8px 0 18px;
  font-size: 14px;
  color: var(--ink-dim);
}
.lead-sub strong { color: var(--lime); }
.field {
  display: block;
  text-align: left;
  margin-bottom: 12px;
}
.field span {
  display: block;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--ink-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 700;
}
.field input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.14);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  transition: border-color .2s, background .2s;
}
.field input:focus {
  outline: none;
  border-color: var(--lime);
  background: rgba(0,200,83,.06);
}
.field input.invalid {
  border-color: var(--chili);
  background: rgba(229,57,53,.08);
  animation: shake .3s ease;
}
.lead-note {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 12px;
}

/* =====================================================
   5. SHARE SCREEN
   ===================================================== */
.share-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 10px;
}
.share-h {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--lime);
  text-shadow: var(--glow-grn);
}
.share-sub {
  margin: 8px 0 18px;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.5;
}
.share-quote {
  background: rgba(255,214,0,.08);
  border: 2px dashed var(--lemon);
  padding: 18px;
  border-radius: var(--radius-lg);
  font-size: 17px;
  line-height: 1.55;
  font-weight: 700;
  margin-bottom: 18px;
  width: 100%;
  max-width: 340px;
}
.share-quote strong { color: var(--chili); font-size: 22px; }

/* small confetti for results */
.confetti {
  position: absolute;
  width: 8px; height: 14px;
  top: -20px;
  pointer-events: none;
  animation: fall linear forwards;
  z-index: 2;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* tablet+ desktop centering */
@media (min-width: 481px) {
  body { background: #0a0a0a; }
  #app {
    margin-top: 0;
    box-shadow: 0 0 80px rgba(229,57,53,.2);
  }
}
