:root {
  --bg: #0d0d0d;
  --panel: #151515;
  --text: #ffffff;
  --muted: #d8d8d8;
  --accent: #ff7a00;
  --accent-deep: #ca5900;
  --line: #2a2a2a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Barlow", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, #1d1d1d 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, #2f1905 0%, transparent 35%),
    linear-gradient(160deg, #080808 0%, #121212 100%);
}

.app-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  height: 100dvh;
  min-height: 100dvh;
  padding: 14px 14px 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-row h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 24px rgba(255, 122, 0, 0.75);
}

.screen {
  display: none;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  min-height: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: reveal 0.45s ease;
}

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

.step-label {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h2 {
  margin: 6px 0;
  font-size: 1.35rem;
}

.screen-note {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.tiny {
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 16px;
  width: 100%;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  color: #111;
  background: linear-gradient(145deg, #ff9a3d, var(--accent));
}

.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid #5d5d5d;
}

.btn-small {
  min-height: 36px;
  margin-bottom: 8px;
}

.ratio-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.ratio-btn {
  border: 1px solid #4c4c4c;
  border-radius: 10px;
  min-height: 40px;
  color: #eee;
  background: #1a1a1a;
  font-weight: 700;
}

.ratio-btn.active {
  border-color: var(--accent);
  color: #111;
  background: var(--accent);
}

.camera-wrap {
  width: min(100%, 300px, calc(38dvh * 9 / 16));
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #434343;
  position: relative;
  background: #090909;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
}

.camera-wrap[data-ratio="3:4"] {
  width: min(100%, 300px, calc(38dvh * 3 / 4));
  aspect-ratio: 3 / 4;
}

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

.camera-guide {
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.error-text {
  margin: 8px 0 0;
  color: #ff9f9f;
  font-weight: 600;
}

.qr-box {
  width: 100%;
  min-height: 150px;
  height: clamp(150px, 28dvh, 220px);
  border-radius: 14px;
  border: 1px solid #3a3a3a;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 12px;
}

.qr-box img,
.qr-box canvas {
  max-width: 100%;
  height: auto;
}

.qr-url-text {
  margin: 8px 0 10px;
  color: #ffbd85;
  font-size: 0.85rem;
  word-break: break-all;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  z-index: 99;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loader-panel {
  background: #171717;
  border: 1px solid #383838;
  border-radius: 16px;
  padding: 20px;
  min-width: 220px;
  text-align: center;
}

.loader-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  margin: 0 auto 12px;
  border: 4px solid #3d3d3d;
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

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

@media (min-width: 700px) {
  .app-shell {
    padding-top: 20px;
  }

  .screen {
    padding: 18px;
  }
}

@media (max-height: 760px) {
  .app-shell {
    padding: 10px 10px 12px;
    gap: 8px;
  }

  .brand-row h1 {
    font-size: 1.15rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .screen-note {
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .camera-wrap {
    width: min(100%, 260px, calc(32dvh * 9 / 16));
  }

  .camera-wrap[data-ratio="3:4"] {
    width: min(100%, 260px, calc(32dvh * 3 / 4));
  }

  .qr-box {
    height: clamp(130px, 24dvh, 170px);
  }
}
