:root {
  --pt-red: #e30613;
  --pt-red-dark: #b01018;
  --pt-red-deep: #8a0c12;
  --white: #ffffff;
  --gold: #ffd100;
  --muted: rgba(255, 255, 255, 0.82);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-ui: "Nunito", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--pt-red);
  color: var(--white);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

#app {
  width: min(520px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100svh;
  background: var(--pt-red);
  position: relative;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.brand {
  flex: 0 0 auto;
  padding: 16px 18px 12px;
}

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

.brand-star {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.28));
}

.brand-name {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 5.6vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
  line-height: 1;
  flex: 1;
  min-width: 0;
}

.brand-number {
  background: var(--white);
  color: var(--pt-red);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.05rem, 4.8vw, 1.4rem);
  line-height: 1;
  padding: 6px 12px 7px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-tag {
  margin: 8px 0 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.step {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.step.active {
  display: flex;
}

.home-copy {
  padding: 8px 20px 0;
}

.lead {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--muted);
}

.home-preview-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 12px 48px 0;
  min-height: 0;
}

.home-preview-wrap img {
  width: min(240px, 58vw);
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px 8px;
}

.topbar-titles {
  display: flex;
  flex-direction: column;
}

.topbar-titles-center {
  width: 100%;
  text-align: center;
}

.topbar-titles strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.topbar-titles span {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-back {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: var(--white);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-back:active {
  background: rgba(255, 255, 255, 0.12);
}

.step-body {
  flex: 1;
  padding: 8px 20px 12px;
  min-height: 0;
  overflow: auto;
}

.step-lead {
  margin: 0 0 16px;
  color: var(--muted);
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.frame-grid:has(.frame-card:only-child) {
  grid-template-columns: 1fr;
  max-width: 280px;
  margin: 0 auto;
  width: 100%;
}

.frame-card {
  margin: 0;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  aspect-ratio: 1;
}

.frame-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
}

.frame-card.selected {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.frame-card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.empty-msg {
  background: rgba(0, 0, 0, 0.18);
  padding: 16px;
  border-radius: var(--radius);
}

.photo-body {
  display: flex;
  flex-direction: column;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hint {
  margin: 0;
  padding: 0 20px 8px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.stage-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
  touch-action: none;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: #fff;
  touch-action: none;
  user-select: none;
}

.photo-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

.photo-layer img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  pointer-events: none;
  will-change: transform;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 2;
}

.export-canvas {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 4px;
}

.zoom-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--pt-red-dark);
  color: var(--white);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

#zoom {
  flex: 1;
  accent-color: var(--white);
  height: 28px;
}

.done-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#result-img {
  width: min(100%, 380px);
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #fff;
}

.ios-hint {
  margin: 0;
  font-size: 0.88rem;
  text-align: center;
  color: var(--muted);
}

.bottom-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(227, 6, 19, 0), var(--pt-red) 28%);
}

.btn {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-white {
  background: var(--white);
  color: var(--pt-red);
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
}

.btn-whatsapp:active {
  background: #1ebe5d;
}

.whatsapp-ico {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
}

.btn-white:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-outline {
  background: transparent;
  color: var(--white);
  border: 2px solid var(--white);
}

.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 0;
  min-height: 46px;
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-ico {
  font-size: 1.1rem;
}

.privacy {
  margin: 2px 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 20;
  max-width: min(90vw, 360px);
  text-align: center;
}

@media (min-width: 720px) {
  body {
    background: var(--pt-red-deep);
  }

  #app {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 20px 60px rgba(0, 0, 0, 0.35);
  }
}
