:root {
  --bg: #efe9dd;
  --surface: #fffdf8;
  --surface-2: #f6f0e4;
  --ink: #2b2620;
  --muted: #7a7064;
  --line: #e4dccd;
  --accent: #b5532f;      /* terracotta */
  --accent-soft: #f6e1d6;
  --olive: #5f6f3a;
  --olive-soft: #e7ecd8;
  --gold: #c99a2e;
  --gold-soft: #f7ecd0;
  --danger: #b23b3b;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.phone {
  position: relative;
  max-width: 430px;
  height: 100vh; height: 100dvh;
  margin: 0 auto;
  background: var(--surface-2);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,.12);
}

/* --- Header --- */
/* Barra in alto "fluttuante", stesso stile vetro della barra in basso */
.top {
  position: absolute; z-index: 6;
  top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px;
  background: rgba(255, 253, 248, .42);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 26px;
  box-shadow: 0 8px 28px rgba(60, 40, 20, .16), 0 1px 3px rgba(60, 40, 20, .08);
  padding: 12px 14px 10px;
  transition: transform .3s ease, opacity .3s ease;
}
.top.nascosta { transform: translateY(calc(-100% - 24px)); opacity: 0; }
.top .demo-banner { border-radius: 12px; }
.top .pickers select { background: rgba(255, 253, 248, .75); border-color: rgba(0, 0, 0, .08); }
/* Pulsantino per far ricomparire la barra quando è nascosta */
.pill-top {
  position: absolute; z-index: 6; left: 50%; top: calc(8px + env(safe-area-inset-top));
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 999px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
  background: rgba(255, 253, 248, .55);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  box-shadow: 0 4px 16px rgba(60, 40, 20, .14);
  transition: opacity .25s ease, transform .25s ease;
}
.top.nascosta + .pill-top { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.brand-row { display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 18px; }
.muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); }
.pickers { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.pickers label { display: flex; flex-direction: column; min-width: 0; }
.pickers span { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.pickers select { width: 100%; padding: 7px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.demo-banner { margin-top: 8px; font-size: 11px; color: #8a5a00; background: var(--gold-soft); border-radius: 8px; padding: 4px 8px; text-align: center; }

/* --- Main --- */
main { flex: 1; overflow-y: auto; padding: calc(var(--h-top, 160px) + 24px + env(safe-area-inset-top)) 16px 24px; }
h2 { font-size: 22px; margin: 4px 0 2px; }
h3 { font-size: 15px; margin: 22px 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.card.tap:active { transform: scale(.99); }
.hero { background: linear-gradient(135deg, var(--accent), #8c3a1f); color: #fff; border: none; }
.hero .sub { color: rgba(255,255,255,.8); }
.chip { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: 0 4px 4px 0; }
.hero .chip { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat .v { font-weight: 600; margin-top: 2px; }
.stat.missing { border-style: dashed; background: transparent; }
.stat.missing .v { color: var(--muted); font-weight: 400; font-size: 13px; }
.stat.wide { grid-column: 1 / -1; }

.row { display: flex; align-items: center; gap: 10px; }
.row .grow, .list-item .grow { flex: 1; min-width: 0; }
.list-item > span:last-child { color: var(--muted); font-size: 18px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; cursor: pointer; }
.list-item .main-w { font-weight: 600; }
.list-item .sec { color: var(--muted); font-size: 13px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.b-validata { background: var(--olive-soft); color: var(--olive); }
.b-confermata { background: var(--gold-soft); color: #8a5a00; }
.b-proposta { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }

.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: var(--olive); border-radius: 999px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 12px; padding: 11px 16px; background: var(--accent); color: #fff; font-weight: 600; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.olive { background: var(--olive); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btns { display: flex; gap: 8px; margin-top: 12px; }
.btns .btn { flex: 1; }

input[type=text], input[type=number], input[type=search], input[type=email], input[type=tel], textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
textarea { min-height: 64px; resize: vertical; }
.field { margin-bottom: 10px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: none; background: none; padding: 7px; border-radius: 9px; font-size: 13px; }
.seg button.on { background: var(--ink); color: #fff; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 40px; }
.note { font-size: 12px; color: var(--muted); }
.todo { font-size: 12px; background: var(--gold-soft); color: #7a5200; border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
.locked { opacity: .5; }

/* --- Bottom nav --- */
/* Barra in basso "fluttuante", stile iOS: vetro sfocato, bordi arrotondati */
nav.bottom {
  position: absolute; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; justify-content: space-around; align-items: center; gap: 4px;
  padding: 6px;
  background: rgba(255, 253, 248, .38);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 28px;
  box-shadow: 0 8px 28px rgba(60, 40, 20, .16), 0 1px 3px rgba(60, 40, 20, .08);
}
nav.bottom button {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 7px 2px; border-radius: 22px;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
nav.bottom button:active { transform: scale(.94); }
nav.bottom button span { font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: .65; transition: filter .2s, opacity .2s; }
nav.bottom button.on { color: var(--accent); font-weight: 600; background: rgba(181, 83, 47, .12); }
nav.bottom button.on span { filter: none; opacity: 1; }
main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

/* --- Sheet (bottom modal) --- */
.sheet { position: absolute; inset: 0; background: rgba(30,25,20,.45); display: flex; align-items: flex-end; z-index: 10; }
.sheet.hidden { display: none; }
.sheet-body { background: var(--surface-2); width: 100%; max-height: 88%; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 16px 28px; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.x { border: none; background: var(--surface); border-radius: 50%; width: 32px; height: 32px; }

/* --- Games --- */
.flash { min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 28px; font-weight: 700; cursor: pointer; }
.flash .hint { font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 10px; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match button { padding: 14px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.match button.sel { border-color: var(--accent); background: var(--accent-soft); }
.match button.ok { background: var(--olive-soft); border-color: var(--olive); color: var(--olive); opacity: .6; }
.match button.ko { background: #f6dcdc; border-color: var(--danger); }
.opts { display: grid; gap: 8px; margin-top: 12px; }
.opts button { padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; font-weight: 600; }
.opts button.ok { background: var(--olive-soft); border-color: var(--olive); }
.opts button.ko { background: #f6dcdc; border-color: var(--danger); }
.tokens { display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; padding: 8px; border-radius: 12px; border: 1px dashed var(--line); background: var(--surface); margin: 10px 0; }
.tokens button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.big-word { font-size: 30px; font-weight: 700; text-align: center; margin: 14px 0 4px; }
.backlink { border: none; background: none; color: var(--accent); padding: 0; margin-bottom: 8px; font-weight: 600; }

.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; text-align: left; }
.game-card .e { font-size: 28px; }
.game-card b { display: block; margin-top: 6px; }
.game-card small { color: var(--muted); }

.toast { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; max-width: 90%; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%); }

/* --- Mappa --- */
.mappa { padding: 8px; }
.mappa svg { width: 100%; height: auto; display: block; }
.mappa path { stroke: var(--surface); stroke-width: 1; cursor: pointer; transition: opacity .15s; }
.mappa path:hover { opacity: .8; }
.mappa path.sel { stroke: var(--ink); stroke-width: 2; }
.mappa .pin { fill: var(--ink); stroke: #fff; stroke-width: 2; pointer-events: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.timeline { display: grid; gap: 6px; }
.tl { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.tl-n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* Comuni: nero = dizionario del paese, grigio = ancora da raccogliere */
select option.c-si { color: var(--accent); font-weight: 800; }
.pickers select.c-si { color: var(--accent); font-weight: 800; border-color: var(--accent); }
select option.c-no { color: #9a958c; }
select.c-no { color: #8a857c; }
.progresso .riga-p { display: flex; justify-content: space-between; font-size: 13px; margin: 10px 0 4px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; vertical-align: middle; margin-right: 2px; }
.adotta { border: 1.5px dashed var(--gold); background: var(--gold-soft); }
.adotta.si { border-style: solid; }

/* Home corta */
.pdg-w { font-size: 28px; font-weight: 800; margin: 2px 0; }
.azioni { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 14px; }
.azione { border: none; background: var(--accent); color: #fff; border-radius: var(--radius); padding: 14px 6px; font-size: 14px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.azione span { font-size: 26px; }
.azione:nth-child(2) { background: var(--olive); }
.azione:nth-child(3) { background: var(--ink); }
.progresso-mini { margin-top: 14px; padding: 10px 4px; font-size: 13px; color: var(--muted); cursor: pointer; }
.progresso-mini .bar { margin-top: 6px; height: 6px; }
.seg-big button { padding: 10px; font-size: 15px; font-weight: 600; }
.testo p { margin: 0 0 10px; line-height: 1.55; }
.testo p:last-child { margin-bottom: 0; }
.nonso { align-items: flex-start; gap: 10px; background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; margin: 4px 0 10px; }
.nonso input { margin-top: 3px; }
.nonso-info { background: var(--gold-soft); border-color: transparent; }

/* Benvenuto e panoramica */
.benvenuto { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(180deg, rgba(208,104,61,.92), rgba(165,71,42,.95));
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.benvenuto.hidden { display: none; }
.benv-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 28px; padding: 26px 22px 20px; text-align: center;
  box-shadow: 0 20px 50px rgba(40, 20, 10, .3); animation: up .25s ease-out; }
.benv-card .field, .benv-card .backlink { text-align: left; }
.benv-card h2 { margin: 6px 0 6px; }
.benv-card .btn { margin-top: 10px; }
.benv-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 8px 20px rgba(0,0,0,.15); }
.link-btn { display: block; margin: 14px auto 0; border: none; background: none; color: var(--muted); font-size: 14px; text-decoration: underline; cursor: pointer; }
.passi { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.passi span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.passi span.on { background: var(--accent); width: 22px; border-radius: 999px; }
.raccogli { border: 1.5px dashed var(--accent); background: var(--accent-soft); }

/* Padre fondatore */
.fondatore { border-left: 4px solid var(--gold); background: var(--gold-soft); }
.fondatore .f-nome { font-size: 20px; font-weight: 800; margin-top: 2px; }

/* Lezione */
.lezione { text-align: center; padding: 26px 16px; }
.lez-it { font-size: 22px; font-weight: 600; margin: 2px 0 6px; }
.lez-dia { font-size: 34px; font-weight: 800; color: var(--accent); margin: 4px 0 2px; }
.passi-bar { display: flex; gap: 4px; margin: 0 0 10px; }
.passi-bar span { flex: 1; height: 5px; border-radius: 999px; background: var(--line); }
.passi-bar span.on { background: var(--accent); }
.feedback { border-radius: 14px; padding: 10px 12px; margin-top: 12px; line-height: 1.45; }
.feedback.ok { background: var(--olive-soft); color: #33421a; }
.feedback.ko { background: #f8dede; color: #6b1f1f; }
.fondatore.comunita { border-left-color: var(--olive); background: var(--olive-soft); }
/* logo in pixel art: quadretti netti anche quando è rimpicciolito */
.brand .logo, .benv-logo { image-rendering: auto; }

/* Metti nella Home */
.inst-top { display: flex; gap: 12px; align-items: center; }
.inst-icona { width: 56px; height: 56px; border-radius: 14px; flex: none; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.passi-inst { margin: 4px 0 0; padding-left: 22px; line-height: 1.55; }
.passi-inst li { margin-bottom: 10px; }
.ico-inst { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); color: #1a73e8; vertical-align: middle; font-weight: 700; }

/* ---------------------------------------------------------------
   Tablet: un po' più largo
   --------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 979px) {
  .phone { max-width: 680px; }
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .sheet { align-items: center; justify-content: center; }
  .sheet-body { width: 560px; max-width: 92%; border-radius: 22px; }
}

/* ---------------------------------------------------------------
   Computer: barra in alto fissa, menu a sinistra, contenuto al centro
   --------------------------------------------------------------- */
@media (min-width: 980px) {
  body { font-size: 16px; }
  .phone { max-width: none; box-shadow: none; background: var(--bg); }

  .top { left: 24px; right: 24px; top: 14px; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 28px; padding: 12px 18px; }
  .top.nascosta { transform: none; opacity: 1; }
  .pill-top { display: none; }
  .brand-row { gap: 18px; justify-content: flex-start; }
  .brand { font-size: 21px; }
  .brand .logo { width: 34px; height: 34px; }
  .pickers { margin-top: 0; max-width: 680px; justify-self: end; width: 100%; }
  .pickers select { font-size: 14px; padding: 8px; }
  .top .demo-banner { grid-column: 1 / -1; justify-self: center; margin-top: 8px; padding: 3px 14px; }

  nav.bottom {
    left: 24px; right: auto; bottom: auto; top: calc(var(--h-top, 100px) + 32px); width: 220px;
    flex-direction: column; align-items: stretch; gap: 4px; padding: 8px; border-radius: 22px;
  }
  nav.bottom button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 12px 14px; border-radius: 14px; }
  nav.bottom button:hover { background: rgba(181, 83, 47, .07); }
  nav.bottom button span { font-size: 20px; }

  main { padding: calc(var(--h-top, 100px) + 32px) 40px 48px 280px; }
  main > * { max-width: 860px; margin-left: auto; margin-right: auto; }
  main::-webkit-scrollbar { width: 10px; }
  main::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 10px; }

  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .azione { padding: 20px 8px; font-size: 15px; }
  .list-item:hover, .game-card:hover { border-color: var(--accent); }
  .flash { min-height: 260px; }

  .sheet { align-items: center; justify-content: center; }
  .sheet-body { width: 600px; max-width: 92%; max-height: 84%; border-radius: 22px; padding: 22px 24px 26px; }
  .toast { bottom: 36px; }
}
@media (min-width: 1300px) {
  main { padding-right: 280px; }
}
