/* ============ DRAWING MASTER — tema atelier grunge ============ */
@font-face {
  font-family: 'Playfair Display';
  src: url('../fonts/playfair.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #0e0c0a;
  --bg2: #171310;
  --panel: #1d1814;
  --line: #34291f;
  --gold: #c9a227;
  --gold-hi: #eecf6d;
  --paper: #d8d2c4;
  --muted: #8d8375;
  --red: #a03c2e;
  --ok: #5f8a4e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--paper);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  /* grana carta */
  background-image:
    radial-gradient(ellipse at 50% -10%, #1c1712 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.8 0 0 0 0 0.72 0 0 0 0 0.55 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--gold); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- logo (vittoriano essenziale) ---------- */
.logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
  background: linear-gradient(178deg, #e9d189 12%, #c9a227 52%, #96761a 94%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.6));
  user-select: none;
}
.logo-big { font-size: clamp(2rem, 8.6vw, 3.5rem); line-height: 1.12; text-align: center; }
.logo-small { font-size: 1.02rem; letter-spacing: .13em; white-space: nowrap; }
.logo-sub {
  color: var(--muted);
  text-align: center;
  font-size: .74rem;
  margin-top: .55rem;
  text-transform: uppercase;
  letter-spacing: .26em;
}
/* filetto ornamentale vittoriano */
.ornament {
  display: flex; align-items: center; gap: 12px;
  width: min(340px, 74vw); margin: 10px auto 0;
  color: var(--gold);
}
.ornament::before, .ornament::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, #8a6f24);
}
.ornament::after { background: linear-gradient(90deg, #8a6f24, transparent); }
.ornament i {
  width: 7px; height: 7px; transform: rotate(45deg);
  border: 1px solid var(--gold); display: block;
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; gap: 8px;
}
.login-card {
  width: 100%; max-width: 380px;
  margin-top: 28px;
  background: linear-gradient(180deg, var(--panel), #16110d);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.login-card label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 6px; letter-spacing: .06em; text-transform: uppercase; }
.login-card input[type=password] {
  width: 100%; padding: 13px 14px;
  border-radius: 8px; border: 1px solid var(--line);
  background: #0c0a08; color: var(--paper);
  font-size: 1.25rem; letter-spacing: .35em; text-align: center;
}
.login-card input[type=password]:focus { outline: none; border-color: var(--gold); }
.remember { display: flex; align-items: center; gap: 9px; margin: 16px 0 18px; color: var(--paper); font-size: .95rem; }
.remember input { width: 19px; height: 19px; accent-color: var(--gold); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 18px;
  border-radius: 9px; border: 1px solid #a3821f;
  background: linear-gradient(180deg, #d9b23a, #9a7a16);
  color: #17120a; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; font-size: .95rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn:active { transform: translateY(1px); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: transparent; color: var(--paper);
  border: 1px solid var(--line); box-shadow: none; font-weight: 600;
}
.btn-ghost:disabled { opacity: .38; cursor: not-allowed; }
.err { background: #2a1310; border: 1px solid #57221b; color: #e0a294; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }

/* ---------- barra alta ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: rgba(14,12,10,.88);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.topbar .spacer { flex: 1; }
.stat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .84rem; color: var(--paper);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; background: var(--bg2);
  white-space: nowrap;
}
.icon-link { line-height: 1; padding: 4px; color: var(--paper); opacity: .85; display: inline-flex; }
.icon-link:hover { opacity: 1; color: var(--gold-hi); }

/* icone SVG a tratto */
.ic { width: 1.06em; height: 1.06em; flex: none; vertical-align: -.15em; }
.stat-chip .ic { width: 15px; height: 15px; color: var(--gold); }
.icon-link .ic { width: 21px; height: 21px; }
.chip .ic { width: 14px; height: 14px; }
.fs-btn .ic { width: 20px; height: 20px; }
.set-card h3 .ic { width: 18px; height: 18px; color: var(--gold); vertical-align: -.2em; margin-right: 6px; }

/* ---------- sfida ---------- */
.stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100dvh - 58px - env(safe-area-inset-top));
  padding: 0;
}
.artwork {
  max-width: 100vw;
  max-height: calc(100dvh - 58px - env(safe-area-inset-top));
  width: auto; height: auto;
  object-fit: contain;
  display: block;
  box-shadow: 0 12px 60px rgba(0,0,0,.8);
}
.stage.zen .hud { opacity: 0; pointer-events: none; }
.hud { transition: opacity .3s; }

/* pulsante schermo intero */
.fs-btn {
  position: absolute; top: 12px; right: 12px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(14,12,10,.82); backdrop-filter: blur(6px);
  color: var(--paper); font-size: 1.25rem; line-height: 1;
}
.fs-btn:hover { border-color: var(--gold); color: var(--gold-hi); }

/* modalità immersiva: solo l'immagine, nient'altro */
body.immersive { background: #000; }
body.immersive .topbar { display: none; }
body.immersive .stage { min-height: 100dvh; }
body.immersive .artwork,
.stage:fullscreen .artwork { max-height: 100dvh; box-shadow: none; }
.stage:fullscreen { background: #000; }

.hud-top {
  position: absolute; top: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 0 12px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(14,12,10,.82); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; font-size: .84rem; letter-spacing: .03em;
}
.chip .cat { color: var(--gold-hi); font-weight: 700; text-transform: uppercase; font-size: .78rem; }
.chip.diff { color: var(--gold); font-size: .9rem; letter-spacing: .12em; }
.chip.locked { color: var(--gold-hi); border-color: #6d5716; }
.chip.done { color: #a5cc93; border-color: #3c5a30; }

.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(10,8,6,.96) 0%, rgba(10,8,6,.82) 55%, transparent 100%);
}
.focus-line {
  font-size: 1.04rem; line-height: 1.35; font-weight: 600;
  color: var(--gold-hi);
  text-align: center; margin-bottom: 5px;
  text-shadow: 0 2px 8px rgba(0,0,0,.9);
}
.meta-line {
  text-align: center; color: var(--muted); font-size: .82rem;
  margin-bottom: 12px;
}
.meta-line a { color: var(--muted); text-decoration: underline; }
.actions {
  display: flex; gap: 9px; justify-content: center; flex-wrap: wrap;
  max-width: 560px; margin: 0 auto;
}
.actions .btn, .actions .btn-ghost { width: auto; flex: 1 1 150px; padding: 12px 10px; font-size: .84rem; border-radius: 9px; }
.btn-done {
  border-color: #4c6c3e;
  background: linear-gradient(180deg, #79a566, #4d7040);
  color: #10180c;
}

/* filtro parti */
.filter-row {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  margin: 0 0 10px;
}
.f-chip { font-size: .78rem; padding: 4px 12px; }
.f-chip.active { color: var(--gold-hi); border-color: var(--gold); background: rgba(201,162,39,.12); }

/* tabs slot */
.slot-tabs { display: flex; gap: 7px; justify-content: center; margin: 0 0 8px; }
.slot-tab {
  border: 1px solid var(--line); background: rgba(14,12,10,.8);
  color: var(--muted); border-radius: 999px; padding: 5px 14px; font-size: .82rem;
}
.slot-tab.active { color: var(--gold-hi); border-color: var(--gold); }
.slot-tab.completed::after { content: ' ✓'; color: #a5cc93; }

/* countdown */
.countdown { font-variant-numeric: tabular-nums; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--panel); border: 1px solid var(--gold);
  color: var(--paper); border-radius: 10px; padding: 12px 20px;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 100;
  max-width: 90vw; text-align: center; font-size: .95rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.7);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- pagine interne (archivio / impostazioni) ---------- */
.page { max-width: 960px; margin: 0 auto; padding: 22px 16px 60px; }
.page h2 { font-family: 'Playfair Display', Georgia, serif; font-weight: 700; color: var(--gold); font-size: 1.7rem; margin: 26px 0 12px; letter-spacing: .09em; text-transform: uppercase; }
.page h2:first-of-type { margin-top: 10px; }
.stats-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.stat-big {
  flex: 1 1 130px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; text-align: center;
}
.stat-big b { display: block; font-size: 1.9rem; color: var(--gold-hi); font-family: 'Playfair Display', Georgia, serif; font-weight: 700; }
.stat-big span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; }

.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-top: 14px; }
.arch-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: border-color .2s;
}
.arch-card:hover { border-color: var(--gold); }
.arch-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #000; }
.arch-pair figure { margin: 0; position: relative; aspect-ratio: 3/4; overflow: hidden; }
.arch-pair img { width: 100%; height: 100%; object-fit: cover; display: block; }
.arch-pair figcaption {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 7px; background: rgba(10,8,6,.75); color: var(--muted);
}
.arch-pair .missing {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--muted); font-size: .8rem; background: var(--bg2);
}
.arch-info { padding: 10px 12px; }
.arch-info .d { color: var(--gold-hi); font-size: .82rem; letter-spacing: .04em; }
.arch-info .f { color: var(--paper); font-size: .88rem; margin-top: 2px; }
.arch-info .m { color: var(--muted); font-size: .76rem; margin-top: 2px; }

/* lightbox archivio */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(5,4,3,.96);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 10px;
}
.lightbox.open { display: flex; }
.lightbox .lb-imgs { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; max-height: 78dvh; overflow: auto; }
.lightbox img { max-width: min(92vw, 640px); max-height: 74dvh; object-fit: contain; border: 1px solid var(--line); }
.lightbox .lb-cap { color: var(--muted); font-size: .85rem; text-align: center; max-width: 700px; }
.lightbox .lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; font-size: 2rem; color: var(--paper); background: none; border: none; }

/* impostazioni */
.set-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-top: 14px; }
.set-card h3 { color: var(--gold-hi); font-size: 1.05rem; margin-bottom: 6px; }
.set-card p { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.set-card select {
  background: #0c0a08; color: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; font-size: 1rem;
}
.set-card .btn, .set-card .btn-ghost { width: auto; padding: 11px 20px; font-size: .85rem; }
.set-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.code-box {
  background: #0c0a08; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, monospace; font-size: .78rem;
  color: var(--paper); word-break: break-all; user-select: all;
}
.pill-ok { color: #a5cc93; } .pill-no { color: #e0a294; }

/* ---------- landing pubblica ---------- */
.landing { max-width: 1020px; margin: 0 auto; padding: 0 18px 40px; }
.hero { text-align: center; padding: 64px 0 26px; }
.hero-tagline {
  margin-top: 14px; color: var(--gold-hi);
  text-transform: uppercase; letter-spacing: .24em; font-size: .84rem;
}
.no-ai-badge {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 16px; padding: 7px 16px;
  border: 1px solid #6d5716; border-radius: 999px;
  color: var(--gold-hi); font-size: .82rem; font-weight: 600;
  background: rgba(201,162,39,.08);
}
.no-ai-badge .ic { width: 14px; height: 14px; color: var(--gold); }
.hero-p {
  max-width: 680px; margin: 18px auto 0; color: var(--paper);
  font-size: 1.02rem; line-height: 1.75;
}
.hero-cta {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  margin-top: 28px;
}
.hero-cta .btn, .hero-cta .btn-ghost { width: auto; padding: 14px 26px; font-size: .9rem; }
.hero-note { margin-top: 14px; color: var(--muted); font-size: .82rem; max-width: 520px; margin-left: auto; margin-right: auto; }

.features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px; margin-top: 36px;
}
.feature {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 18px;
}
.feature h2 {
  font-family: 'Playfair Display', Georgia, serif; font-weight: 700;
  color: var(--gold-hi); font-size: 1.05rem; letter-spacing: .04em; margin-bottom: 8px;
}
.feature h2 .ic { width: 18px; height: 18px; color: var(--gold); margin-right: 8px; vertical-align: -.2em; }
.feature p { color: var(--muted); font-size: .92rem; line-height: 1.6; }

.samples { margin-top: 40px; }
.samples-title {
  font-family: 'Playfair Display', Georgia, serif; font-weight: 700;
  color: var(--gold); font-size: 1.3rem; letter-spacing: .08em;
  text-transform: uppercase; text-align: center; margin-bottom: 16px;
}
.sample-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.sample-strip figure {
  margin: 0; aspect-ratio: 3/4; overflow: hidden; border-radius: 8px;
  border: 1px solid var(--line); position: relative; background: #171310;
}
.sample-strip img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: opacity 1.3s ease;
}
.sample-strip .s-a { opacity: 1; }
.sample-strip .s-b { opacity: 0; }

.site-footer {
  margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line);
  text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.7;
}
.site-footer a { color: var(--muted); text-decoration: underline; }

/* ---------- login OTP ---------- */
.login-card input[type=email], .login-card input[type=text] {
  width: 100%; padding: 13px 14px;
  border-radius: 8px; border: 1px solid var(--line);
  background: #0c0a08; color: var(--paper); font-size: 1.05rem;
}
.login-card input:focus { outline: none; border-color: var(--gold); }
.login-card .code-input { font-size: 1.5rem; letter-spacing: .45em; text-align: center; }
.login-h { color: var(--gold-hi); font-size: 1.1rem; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: .86rem; margin-bottom: 16px; }
.login-card label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 6px; letter-spacing: .06em; text-transform: uppercase; }
.err[hidden] { display: none; }
.err { margin-top: 12px; }

/* ---------- livello / XP ---------- */
.level-row { display: flex; align-items: center; gap: 18px; }
.level-badge {
  position: relative; flex: none;
  width: 74px; height: 74px; border-radius: 50%;
  border: 2px solid var(--gold); background: radial-gradient(circle at 50% 35%, #262019, #14100c);
  display: flex; align-items: center; justify-content: center;
}
.level-badge .ic { position: absolute; top: 9px; width: 15px; height: 15px; color: var(--gold); }
.level-badge span {
  font-family: 'Playfair Display', Georgia, serif; font-weight: 800;
  font-size: 1.9rem; color: var(--gold-hi); margin-top: 10px;
}
.level-info { flex: 1; min-width: 0; }
.level-info h3 { color: var(--gold-hi); font-size: 1.05rem; margin-bottom: 8px; }
.xp-bar {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: #0c0a08; border: 1px solid var(--line);
}
.xp-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #8a6b14, #c9a227 60%, #eecf6d);
  box-shadow: 0 0 8px rgba(201,162,39,.35);
  transition: width .6s;
}
.xp-text { color: var(--muted); font-size: .82rem; margin-top: 7px; }
.donate-card { border-color: #6d5716; }

@media (max-width: 560px) {
  .hide-narrow { display: none; }
  .hero { padding-top: 42px; }
}
@media (max-width: 480px) {
  .actions .btn, .actions .btn-ghost { flex: 1 1 46%; }
  .arch-grid { grid-template-columns: 1fr 1fr; }
  .arch-pair figure { aspect-ratio: 3/4.2; }
  .sample-strip { grid-template-columns: repeat(3, 1fr); }
}
