:root {
  --bg: #090b10;
  --text: #f5f6f7;
  --muted: rgba(255,255,255,0.74);
  --accent: #e4bb6b;
  --accent-2: rgba(228, 187, 107, 0.18);
  --panel: rgba(10, 14, 22, 0.5);
  --panel-strong: rgba(8, 12, 18, 0.7);
  --stroke: rgba(255,255,255,0.12);
  --shadow: 0 20px 60px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }

.app, .stage {
  width: 100%;
  height: 100%;
  position: relative;
}

.stage {
  overflow: hidden;
  background: #000;
}

video, #capturedPreview, #resultImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.gradient-top {
  background: linear-gradient(to bottom, rgba(0,0,0,0.42), rgba(0,0,0,0));
}
.gradient-bottom {
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0));
}
.gradient-bottom.strong {
  background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.12) 45%, rgba(0,0,0,0));
}

.center-copy {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: min(92vw, 980px);
  text-align: center;
  z-index: 2;
}
.center-copy h1 {
  margin: 0 0 16px;
  font-size: clamp(40px, 4vw, 72px);
  line-height: 1.05;
}
.status {
  font-size: clamp(22px, 2vw, 32px);
  color: var(--muted);
  margin-bottom: 22px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.actions-main { justify-content: center; }

button {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 18px 30px;
  min-height: 68px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.6; cursor: default; transform: none; }
button.primary {
  color: #221400;
  background: linear-gradient(180deg, #f3d48e, #e1b461);
  font-weight: 800;
}
button.secondary {
  color: var(--text);
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--stroke);
  font-weight: 700;
}
button.xl {
  min-height: 84px;
  padding: 22px 42px;
  font-size: clamp(24px, 2vw, 34px);
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 6;
  font-size: clamp(140px, 20vw, 260px);
  font-weight: 900;
  text-shadow: 0 18px 60px rgba(0,0,0,0.55);
}

.loader {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  backdrop-filter: blur(24px) saturate(1.05);
  background: rgba(5, 8, 14, 0.38);
}
.loader-card {
  width: min(92vw, 620px);
  border-radius: 32px;
  padding: 34px 28px;
  background: rgba(9, 12, 19, 0.76);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 20px 80px rgba(0,0,0,0.38);
  text-align: center;
}
.spinner {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 8px solid rgba(255,255,255,0.18);
  border-top-color: var(--accent);
  margin: 0 auto 18px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-size: clamp(28px, 2.2vw, 38px);
  font-weight: 800;
  margin-bottom: 8px;
}
.loader-subtext {
  font-size: clamp(18px, 1.5vw, 24px);
  color: var(--muted);
}

.photo-panel,
.result-panel,
.gallery-shell,
.qr-card,
.idle-badge {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.photo-panel {
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  width: min(94vw, 1240px);
  padding: 28px;
  border-radius: 32px;
}
.panel-head h2,
.result-title,
.gallery-head h3 {
  margin: 0 0 10px;
  font-size: clamp(28px, 2.6vw, 48px);
}
.panel-head p,
.result-subtitle {
  margin: 0 0 20px;
  font-size: clamp(18px, 1.5vw, 25px);
  color: var(--muted);
}

.styles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.style-card {
  min-height: 96px;
  border-radius: 26px;
  padding: 16px 20px;
  text-align: left;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.09);
  color: var(--text);
}
.style-card span {
  display: block;
  font-size: clamp(22px, 1.9vw, 30px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
}
.style-card small {
  display: block;
  font-size: 16px;
  color: var(--muted);
}

.result-side {
  position: absolute;
  top: 28px;
  right: 28px;
  z-index: 3;
}
.qr-card {
  width: 220px;
  padding: 16px;
  border-radius: 24px;
  text-align: center;
  background: rgba(10, 14, 22, 0.72);
}
.qr-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 10px;
}
#qrImage {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  background: #fff;
  display: block;
}
.qr-hint {
  margin-top: 10px;
  font-size: 15px;
  color: var(--muted);
}

.result-panel {
  left: 28px;
  right: 28px;
  bottom: 176px;
  border-radius: 32px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.result-title { margin-bottom: 8px; }
.result-subtitle { margin: 0; }

.gallery-shell {
  left: 28px;
  right: 28px;
  bottom: 28px;
  border-radius: 28px;
  padding: 16px;
  background: rgba(7, 10, 16, 0.74);
}
.gallery-head h3 {
  font-size: clamp(22px, 1.8vw, 30px);
  margin-bottom: 12px;
}
.gallery-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.gallery-strip::-webkit-scrollbar { height: 8px; }
.gallery-strip::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 999px;
}
.gallery-item,
.gallery-empty {
  flex: 0 0 180px;
}
.gallery-item {
  text-decoration: none;
  color: var(--text);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.gallery-meta {
  padding: 10px;
  display: grid;
  gap: 4px;
}
.gallery-meta strong {
  font-size: 14px;
  line-height: 1.15;
}
.gallery-meta span,
.gallery-empty {
  font-size: 13px;
  color: var(--muted);
}
.gallery-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(255,255,255,0.1);
}

.idle-badge {
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
}
.idle-badge-bottom {
  bottom: 18px;
}

@media (max-width: 980px) {
  .styles { grid-template-columns: 1fr; }
  .result-panel {
    bottom: 210px;
    flex-direction: column;
    align-items: stretch;
  }
  .actions { width: 100%; }
  .actions button { flex: 1 1 auto; }
  .result-side {
    top: 14px;
    right: 14px;
  }
  .qr-card { width: 160px; }
  .gallery-item, .gallery-empty { flex-basis: 140px; }
}
