/* Viena → Italija family quest. Visual language carried over from Barcelona:
   dark glassmorphism, warm gradients, rounded SF-style type. Mobile-first. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b0b10;
  --ink: #f3f3f6;
  --dim: #a8a8b3;
  --glass: rgba(28,28,34,0.55);
  --glass-2: rgba(255,255,255,0.10);
  --stroke: rgba(255,255,255,0.18);
  --pink: #ff375f;
  --pink-2: #ff5c7c;
  --gold: #ffd60a;
  --blue: #0a84ff;
  --green: #30d158;
  --r-card: 28px;
  --r-cell: 20px;
  --r-btn: 16px;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-rounded, -apple-system, 'SF Pro Rounded', 'SF Pro Display', BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh; min-height: 100svh;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  position: relative;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
body::before {
  content: ''; position: fixed; inset: -10vh -10vw; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40vw 40vw at 8% -5%,  rgba(255,55,95,.50), transparent 60%),
    radial-gradient(45vw 45vw at 110% 18%, rgba(10,132,255,.42), transparent 60%),
    radial-gradient(55vw 45vw at 50% 110%, rgba(255,214,10,.38), transparent 60%),
    linear-gradient(180deg, #11111a, #0b0b10);
  filter: blur(12px) saturate(120%);
}
body > section { display: none; }
body[data-screen="gate"]   #gate,
body[data-screen="pick"]   #pick,
body[data-screen="board"]  #board,
body[data-screen="finale"] #finale { display: flex; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--stroke);
  box-shadow: 0 18px 60px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.10);
}
.card { border-radius: var(--r-card); padding: 20px; }
.field-label {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--dim); margin: 14px 2px 8px;
}

/* avatars */
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c, #555) 70%, white 10%), var(--c, #333));
  border: 1px solid rgba(255,255,255,.25);
}
.avatar.lg { width: 48px; height: 48px; font-size: 26px; }
.avatar.sm { width: 22px; height: 22px; font-size: 12px; }

/* buttons */
.btn {
  min-height: 46px; padding: 0 16px; font: inherit; font-size: 15px; font-weight: 700;
  background: var(--glass-2); border: 1px solid var(--stroke); border-radius: var(--r-btn);
  color: var(--ink); cursor: pointer; transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, var(--pink-2), var(--pink));
  border-color: rgba(255,55,95,.6); color: #fff;
  box-shadow: 0 10px 24px rgba(255,55,95,.32), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn.danger { background: linear-gradient(180deg, rgba(255,55,95,.30), rgba(255,55,95,.15)); border-color: rgba(255,55,95,.45); color: #fff; }

/* ============ GATE (passcode) ============ */
#gate { flex-direction: column; justify-content: center; padding: 32px 18px; max-width: 420px; margin: 0 auto; width: 100%; min-height: 100svh; }
#gateInput {
  width: 100%; padding: 16px; min-height: 56px; font: inherit; font-size: 20px; font-weight: 700; letter-spacing: 4px;
  text-align: center; background: var(--glass-2); border: 1px solid var(--stroke); border-radius: 18px; color: var(--ink);
}
#gateInput:focus { outline: none; border-color: rgba(255,55,95,.55); box-shadow: 0 0 0 4px rgba(255,55,95,.15); }
.gate-error { margin-top: 12px; text-align: center; font-size: 13px; font-weight: 700; color: var(--pink); min-height: 18px; }

/* ============ PICK ============ */
#pick { flex-direction: column; padding: 32px 18px 24px; max-width: 480px; margin: 0 auto; width: 100%; }
.brand { text-align: center; margin: 8px 4px 18px; }
.brand .flag { font-size: 34px; }
.brand h1 {
  font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 4px;
  background: linear-gradient(180deg, #fff, #d6d6e0); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .lede { color: var(--dim); font-size: 15px; font-weight: 600; margin: 0; }
.pick-list { display: flex; flex-direction: column; gap: 10px; }
.pick-slot {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px;
  border-radius: 20px; background: var(--glass-2); border: 1px solid var(--stroke);
  color: var(--ink); font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
  transition: transform .12s, border-color .15s; text-align: left;
}
.pick-slot:active { transform: scale(.98); }
.pick-slot { border-left: 4px solid var(--c, var(--stroke)); }
.warn {
  margin-top: 18px; padding: 12px 14px; font-size: 13px; line-height: 1.4; font-weight: 600;
  color: rgba(255,214,10,.95); background: rgba(255,214,10,.08); border: 1px solid rgba(255,214,10,.25); border-radius: 14px;
}

/* ============ BOARD ============ */
#board { flex-direction: column; min-height: 100svh; max-width: 520px; margin: 0 auto; width: 100%; }
#topbar { position: sticky; top: 0; z-index: 5; margin: 8px; padding: 12px 14px; border-radius: 22px; display: flex; flex-direction: column; gap: 9px; }
.topbar-row { display: flex; align-items: center; gap: 10px; }
.me { display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--ink); font: inherit; cursor: pointer; padding: 0; }
.me-name { font-size: 16px; font-weight: 800; }
.score { margin-left: auto; text-align: right; }
.score b { font-size: 22px; font-weight: 800; color: var(--gold); }
.score small { color: var(--dim); font-weight: 600; }
.progress { height: 10px; border-radius: 999px; background: rgba(255,255,255,.10); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--pink), var(--gold)); transition: width .4s cubic-bezier(.34,1.4,.64,1); }
.progress-meta { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; }
.milestone { color: var(--gold); }
.done-count { color: var(--dim); }
.badge { align-self: flex-start; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--stroke); }
.badge.ok  { color: var(--green); background: rgba(48,209,88,.12); }
.badge.sync{ color: var(--gold);  background: rgba(255,214,10,.12); }
.badge.off { color: var(--pink);  background: rgba(255,55,95,.12); }
.badge.local { color: var(--dim); background: rgba(255,255,255,.06); }
.frozen-banner { margin-top: 6px; text-align: center; font-size: 13px; font-weight: 800; color: var(--gold); background: rgba(255,214,10,.12); border: 1px solid rgba(255,214,10,.35); border-radius: 12px; padding: 8px; }

.board-body { flex: 1; overflow-y: auto; padding: 4px 8px 84px; }
.stage { margin-bottom: 18px; }
.stage.personal {
  background: rgba(191,90,242,.07); border: 1px solid rgba(191,90,242,.22);
  border-radius: var(--r-card); padding: 12px 12px 6px; margin: 2px 2px 20px;
}
.stage.personal .stage-name { color: #d3a0ff; }
.stage-head { display: flex; align-items: center; gap: 10px; margin: 6px 6px 10px; }
.stage-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stage-name { font-size: 16px; font-weight: 800; }
.stage-when { font-size: 11px; font-weight: 700; color: var(--dim); }
.stage-prog { font-size: 13px; font-weight: 700; color: var(--dim); margin-left: auto; }
.stage-lock { background: none; border: none; cursor: pointer; font-size: 14px; opacity: .55; padding: 4px; }
.stage-lock:active { transform: scale(.9); }

.locked-row {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border-radius: var(--r-cell); background: rgba(255,255,255,.035); border: 1px dashed var(--stroke);
}
.locked-info { flex: 1; min-width: 0; }
.locked-name { font-size: 15px; font-weight: 800; color: var(--dim); }
.locked-when { font-size: 12px; font-weight: 600; color: var(--dim); opacity: .8; margin-top: 3px; }
.unlock-btn {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 13px; color: #fff;
  background: linear-gradient(180deg, var(--pink-2), var(--pink)); border: 1px solid rgba(255,55,95,.5);
}
.unlock-btn:active { transform: scale(.97); }

.challenge {
  display: flex; gap: 12px; align-items: stretch; width: 100%; text-align: left;
  padding: 10px; margin-bottom: 8px; border-radius: var(--r-cell);
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--ink);
  font: inherit; cursor: pointer; position: relative; transition: transform .12s, border-color .18s;
}
.challenge:active { transform: scale(.985); }
.challenge.bonus { border-color: rgba(255,214,10,.4); }
.challenge.done { border-color: rgba(48,209,88,.55); background: rgba(48,209,88,.08); }
.thumb {
  width: 64px; height: 64px; flex: none; border-radius: 14px; overflow: hidden;
  background: linear-gradient(135deg, #2a2a32, #16161c); display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-ph { font-size: 30px; opacity: .9; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; justify-content: center; }
.card-title { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.card-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; font-weight: 700; }
.pts { color: var(--gold); }
.tag-bonus { color: var(--gold); background: rgba(255,214,10,.12); padding: 2px 7px; border-radius: 999px; }
.needs { color: var(--dim); }
.card-who { display: flex; gap: 4px; margin-top: 2px; }
.card-check {
  position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--green); color: #06310f; display: grid; place-items: center; font-weight: 900; font-size: 13px;
}

/* album */
.album-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.album-cell {
  position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden; border: 1px solid var(--stroke);
  background: #16161c; cursor: pointer; padding: 0;
}
.album-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 8px 6px; font-size: 11px; font-weight: 700;
  color: #fff; text-align: left; line-height: 1.2;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.78));
}
.empty { color: var(--dim); text-align: center; font-weight: 600; padding: 40px 20px; }

/* tabbar */
.tabbar { position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; border-radius: 999px; z-index: 6; }
.tab { min-height: 40px; padding: 0 18px; border: none; background: transparent; color: var(--dim); font: inherit; font-size: 14px; font-weight: 700; border-radius: 999px; cursor: pointer; }
.tab.active { background: linear-gradient(180deg, var(--pink-2), var(--pink)); color: #fff; }

/* ============ COMPLETE MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.55); backdrop-filter: blur(8px); }
.modal.open { display: flex; }
.sheet {
  width: 100%; max-width: 520px; border-radius: 26px 26px 0 0; padding: 20px 18px;
  padding-bottom: max(20px, env(safe-area-inset-bottom)); max-height: 92svh; overflow-y: auto;
  animation: sheetUp .25s cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet h2 { margin: 4px 0 4px; font-size: 20px; font-weight: 800; line-height: 1.2; }
.cm-needs { margin: 0 0 14px; color: var(--dim); font-weight: 700; font-size: 13px; }
.cm-preview {
  width: 100%; aspect-ratio: 4/3; border-radius: 18px; overflow: hidden; margin-bottom: 12px;
  background: linear-gradient(135deg, #2a2a32, #16161c); display: grid; place-items: center; border: 1px solid var(--stroke);
}
.cm-preview img { width: 100%; height: 100%; object-fit: cover; }
.cm-ph { color: var(--dim); font-weight: 700; font-size: 15px; }
.cm-photo-btns { display: flex; gap: 10px; }
.cm-photo-btn {
  flex: 1; text-align: center; min-height: 50px; line-height: 50px; border-radius: var(--r-btn); cursor: pointer;
  font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(180deg, #3a3a44, #23232b); border: 1px solid var(--stroke);
}
.cm-photo-btn:active { transform: scale(.98); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.chip.on { background: color-mix(in srgb, var(--c) 30%, transparent); border-color: var(--c); }
.chip-emoji { font-size: 16px; }
.chip-note { font-size: 10px; opacity: .7; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

/* ============ LIGHTBOX ============ */
.lightbox { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; background: rgba(0,0,0,.9); backdrop-filter: blur(20px); padding: 14px; padding-top: max(14px, env(safe-area-inset-top)); }
.lightbox.open { display: flex; }
.lightbox img { flex: 1; min-height: 0; width: 100%; object-fit: contain; border-radius: 16px; }
.lb-bar { margin-top: 12px; padding: 12px 14px; border-radius: 18px; display: flex; flex-direction: column; gap: 10px; }
.lb-info { min-width: 0; }
.lb-title { font-size: 15px; font-weight: 800; }
.lb-who { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.lb-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--dim); }
.lb-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.lb-btns .btn { flex: 1; min-height: 44px; }
#lbReplace { flex: 1 1 100%; }

/* ============ FINALE ============ */
#finale { align-items: center; justify-content: center; padding: 24px; text-align: center; position: fixed; inset: 0; overflow: hidden; }
.winner-card { max-width: 360px; width: 100%; padding: 30px 24px; z-index: 2; }
.winner-card .crown { font-size: 48px; }
.winner-card h2 { font-size: 30px; font-weight: 800; margin: 8px 0 6px; background: linear-gradient(180deg, #fff, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.winner-card .sub { color: var(--dim); font-weight: 600; margin: 0 0 20px; }
.confetti-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.confetti { position: absolute; top: -20px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { 0% { transform: translate3d(0,-20vh,0) rotate(0); opacity: 1; } 100% { transform: translate3d(var(--x,0),110vh,0) rotate(720deg); opacity: .9; } }
