:root {
  --navy-900: #071633;
  --navy-800: #0b1e4b;
  --navy-700: #12295f;
  --navy-600: #1b3a7a;
  --gold: #f6b012;
  --gold-bright: #ffc93a;
  --gold-deep: #d6920a;
  --green: #00913f;
  --green-bright: #12b356;
  --white: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.72);
  --ink-faint: rgba(255, 255, 255, 0.5);
  --line: rgba(255, 255, 255, 0.12);
  --panel: rgba(255, 255, 255, 0.05);
  --panel-2: rgba(255, 255, 255, 0.08);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --radius: 18px;
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--white);
  background: var(--navy-900);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
  padding: max(0px, env(safe-area-inset-top)) 0 max(0px, env(safe-area-inset-bottom));
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 85% -10%, rgba(0, 145, 63, 0.22), transparent 55%),
    radial-gradient(120% 90% at 10% 0%, rgba(246, 176, 18, 0.16), transparent 50%),
    linear-gradient(160deg, var(--navy-800) 0%, var(--navy-900) 55%, #050f22 100%);
}
.bg-decor::after {
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -6%;
  height: 42%;
  background:
    linear-gradient(90deg, transparent, rgba(0, 145, 63, 0.16), rgba(246, 176, 18, 0.14), transparent);
  transform: skewY(-6deg);
  filter: blur(6px);
  opacity: 0.7;
}

/* HEADER */
.site-header {
  text-align: center;
  padding: 26px 20px 10px;
}
.site-logo {
  width: min(240px, 62vw);
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
}
.site-tagline {
  margin-top: 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--gold);
  text-transform: uppercase;
  font-size: clamp(0.82rem, 3.4vw, 1rem);
}

/* STAGE + SCREENS */
.stage {
  flex: 1;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 12px 18px 40px;
}
.screen { display: none; animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.screen.is-active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 8px 0 22px;
}
.step-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--navy-900);
  background: var(--gold);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.screen-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  font-size: clamp(1.7rem, 7vw, 2.9rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
}
.screen-sub {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: clamp(0.9rem, 3.6vw, 1.02rem);
  max-width: 32ch;
  margin-inline: auto;
}

.btn-back {
  align-self: flex-start;
  margin-bottom: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.btn-back:hover { background: rgba(255, 255, 255, 0.14); transform: translateX(-2px); }

/* FORMAT CARDS */
.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: stretch;
}
.format-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 12px;
  cursor: pointer;
  text-align: center;
  color: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.format-frame-box {
  height: 116px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.format-card:hover,
.format-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(246, 176, 18, 0.6);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  outline: none;
}
.format-frame {
  height: 100%;
  width: auto;
  max-width: 100%;
  border-radius: 8px;
  border: 2px solid var(--gold);
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.06) 0 8px, rgba(255,255,255,0.02) 8px 16px);
  position: relative;
}
.format-frame.ar-1-1 { aspect-ratio: 1 / 1; }
.format-frame.ar-4-5 { aspect-ratio: 4 / 5; }
.format-frame.ar-9-16 { aspect-ratio: 9 / 16; }
.format-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(0.86rem, 3.5vw, 1.05rem);
  line-height: 1;
}
.format-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.format-dim { font-size: 0.72rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.format-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
}

/* GALLERY */
.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
}
.mask-card {
  flex: 0 1 calc(50% - 8px);
  max-width: 210px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  color: var(--white);
  text-align: left;
  transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s;
}
.mask-card:hover,
.mask-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(246, 176, 18, 0.6);
  box-shadow: var(--shadow);
  outline: none;
}
.mask-thumb {
  width: 100%;
  border-radius: 8px;
  display: block;
  background:
    repeating-conic-gradient(#0d1f45 0% 25%, #0a1839 0% 50%) 50% / 18px 18px;
}
.mask-name {
  margin-top: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
}
.empty-note { text-align: center; color: var(--ink-faint); padding: 40px 0; }

/* EDITOR */
.editor {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}
.canvas-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a1839;
  box-shadow: var(--shadow);
  touch-action: none;
}
#editor-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: grab;
}
#editor-canvas:active { cursor: grabbing; }

.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 22, 51, 0.86);
  backdrop-filter: blur(2px);
  cursor: pointer;
  text-align: center;
  padding: 24px;
}
.drop-zone.is-hidden { display: none; }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--navy-900);
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 10px 26px -8px rgba(246, 176, 18, 0.7);
}
.drop-title { font-family: var(--font-display); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 1.05rem; }
.drop-hint { color: var(--ink-faint); font-size: 0.82rem; }

.controls {
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.control-row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 12px; }
.control-label {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-deep));
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--gold-deep);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--gold-deep);
  cursor: pointer;
}

.control-actions { display: flex; gap: 10px; }
.control-actions .btn { flex: 1; }
.primary-actions { margin-top: 2px; }
.save-hint {
  margin-top: 2px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-faint);
  line-height: 1.4;
}
.save-hint strong { color: var(--gold); }

.btn {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 0.92rem;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: transform 0.18s, filter 0.18s, background 0.18s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-gold { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: var(--navy-900); box-shadow: 0 12px 26px -10px rgba(246, 176, 18, 0.8); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-outline { background: transparent; color: var(--white); border: 2px solid var(--gold); }
.btn-outline:hover { background: rgba(246, 176, 18, 0.14); }
.btn-ghost { background: var(--panel-2); color: var(--white); border: 1px solid var(--line); font-size: 0.82rem; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* FOOTER */
.site-footer {
  text-align: center;
  padding: 22px 20px 30px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  margin-top: auto;
}
.site-footer strong { color: var(--ink-soft); }

/* TOAST */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: var(--navy-700);
  border: 1px solid var(--line);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

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

/* Passo 1 no celular: lista vertical de cards horizontais (mais legível e clicável) */
@media (max-width: 560px) {
  .format-grid { grid-template-columns: 1fr; gap: 12px; }
  .format-card {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 16px;
    padding: 14px 16px;
  }
  .format-frame-box {
    height: 86px;
    width: 86px;
    flex: 0 0 auto;
  }
  .format-info {
    align-items: flex-start;
    gap: 3px;
  }
  .format-name { font-size: 1.15rem; }
  .format-dim { font-size: 0.8rem; }
  .format-count { font-size: 0.8rem; }
}
