:root {
  --bg: #f8f4ee;
  --paper: #ffffff;
  --ink: #2b2724;
  --muted: #8a8079;
  --line: #e7dfd4;
  --gold: #b08d57;
  --gold-soft: #f1e7d6;
  --green: #5f8a68;
  --green-soft: #e3eee4;
  --red: #b5615f;
  --red-soft: #f8e9e7;
  --orange: #d58a3a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 30, .06), 0 4px 16px rgba(60, 45, 30, .06);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --script: 'Great Vibes', 'Cormorant Garamond', cursive;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45;
  min-height: 100vh; overscroll-behavior-y: none;
}
img { max-width: 100%; display: block; }
a { color: var(--gold); }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.6rem; } h3 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.script { font-family: var(--script); font-weight: 400; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; background: rgba(248, 244, 238, .94);
  border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.topbar .brand { font-family: var(--script); font-size: 1.6rem; line-height: 1; color: var(--gold); white-space: nowrap; }
.topbar .brand small { display: block; font-family: var(--serif); font-size: .8rem; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: .85rem; white-space: nowrap; }
.chip b { font-size: 1rem; }
main { max-width: 640px; margin: 0 auto; padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a { flex: 1; text-align: center; padding: 8px 2px 9px; color: var(--muted); text-decoration: none; font-size: .72rem; }
.nav a .i { display: block; font-size: 1.3rem; line-height: 1.3; filter: grayscale(1); opacity: .7; }
.nav a.on { color: var(--ink); font-weight: 600; }
.nav a.on .i { filter: none; opacity: 1; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

/* ---------- Gumbi i forme ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  position: relative; overflow: hidden; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { display: flex; width: 100%; }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.outline { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.green { background: var(--green); border-color: var(--green); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 0; }
.linkbtn { background: none; border: 0; padding: 4px; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .9rem; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.pin-input { letter-spacing: .5em; text-align: center; font-size: 1.4rem; }
label.lbl { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 4px 2px; }
.err { color: var(--red); font-size: .92rem; min-height: 1.2em; }
.note { background: var(--gold-soft); border-radius: 12px; padding: 12px 14px; font-size: .92rem; }

/* ---------- Auth ---------- */
.hero { text-align: center; padding: 28px 8px 8px; }
.hero .names { font-family: var(--script); font-size: 3.2rem; color: var(--gold); line-height: 1.1; }
.hero .title { font-family: var(--serif); letter-spacing: .3em; text-transform: uppercase; font-size: .95rem; color: var(--muted); }
.hero .rings { font-size: 1.5rem; margin: 8px 0; }
.ornament { display: flex; align-items: center; gap: 12px; color: var(--gold); margin: 14px 0; }
.ornament::before, .ornament::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Bingo kartica ---------- */
.score { display: flex; justify-content: space-around; text-align: center; padding: 10px 6px; }
.score .v { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; line-height: 1; }
.score .k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: .85rem; cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cell { position: relative; width: 100%; padding-top: 100%; border-radius: 8px; overflow: hidden; cursor: pointer; border: 1px solid #edd0cc; background: var(--red-soft); }
.cell > * { position: absolute; }
.cell .bg { inset: 0; background-size: cover; background-position: center; }
.cell .tint { inset: 0; }
.cell .txt {
  inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 3px;
  font-size: clamp(8.5px, 2.35vw, 13px); line-height: 1.12; color: #7b3c38; overflow: hidden; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto;
}
.cell.done { border-color: #8fb596; background: var(--green-soft); }
.cell.done .tint { background: linear-gradient(180deg, rgba(48, 92, 58, .35), rgba(38, 76, 47, .62)); }
.cell.done .txt { color: #fff; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }
.cell.center:not(.done) { border: 2px solid var(--gold); background: var(--gold-soft); }
.cell.center:not(.done) .txt { color: #6f5530; font-weight: 600; }
.cell .badge { top: 2px; right: 2px; font-size: 11px; line-height: 1; padding: 2px 3px; border-radius: 6px; background: rgba(255, 255, 255, .92); }
.cell.hiddenph .tint { background: #cfc8c0; }
.grid.small .txt { font-size: clamp(7px, 1.9vw, 11px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--muted); margin-top: 10px; justify-content: center; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }

/* ---------- Ljestvica ---------- */
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; cursor: pointer; }
.lb li.me { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.lb .rank { width: 26px; text-align: center; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--muted); flex: none; }
.lb li:nth-child(1) .rank, .lb li:nth-child(2) .rank, .lb li:nth-child(3) .rank { color: var(--gold); }
.lb .who { flex: 1; min-width: 0; }
.lb .who .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .who .s { font-size: .78rem; color: var(--muted); }
.lb .pts { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; text-align: right; min-width: 44px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; background: var(--gold-soft); color: var(--gold); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; overflow: hidden; }
.avatar.lg { width: 84px; height: 84px; font-size: 2rem; }
.mini { display: grid; grid-template-columns: repeat(5, 6px); gap: 1.5px; flex: none; }
.mini i { width: 6px; height: 6px; border-radius: 1.5px; background: #ecd9d6; }
.mini i.f { background: var(--green); } .mini i.a { background: var(--gold); } .mini i.r { background: var(--orange); }

/* ---------- Galerija ---------- */
.filters { display: flex; gap: 6px; margin-bottom: 10px; }
.gal { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.gal .ph { position: relative; padding-top: 100%; background: var(--line) center / cover no-repeat; border-radius: 4px; cursor: pointer; }
.gal .ph .k { position: absolute; left: 3px; bottom: 3px; font-size: 10px; background: rgba(255, 255, 255, .9); border-radius: 5px; padding: 1px 4px; }

/* ---------- Modal / sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(30, 24, 20, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: var(--paper); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .2s ease-out; -webkit-overflow-scrolling: touch;
}
@media (min-width: 600px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet .x { float: right; background: none; border: 0; font-size: 1.6rem; line-height: 1; padding: 0 4px; cursor: pointer; color: var(--muted); }
.sheet .photo { width: 100%; border-radius: 12px; margin: 10px 0; background: var(--line); }
.status { display: inline-block; font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--line); }
.status.ok { background: var(--green-soft); color: #2f5b39; }
.status.ap { background: var(--gold-soft); color: #6f5530; }
.status.rp { background: #fbe6cf; color: #8a4f12; }
.status.no { background: var(--red-soft); color: #7b3c38; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }

/* ---------- Toast i slavlje ---------- */
.toasts { position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: 0; right: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 12px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .92rem; box-shadow: var(--shadow); max-width: 520px; animation: fade .2s; pointer-events: auto; }
.toast.err { background: var(--red); }
.celebrate { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(30, 24, 20, .6); padding: 20px; animation: fade .2s; overflow: hidden; }
.celebrate .box { background: var(--paper); border-radius: 22px; padding: 28px 22px; text-align: center; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); position: relative; z-index: 2; }
.celebrate .big { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; color: var(--gold); line-height: 1; margin-bottom: 8px; }
.celebrate .who { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; z-index: 1; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.banner { display: flex; gap: 10px; align-items: flex-start; background: var(--paper); border: 1px solid var(--gold); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: .92rem; }
.banner .i { font-size: 1.4rem; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
details summary { cursor: pointer; font-weight: 600; }
.pinbig { font-family: var(--serif); font-size: 2.6rem; letter-spacing: .3em; font-weight: 700; text-align: center; color: var(--ink); margin: 6px 0; }
.copy { display: flex; gap: 6px; }
.copy input { flex: 1; min-width: 0; font-size: .85rem; }

/* ---------- Postolje (kraj igre) ---------- */
.lb .pts small { font-size: .7rem; color: var(--muted); font-family: var(--sans); font-weight: 400; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 6px; margin: 6px 0 16px; text-align: center; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; min-width: 0; }
.pod .m { font-size: 1.8rem; line-height: 1; }
.pod .n { font-weight: 600; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .step { width: 100%; background: var(--gold-soft); border: 1px solid #e3d2b4; border-radius: 10px 10px 0 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--gold); }
.pod.p1 .step { height: 84px; padding-top: 18px; } .pod.p2 .step { height: 60px; padding-top: 10px; } .pod.p3 .step { height: 44px; padding-top: 4px; }

/* ---------- Ikone (Font Awesome) ---------- */
.hero .rings { color: var(--gold); font-size: 1.3rem; }
.nav a .i { filter: none; opacity: 1; font-size: 1.15rem; color: #b3a99f; }
.nav a.on .i { color: var(--gold); }
.bigicon { font-size: 2.4rem; color: var(--gold); line-height: 1; }
.bigicon.red { color: var(--red); }
.celebrate .bigicon { margin-bottom: 10px; }
.goldc { color: var(--gold); }
.cell .badge { width: 18px; height: 18px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); }
.cell .badge .ok, .legend .ok { color: var(--green); }
.cell .badge .rp, .legend .rp { color: var(--orange); }
.legend span.li::before { display: none; }
.pod .m { font-size: 1.7rem; }
.pod .m.gold { color: #c9a227; } .pod .m.silver { color: #9ea3a8; } .pod .m.bronze { color: #b87333; }
.gal .ph .k { color: var(--gold); }
.hero .ornament { max-width: 220px; margin: 10px auto 4px; font-size: .8rem; }
.welcome-av { display: flex; gap: 12px; align-items: center; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.welcome-av .avatar { width: 56px; height: 56px; }
