/* ============================================================
   VIAGGIO CON L'AI: LA MAPPA DEL TESORO — style.css
   Mobile-first, responsive
   ============================================================ */

:root {
  --gold:       #8B6914;
  --gold-lt:    #c4a55a;
  --gold-pale:  #f5ecd4;
  --ink:        #3a2800;
  --forest:     #2D5A3D;
  --forest-lt:  #4A8A60;
  --rust:       #B84A2A;
  --parch:      #e8d5a0;
  --r:          12px;
  --rs:         8px;
  --t:          0.22s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0e8d0;
  min-height: 100vh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1rem 0.5rem 3rem;
}
#app { width: 100%; max-width: 700px; }

.screen { display: none; }
.screen.active { display: block; }

/* ===== AUTH ===== */
#s-auth {
  background: var(--parch); border: 3px solid var(--gold);
  border-radius: var(--r); padding: 1.75rem 1.25rem; text-align: center;
}
.auth-logo { font-size: 2.5rem; margin-bottom: 0.4rem; }
.auth-title { font-size: 1.3rem; font-weight: 700; color: var(--ink); font-family: Georgia,serif; line-height: 1.25; }
.auth-title em { color: var(--gold); font-style: italic; }
.auth-subtitle { font-size: 0.82rem; color: #7a5c2a; margin: 0.5rem 0 1.25rem; line-height: 1.6; }

.auth-tabs { display: flex; border-radius: var(--rs); overflow: hidden; border: 1.5px solid var(--gold-lt); margin-bottom: 1.25rem; }
.auth-tab { flex: 1; padding: 0.55rem; background: transparent; border: none; cursor: pointer; font-size: 0.85rem; font-weight: 700; color: var(--gold); transition: var(--t); }
.auth-tab.active { background: var(--gold); color: #fff; }

.auth-form { display: flex; flex-direction: column; gap: 0.65rem; text-align: left; }
.auth-form label { font-size: 0.78rem; font-weight: 700; color: var(--ink); }
.auth-form small { font-size: 0.72rem; color: #7a5c2a; display: block; margin-top: 2px; }
.auth-form input {
  width: 100%; padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--gold-lt); border-radius: var(--rs);
  font-size: 1rem; background: #fff8e8; color: var(--ink); transition: var(--t);
  -webkit-appearance: none;
}
.auth-form input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(139,105,20,0.15); }

.nick-check { font-size: 0.75rem; min-height: 1rem; padding: 2px 0; }
.nick-check.ok  { color: var(--forest); }
.nick-check.err { color: var(--rust); }

/* Regolamento */
.regolamento-toggle {
  display: block; margin: 0.5rem 0 0; text-align: center;
  font-size: 0.8rem; font-weight: 700; color: var(--gold);
  cursor: pointer; text-decoration: underline; background: none; border: none;
  font-family: inherit;
}
.regolamento-box {
  display: none; margin-top: 0.5rem;
  background: #fff8e8; border: 1px solid var(--gold-lt);
  border-radius: var(--rs); padding: 0.9rem 1rem;
  text-align: left; font-size: 0.78rem; color: var(--ink); line-height: 1.65;
}
.regolamento-box.open { display: block; }
.regolamento-box h4 { font-size: 0.82rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--gold); }
.regolamento-box ol { padding-left: 1.1rem; }
.regolamento-box ol li { margin-bottom: 0.3rem; }

.btn-primary {
  background: var(--gold); color: #fff8e8; font-size: 0.95rem; font-weight: 700;
  padding: 0.75rem; border: none; border-radius: var(--rs);
  cursor: pointer; transition: var(--t); margin-top: 0.4rem; width: 100%;
  touch-action: manipulation;
}
.btn-primary:hover, .btn-primary:active { background: #a07820; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.auth-cls-link {
  text-align: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--gold-lt);
}
.auth-cls-link button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gold);
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}
.auth-cls-link button:hover { color: #a07820; }
.auth-msg { margin-top: 0.6rem; font-size: 0.82rem; min-height: 1.1rem; text-align: center; }
.auth-msg.ok  { color: var(--forest); }
.auth-msg.err { color: var(--rust); }

/* ===== MAPPA ===== */
#s-map { padding: 0; }
.map-header { text-align: center; margin-bottom: 0.6rem; padding-top: 0.4rem; }
.map-main-title { font-size: 1.15rem; font-weight: 700; color: var(--ink); font-family: Georgia,serif; line-height: 1.2; }
.map-main-title em { color: var(--gold); font-style: italic; }
.map-main-sub { font-size: 0.75rem; color: #7a5c2a; margin-top: 2px; }

.score-strip { display: flex; justify-content: center; gap: 0.5rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.score-pill { background: #fff8e8; border: 1px solid var(--gold-lt); border-radius: 100px; padding: 3px 10px; font-size: 0.75rem; color: #7a5c2a; }
.score-pill b { color: var(--ink); }

.parchment-wrap { border: 3px solid var(--gold); border-radius: var(--r); overflow: hidden; background: var(--parch); }
.parchment-wrap svg { display: block; width: 100%; height: auto; }
.map-legend { display: flex; justify-content: center; gap: 1rem; padding: 5px 0 3px; font-size: 0.68rem; color: #5a3e10; border-top: 1px dashed var(--gold-lt); background: #edd8a0; flex-wrap: wrap; }
.leg-item { display: flex; align-items: center; gap: 3px; }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.btn-classifica { display: block; margin: 0.6rem auto 0; background: transparent; border: 1.5px solid var(--gold); color: var(--gold); font-size: 0.82rem; font-weight: 700; padding: 6px 20px; border-radius: 100px; cursor: pointer; transition: var(--t); touch-action: manipulation; }
.btn-classifica:hover { background: var(--gold); color: #fff; }

/* ===== LIVELLO ===== */
#s-level { padding: 0; }
.level-hud { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; background: var(--ink); border-radius: var(--r) var(--r) 0 0; color: #fff8e8; }
.lhud-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.lhud-badge { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; background: var(--gold); color: #fff; padding: 2px 8px; border-radius: 100px; white-space: nowrap; }
.lhud-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lhud-timer { font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold-lt); white-space: nowrap; }
.lhud-timer.warning { color: #e8896a; }

.q-dots { display: flex; gap: 4px; padding: 8px 14px 0; background: #f5f0e8; }
.q-dot { width: 7px; height: 7px; border-radius: 50%; background: #ddd0b0; transition: background 0.2s; flex-shrink: 0; }
.q-dot.done-ok  { background: var(--forest); }   /* verde: risposta corretta */
.q-dot.done-err { background: var(--rust); }     /* rosso: risposta sbagliata */
.q-dot.current  { background: var(--gold); }     /* giallo: domanda attuale */

.q-card { background: #fffdf5; border: 1px solid #e0d0a0; border-radius: 0 0 var(--r) var(--r); padding: 1rem; }
.q-icon { font-size: 1.8rem; margin-bottom: 0.4rem; display: block; line-height: 1; }
.q-text { font-size: 0.92rem; font-weight: 700; color: var(--ink); line-height: 1.5; margin-bottom: 0.9rem; }

.choices { display: flex; flex-direction: column; gap: 6px; }
.choice {
  display: flex; align-items: flex-start; gap: 8px;
  background: transparent; border: 1px solid #c8b070;
  border-radius: var(--rs); padding: 9px 11px;
  cursor: pointer; text-align: left; font-family: inherit;
  font-size: 0.85rem; width: 100%; color: var(--ink); transition: var(--t);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.choice:hover, .choice:active { border-color: var(--gold); background: rgba(139,105,20,0.06); }
.choice-l { font-weight: 700; color: var(--gold); min-width: 15px; line-height: 1.5; flex-shrink: 0; }
.choice.correct { border-color: var(--forest); background: rgba(45,90,61,0.12); font-weight: 500; }
.choice.wrong   { border-color: var(--rust);   background: rgba(184,74,42,0.09); opacity: 0.8; }
.choice.correct .choice-l { color: var(--forest); }
.choice.wrong   .choice-l { color: var(--rust); }

/* Icona esito a destra del testo risposta */
.choice.correct::after {
  content: '✓';
  margin-left: auto;
  font-size: 1rem;
  color: var(--forest);
  font-weight: 700;
  flex-shrink: 0;
  padding-left: 8px;
}
.choice.wrong::after {
  content: '✗';
  margin-left: auto;
  font-size: 1rem;
  color: var(--rust);
  font-weight: 700;
  flex-shrink: 0;
  padding-left: 8px;
}

/* Feedback */
.feedback {
  display: none;
  margin-top: 1rem;
  border-radius: var(--rs);
  background: #f5f0e8;
  border: 1px solid #c8b070;
  border-top: 3px solid var(--gold);
  padding: 10px 12px;
}
.feedback.vis { display: block; }
.fb-text { font-size: 0.82rem; line-height: 1.6; color: #4a3810; margin-bottom: 8px; }

/* Approfondisci */
.approfondisci-wrap { margin-bottom: 10px; }
.approfondisci-btn {
  display: flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  font-size: 0.78rem; font-weight: 700; color: var(--gold);
  font-family: inherit; padding: 0; touch-action: manipulation;
}
.approfondisci-btn .arrow { display: inline-block; transition: transform 0.2s; font-style: normal; }
.approfondisci-btn.open .arrow { transform: rotate(90deg); }
.approfondisci-content {
  display: none; margin-top: 6px;
  background: #fff8e8; border-left: 3px solid var(--gold-lt);
  border-radius: 0 var(--rs) var(--rs) 0;
  padding: 8px 10px; font-size: 0.79rem; color: #4a3810; line-height: 1.65;
}
.approfondisci-content.open { display: block; }

.fb-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; }
.tip-pill { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 100px; background: #e8d5a0; border: 1px solid var(--gold-lt); color: #5a3e10; }
.btn-next { background: var(--forest); color: #fff; font-size: 0.82rem; font-weight: 700; padding: 7px 16px; border: none; border-radius: 100px; cursor: pointer; transition: var(--t); touch-action: manipulation; min-height: 36px; }
.btn-next:hover { background: var(--forest-lt); }

/* ===== FINE LIVELLO ===== */
#s-level-end { padding: 1.75rem 1rem; text-align: center; }
.le-icon  { font-size: 2.8rem; margin-bottom: 0.4rem; display: block; }
.le-title { font-size: 1.3rem; font-weight: 700; color: var(--ink); font-family: Georgia,serif; margin-bottom: 0.35rem; }
.le-sub   { font-size: 0.84rem; color: #7a5c2a; line-height: 1.65; margin-bottom: 1rem; }
.le-score { background: var(--parch); border: 1px solid var(--gold-lt); border-radius: var(--rs); padding: 10px; margin-bottom: 1rem; font-size: 0.85rem; color: #5a3e10; }
.le-score strong { font-size: 1.2rem; color: var(--ink); }
.btn-map { background: var(--gold); color: #fff8e8; font-size: 0.92rem; font-weight: 700; padding: 10px 26px; border: none; border-radius: 100px; cursor: pointer; transition: var(--t); touch-action: manipulation; }
.btn-map:hover { background: #a07820; }
.btn-home { display: block; margin: 0.6rem auto 0; background: transparent; border: 1.5px solid var(--gold); color: var(--gold); font-size: 0.85rem; font-weight: 700; padding: 7px 22px; border-radius: 100px; cursor: pointer; transition: var(--t); touch-action: manipulation; }
.btn-home:hover { background: var(--gold); color: #fff8e8; }

/* ===== FINE GIOCO ===== */
#s-end { padding: 1.5rem 1rem; text-align: center; }
.end-chest-wrap { max-width: 140px; margin: 0 auto 0.9rem; }
.end-title { font-size: 1.4rem; font-weight: 700; color: var(--ink); font-family: Georgia,serif; margin-bottom: 0.35rem; }
.end-sub   { font-size: 0.84rem; color: #7a5c2a; line-height: 1.65; margin-bottom: 1.1rem; }
.end-grid  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 1.1rem; }
.end-card  { background: var(--parch); border: 1px solid var(--gold-lt); border-radius: var(--rs); padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.end-card.hl { border-color: var(--gold); background: #f5e8c0; }
.end-lbl { font-size: 0.67rem; text-transform: uppercase; letter-spacing: 0.07em; color: #7a5c2a; }
.end-val { font-size: 1rem; font-weight: 700; color: var(--ink); }

/* ===== CLASSIFICA ===== */
#s-classifica { padding: 0.75rem; }
.cls-title { font-size: 1.2rem; font-weight: 700; color: var(--ink); text-align: center; margin-bottom: 0.9rem; font-family: Georgia,serif; }
.cls-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.cls-table th { background: var(--gold); color: #fff; padding: 7px 8px; text-align: left; font-weight: 700; font-size: 0.78rem; }
.cls-table th:first-child { border-radius: 6px 0 0 0; }
.cls-table th:last-child  { border-radius: 0 6px 0 0; }
.cls-table td { padding: 7px 8px; border-bottom: 1px solid #e0d0a0; color: var(--ink); }
.cls-table tr:nth-child(even) td { background: #f5ecd4; }
.cls-table tr.me td { background: #fff3c0 !important; font-weight: 700; }
.cls-table tr.top1 td { background: #fff0d0; }
.cls-separator td { background: #e8d5a0 !important; text-align: center; font-size: 0.72rem; color: #7a5c2a; letter-spacing: 0.05em; padding: 3px; }
.cls-loading { text-align: center; color: #7a5c2a; padding: 1.5rem; font-size: 0.88rem; }
.btn-back { display: block; margin: 0.9rem auto 0; background: transparent; border: 1.5px solid var(--gold); color: var(--gold); font-size: 0.82rem; font-weight: 700; padding: 7px 20px; border-radius: 100px; cursor: pointer; transition: var(--t); touch-action: manipulation; }
.btn-back:hover { background: var(--gold); color: #fff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  html { font-size: 14px; }
  #s-auth { padding: 1.25rem 0.9rem; }
  .end-grid { grid-template-columns: 1fr 1fr; }
  .cls-table th, .cls-table td { padding: 6px 5px; font-size: 0.75rem; }
}
@media (min-width: 600px) {
  body { padding: 1.5rem 1rem 3rem; }
  html { font-size: 15.5px; }
}

/* ===== RIEPILOGO SEZIONI (schermata finale) ===== */
#end-sections { margin: 0.9rem 0 0; }
.sec-title {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted);
  margin-bottom: 0.5rem; text-align: center;
}
.sec-list { display: flex; flex-direction: column; gap: 5px; }
.sec-row {
  display: flex; align-items: center; gap: 7px;
  background: var(--parch); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 7px 10px;
  font-size: 0.8rem; flex-wrap: wrap;
}
.sec-row.sec-best { background: rgba(45,90,61,0.1); border-color: var(--forest); }
.sec-row.sec-worst { background: rgba(184,74,42,0.08); border-color: var(--rust); }
.sec-ico  { font-size: 1rem; flex-shrink: 0; }
.sec-lbl  { font-weight: 600; color: var(--ink); min-width: 88px; font-size: 0.78rem; }
.sec-dots { display: flex; gap: 3px; flex-shrink: 0; }
.sec-dot  { width: 7px; height: 7px; border-radius: 50%; background: #ddd0b0; flex-shrink: 0; }
.sec-dot.sec-dot-ok { background: var(--forest); }
.sec-row.sec-worst .sec-dot.sec-dot-ok { background: var(--rust); }
.sec-score { font-weight: 700; color: var(--ink); font-size: 0.78rem; min-width: 28px; }
.sec-time  { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sec-badge { font-size: 0.68rem; font-weight: 700; padding: 2px 7px; border-radius: 100px; margin-left: auto; white-space: nowrap; }
.sec-b-best  { background: rgba(45,90,61,0.15); color: var(--forest); border: 1px solid rgba(45,90,61,0.3); }
.sec-b-worst { background: rgba(184,74,42,0.12); color: var(--rust); border: 1px solid rgba(184,74,42,0.25); }

/* ===== PULSANTE CONDIVIDI ===== */
.btn-share {
  display: block; margin: 0.6rem auto 0;
  background: transparent;
  border: 1.5px solid #4a7ab5;
  color: #4a7ab5;
  font-size: 0.85rem; font-weight: 700;
  padding: 7px 22px; border-radius: 100px;
  cursor: pointer; transition: var(--t); touch-action: manipulation;
}
.btn-share:hover { background: #4a7ab5; color: #fff; }
.btn-share-auth {
  background: none; border: none; cursor: pointer;
  font-size: 0.82rem; font-weight: 500; color: #4a7ab5;
  font-family: inherit; text-decoration: underline;
  text-underline-offset: 3px; padding: 4px 0; display: block; margin: 6px auto 0;
}
.btn-share-auth:hover { color: #2d5a8a; }

/* ===== MODALE CONDIVISIONE ===== */
.share-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(26,21,16,0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.share-box {
  background: var(--parch);
  border: 2px solid var(--gold);
  border-radius: var(--r);
  padding: 1.25rem;
  max-width: 420px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.share-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.95rem; font-weight: 700; color: var(--ink);
}
.share-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--muted); padding: 2px 6px;
  border-radius: 4px; line-height: 1;
}
.share-close:hover { background: rgba(0,0,0,0.08); }
.share-preview {
  width: 100%; border-radius: var(--rs);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.share-actions {
  display: flex; gap: 8px; margin-bottom: 1rem;
}
.btn-dl, .btn-copy-lnk {
  flex: 1; padding: 8px; border-radius: var(--rs);
  font-size: 0.82rem; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: var(--t);
}
.btn-dl { background: var(--gold); color: #fff8e8; border: none; }
.btn-dl:hover { background: #a07820; }
.btn-copy-lnk { background: transparent; border: 1.5px solid var(--gold); color: var(--gold); }
.btn-copy-lnk:hover { background: var(--gold); color: #fff8e8; }
.share-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.5rem;
}
.share-networks {
  display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 0.9rem;
}
.sn {
  flex: 1; min-width: 80px; text-align: center;
  padding: 7px 6px; border-radius: var(--rs);
  font-size: 0.78rem; font-weight: 700;
  text-decoration: none; transition: var(--t); border: none;
  cursor: pointer;
}
.sn:hover { opacity: 0.85; transform: translateY(-1px); }
.sn-wa { background: #25D366; color: #fff; }
.sn-tg { background: #0088cc; color: #fff; }
.sn-tw { background: #000; color: #fff; }
.sn-fb { background: #1877F2; color: #fff; }
.sn-li { background: #0A66C2; color: #fff; }
.share-note {
  font-size: 0.75rem; color: var(--muted); text-align: center;
  line-height: 1.5; border-top: 1px dashed var(--border); padding-top: 0.7rem;
}
