:root {
  --bg: #0b1020;
  --bg-2: #0f1630;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.1);
  --stroke: rgba(255, 255, 255, 0.12);
  --stroke-strong: rgba(255, 255, 255, 0.22);
  --text: #f7f9fc;
  --muted: #b7c0d8;
  --soft: #8a95b5;
  --brand: #f97316;
  --brand-2: #fb923c;
  --cyan: #38bdf8;
  --violet: #a78bfa;
  --gold: #facc15;
  --good: #34d399;
  --bad: #fb7185;
  --grad-brand: linear-gradient(135deg, #fbbf24 0%, #f97316 55%, #ef4444 100%);
  --grad-cyan: linear-gradient(135deg, #67e8f9, #38bdf8);
  --grad-violet: linear-gradient(135deg, #c4b5fd, #8b5cf6);
  --radius: 20px;
  --radius-lg: 28px;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
  --shadow-sm: 0 8px 24px rgba(2, 6, 23, 0.35);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 74px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 8% -8%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(249, 115, 22, 0.16), transparent 55%),
    radial-gradient(700px 600px at 50% 120%, rgba(167, 139, 250, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 60%, #060912 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
img { max-width: 100%; display: block; }
::selection { background: rgba(249, 115, 22, 0.35); }

/* ── App layout (mobile-first) ─────────────────────────────── */
.app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(var(--nav-h) + 28px);
}

/* ── Hero header ───────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 6px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  box-shadow: var(--shadow-sm);
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% 50% auto -20%;
  height: 220px;
  background: radial-gradient(closest-side, rgba(249, 115, 22, 0.35), transparent);
  filter: blur(6px);
}
.hero-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}
.hero-copy { min-width: 0; }
.profile-avatar {
  width: 84px;
  height: 84px;
  flex: 0 0 auto;
  object-fit: cover;
  object-position: 54% 38%;
  border-radius: 50%;
  border: 3px solid rgba(250, 204, 21, 0.7);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.42);
}
.hero-avatar {
  width: 92px;
  height: 92px;
}
.eyebrow {
  position: relative;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.hero h1 {
  position: relative;
  margin: 14px 0 6px;
  font-size: clamp(30px, 9vw, 42px);
  line-height: 0.98;
  letter-spacing: 0;
  font-weight: 900;
  overflow-wrap: anywhere;
}
.hero h1 .grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .subtitle { position: relative; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.hero-stats { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.hstat {
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  text-align: center;
}
.hstat b { display: block; font-size: 22px; font-weight: 900; line-height: 1; }
.hstat span { display: block; margin-top: 6px; color: var(--soft); font-size: 11px; letter-spacing: 0.02em; }

/* ── Sections & cards ──────────────────────────────────────── */
main { margin-top: 18px; }
section { display: none; animation: fade-up 0.32s ease both; }
section.active { display: block; }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-title { margin: 4px 2px 12px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--soft); font-weight: 800; }

.stack { display: grid; gap: 14px; }

.card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: 0; }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; font-size: 14px; }

.pillrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.06);
  color: var(--muted); font-size: 12.5px; font-weight: 600;
}

/* ── Progress ──────────────────────────────────────────────── */
.progress { height: 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--stroke); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #34d399, #facc15, #f97316); transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1); }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.mini {
  padding: 13px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--stroke);
}
.mini b { display: block; font-size: 20px; font-weight: 900; }
.mini span { color: var(--soft); font-size: 11.5px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn {
  appearance: none; border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.08); color: var(--text);
  border-radius: 14px; padding: 12px 15px; font-weight: 800; font-size: 14px;
  transition: transform 0.12s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn.block { width: 100%; text-align: center; }
.btn.primary { background: var(--grad-brand); color: #1a0f04; border-color: transparent; box-shadow: 0 10px 26px rgba(249, 115, 22, 0.32); }
.btn.cyan { background: var(--grad-cyan); color: #062036; border-color: transparent; }
.btn.violet { background: var(--grad-violet); color: #1c1036; border-color: transparent; }
.btn.ghost { background: rgba(255, 255, 255, 0.05); }
.btn.danger { background: rgba(251, 113, 133, 0.14); border-color: rgba(251, 113, 133, 0.4); color: #fecdd3; }
.btn.sm { padding: 9px 12px; font-size: 13px; border-radius: 12px; }

/* ── Missions ──────────────────────────────────────────────── */
.mission {
  display: grid; grid-template-columns: 44px 1fr 40px; gap: 12px; align-items: start;
  padding: 14px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--stroke);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.12s ease;
}
.mission.done { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.4); }
.mission .ic { width: 44px; height: 44px; display: grid; place-items: center; font-size: 22px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--stroke); }
.mission h3 { margin: 0; font-size: 15px; }
.mission p { margin: 4px 0 0; font-size: 13px; }
.mission small { display: block; margin-top: 7px; color: var(--soft); font-size: 12px; }
.mission .meta { margin-top: 7px; font-size: 11.5px; color: var(--good); }
.check {
  width: 40px; height: 40px; border-radius: 13px; font-size: 18px;
  border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.06); color: var(--text);
  display: grid; place-items: center; transition: transform 0.14s ease;
}
.check:active { transform: scale(0.9); }
.mission.done .check { background: var(--good); color: #052e16; border-color: transparent; font-weight: 900; }
.mission .del { grid-column: 1 / -1; justify-self: end; margin-top: 2px; font-size: 12px; color: var(--soft); background: none; border: 0; padding: 4px; }

/* ── Card draw (flip) ──────────────────────────────────────── */
.deck { perspective: 1400px; }
.flipcard { position: relative; width: 100%; min-height: 260px; transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(0.2, 0.75, 0.25, 1); }
.flipcard.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg); padding: 24px; border: 1px solid var(--stroke-strong);
  display: grid; align-content: center; gap: 14px; text-align: center;
  box-shadow: var(--shadow);
}
.face.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 12px, transparent 12px 24px),
    linear-gradient(150deg, #1b2350, #0d1330);
  color: var(--text);
}
.face.back .logo { font-size: 60px; }
.face.back .lbl { color: var(--muted); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; }
.face.front {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 20% 0%, rgba(250, 204, 21, 0.2), transparent 45%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
}
.face.front .type { color: var(--gold); font-weight: 900; text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px; }
.face.front .text { font-size: clamp(22px, 6vw, 32px); font-weight: 900; line-height: 1.08; letter-spacing: 0; }
.face.front .hint { color: var(--muted); font-size: 13.5px; }

.type-chip { display: inline-flex; gap: 8px; }
.tchip { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.05); font-size: 12.5px; font-weight: 700; color: var(--muted); }

/* voto */
.vote-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.vote { padding: 13px 8px; border-radius: 14px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.06); font-weight: 800; font-size: 13px; }
.vote.bene { border-color: rgba(52,211,153,0.5); }
.vote.male { border-color: rgba(251,113,133,0.5); }
.vote.done { opacity: 0.5; }

/* ── Timeline / archive ────────────────────────────────────── */
.timeline { display: grid; gap: 10px; }
.tl-day { margin: 12px 2px 2px; font-weight: 900; font-size: 15px; }
.tl {
  display: grid; grid-template-columns: 60px 1fr; gap: 12px;
  padding: 13px; border-radius: 16px; background: rgba(255,255,255,0.05); border: 1px solid var(--stroke);
}
.tl .t { color: var(--gold); font-weight: 900; font-size: 12.5px; }
.tl strong { display: block; font-size: 14px; margin-bottom: 3px; }
.tl span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.badge-vote { display: inline-block; margin-top: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-vote.bene { background: rgba(52,211,153,0.18); color: #6ee7b7; }
.badge-vote.male { background: rgba(251,113,133,0.18); color: #fda4af; }
.badge-vote.skip { background: rgba(255,255,255,0.1); color: var(--muted); }
.badge-src { font-size: 10px; color: var(--soft); margin-left: 6px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Gallery ───────────────────────────────────────────────── */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.gallery figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; border: 1px solid var(--stroke); background: rgba(255,255,255,0.04); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 10px; background: linear-gradient(transparent, rgba(0,0,0,0.7)); }
.gallery .rm { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 8px; border: 0; background: rgba(0,0,0,0.55); color: #fff; font-size: 12px; }

.uploader { border: 2px dashed var(--stroke-strong); border-radius: 18px; padding: 20px; text-align: center; color: var(--muted); }
.uploader input { display: none; }

/* ── Diploma / certificati ─────────────────────────────────── */
.cert {
  position: relative; overflow: hidden;
  border: 3px double rgba(250, 204, 21, 0.6); border-radius: 20px; padding: 22px 18px; text-align: center;
  background: linear-gradient(180deg, rgba(250,204,21,0.06), rgba(255,255,255,0.03));
}
.cert .seal { width: 76px; height: 76px; margin: 6px auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 36px; background: var(--grad-brand); box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
.cert .kicker { color: var(--gold); letter-spacing: 0.18em; text-transform: uppercase; font-size: 11px; font-weight: 800; }
.cert h2 { font-size: 22px; margin: 6px 0; }
.cert .sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.cert .who { font-size: 26px; font-weight: 900; margin: 8px 0; letter-spacing: 0; }
.cert .body { color: var(--text); font-size: 14px; line-height: 1.55; }
.cert .photos { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }
.cert .photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 2px solid rgba(250,204,21,0.5); }
.cert .foot { margin-top: 14px; display: flex; justify-content: space-between; font-size: 11px; color: var(--soft); }

.template-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl { text-align: left; padding: 12px; border-radius: 14px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.05); }
.tpl.active { border-color: var(--brand); background: rgba(249,115,22,0.12); }
.tpl b { display: block; font-size: 13px; }
.tpl span { font-size: 11px; color: var(--soft); }

.chip-select { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pchip { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; border: 2px solid transparent; }
.pchip img { width: 100%; height: 100%; object-fit: cover; }
.pchip.active { border-color: var(--gold); }

/* ── Forms ─────────────────────────────────────────────────── */
label { display: block; margin: 14px 0 6px; color: var(--muted); font-weight: 700; font-size: 13px; }
.input {
  width: 100%; border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.06);
  color: var(--text); border-radius: 14px; padding: 13px 14px; outline: none;
  transition: border-color 0.2s ease;
}
.input:focus { border-color: var(--brand-2); }
textarea.input { min-height: 110px; resize: vertical; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch input { width: 46px; height: 26px; appearance: none; background: rgba(255,255,255,0.15); border-radius: 999px; position: relative; transition: background 0.2s; }
.switch input:checked { background: var(--good); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked::after { transform: translateX(20px); }

/* ── Bottom nav ────────────────────────────────────────────── */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 10px);
  width: min(540px, calc(100% - 20px)); z-index: 40;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px;
  padding: 8px; border-radius: 22px;
  background: rgba(12, 17, 34, 0.82); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--stroke); box-shadow: var(--shadow);
}
.nav button {
  display: grid; justify-items: center; gap: 3px; padding: 8px 2px; border: 0; background: none;
  color: var(--soft); border-radius: 14px; font-size: 10px; font-weight: 700; transition: color 0.2s, background 0.2s;
}
.nav button .ic { font-size: 19px; line-height: 1; }
.nav button.active { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.nav button.active .ic { filter: drop-shadow(0 4px 10px rgba(249, 115, 22, 0.5)); }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 16px); opacity: 0; z-index: 90; pointer-events: none;
  padding: 12px 16px; border-radius: 999px; font-weight: 700; font-size: 13.5px; white-space: nowrap;
  background: rgba(9, 13, 27, 0.96); border: 1px solid var(--stroke-strong); box-shadow: var(--shadow);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Confetti canvas ───────────────────────────────────────── */
#confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; }

/* ── Login gate ────────────────────────────────────────────── */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 600px at 50% 0%, rgba(249,115,22,0.18), transparent 60%), var(--bg); }
.gate.hidden { display: none; }
.gate-card { width: min(400px, 100%); text-align: center; }
.gate-card .logo { font-size: 56px; }
.gate-avatar { margin: 0 auto; width: 96px; height: 96px; }
.gate-card h1 { font-size: 26px; margin: 10px 0 4px; }
.gate-card p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.gate .err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ── Install banner ────────────────────────────────────────── */
.install {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  width: min(520px, calc(100% - 24px)); z-index: 70; display: none;
  padding: 12px 14px; border-radius: 18px; align-items: center; gap: 12px;
  background: rgba(12, 17, 34, 0.95); border: 1px solid var(--stroke-strong); box-shadow: var(--shadow);
}
.install.show { display: flex; }
.install .txt { flex: 1; font-size: 13px; }
.install .txt b { display: block; }
.install .txt span { color: var(--soft); }

/* ── Lightbox ──────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 110; display: none; place-items: center; padding: 20px; background: rgba(2,4,10,0.92); }
.lightbox.show { display: grid; }
.lightbox img { max-width: 100%; max-height: 84vh; border-radius: 16px; }

.empty { text-align: center; color: var(--soft); padding: 24px 10px; font-size: 14px; }
.rules { padding-left: 18px; margin: 8px 0 0; }
.rules li { color: var(--muted); margin: 8px 0; line-height: 1.45; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
