:root {
  --bg: #040608;
  --panel: #071116;
  --cyan: #18E2EF;
  --gold: #F5B82E;
  --gold-dark: #D98A12;
  --foam: #FFF3D2;
  --white: #F6F6F1;
  --green: #A6FF3D;
  --red: #FF443D;
  --muted: #98A7AD;
  --amazon: #FF9800;
  --fill: 1%;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--white);
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(24, 226, 239, .14), transparent 28rem),
    linear-gradient(180deg, #040608 0%, #071116 100%);
}

button, a { font: inherit; }

.shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 36px);
}

.console {
  width: min(1040px, 100%);
  min-height: min(860px, calc(100svh - 28px));
  display: grid;
  grid-template-rows: minmax(390px, 1fr) auto;
  align-items: center;
  border: 1px solid rgba(24, 226, 239, .3);
  background: linear-gradient(145deg, rgba(7, 17, 22, .96), rgba(4, 6, 8, .98));
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 243, 210, .05);
  overflow: hidden;
  position: relative;
}

.console::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(24, 226, 239, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 226, 239, .06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 44%, #000 0 34%, transparent 70%);
  pointer-events: none;
}

.scan-stage {
  position: relative;
  min-height: 390px;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  padding: 18px;
}

.tech-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: -1;
}

.scanner-ring {
  width: min(68vw, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(24, 226, 239, .42);
  box-shadow: 0 0 38px rgba(24, 226, 239, .15), inset 0 0 44px rgba(24, 226, 239, .07);
  background:
    conic-gradient(from 0deg, transparent 0 32deg, rgba(24, 226, 239, .42) 36deg, transparent 42deg 180deg, rgba(245, 184, 46, .22) 186deg, transparent 193deg 360deg);
  animation: spin 7s linear infinite;
}

.scanner-frame {
  position: absolute;
  width: min(76vw, 610px);
  aspect-ratio: 1;
  border: 1px dashed rgba(24, 226, 239, .22);
  transform: rotate(45deg);
}

.tap-line {
  position: absolute;
  top: 2%;
  width: 2px;
  height: 34%;
  background: linear-gradient(var(--cyan), rgba(245, 184, 46, .25), transparent);
  opacity: .55;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: .6;
  animation: drift 5s ease-in-out infinite;
}

.p1 { left: 22%; top: 28%; }
.p2 { right: 20%; top: 35%; animation-delay: -1.4s; background: var(--gold); }
.p3 { left: 28%; bottom: 24%; animation-delay: -2.1s; }
.p4 { right: 30%; bottom: 18%; animation-delay: -3.1s; background: var(--foam); }

.beer-mug {
  width: min(72vw, 360px);
  max-height: min(49svh, 420px);
  overflow: visible;
  filter: drop-shadow(0 16px 32px rgba(0,0,0,.5));
  transform-origin: 50% 70%;
  transition: transform 360ms ease;
}

.phase-success .beer-mug,
.phase-final .beer-mug { animation: celebrate 1.3s ease-in-out 1; }

.mug-shadow ellipse { fill: rgba(0, 0, 0, .45); }
.mug-body { fill: rgba(255, 255, 255, .05); stroke: url(#glassStroke); stroke-width: 5; }
.rim { fill: none; stroke: rgba(255, 243, 210, .7); stroke-width: 4; stroke-linecap: round; }
.handle path:first-child { stroke: rgba(255, 243, 210, .52); stroke-width: 17; stroke-linecap: round; }
.handle path:last-child { stroke: rgba(24, 226, 239, .18); stroke-width: 10; stroke-linecap: round; }
.glass-reflection { fill: none; stroke: rgba(255, 255, 255, .42); stroke-width: 4; stroke-linecap: round; }
.r2 { opacity: .35; }

.beer-fill {
  fill: url(#beerGold);
  transform-origin: 50% 100%;
  transform: translateY(calc(100% - var(--fill))) scaleY(calc(var(--fill) / 100));
  transition: transform 560ms cubic-bezier(.2,.7,.2,1);
}

.liquid-wave {
  fill: rgba(255, 243, 210, .18);
  transform: translateY(calc(100% - var(--fill)));
  transition: transform 560ms cubic-bezier(.2,.7,.2,1);
  animation: wave 2.4s ease-in-out infinite;
}

.foam-layer {
  fill: var(--foam);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 360ms ease, transform 560ms ease;
}

.phase-fill-3 .foam-layer,
.phase-success .foam-layer,
.phase-ticket .foam-layer,
.phase-final .foam-layer {
  opacity: 1;
  transform: translateY(0);
}

.bubbles circle {
  fill: rgba(255, 243, 210, .72);
  animation: bubble 2.7s ease-in-out infinite;
}
.bubbles circle:nth-child(2) { animation-delay: -.7s; }
.bubbles circle:nth-child(3) { animation-delay: -1.3s; }
.bubbles circle:nth-child(4) { animation-delay: -2.1s; }
.bubbles circle:nth-child(5) { animation-delay: -1.8s; }

.copy-panel {
  position: relative;
  z-index: 2;
  padding: 0 clamp(18px, 4vw, 48px) clamp(18px, 4vw, 44px);
  display: grid;
  gap: 12px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: clamp(12px, 1.4vw, 15px);
  font-weight: 800;
}

h1 {
  margin: 0;
  color: var(--white);
  font-size: clamp(26px, 5vw, 58px);
  line-height: .98;
}

.status {
  min-height: 1.35em;
  margin: 0;
  color: var(--foam);
  font-size: clamp(15px, 2.1vw, 22px);
  font-weight: 700;
}

.progress-wrap {
  width: min(640px, 100%);
  height: 54px;
  margin: 4px auto 0;
  position: relative;
  display: grid;
  place-items: center;
}

.progress-track {
  position: absolute;
  inset: 10px 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(24, 226, 239, .28);
  background: rgba(4, 6, 8, .72);
}

.progress-track span {
  display: block;
  width: var(--fill);
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--foam));
  transition: width 560ms cubic-bezier(.2,.7,.2,1);
}

.percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--white);
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  font-size: 18px;
  z-index: 2;
}

.diagnostics {
  width: min(640px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.diagnostics div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid rgba(255, 243, 210, .14);
  border-radius: 8px;
  background: rgba(4, 6, 8, .45);
}

dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  color: var(--green);
  font-size: clamp(10px, 1.6vw, 13px);
  font-weight: 800;
}

.phase-pause .scanner-ring {
  animation-duration: 1.15s;
  box-shadow: 0 0 48px rgba(24, 226, 239, .24), inset 0 0 54px rgba(245, 184, 46, .11);
}

.phase-success .console,
.phase-ticket .console,
.phase-final .console {
  border-color: rgba(166, 255, 61, .48);
}

.ticket {
  position: absolute;
  top: 9%;
  left: 50%;
  width: min(330px, 82vw);
  min-height: 230px;
  padding: 18px;
  border-radius: 8px;
  color: #071116;
  background: linear-gradient(155deg, #fff8df, #f6f6f1 58%, #fff3d2);
  box-shadow: 0 22px 50px rgba(0,0,0,.45);
  transform: translate(-50%, -140%) rotate(-3deg);
  opacity: 0;
  transition: transform 620ms cubic-bezier(.2,.8,.2,1), opacity 300ms ease;
  z-index: 4;
}

.phase-ticket .ticket,
.phase-final .ticket {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-2deg);
}

.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #071116;
  font-size: 12px;
  font-weight: 900;
}

.ticket-top i {
  width: 42px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid var(--gold-dark);
  background: linear-gradient(90deg, transparent 20%, rgba(217,138,18,.25) 20% 28%, transparent 28%);
}

.ticket strong {
  display: block;
  margin-top: 18px;
  font-size: 34px;
  line-height: 1;
}

.ticket p {
  margin: 9px 0 0;
  font-size: 14px;
  font-weight: 800;
}

.stamp {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 10px;
  border: 3px solid var(--red);
  color: var(--red);
  font-size: 20px;
  font-weight: 900;
  transform: rotate(-7deg);
}

.punchline {
  display: none;
  gap: 8px;
  margin-top: 2px;
}

.phase-final .punchline {
  display: grid;
}

.punchline p {
  margin: 0;
  font-weight: 900;
}

.punchline p:first-child {
  color: var(--gold);
  font-size: clamp(24px, 4.8vw, 48px);
}

.punchline p:last-child {
  color: var(--white);
  font-size: clamp(20px, 3.6vw, 34px);
  line-height: 1.05;
}

.actions {
  display: none;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.phase-final .actions {
  display: flex;
}

.button {
  min-height: 52px;
  min-width: min(100%, 210px);
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  padding: 14px 18px;
  text-decoration: none;
  font-weight: 900;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary {
  color: #040608;
  background: var(--amazon);
}

.primary[hidden] { display: none; }

.secondary {
  color: var(--white);
  background: rgba(4, 6, 8, .5);
  border-color: rgba(246, 246, 241, .58);
  font-size: 14px;
}

.confetti {
  position: absolute;
  width: 7px;
  height: 12px;
  top: -24px;
  left: var(--x);
  background: var(--c);
  opacity: .9;
  transform: rotate(var(--r));
  animation: confettiFall var(--d) linear forwards;
  z-index: 6;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift {
  50% { transform: translateY(-18px) translateX(8px); opacity: 1; }
}
@keyframes wave {
  50% { transform: translateY(calc(100% - var(--fill))) translateX(-10px); }
}
@keyframes bubble {
  0% { transform: translateY(22px); opacity: 0; }
  25%, 80% { opacity: .86; }
  100% { transform: translateY(-44px); opacity: 0; }
}
@keyframes celebrate {
  0%, 100% { transform: rotate(0deg) scale(1); }
  28% { transform: rotate(-3deg) scale(1.02); }
  58% { transform: rotate(3deg) scale(1.01); }
}
@keyframes confettiFall {
  to { transform: translateY(112svh) rotate(520deg); opacity: .2; }
}

@media (min-width: 820px) {
  .console {
    grid-template-rows: 1fr auto;
  }
  .scan-stage {
    min-height: 520px;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 10px;
    align-items: stretch;
  }
  .console {
    min-height: calc(100svh - 20px);
    grid-template-rows: minmax(360px, 1fr) auto;
  }
  .scan-stage {
    min-height: 360px;
    padding: 10px;
  }
  .beer-mug {
    width: min(84vw, 300px);
    max-height: 43svh;
  }
  .copy-panel {
    padding: 0 14px 16px;
    gap: 10px;
  }
  .diagnostics {
    grid-template-columns: repeat(2, 1fr);
  }
  .ticket {
    top: 5%;
    width: min(280px, 82vw);
    min-height: 198px;
    padding: 15px;
  }
  .ticket strong {
    font-size: 25px;
  }
  .ticket p { font-size: 13px; }
  .stamp {
    font-size: 15px;
  }
  .punchline p:first-child { font-size: clamp(22px, 7.2vw, 30px); }
  .punchline p:last-child { font-size: clamp(18px, 6vw, 24px); }
  .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .beer-fill,
  .liquid-wave,
  .foam-layer,
  .ticket,
  .progress-track span {
    transition-duration: 80ms;
  }
}
