:root {
  --bg: #05030a;
  --panel: rgba(16, 10, 30, 0.82);
  --panel-strong: rgba(20, 12, 42, 0.95);
  --text: #fff8ff;
  --muted: #cfc2dc;
  --neon-pink: #ff3df2;
  --neon-cyan: #26f7ff;
  --neon-lime: #bcff2f;
  --soft-red: #ff6f7d;
  --disabled: #5d576b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 61, 242, .23), transparent 28%),
    radial-gradient(circle at 80% 80%, rgba(38, 247, 255, .18), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

button, label { -webkit-tap-highlight-color: transparent; }

.app-shell {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 100dvh;
  padding: calc(18px + var(--safe-top)) 18px calc(92px + var(--safe-bottom));
}

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

.screen-welcome,
.screen-done {
  place-items: center;
}

.screen-capture {
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding-bottom: calc(86px + var(--safe-bottom));
}

.neon-card {
  width: min(720px, 94vw);
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.02)), var(--panel);
  box-shadow: 0 0 36px rgba(255, 61, 242, .22), inset 0 0 24px rgba(38, 247, 255, .08);
  text-align: center;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(2.2rem, 7vw, 5rem);
  letter-spacing: -0.05em;
  text-shadow: 0 0 18px rgba(255, 61, 242, .75);
}

h2 {
  font-size: clamp(1.9rem, 6vw, 4rem);
  line-height: 1;
  text-shadow: 0 0 18px rgba(38, 247, 255, .65);
}

.welcome-text {
  max-width: 520px;
  margin: 18px auto 24px;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  line-height: 1.25;
  color: var(--muted);
}

.btn,
.round-btn {
  border: 0;
  border-radius: 999px;
  color: #150619;
  font-weight: 900;
  text-transform: lowercase;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255,255,255,.13);
}

.btn {
  min-height: 54px;
  padding: 14px 24px;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
}

.btn-big {
  min-width: min(340px, 82vw);
  min-height: 70px;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.btn-primary {
  background: linear-gradient(90deg, var(--soft-red), #ff9ba5);
  box-shadow: 0 0 22px rgba(255, 111, 125, .5);
}

.btn-install {
  margin-top: 14px;
  background: linear-gradient(90deg, var(--neon-lime), var(--neon-cyan));
  box-shadow: 0 0 22px rgba(188, 255, 47, .32);
}

.btn-secondary {
  background: linear-gradient(90deg, #e9e4ff, var(--neon-cyan));
  box-shadow: 0 0 22px rgba(38, 247, 255, .35);
}

.btn-ghost {
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: inset 0 0 18px rgba(255,255,255,.04);
}

.btn-action {
  background: linear-gradient(90deg, #fff, var(--neon-pink));
  box-shadow: 0 0 22px rgba(255, 61, 242, .35);
}

.btn-success {
  background: linear-gradient(90deg, var(--neon-lime), #ffffff);
  box-shadow: 0 0 22px rgba(188, 255, 47, .35);
}

.btn:disabled {
  background: var(--disabled);
  color: #bdb7c7;
  cursor: not-allowed;
  box-shadow: none;
}

.round-btn {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  background: #f4efff;
}

.frame-loader {
  margin-top: 30px;
  display: grid;
  justify-items: center;
  gap: 12px;
}

.frame-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.small-title {
  color: var(--neon-cyan);
  font-weight: 800;
}

.frame-thumb-wrap {
  width: 112px;
  aspect-ratio: 2 / 3;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 14px;
  background: rgba(0,0,0,.35);
  overflow: hidden;
}

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

.file-label {
  display: inline-grid;
  place-items: center;
}

.hint {
  color: var(--muted);
  font-size: .92rem;
}

.top-status {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  background: rgba(0,0,0,.25);
}

.top-status strong {
  display: block;
  color: var(--neon-cyan);
}

.top-status span {
  display: block;
  color: var(--muted);
  font-size: .95rem;
}

.preview-stage {
  min-height: 0;
  display: grid;
  place-items: center;
}

#previewCanvas {
  display: block;
  max-width: min(94vw, calc((100dvh - 166px) * 0.6667));
  max-height: calc(100dvh - 166px - var(--safe-bottom));
  width: auto;
  height: auto;
  border-radius: 18px;
  background: #111;
  box-shadow: 0 0 28px rgba(38, 247, 255, .25), 0 0 44px rgba(255, 61, 242, .18);
}

.bottom-actions {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  max-width: 980px;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  background: rgba(5, 3, 10, .88);
  backdrop-filter: blur(14px);
}

.done-actions {
  grid-template-columns: 1fr 1fr;
}

.final-preview-wrap {
  margin: 24px auto 0;
  width: min(260px, 54vw);
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.16);
}

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

.screensaver {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  background: #000;
  overflow: hidden;
}

.screensaver.is-active {
  display: block;
}

.dvd-text {
  position: absolute;
  left: 30px;
  top: 30px;
  white-space: nowrap;
  color: var(--neon-cyan);
  font-weight: 900;
  font-size: clamp(1.3rem, 5vw, 3rem);
  text-shadow: 0 0 16px var(--neon-cyan), 0 0 28px var(--neon-pink);
}

@media (orientation: landscape) and (min-width: 720px) {
  .screen-capture {
    padding-top: calc(12px + var(--safe-top));
  }

  #previewCanvas {
    max-height: calc(100dvh - 138px - var(--safe-bottom));
  }

  .top-status {
    max-width: 780px;
    padding: 9px 14px;
  }

  .bottom-actions {
    max-width: 860px;
  }

  .btn { min-height: 50px; }
  .round-btn { width: 56px; height: 56px; }
}

@media (max-width: 560px) {
  .screen {
    padding-left: 12px;
    padding-right: 12px;
  }

  .bottom-actions {
    grid-template-columns: auto 1fr 1fr;
  }

  #btnContinue {
    grid-column: 1 / -1;
  }

  .done-actions {
    grid-template-columns: 1fr;
  }
}
