:root {
  --bg: #081120;
  --bg-2: #101a34;
  --card: rgba(255, 255, 255, 0.08);
  --card-2: rgba(255, 255, 255, 0.05);
  --text: #ffffff;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.14);
  --primary-a: #14b8a6;
  --primary-b: #2563eb;
  --danger: #e11d48;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --btn-height: 54px;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.18), transparent 28%),
    linear-gradient(180deg, #081120 0%, #0b1328 100%);
  color: var(--text);
  font-family: "Inter", sans-serif;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
a,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.42;
  pointer-events: none;
}

.orb-1 {
  width: 340px;
  height: 340px;
  top: -120px;
  left: -70px;
  background: rgba(20, 184, 166, 0.35);
}

.orb-2 {
  width: 420px;
  height: 420px;
  right: -160px;
  bottom: -120px;
  background: rgba(37, 99, 235, 0.30);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent);
  pointer-events: none;
}

.app-container {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  padding: 12px;
  display: grid;
  place-items: center;
}

.screen {
  display: none;
  width: 100%;
  min-height: calc(100vh - 24px);
  animation: fadeUp .22s ease;
}

.screen.active {
  display: block;
}

.glass {
  background: linear-gradient(180deg, rgba(255,255,255,.11), rgba(255,255,255,.05));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand-badge,
.brand-mini {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.welcome-card {
  width: min(96vw, 1180px);
  margin: auto;
  padding: 34px 26px;
  border-radius: 34px;
  text-align: center;
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.welcome-card h1 {
  margin: 18px 0 14px;
  font-family: "Poppins", sans-serif;
  font-size: clamp(42px, 8vw, 84px);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.welcome-card p {
  max-width: 900px;
  margin: 0 auto 28px;
  color: var(--text-soft);
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.6;
}

.welcome-actions-stack {
  display: grid;
  gap: 14px;
  width: min(100%, 420px);
  margin: 0 auto;
}

.welcome-actions-stack .btn {
  width: 100%;
}

.btn {
  min-height: var(--btn-height);
  padding: 0 22px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  transition: transform .15s ease, opacity .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.btn:hover {
  opacity: 0.98;
}

.btn:active {
  transform: scale(.985);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-a), var(--primary-b));
  box-shadow: 0 16px 40px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
  color: #fff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
}

.template-picker {
  margin: 0 auto 28px;
  width: min(100%, 1080px);
  text-align: left;
}

.template-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.template-picker-head h3 {
  margin: 0;
  font-size: 20px;
}

#selectedTemplateName {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 700;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.template-card,
.filter-card {
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  border-radius: 20px;
  padding: 12px;
  cursor: pointer;
  transition: transform .15s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
  text-align: left;
  color: inherit;
}

.template-card:hover,
.filter-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.24);
  background: rgba(255,255,255,.08);
}

.template-card.active,
.filter-card.active {
  border-color: rgba(20, 184, 166, 0.95);
  box-shadow: 0 0 0 1px rgba(20,184,166,.42) inset, 0 10px 30px rgba(20,184,166,.12);
  background: rgba(255,255,255,.10);
}

.template-thumb {
  height: 170px;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  display: grid;
  place-items: center;
}

.template-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.filter-thumb {
  height: 130px;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  display: grid;
  place-items: center;
}

.filter-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.emoji-thumb {
  height: 110px;
  border-radius: 14px;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  display: grid;
  place-items: center;
  font-size: 54px;
}

.template-meta,
.filter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.template-title,
.filter-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.template-badge,
.filter-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

.top-bar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.shot-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}

#shotInfo {
  font-size: 14px;
  font-weight: 700;
}

.shot-dots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shot-dots span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  transition: transform .18s ease, background .18s ease;
}

.shot-dots span.active {
  background: #fff;
  transform: scale(1.15);
}

.camera-layout {
  height: calc(100vh - 92px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
}

.camera-stage {
  position: relative;
  min-height: 0;
  height: 100%;
  border-radius: 28px;
  overflow: hidden;
}

.camera-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transform: scale(1.06);
  transform-origin: center center;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}

.frame-corner {
  position: absolute;
  width: 42px;
  height: 42px;
  border-color: rgba(255,255,255,.9);
  border-style: solid;
}

.frame-corner.tl {
  top: 14px;
  left: 14px;
  border-width: 4px 0 0 4px;
  border-top-left-radius: 14px;
}

.frame-corner.tr {
  top: 14px;
  right: 14px;
  border-width: 4px 4px 0 0;
  border-top-right-radius: 14px;
}

.frame-corner.bl {
  bottom: 14px;
  left: 14px;
  border-width: 0 0 4px 4px;
  border-bottom-left-radius: 14px;
}

.frame-corner.br {
  bottom: 14px;
  right: 14px;
  border-width: 0 4px 4px 0;
  border-bottom-right-radius: 14px;
}

.side-panel,
.filter-side {
  border-radius: 28px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 10px;
  overflow: hidden;
}

.panel-top {
  display: grid;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.panel-section {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}

.panel-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.panel-value {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.panel-actions {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
  margin-top: 0;
  padding-top: 4px;
}

.panel-actions .btn {
  width: 100%;
}

.preview-grid {
  display: grid;
  gap: 10px;
}

.preview-grid img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Poppins", sans-serif;
  font-size: clamp(92px, 16vw, 160px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 18px 40px rgba(0,0,0,.45);
  z-index: 4;
}

.filter-layout {
  height: calc(100vh - 24px);
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  gap: 12px;
  align-items: stretch;
}

.filter-main {
  border-radius: 28px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.filter-header {
  margin-bottom: 12px;
}

.filter-header h2 {
  margin: 12px 0 8px;
  font-size: 30px;
  line-height: 1.1;
  font-family: "Poppins", sans-serif;
}

.filter-header p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.5;
}

.filter-preview-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.07);
}

.filter-preview-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

.filter-list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.filter-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-right: 2px;
}

.emoji-grid {
  grid-template-columns: 1fr 1fr;
}

.result-layout {
  height: calc(100vh - 24px);
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 320px;
  gap: 12px;
  align-items: stretch;
}

.result-card {
  border-radius: 28px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.result-header {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.result-header h2 {
  margin: 10px 0 0;
  font-size: 28px;
  line-height: 1.1;
  font-family: "Poppins", sans-serif;
}

.strip-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.07);
}

.strip-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

.result-side {
  border-radius: 28px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 0;
}

.qr-wrap {
  width: 220px;
  height: 220px;
  padding: 12px;
  border-radius: 22px;
  background: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  flex: 0 0 auto;
  box-shadow: 0 14px 40px rgba(0,0,0,.16);
}

.qr-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-text {
  margin: 0 0 16px;
  color: var(--text-soft);
  line-height: 1.5;
  font-size: 14px;
}

.result-actions {
  display: grid;
  gap: 10px;
  width: 100%;
}

.result-actions .btn,
.result-actions a {
  width: 100%;
}

.auto-reset-text {
  margin-top: 12px;
  font-size: 14px;
  color: rgba(255,255,255,.75);
  text-align: center;
}

.auto-reset-text strong {
  color: #fff;
}

.flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}

.flash.show {
  animation: flashCapture .25s ease;
}

body.booth-mode {
  cursor: none;
}

body.booth-mode .app-container {
  padding: 8px;
}

body.booth-mode .top-bar {
  height: 42px;
  margin-bottom: 6px;
}

body.booth-mode .camera-layout {
  height: calc(100vh - 64px);
}

@keyframes flashCapture {
  0% { opacity: 0; }
  35% { opacity: .96; }
  100% { opacity: 0; }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .app-container {
    padding: 12px;
  }

  .screen {
    min-height: auto;
  }

  .welcome-card {
    min-height: auto;
    padding: 30px 22px;
  }

  .camera-layout,
  .result-layout,
  .filter-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .camera-stage {
    min-height: 58vh;
  }

  .side-panel,
  .result-side,
  .filter-side {
    height: auto;
    overflow: visible;
  }

  .panel-top {
    overflow: visible;
  }

  .template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .strip-stage img,
  .filter-preview-stage img {
    max-height: 56vh;
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 10px;
  }

  .welcome-card h1 {
    font-size: clamp(34px, 10vw, 52px);
  }

  .welcome-card p {
    font-size: 17px;
  }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }

  .template-grid,
  .filter-grid,
  .emoji-grid {
    grid-template-columns: 1fr;
  }

  .template-picker-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-card {
    padding: 24px 16px;
  }

  .result-layout,
  .filter-layout {
    gap: 12px;
  }

  .qr-wrap {
    width: 180px;
    height: 180px;
  }

  .camera-stage {
    min-height: 50vh;
  }

  .btn {
    font-size: 16px;
  }
}