:root {
  --bg: #061018;
  --panel: #0e1b27;
  --panel-soft: #15293c;
  --ink: #f2f8ff;
  --muted: #8fa3b6;
  --line: #284057;
  --accent: #30eec0;
  --danger: #ff5f7f;
  --warn: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  background:
    radial-gradient(circle at top, #17415f 0%, #17415f00 33%),
    linear-gradient(180deg, #071019 0%, var(--bg) 100%);
}

.scanner-shell,
.result-shell {
  width: min(760px, 96vw);
  height: 100dvh;
  margin: 0 auto;
  padding: 0.5rem 0.25rem 0;
  overflow: hidden;
}

.scanner-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 0.35rem;
}

.result-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.55rem;
}

.scanner-header,
.scanner-frame-card,
.scanner-manual,
.result-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, #0b1520 100%);
  border-radius: 24px;
  box-shadow: 0 20px 50px #00000045;
}

.scanner-eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--warn);
}

.scanner-header h1,
.result-card h1 {
  margin: 0;
  font-family: "Sora", sans-serif;
  letter-spacing: -0.01em;
}

.scanner-copy,
.scanner-feedback,
.result-message {
  color: var(--muted);
}

.scanner-stat {
  min-width: 136px;
  padding: 0.8rem;
  border-radius: 16px;
  background: var(--panel-soft);
}

.scanner-stat span {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.scanner-stat strong {
  font-size: 1.75rem;
  font-family: "Sora", sans-serif;
}

.scanner-frame-card {
  position: relative;
  overflow: hidden;
  padding: 0;
  min-height: 0;
  height: auto;
  border-radius: 18px;
  animation: slide-up 0.22s ease;
}

.reader {
  height: 100%;
}

#reader {
  width: 100%;
  height: 100%;
}

#reader__scan_region {
  min-height: 100%;
  display: grid;
  place-items: center;
}

#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.scanner-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.scanner-box {
  width: min(286px, 62vw);
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 24px;
  box-shadow:
    0 0 0 200vmax #00000055,
    0 0 30px #30eec045;
}

.scanner-box::before,
.scanner-box::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.scanner-box::before {
  border: 2px solid #ffffff20;
  transform: scale(1.06);
}

.scanner-box::after {
  border-top: 2px solid #9effdf;
  animation: sweep 1.6s linear infinite;
}

.scanner-manual {
  padding: 0.5rem;
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 0.45rem;
  border-radius: 14px;
}

label {
  display: grid;
  gap: 0.18rem;
  color: var(--muted);
  font-size: 0.78rem;
}

input,
button,
.discard-link {
  width: 100%;
  border-radius: 12px;
  padding: 0.66rem 0.8rem;
  font: inherit;
}

input {
  border: 1px solid #2c4f6f;
  background: #0d1822;
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus {
  outline: none;
  border-color: #4d7da1;
  box-shadow: 0 0 0 3px #4d7da133;
}

button,
.discard-link {
  border: 0;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease;
}

button:hover,
.discard-link:hover {
  filter: saturate(1.05);
}

button:active,
.discard-link:active {
  transform: scale(0.99);
}

#manual-submit,
.redeem-button {
  background: linear-gradient(180deg, #4affc7 0%, var(--accent) 100%);
  color: #052117;
  font-weight: 800;
}

.discard-link {
  background: #162738;
  color: #dfeaf6;
}

.hidden {
  display: none !important;
}

.scan-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 0.75rem;
  background: #04080ecc;
  z-index: 70;
  backdrop-filter: blur(6px);
}

.scan-loading p {
  margin: 0;
  font-family: "Sora", sans-serif;
  letter-spacing: 0.03em;
}

.scan-loading-spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid #ffffff26;
  border-top-color: #98fce0;
  animation: spin 0.8s linear infinite;
}

.scanner-feedback {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 4.2rem);
  min-height: 0;
  margin: 0;
  text-align: center;
  font-size: 0.76rem;
  opacity: 0.82;
  pointer-events: none;
  z-index: 25;
}

.result-card {
  max-width: 580px;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  max-height: none;
  overflow: auto;
  animation: pop-in 0.28s ease;
}

.result-card.is-valid {
  border-color: #2b7b68;
}

.result-card.is-invalid {
  border-color: #763243;
}

.result-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 0.9rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: "Sora", sans-serif;
  font-size: 2.8rem;
}

.is-valid .result-icon {
  background: #1f5e4f;
  color: #a4ffe2;
}

.is-invalid .result-icon {
  background: #5c2430;
  color: #ffc4cf;
}

.result-ticket-meta {
  display: grid;
  gap: 0.3rem;
  margin: 1rem auto;
  padding: 0.9rem;
  max-width: 420px;
  border-radius: 14px;
  background: var(--panel-soft);
}

.inline-stat {
  max-width: 220px;
  margin: 1.2rem auto;
}

.result-actions {
  display: grid;
  gap: 0.8rem;
  max-width: 380px;
  margin: 1rem auto 0;
}

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  color: #9fb0c0;
  font-size: 0.8rem;
  padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
}

.site-footer a {
  color: #dce8f7;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.scanner-footer {
  margin-top: 0.2rem;
}

.redeem-button {
  font-size: 1.22rem;
  min-height: 66px;
  letter-spacing: 0.03em;
}

.redeem-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 760px) {
  html,
  body {
    overflow: hidden;
  }

  .scanner-header,
  .scanner-manual {
    grid-template-columns: 1fr;
    display: grid;
  }

  .scanner-shell,
  .result-shell {
    width: 100vw;
    padding: max(0.35rem, env(safe-area-inset-top)) 0.35rem 0;
  }

  .scanner-shell {
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 0.35rem;
  }

  .scanner-frame-card {
    min-height: 0;
    border-radius: 14px;
  }

  .scanner-manual {
    grid-template-columns: 1fr 108px;
    padding: 0.38rem 0.38rem max(0.38rem, env(safe-area-inset-bottom));
    gap: 0.42rem;
  }

  .scanner-box {
    width: min(230px, 62vw);
    border-radius: 16px;
  }

  label {
    font-size: 0.72rem;
  }

  input,
  button {
    padding: 0.6rem 0.72rem;
    font-size: 0.92rem;
  }

  .result-card {
    padding: 1.05rem;
    border-radius: 18px;
  }

  .scanner-feedback {
    bottom: calc(env(safe-area-inset-bottom) + 3.55rem);
  }

  .result-card h1 {
    font-size: 1.35rem;
  }

  .result-message {
    font-size: 0.94rem;
    margin-top: 0.45rem;
  }

  .result-ticket-meta {
    margin: 0.8rem auto;
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .inline-stat {
    margin: 0.75rem auto;
  }

  .result-actions {
    gap: 0.55rem;
    margin-top: 0.7rem;
  }

  .redeem-button {
    min-height: 58px;
    font-size: 1.08rem;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sweep {
  from {
    transform: translateY(-2px) scaleX(0.96);
    opacity: 0.85;
  }
  50% {
    transform: translateY(244px) scaleX(1);
    opacity: 1;
  }
  to {
    transform: translateY(0) scaleX(0.96);
    opacity: 0.85;
  }
}