:root {
  color-scheme: dark;
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --panel: rgba(6, 31, 24, 0.78);
  --line: rgba(255, 255, 255, 0.22);
  --primary: #00d084;
  --primary-strong: #00a86b;
  --primary-soft: #9dffcb;
  --teal: #17d7bd;
  --lime: #9dff6a;
  --amber: #f8d55f;
  --danger: #ff5a6a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #03110d;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

body {
  display: grid;
  min-height: 100svh;
  place-items: center;
  overflow: hidden;
}

.phone-shell {
  position: relative;
  width: min(100vw, 430px);
  height: 100svh;
  min-height: 620px;
  max-height: 932px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 208, 132, 0.28), transparent 30%),
    linear-gradient(165deg, #06271d 0%, #0b3a2b 46%, #03110d 100%);
  isolation: isolate;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 100%;
  padding: max(22px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

.screen.is-active {
  display: flex;
}

.intro-screen,
.complete-screen {
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.ambient-grid {
  position: absolute;
  inset: -18%;
  z-index: -1;
  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: 36px 36px;
  mask-image: radial-gradient(circle at 50% 35%, black 0%, transparent 72%);
  transform: perspective(500px) rotateX(58deg) scale(1.18);
}

.brand-lockup {
  width: 100%;
  padding-top: 6px;
  text-align: center;
}

.brand-lockup.compact {
  padding-top: 28px;
}

.brand-kicker {
  display: block;
  color: var(--lime);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 3px 0 0;
  font-size: clamp(2rem, 9vw, 2.95rem);
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.25), 0 0 28px rgba(0, 208, 132, 0.34);
}

.character-stage {
  width: min(82vw, 330px);
  border: 2px solid rgba(0, 208, 132, 0.78);
  background: linear-gradient(180deg, rgba(8, 65, 47, 0.66), rgba(5, 30, 23, 0.88));
  box-shadow: 0 0 28px rgba(0, 208, 132, 0.3);
}

.character-stage canvas,
.preview-viewport canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.preview-viewport,
.reward-viewport {
  width: 100%;
  overflow: hidden;
}

.preview-viewport {
  aspect-ratio: 1 / 1;
}

.preview-viewport canvas,
.reward-viewport canvas {
  height: 100%;
}

.collector-card {
  display: grid;
  min-height: 56px;
  place-items: center;
  background: linear-gradient(90deg, #008f5d, #00d084);
  font-weight: 900;
  font-size: 1.2rem;
}

.qr-panel {
  display: flex;
  width: min(82vw, 330px);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.86rem;
}

.qr-panel[hidden] {
  display: none;
}

select {
  min-width: 118px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(3, 17, 13, 0.9);
  color: var(--ink);
  font-weight: 800;
}

.intro-actions,
.complete-actions {
  display: grid;
  gap: 12px;
}

.primary-action,
.secondary-action {
  width: min(82vw, 330px);
  min-height: 56px;
  border: 0;
  border-radius: 5px;
  color: white;
  font-weight: 950;
  text-transform: uppercase;
}

.primary-action {
  background: linear-gradient(135deg, #008f5d, #00d084);
  box-shadow: 0 10px 28px rgba(0, 208, 132, 0.32);
}

.secondary-action {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
}

.primary-action:disabled {
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.54);
  box-shadow: none;
}

.game-screen {
  padding: 0;
  background: #111;
}

#cameraFeed,
.camera-fallback,
#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-fallback {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(155deg, #28443a 0%, #6f8b78 50%, #23332e 100%);
  background-size: 58px 58px, 58px 58px, auto;
}

#gameCanvas {
  z-index: 2;
  touch-action: none;
}

.top-hud {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.top-hud strong,
.eyebrow {
  display: block;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.top-hud strong {
  margin-top: 2px;
  font-size: 1.04rem;
}

.eyebrow {
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(4, 26, 20, 0.76);
  color: var(--ink);
  font-weight: 900;
}

.capture-reticle {
  position: absolute;
  z-index: 3;
  top: 27%;
  left: 50%;
  width: min(72vw, 300px);
  height: min(72vw, 300px);
  transform: translateX(-50%);
  pointer-events: none;
}

.capture-reticle span {
  position: absolute;
  width: 72px;
  height: 72px;
  border-color: var(--primary);
  filter: drop-shadow(0 0 10px rgba(0, 208, 132, 0.8));
}

.capture-reticle span:nth-child(1) {
  top: 0;
  left: 0;
  border-top: 7px solid;
  border-left: 7px solid;
  border-radius: 18px 0 0 0;
}

.capture-reticle span:nth-child(2) {
  top: 0;
  right: 0;
  border-top: 7px solid;
  border-right: 7px solid;
  border-radius: 0 18px 0 0;
}

.capture-reticle span:nth-child(3) {
  bottom: 0;
  left: 0;
  border-bottom: 7px solid;
  border-left: 7px solid;
  border-radius: 0 0 0 18px;
}

.capture-reticle span:nth-child(4) {
  right: 0;
  bottom: 0;
  border-right: 7px solid;
  border-bottom: 7px solid;
  border-radius: 0 0 18px 0;
}

.start-overlay {
  position: absolute;
  z-index: 5;
  top: calc(27% + min(72vw, 300px) * 0.27);
  left: 50%;
  display: grid;
  width: min(76vw, 320px);
  transform: translateX(-50%);
  gap: 13px;
  justify-items: center;
  text-align: center;
  pointer-events: none;
}

.start-overlay.is-hidden {
  display: none;
}

.start-copy {
  display: grid;
  gap: 2px;
  color: var(--ink);
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.78);
}

.start-copy strong {
  color: var(--primary);
  font-size: 1.12rem;
  font-weight: 950;
  text-transform: uppercase;
}

.start-copy span {
  font-size: 0.92rem;
  font-weight: 800;
}

.start-now-button {
  pointer-events: auto;
  width: min(68vw, 292px);
  min-height: 54px;
  border: 0;
  border-radius: 5px;
  background: linear-gradient(135deg, #00a86b, #00d084);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.36),
    0 0 24px rgba(0, 208, 132, 0.42);
  color: white;
  font-size: 1rem;
  font-weight: 950;
  text-transform: uppercase;
}

.status-pill {
  position: absolute;
  z-index: 4;
  right: 18px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  left: 18px;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 5px;
  background: rgba(0, 143, 93, 0.92);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.status-pill strong {
  min-width: 0;
}

.status-pill.is-escaped {
  background: rgba(228, 34, 61, 0.92);
}

.status-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px rgba(145, 255, 62, 0.8);
}

.is-escaped .status-dot {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.86);
}

.timer-card {
  position: absolute;
  z-index: 4;
  right: 18px;
  bottom: calc(32px + env(safe-area-inset-bottom));
  left: 18px;
  display: grid;
  grid-template-columns: 36px 1fr 58px;
  align-items: center;
  gap: 10px;
}

.timer-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-strong);
  font-weight: 950;
}

.timer-track {
  height: 20px;
  border-radius: 3px;
  background: rgba(7, 7, 14, 0.76);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.timer-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--lime), var(--primary-soft));
}

#timerText {
  font-size: 1.65rem;
  text-align: right;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.78);
}

.reward-card {
  position: relative;
  width: min(82vw, 330px);
  border: 2px solid rgba(0, 208, 132, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 35%),
    rgba(4, 24, 19, 0.84);
  box-shadow: 0 0 30px rgba(0, 208, 132, 0.28);
}

.reward-card::before,
.reward-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

.reward-card canvas,
.reward-viewport {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.reward-name {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.complete-actions {
  padding-bottom: 8px;
}

@media (min-width: 700px) {
  body {
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
      #020b08;
    background-size: 42px 42px;
  }

  .phone-shell {
    height: min(100svh, 932px);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }
}
