:root {
  --blue: #5b8def;
  --blue-deep: #4a78d9;
  --blue-soft: #e8efff;
  --bg: #f5f8fe;
  --card: #ffffff;
  --text: #1c2540;
  --muted: #6b7591;
  --danger: #ef5a5a;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(40, 70, 140, 0.14);
}

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

html, body { height: 100%; }

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.hidden { display: none !important; }

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Conteúdo centralizado com largura confortável em telas médias */
.bar, .fields, .colors-block { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }
.view > * { max-width: 520px; }
.summary { max-width: 520px; }

/* ---------- Topo ---------- */
.top {
  background: linear-gradient(160deg, #6f9df4 0%, var(--blue) 55%, var(--blue-deep) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 56px;
}

.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}
.brand h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.26); }
.icon-btn:active { transform: rotate(-60deg); }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field > span, .colors-block .label {
  display: block; font-size: 0.82rem; font-weight: 600;
  opacity: 0.92; margin-bottom: 8px;
}
.colors-block .label small { font-weight: 400; opacity: 0.8; }

.stepper {
  display: flex; align-items: center;
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 4px 14px rgba(30, 60, 130, 0.15);
}
.stepper button {
  width: 40px; height: 50px; font-size: 1.3rem; font-weight: 600;
  color: var(--blue-deep);
}
.stepper button:active { background: var(--blue-soft); }
.stepper input {
  flex: 1; min-width: 0; height: 50px; border: none; outline: none;
  text-align: center; font: inherit; font-size: 1.15rem; font-weight: 700;
  color: var(--text); background: transparent;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.locked .stepper { opacity: 0.6; }
.locked .stepper button, .locked .stepper input { pointer-events: none; }
.locked .team-color { pointer-events: none; }

.colors-block { margin-top: 18px; }
.team-colors { display: flex; flex-wrap: wrap; gap: 10px; }

.team-color {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.95rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s;
}
.team-color:hover { transform: scale(1.08); }

/* ---------- Folha branca ---------- */
.sheet {
  flex: 1;
  background: var(--bg);
  margin-top: -32px;
  border-radius: 32px 32px 0 0;
  padding: 36px 20px calc(env(safe-area-inset-bottom) + 32px);
  display: flex; flex-direction: column;
}

.view {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center;
  animation: fadeUp 0.35s ease;
}

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

.btn-primary {
  background: var(--blue); color: #fff;
  padding: 15px 34px; border-radius: 14px;
  font-weight: 700; font-size: 1rem;
  box-shadow: 0 8px 20px rgba(91, 141, 239, 0.35);
  transition: transform 0.15s, background 0.2s;
}
.btn-primary:hover { background: var(--blue-deep); }
.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.45; pointer-events: none; }

/* ---------- Botão de segurar ---------- */
#viewDraw, #viewDraw * {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hold-btn svg { pointer-events: none; }

.hold-wrap { position: relative; width: 170px; height: 170px; display: grid; place-items: center; }

.ring { position: absolute; inset: 0; transform: rotate(-90deg); pointer-events: none; }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--blue-soft); }
.ring-fg {
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 339.3;
}

.hold-btn {
  position: relative; z-index: 1;
  width: 124px; height: 124px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow), 0 0 0 0 rgba(91, 141, 239, 0.45);
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 0.2s, background-color 0.12s;
  animation: pulse 2.2s infinite;
}
.hold-btn.holding { transform: scale(0.92); animation: shake 0.12s infinite; }

.counter { color: var(--muted); font-size: 0.95rem; }
.counter strong { color: var(--text); font-weight: 700; }

/* ---------- Fim ---------- */
.done-badge {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue-deep);
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 800;
}
.view h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }

.summary { width: 100%; display: grid; gap: 8px; margin: 6px 0 8px; }
.summary-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); padding: 12px 14px; border-radius: 14px;
  box-shadow: 0 2px 8px rgba(40, 70, 140, 0.06);
  font-weight: 600;
}
.summary-row .dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }
.summary-row .count { margin-left: auto; color: var(--muted); font-weight: 500; }

/* ---------- Instagram ---------- */
.insta-card {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 16px;
  background: var(--card); color: var(--text); text-decoration: none; text-align: left;
  box-shadow: 0 6px 18px rgba(40, 70, 140, 0.1);
  border: 1px solid #eef1f8;
  transition: transform 0.15s;
}
.insta-card:active { transform: scale(0.98); }
.insta-icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
}
.insta-text { display: flex; flex-direction: column; gap: 2px; }
.insta-text strong { font-size: 0.95rem; font-weight: 700; }
.insta-text span { font-size: 0.85rem; color: var(--muted); }
.insta-arrow { margin-left: auto; font-size: 1.2rem; color: var(--blue); font-weight: 700; }

.credit {
  text-align: center; font-size: 0.8rem; color: var(--muted);
  padding-top: 16px;
}
.credit a { color: var(--blue-deep); font-weight: 600; text-decoration: none; }

/* ---------- Convite de instalação ---------- */
.install {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 16px; padding: 12px 12px 12px 14px;
  box-shadow: 0 6px 18px rgba(40, 70, 140, 0.1);
  margin-top: 16px; width: 100%; max-width: 520px; align-self: center;
}
.install img { border-radius: 10px; flex-shrink: 0; }
.install-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.install-text strong { font-size: 0.92rem; }
.install-text span { font-size: 0.8rem; color: var(--muted); }
.install-btn {
  background: var(--blue); color: #fff; font-weight: 700; font-size: 0.85rem;
  padding: 9px 14px; border-radius: 10px;
}
.install-close { font-size: 1.4rem; color: var(--muted); width: 28px; height: 28px; line-height: 1; }

/* ---------- Revelação ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: revealIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.reveal-content { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reveal-sub { font-size: 1.05rem; font-weight: 500; opacity: 0.85; }
.reveal-name { font-size: clamp(3rem, 14vw, 5rem); font-weight: 800; letter-spacing: -0.03em; }
.reveal-close {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 48px);
  width: 72px; height: 72px; border-radius: 50%;
  border: 2px solid currentColor;
  display: grid; place-items: center;
  transition: transform 0.15s;
}
.reveal-close:active { transform: scale(0.9); }

/* ---------- Modais ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 30, 60, 0.45);
  display: grid; place-items: center; padding: 20px;
  animation: fade 0.2s ease;
}
.modal-card {
  width: 100%; max-width: 360px;
  background: var(--card); border-radius: 24px;
  padding: 26px 22px 22px; text-align: center;
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s ease;
}
.modal-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 18px; }
.modal-card p { color: var(--muted); font-size: 0.95rem; line-height: 1.5; margin: -8px 0 22px; }

.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; justify-items: center; margin-bottom: 24px; }
.swatch {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--text); }

.warn-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%;
  background: #fdecec; color: var(--danger);
  display: grid; place-items: center; font-size: 1.5rem; font-weight: 800;
}
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-ghost { padding: 13px; border-radius: 12px; background: #eef1f7; font-weight: 600; }
.btn-danger { padding: 13px; border-radius: 12px; background: var(--danger); color: #fff; font-weight: 700; }

/* ---------- Desktop: duas colunas ---------- */
@media (min-width: 900px) {
  .app { flex-direction: row; height: 100dvh; }

  .top {
    width: 420px; flex-shrink: 0;
    padding: 44px 40px;
    display: flex; flex-direction: column;
    overflow-y: auto;
  }
  .bar { margin-bottom: 40px; }
  .brand h1 { font-size: 1.5rem; }
  .fields { grid-template-columns: 1fr; gap: 20px; }
  .colors-block { margin-top: 28px; }
  .team-color { width: 54px; height: 54px; }

  .sheet {
    margin-top: 0; margin-left: -32px;
    border-radius: 32px 0 0 32px;
    padding: 48px;
    overflow-y: auto;
  }

  .hint { font-size: 1.05rem; }
  .btn-primary { padding: 17px 42px; font-size: 1.05rem; }

  .hold-wrap { width: 230px; height: 230px; }
  .hold-btn { width: 170px; height: 170px; }
  .hold-btn svg { width: 56px; height: 56px; }
  .counter { font-size: 1.1rem; }

  .view h2 { font-size: 1.8rem; }
  .summary { grid-template-columns: 1fr 1fr; max-width: 640px; }
  .view > * { max-width: 640px; }
}

@media (min-width: 1400px) {
  .top { width: 480px; padding: 56px 52px; }
}

/* ---------- Animações ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } }
@keyframes revealIn { from { opacity: 0; transform: scale(1.08); } }
@keyframes pulse {
  0%   { box-shadow: var(--shadow), 0 0 0 0 rgba(91, 141, 239, 0.45); }
  70%  { box-shadow: var(--shadow), 0 0 0 18px rgba(91, 141, 239, 0); }
  100% { box-shadow: var(--shadow), 0 0 0 0 rgba(91, 141, 239, 0); }
}
@keyframes shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -1.5px 1px; }
  75% { translate: 1.5px -1px; }
}

/* Durante o sorteio as cores ficam travadas: esconde a dica */
.locked .colors-block small { display: none; }
