/* ===================================================================
   Sweet Swap — Biotane Stevia Challenge
   Warm daylight kitchen. Light source is always upper-left, so every
   raised surface gets a soft warm shadow below and to the right.
   =================================================================== */
:root {
  --cream:      #FDFBF6;
  --cream-2:    #F6F1E7;
  --card:       #FFFFFF;
  /* Brand colours are taken from the Biotane logo: lime #95C11F and gold #EABD23.
     Neither carries text at readable contrast, so --green and --gold-deep are
     darkened derivatives (both verified above 4.5:1 on white / cream). */
  --ink:        #22300E;
  --ink-2:      #5C6652;
  --ink-3:      #7C8672;
  --line:       #EAE3D6;

  --green:      #5F7D13;
  --green-mid:  #7FA61A;
  --green-lt:   #95C11F;
  --green-deep: #2E3D0A;
  --green-wash: #F2F7E4;

  --gold:       #EABD23;
  --gold-deep:  #8A6D06;
  --gold-wash:  #FCF4DA;

  --sugar:      #C9CBD8;
  --alert:      #D9542B;
  --alert-wash: #FCEDE7;

  --sh-1: 0 1px 2px rgba(94,72,45,.06), 0 2px 6px rgba(94,72,45,.05);
  --sh-2: 0 2px 4px rgba(94,72,45,.06), 0 10px 24px -10px rgba(94,72,45,.24);
  --sh-3: 0 4px 8px rgba(94,72,45,.07), 0 22px 44px -18px rgba(94,72,45,.34);

  --radius: 20px;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(900px 460px at 78% -8%, #FDF4D8 0%, transparent 62%),
    radial-gradient(760px 420px at 8% 4%, #F3F8E4 0%, transparent 58%),
    var(--cream);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior: none;
}

.app {
  width: min(100%, 560px);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px env(safe-area-inset-bottom);
}

/* ---------------- top bar ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px 10px; }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { display: block; width: auto; height: 34px; }

.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  width: 40px; height: 40px; border-radius: 13px; cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--sh-1); transition: .18s;
}
.icon-btn svg { display: block; }
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.icon-btn.is-off { opacity: .45; }

/* ---------------- screens ---------------- */
.screen { display: none; flex: 1; flex-direction: column; padding: 4px 0 26px; }
.screen.is-active { display: flex; animation: rise .4s cubic-bezier(.2,.7,.3,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.eyebrow {
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--green); font-weight: 800; margin: 0 0 10px;
}
.display {
  font-family: var(--serif); font-weight: 800; font-size: clamp(54px, 17vw, 80px);
  line-height: .9; margin: 0 0 16px; letter-spacing: -.025em; color: var(--green-deep);
}
.display span { display: block; color: var(--green); }
.h-display { font-family: var(--serif); font-weight: 800; font-size: clamp(30px, 8vw, 42px); margin: 0 0 12px; line-height: 1.04; }
.lede { font-size: 15.5px; line-height: 1.62; color: var(--ink-2); margin: 0 0 20px; }
.micro { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; text-align: center; }
.micro b { color: var(--gold-deep); }
.section-h { font-family: var(--serif); font-size: 20px; margin: 28px 0 12px; }

/* ---------------- title ---------------- */
#screen-title { justify-content: center; }
.hero-art { height: 148px; margin: 0 -6px 6px; position: relative; }
.hero-art canvas { width: 100%; height: 100%; display: block; }

.facts { display: flex; gap: 10px; margin: 2px 0 22px; }
.facts > div {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 13px 8px; text-align: center; box-shadow: var(--sh-1);
}
.facts b { display: block; font-family: var(--serif); font-size: 28px; color: var(--green); line-height: 1; }
.facts span { font-size: 10.5px; color: var(--ink-3); letter-spacing: .03em; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-weight: 700; font-size: 15px;
  border-radius: 15px; border: none; cursor: pointer; text-decoration: none;
  padding: 15px 22px; transition: transform .14s cubic-bezier(.2,.8,.3,1), box-shadow .2s;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn-lg { width: 100%; padding: 18px 22px; font-size: 16.5px; }
.btn-primary {
  background: linear-gradient(160deg, var(--green-lt), var(--green) 72%, #4F690F);
  color: #fff; box-shadow: 0 2px 3px rgba(50,70,10,.22), 0 12px 26px -10px rgba(95,125,19,.7);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 6px rgba(50,70,10,.22), 0 18px 34px -12px rgba(95,125,19,.8); }
.btn-ghost {
  background: var(--card); color: var(--ink-2); border: 1px solid var(--line);
  width: 100%; margin-top: 12px; box-shadow: var(--sh-1);
}
.link-btn { background: none; border: none; color: var(--ink-3); font-size: 12px; cursor: pointer; text-decoration: underline; font-family: var(--sans); }

.dots { display: flex; gap: 6px; margin-bottom: 18px; }
.dot { width: 30px; height: 5px; border-radius: 4px; background: var(--line); }
.dot.on { background: var(--green); }
.dot.done { background: #C6DE92; }

.how { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 9px; }
.how li {
  position: relative; padding: 13px 15px 13px 42px; font-size: 13.5px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink-2); box-shadow: var(--sh-1);
}
.how li::before {
  content: ''; position: absolute; left: 15px; top: 50%; width: 14px; height: 14px;
  margin-top: -7px; border-radius: 5px;
  background: linear-gradient(145deg, var(--green-lt), var(--green));
}

/* ---------------- play ---------------- */
.screen-play { padding-bottom: 8px; }
.play-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--ink-3); letter-spacing: .1em;
  text-transform: uppercase; font-weight: 700; margin-bottom: 10px;
}
.stage { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.hud { display: flex; gap: 8px; }
.hud-chip {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 12px; display: grid; gap: 2px; min-height: 50px;
  align-content: center; box-shadow: var(--sh-1);
}
.hud-key { font-size: 9.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.hud-chip b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.hud-lives { display: flex; align-items: center; gap: 6px; }
.heart {
  width: 17px; height: 16px; background: var(--alert); display: inline-block;
  clip-path: path('M8.5 16S0 10.3 0 5A4.1 4.1 0 0 1 8.5 3 4.1 4.1 0 0 1 17 5c0 5.3-8.5 11-8.5 11Z');
  transition: .25s cubic-bezier(.2,.8,.3,1);
}
.heart.spent { background: var(--line); transform: scale(.76); }

.timer { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(94,72,45,.12); }
.timer i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--green-lt)); transform-origin: left; transition: transform .12s linear; }

.stage-canvas {
  position: relative; flex: 1; min-height: 340px; max-height: min(70vh, 580px);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--sh-2);
}
.stage-canvas canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.stage-hint { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 0; }
kbd {
  font-family: var(--sans); font-size: 10px; background: var(--card); color: var(--ink-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; margin: 0 1px;
}

/* ---------------- round 2: chai kitchen ---------------- */
.ticket {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-1);
}
.ticket-icon { width: 44px; height: 44px; flex: none; }
.ticket-icon canvas, .ticket-icon svg { width: 100%; height: 100%; display: block; }
.ticket-body { display: grid; gap: 1px; flex: 1; min-width: 0; }
.ticket-who { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.ticket-body strong { font-family: var(--serif); font-size: 20px; line-height: 1.1; }
.ticket-need { font-size: 12px; color: var(--ink-2); }
.ticket-need b { color: var(--ink); }
.ticket-target {
  text-align: center; padding: 8px 13px; border-radius: 13px; flex: none;
  background: var(--green-wash); border: 1px solid #D3E4A8;
}
.ticket-target b { display: block; font-family: var(--serif); font-size: 21px; color: var(--green); line-height: 1; }
.ticket-target span { font-size: 8.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }

.pour-btn {
  width: 100%; padding: 21px; border-radius: 17px; border: none; cursor: pointer;
  font-family: var(--sans); font-weight: 800; font-size: 16px; letter-spacing: .12em;
  background: linear-gradient(160deg, #F8DE85, var(--gold) 65%, #C79D14);
  color: #4A3407; box-shadow: 0 2px 3px rgba(150,110,20,.22), 0 14px 28px -12px rgba(242,193,78,.95);
  touch-action: none; user-select: none; transition: transform .1s, box-shadow .2s;
}
.pour-btn.is-pouring { transform: scale(.98); box-shadow: 0 0 0 5px var(--gold-wash), 0 10px 22px -10px rgba(242,193,78,.9); }
.pour-btn:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

/* ---------------- results ---------------- */
.score-pop {
  background: linear-gradient(165deg, #FFFDF7, #FBF3DE);
  border: 1px solid #EFE1BC; border-radius: var(--radius);
  padding: 20px; text-align: center; margin-bottom: 18px; box-shadow: var(--sh-1);
}
.score-pop b { display: block; font-family: var(--serif); font-size: 50px; color: var(--gold-deep); line-height: 1; font-variant-numeric: tabular-nums; }
.score-pop span { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.score-pop.big b { font-size: 62px; }

.stats { display: grid; gap: 8px; margin-bottom: 6px; }
.stat {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 15px; background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; font-size: 13.5px; box-shadow: var(--sh-1);
}
.stat span { color: var(--ink-2); }
.stat b { font-variant-numeric: tabular-nums; font-size: 14.5px; }

.badge {
  width: 108px; height: 108px; margin: 4px auto 16px; position: relative;
  display: grid; place-items: center;
}
.badge canvas { width: 100%; height: 100%; }

.recap { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; }
.recap li {
  display: flex; gap: 13px; align-items: flex-start; padding: 14px 15px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-1);
}
.recap-icon { width: 34px; height: 34px; flex: none; color: var(--green); }
.recap-icon svg { width: 100%; height: 100%; }
.recap strong { display: block; font-size: 14.5px; margin-bottom: 3px; }
.recap p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }

.cta {
  background: linear-gradient(165deg, #F7FBEB, #EDF5D8);
  border: 1px solid #D8E7AE; border-radius: var(--radius);
  padding: 22px; text-align: center; display: grid; gap: 6px; box-shadow: var(--sh-2);
}
.cta-kicker { margin: 0; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--green); font-weight: 800; }
.cta strong { font-family: var(--serif); font-size: 25px; }
.cta-price { font-size: 13.5px; color: var(--ink-2); margin-bottom: 10px; }

.foot {
  margin-top: auto; padding: 18px 2px 22px; display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: space-between; font-size: 11px; color: var(--ink-3);
  border-top: 1px solid var(--line);
}
.foot a { color: var(--green); text-decoration: none; font-weight: 600; }

/* ---------------- ingredient card ---------------- */
.ingredients { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 10px; }
.ingredients li {
  display: flex; gap: 14px; align-items: flex-start; padding: 15px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--sh-1);
}
.ing-art { width: 46px; height: 46px; flex: none; }
.ing-art canvas { width: 100%; height: 100%; display: block; }
.ing-body { min-width: 0; }
.ing-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.ing-head strong { font-size: 15px; }
.ing-code {
  font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: var(--green); background: var(--green-wash); border-radius: 6px; padding: 2px 7px;
}
.ing-body p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }

/* ---------------- loading gate ---------------- */
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: var(--cream); z-index: 20; transition: opacity .4s; }
.loader.done { opacity: 0; pointer-events: none; }
.loader-mark { width: 74px; height: 74px; position: relative; }
.loader-mark svg { width: 100%; height: 100%; color: var(--line); }
.loader-fill { position: absolute; inset: 0; overflow: hidden; height: 0%; transition: height .3s; }
.loader-fill svg { position: absolute; bottom: 0; width: 74px; height: 74px; color: var(--green); }

/* ---------------- embed ---------------- */
body.is-embed .topbar, body.is-embed .foot { display: none; }
body.is-embed .app { padding-top: 12px; }

/* ---------------- responsive / motion ---------------- */
@media (min-width: 640px) {
  .app { padding: 0 24px; }
  .stage-canvas { min-height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .08s !important; }
}
