:root {
  --ink: #f4f1ea;
  --muted: #b9b3a6;
  --panel: rgba(12, 12, 14, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ff7a1a;
  --ok: #4ade80;
  --warn: #facc15;
  --off: #8a8578;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

/* Size and position are set from script to match the camera's shape (see fitCanvas).
   Avoid 100vh: on Android Chrome it includes the area under the address bar. */
#camerafeed {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}

[hidden] { display: none !important; }

#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: calc(env(safe-area-inset-left) + 10px);
  min-width: 190px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#hud .row { display: flex; justify-content: space-between; gap: 14px; }
#hud span { color: var(--muted); }
#hud b { font-weight: 600; }
#hud b.ok { color: var(--ok); }
#hud b.warn { color: var(--warn); }
#hud b.off { color: var(--off); }

#hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 86px);
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
}

#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px;
}
#controls button { padding: 9px 12px; font-size: 13px; }

button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
button[aria-pressed="false"] { color: var(--off); }
button:active { transform: scale(0.97); }

#start {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(120% 80% at 50% 0%, #2a1a0c 0%, #000 70%);
}
#start .card { max-width: 420px; }
#start .eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
#start h1 { margin: 0 0 12px; font-size: 30px; }
#start p, #start li { color: var(--muted); font-size: 15px; line-height: 1.5; }
#start ol { padding-left: 20px; margin: 12px 0 22px; }
#start strong { color: var(--ink); }
#btn-start {
  width: 100%;
  background: var(--accent);
  border-color: transparent;
  color: #1a0d00;
  font-size: 16px;
  min-height: 52px;
}
#btn-start:disabled { opacity: 0.6; }
#start-msg { min-height: 1.5em; margin-top: 12px; }
#start-msg.err { color: #fca5a5; }

/* Lens switcher, for phones that open on the wrong lens (e.g. the 0.6× ultra-wide). */
#btn-lens {
  position: fixed;
  right: calc(env(safe-area-inset-right) + 12px);
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 20;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  font: 600 13px/1 system-ui, sans-serif;
}
#btn-lens[hidden] { display: none; }

/* Scan guide: a translucent picture of the side to aim at, over the camera view while
   searching. Fades out once the can is found. */
#scan-guide {
  position: fixed;
  left: 50%;
  top: 46%;
  width: min(46vw, 34vh);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 5;
}
#scan-guide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 22% / 9%;
  opacity: 0.42;
  filter: saturate(1.15);
}
#scan-guide::after { /* corner brackets, like a viewfinder */
  content: '';
  position: absolute;
  inset: -10px;
  --c: rgba(255, 255, 255, 0.85);
  background:
    linear-gradient(var(--c) 0 0) top left / 26px 3px, linear-gradient(var(--c) 0 0) top left / 3px 26px,
    linear-gradient(var(--c) 0 0) top right / 26px 3px, linear-gradient(var(--c) 0 0) top right / 3px 26px,
    linear-gradient(var(--c) 0 0) bottom left / 26px 3px, linear-gradient(var(--c) 0 0) bottom left / 3px 26px,
    linear-gradient(var(--c) 0 0) bottom right / 26px 3px, linear-gradient(var(--c) 0 0) bottom right / 3px 26px;
  background-repeat: no-repeat;
}
#scan-guide.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: guide-breathe 2.4s ease-in-out 0.35s infinite;
}
@keyframes guide-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.035); }
}
@media (prefers-reduced-motion: reduce) { #scan-guide.show { animation: none; } }



/* ===== Sprite look (2022 identity: "Short & Crisp, with a bold sense of clarity")
   One flat Sprite green, white and black; Gloock as the display serif, Barlow Condensed for
   support lines; flat colour-block cards; water drops. Fits one phone screen, no scrolling. */
@font-face { font-family: Gloock; font-weight: 400; font-display: swap; src: url(fonts/gloock-400.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-display: swap; src: url(fonts/barlow-condensed-800.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-400.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-600.woff2) format("woff2"); }
:root {
  --sp-green: #00A84E; --sp-deep: #063B1E; --sp-lime: #D8FF3D; --sp-white: #ffffff; --sp-black: #000000;
  --display: Gloock, "DM Serif Display", Georgia, serif;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --u: min(1dvh, 1.9vw); /* one-screen sizing unit */
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
html, body { background: var(--sp-green); }

#start {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(env(safe-area-inset-top) + 2.2 * var(--u)) 18px calc(env(safe-area-inset-bottom) + 2.4 * var(--u));
  overflow: hidden; background: var(--sp-green);
}
.sp-top { position: relative; z-index: 1; width: 100%; max-width: 460px; display: flex; }
.sp-chip {
  display: inline-block; border-radius: 999px; padding: 4px 9px 3px; background: rgba(0,0,0,.18); color: #fff;
  font: 600 10px/1.25 Inter, sans-serif;
}
#start .card {
  position: relative; z-index: 1; width: 100%; max-width: 460px; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0;
}
.sp-logo { width: min(310px, 66vw, 30 * var(--u)); height: auto; animation: sp-pop .5s cubic-bezier(.2,1.4,.4,1) both; }
#start .sp-title {
  margin: calc(.6 * var(--u)) 0 0; color: #fff; font: 400 clamp(30px, 6.4 * var(--u), 54px)/1 var(--display); letter-spacing: -.01em;
}
.sp-tag {
  margin: calc(2.2 * var(--u)) 0 0 !important; color: var(--sp-deep);
  font: 800 clamp(19px, 3 * var(--u), 26px)/1.05 var(--cond) !important; text-transform: uppercase; letter-spacing: .01em;
}
.sp-tag span { display: block; color: #fff; font-weight: 700; font-size: .78em; margin-top: 4px; letter-spacing: .04em; }
.sp-steps { list-style: none; padding: 0 !important; margin: calc(2.6 * var(--u)) 0 calc(2.4 * var(--u)) !important; width: 100%;
  display: flex; flex-direction: column; gap: calc(1 * var(--u)); text-align: left; }
.sp-steps li {
  display: flex; gap: 12px; align-items: center; padding: calc(1.2 * var(--u)) 14px; border-radius: 4px;
  background: #fff; color: #3d5a48 !important; font-size: clamp(12px, 1.6 * var(--u), 14px) !important; line-height: 1.35 !important;
}
.sp-steps li.dark { background: var(--sp-black); color: #cfd8d2 !important; }
.sp-steps b { display: block; color: var(--sp-green); font: 800 clamp(16px, 2.3 * var(--u), 20px)/1.05 var(--cond); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 2px; }
.sp-steps li.dark b { color: #fff; }
.sp-num {
  flex: none; width: calc(4.4 * var(--u)); height: calc(4.4 * var(--u)); min-width: 32px; min-height: 32px; border-radius: 50%;
  background: var(--sp-green); color: #fff; display: grid; place-items: center; font: 400 clamp(18px, 2.6 * var(--u), 24px)/1 var(--display);
}
.sp-steps li.dark .sp-num { background: #fff; color: var(--sp-black); }
.sp-btn, #btn-start.sp-btn {
  width: 100%; min-height: max(54px, 6.6 * var(--u)); border-radius: 999px; border: 0 !important;
  background: #fff !important; color: var(--sp-green) !important; box-shadow: 0 6px 0 var(--sp-deep);
  font: 800 clamp(22px, 3.2 * var(--u), 28px)/1 var(--cond) !important; text-transform: uppercase; letter-spacing: .08em; padding: 12px 20px;
  transition: transform 75ms;
}
.sp-btn:active { transform: translateY(6px) scale(.98); box-shadow: 0 0 0 var(--sp-deep); }
.sp-btn:focus-visible { outline: 3px solid var(--sp-lime); outline-offset: 3px; }
#start-msg { color: #e6fff0 !important; font-size: 13px !important; margin-top: calc(1 * var(--u)) !important; min-height: 1.2em; }
#start-msg.err { color: #fff25a !important; }
/* water drops: glassy, with a highlight and a soft shadow */
.sp-drops i {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.95) 0 9%, rgba(255,255,255,.28) 16%, rgba(255,255,255,.06) 52%, rgba(255,255,255,.22) 72%, rgba(255,255,255,.5) 100%);
  box-shadow: 4px 8px 14px rgba(0,60,25,.28), inset -3px -5px 8px rgba(0,80,35,.22);
  animation: sp-float 6s ease-in-out infinite;
}
.sp-drops i:nth-child(1) { width: 64px; height: 58px; left: -14px; top: 18%; }
.sp-drops i:nth-child(2) { width: 26px; height: 24px; right: 9%; top: 9%; animation-delay: -2s; }
.sp-drops i:nth-child(3) { width: 44px; height: 40px; right: -10px; top: 44%; animation-delay: -4s; }
.sp-drops i:nth-child(4) { width: 18px; height: 17px; left: 12%; bottom: 6%; animation-delay: -1s; }
@keyframes sp-float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes sp-pop { 0% { transform: scale(.6) rotate(-4deg); opacity: 0 } 60% { transform: scale(1.06); opacity: 1 } 100% { transform: scale(1) } }
@media (prefers-reduced-motion: reduce) { .sp-logo, .sp-drops i { animation: none; } }
@media (max-height: 600px) { .sp-steps li { padding-block: 6px; } .sp-tag span { display: none; } }

/* In-AR controls */
#hint {
  background: #fff; color: var(--sp-green); border: 0; box-shadow: 0 4px 0 var(--sp-deep);
  font: 800 15px/1 var(--cond); text-transform: uppercase; letter-spacing: .06em; padding: 11px 18px 10px;
}
#btn-lens {
  background: #fff !important; color: var(--sp-green) !important; border: 0 !important; box-shadow: 0 3px 0 var(--sp-deep);
  font: 800 13px/1 var(--cond) !important; text-transform: uppercase; letter-spacing: .06em; padding: 9px 13px 8px !important; min-height: 0;
}
#scan-guide::after { --c: #ffffff; }
#scan-guide img { border: 0; border-radius: 0; object-fit: contain; }
