:root {
  color-scheme: dark;
  --ink: #f7f8ef;
  --muted: #aab0a2;
  --black: #0b0d09;
  --charcoal: #151812;
  --panel: #f8f7ef;
  --panel-ink: #12140f;
  --line: rgba(247, 248, 239, 0.14);
  --acid: #b9ff38;
  --acid-strong: #86d900;
  --hot: #ff5a3d;
  --cyan: #44d7ff;
  --shadow: rgba(0, 0, 0, 0.45);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 12%, rgba(185, 255, 56, 0.14), transparent 24%),
    radial-gradient(circle at 88% 8%, rgba(255, 90, 61, 0.13), transparent 26%),
    linear-gradient(180deg, #171a13 0%, var(--black) 62%);
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 68%);
}

body:has(.result-modal.visible) {
  overflow: hidden;
}

a.button-link,
button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  padding: 28px;
  place-items: center;
}

.scan-stage {
  width: min(100%, 1120px);
}

.brand-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--acid);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(3.2rem, 8vw, 8.7rem);
  font-weight: 1000;
  line-height: 0.82;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 0;
  color: var(--panel-ink);
  font-size: clamp(2.1rem, 5vw, 5rem);
  font-weight: 1000;
  line-height: 0.88;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 11px 14px;
  border: 1px solid rgba(185, 255, 56, 0.35);
  border-radius: 8px;
  background: rgba(185, 255, 56, 0.1);
  color: var(--acid);
  font-size: 0.84rem;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  box-shadow: inset 0 0 24px rgba(185, 255, 56, 0.08);
}

.viewer {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: min(58vh, 620px);
  min-height: 420px;
  border: 1px solid rgba(247, 248, 239, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(185, 255, 56, 0.14), transparent 34%),
    #070906;
  box-shadow:
    0 36px 110px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.viewer::before {
  position: absolute;
  inset: 18px;
  z-index: 2;
  border: 1px solid rgba(185, 255, 56, 0.2);
  border-radius: 6px;
  content: "";
  pointer-events: none;
}

.viewer::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(transparent 0 49%, rgba(185, 255, 56, 0.14) 50%, transparent 51%),
    linear-gradient(90deg, transparent 0 49%, rgba(185, 255, 56, 0.12) 50%, transparent 51%),
    radial-gradient(circle at center, transparent 42%, rgba(0, 0, 0, 0.55));
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

canvas {
  display: none;
}

.viewer.captured video {
  display: none;
}

.viewer.captured canvas {
  display: block;
}

.viewer.flash::after {
  background: rgba(255, 255, 255, 0.9);
  animation: flash-pop 420ms ease forwards;
}

@keyframes flash-pop {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.pose-guide {
  position: absolute;
  inset: 9% 32% 8%;
  z-index: 3;
  pointer-events: none;
}

.viewer.captured .pose-guide {
  display: none;
}

.head,
.body {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.head {
  top: 0;
  width: 76px;
  aspect-ratio: 1;
  border: 2px solid rgba(185, 255, 56, 0.88);
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(185, 255, 56, 0.28);
}

.body {
  top: 96px;
  width: 230px;
  height: calc(100% - 96px);
  border: 2px solid rgba(185, 255, 56, 0.7);
  border-radius: 50% 50% 34% 34%;
  box-shadow: 0 0 42px rgba(185, 255, 56, 0.18);
}

.scan-line {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 14%;
  height: 3px;
  background: var(--acid);
  box-shadow:
    0 0 22px rgba(185, 255, 56, 0.95),
    0 0 70px rgba(68, 215, 255, 0.45);
  animation: scan 2.1s ease-in-out infinite;
}

@keyframes scan {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(395px);
  }
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  color: var(--acid);
  font-size: clamp(7rem, 18vw, 15rem);
  font-weight: 1000;
  line-height: 1;
  pointer-events: none;
  text-shadow:
    0 0 30px rgba(185, 255, 56, 0.65),
    0 18px 70px rgba(0, 0, 0, 0.7);
}

.ai-thinking {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  display: grid;
  width: min(360px, calc(100% - 56px));
  min-height: 220px;
  place-items: center;
  border: 1px solid rgba(185, 255, 56, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(185, 255, 56, 0.14), rgba(68, 215, 255, 0.06)),
    rgba(7, 9, 6, 0.82);
  color: var(--ink);
  opacity: 0;
  padding: 24px;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -50%) scale(0.94);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  backdrop-filter: blur(14px);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.45),
    inset 0 0 40px rgba(185, 255, 56, 0.08);
}

.ai-thinking.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.thinking-orbit {
  position: relative;
  width: 92px;
  aspect-ratio: 1;
  margin-bottom: 14px;
}

.thinking-orbit span {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--acid);
  border-radius: 50%;
  animation: orbit-spin 860ms linear infinite;
  filter: drop-shadow(0 0 12px rgba(185, 255, 56, 0.45));
}

.thinking-orbit span:nth-child(2) {
  inset: 12px;
  border-top-color: var(--cyan);
  animation-duration: 1120ms;
  animation-direction: reverse;
}

.thinking-orbit span:nth-child(3) {
  inset: 25px;
  border-top-color: var(--hot);
  animation-duration: 720ms;
}

@keyframes orbit-spin {
  to {
    transform: rotate(360deg);
  }
}

.ai-thinking p {
  margin: 0 0 7px;
  color: var(--acid);
  font-size: clamp(1.55rem, 5vw, 2.7rem);
  font-weight: 1000;
  line-height: 0.95;
  text-transform: uppercase;
}

.ai-thinking small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button,
.button-link {
  display: inline-grid;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(247, 248, 239, 0.16);
  border-radius: 8px;
  background: rgba(247, 248, 239, 0.08);
  color: var(--ink);
  cursor: pointer;
  font-weight: 950;
  padding: 0 20px;
  text-decoration: none;
  text-transform: uppercase;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

button:hover,
.button-link:hover {
  border-color: rgba(185, 255, 56, 0.72);
  background: rgba(185, 255, 56, 0.11);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.primary {
  min-width: 166px;
  border-color: var(--acid);
  background: var(--acid);
  color: #0d1108;
  box-shadow: 0 14px 34px rgba(185, 255, 56, 0.22);
}

.primary:hover {
  background: var(--acid-strong);
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.result-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(185, 255, 56, 0.18), transparent 34%),
    rgba(5, 7, 4, 0.78);
  backdrop-filter: blur(12px);
}

.modal-panel {
  position: relative;
  overflow: hidden;
  width: min(100%, 500px);
  border: 1px solid rgba(18, 20, 15, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(185, 255, 56, 0.34), transparent 32%),
    var(--panel);
  color: var(--panel-ink);
  padding: 28px;
  text-align: center;
  box-shadow:
    0 44px 140px rgba(0, 0, 0, 0.45),
    0 0 0 10px rgba(185, 255, 56, 0.08);
  transform: scale(0.84) translateY(28px);
}

.result-modal.visible .modal-panel {
  animation: modal-boom 520ms cubic-bezier(0.18, 1.35, 0.28, 1) forwards;
}

@keyframes modal-boom {
  0% {
    transform: scale(0.84) translateY(28px);
  }
  62% {
    transform: scale(1.04) translateY(-4px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.burst span {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 8px;
  height: 118px;
  border-radius: 999px;
  background: rgba(255, 90, 61, 0.15);
  transform-origin: 50% 120%;
}

.burst span:nth-child(1) {
  transform: translate(-50%, -50%) rotate(0deg);
}

.burst span:nth-child(2) {
  transform: translate(-50%, -50%) rotate(38deg);
}

.burst span:nth-child(3) {
  transform: translate(-50%, -50%) rotate(76deg);
}

.burst span:nth-child(4) {
  transform: translate(-50%, -50%) rotate(114deg);
}

.burst span:nth-child(5) {
  transform: translate(-50%, -50%) rotate(152deg);
}

.burst span:nth-child(6) {
  transform: translate(-50%, -50%) rotate(190deg);
}

.boom {
  position: relative;
  display: inline-grid;
  min-height: 34px;
  margin: 0 0 14px;
  place-items: center;
  border-radius: 8px;
  background: var(--hot);
  color: #fff;
  padding: 6px 14px;
  font-size: 0.86rem;
  font-weight: 1000;
  text-transform: uppercase;
  transform: rotate(-2deg);
}

.result-label {
  position: relative;
  margin-bottom: 8px;
  color: #53564d;
  font-size: 0.78rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.modal-score {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  color: var(--panel-ink);
  font-size: clamp(5.5rem, 18vw, 9.5rem);
  font-weight: 1000;
  line-height: 0.86;
  letter-spacing: 0;
}

.modal-score span:last-child {
  color: var(--hot);
  font-size: 2.15rem;
}

.modal-range {
  position: relative;
  margin: 14px 0 22px;
  color: #53564d;
  font-size: 1.02rem;
  font-weight: 900;
}

.modal-actions {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-actions button:not(.primary) {
  border-color: rgba(18, 20, 15, 0.15);
  background: #fff;
  color: var(--panel-ink);
}

.leaderboard {
  margin-top: 18px;
  border: 1px solid rgba(247, 248, 239, 0.14);
  border-radius: 8px;
  background: var(--panel);
  color: var(--panel-ink);
  padding: 18px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.24);
}

.leaderboard.standalone {
  margin-top: 0;
}

.leaderboard-page {
  align-items: start;
}

.leaderboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.leaderboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.leaderboard-actions button:not(.primary) {
  border-color: rgba(18, 20, 15, 0.16);
  background: rgba(18, 20, 15, 0.06);
  color: var(--panel-ink);
}

.leaderboard .eyebrow {
  color: var(--hot);
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  border: 1px solid rgba(18, 20, 15, 0.09);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.leaderboard-list li:first-child {
  min-height: 86px;
  border-color: rgba(185, 255, 56, 0.95);
  background:
    linear-gradient(135deg, rgba(185, 255, 56, 0.4), transparent 44%),
    #11150d;
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(18, 20, 15, 0.22);
}

.leaderboard-list li:nth-child(2) {
  border-color: rgba(68, 215, 255, 0.45);
}

.leaderboard-list li:nth-child(3) {
  border-color: rgba(255, 90, 61, 0.42);
}

.rank {
  display: grid;
  width: 36px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  background: #151812;
  color: var(--acid);
  font-size: 1rem;
  font-weight: 1000;
}

.leaderboard-list input {
  min-width: 0;
  height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 0 8px;
  font-size: 1rem;
  font-weight: 950;
  outline: none;
}

.leaderboard-list input:focus {
  border-color: var(--hot);
  background: rgba(255, 90, 61, 0.08);
}

.leaderboard-list input[readonly] {
  cursor: default;
}

.leaderboard-list input[readonly]:focus {
  border-color: transparent;
  background: transparent;
}

.leaderboard-list strong {
  color: var(--hot);
  font-size: 1.45rem;
  font-weight: 1000;
}

.leaderboard-list li:first-child strong {
  color: var(--acid);
  font-size: 2rem;
}

.leaderboard-list button {
  min-height: 38px;
  padding: 0 12px;
  border-color: rgba(18, 20, 15, 0.12);
  background: rgba(18, 20, 15, 0.04);
  color: inherit;
  font-size: 0.8rem;
}

.leaderboard-list .empty-board {
  display: block;
  color: #56594d;
  font-weight: 950;
  text-align: center;
}

.footnote {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
    place-items: start;
  }

  .brand-row,
  .leaderboard-head {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(3rem, 17vw, 5.8rem);
  }

  .viewer {
    height: 46vh;
    min-height: 340px;
  }

  .pose-guide {
    inset-inline: 19%;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .primary {
    min-width: 0;
  }

  .leaderboard-list li {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    padding-inline: 9px;
  }

  .leaderboard-list button {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .modal-panel {
    padding: 24px 18px;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}
