/* Mirapoli — interfaccia dei pagine 3D (città e interni) */

  html:has(body.gioco), body.gioco { height: 100%; overflow: hidden; background: #BFE0F2; }
  body.gioco { position: fixed; inset: 0; overscroll-behavior: none; }
  #mondo { position: absolute; inset: 0; touch-action: none; }
  #mondo canvas { display: block; width: 100%; height: 100%; }
  #etichette { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
  .hud-top, .hud-bot, .hud-dx { z-index: 2; }
  .etic { position: absolute; left: 0; top: 0; will-change: transform; display: grid; justify-items: center; gap: 6px; }
  .etic .nome { font: 700 12px/1 var(--font-sans); color: var(--ink); background: rgba(255,255,255,.92); padding: 4px 8px; border-radius: var(--radius-pill); white-space: nowrap; box-shadow: 0 1px 0 rgba(31,42,58,.15); }
  .etic.io .nome { background: var(--mare); color: var(--on-mare); }
  .etic .fumetto { order: -1; background: #fff; color: var(--ink); font: 600 14px/1.3 var(--font-sans); padding: 8px 12px; border-radius: 16px; max-width: 200px; width: max-content; box-shadow: 0 3px 0 rgba(31,42,58,.15); position: relative; animation: pop .2s ease-out; overflow-wrap: anywhere; text-align: center; }
  .etic .fumetto::after { content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: #fff; }
  @keyframes pop { from { transform: translateY(6px) scale(.8); opacity: 0; } }

  .hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; pointer-events: none; }
  .hud-top > * { pointer-events: auto; }
  .tondo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.94); border: 0; color: var(--ink); text-decoration: none; font-weight: 800; box-shadow: 0 2px 0 rgba(31,42,58,.15); cursor: pointer; }
  .targa { background: rgba(255,255,255,.94); border-radius: var(--radius-md); padding: 6px 12px; box-shadow: 0 2px 0 rgba(31,42,58,.15); }
  .targa b { display: block; font: 800 16px/1.1 var(--font-display); }
  .targa small { font-size: 12px; color: var(--ink-muted); font-weight: 600; }
  .sp { flex: 1; }
  .stato { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink); background: rgba(255,255,255,.94); padding: 8px 12px; border-radius: var(--radius-pill); box-shadow: 0 2px 0 rgba(31,42,58,.15); white-space: nowrap; }
  .stato i { width: 8px; height: 8px; border-radius: 50%; background: var(--basilico); }
  .stato.off i { background: var(--terracotta); }

  .hud-bot { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 0 env(safe-area-inset-bottom); display: flex; flex-direction: column; pointer-events: none; }
  .hud-bot > * { pointer-events: auto; }
  @media (min-width: 900px) { .hud-bot { left: auto; width: 400px; top: 76px; right: 16px; bottom: 16px; background: rgba(255,255,255,.9); border-radius: var(--radius-lg); padding: 0; overflow: hidden; box-shadow: 0 4px 0 rgba(31,42,58,.12); } }
  .messaggi { max-height: 26vh; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; mask-image: linear-gradient(to bottom, transparent 0, #000 28px); -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px); }
  @media (min-width: 900px) { .messaggi { flex: 1; max-height: none; mask-image: none; -webkit-mask-image: none; } }
  .msg { align-self: flex-start; font-size: 14px; line-height: 19px; background: rgba(255,255,255,.92); padding: 5px 10px; border-radius: 12px; max-width: 92%; box-shadow: 0 1px 0 rgba(31,42,58,.1); }
  .msg b { font-weight: 700; margin-right: 6px; cursor: pointer; }
  .msg b.mio { color: var(--mare); }
  .msg.sistema { background: rgba(31,42,58,.55); color: #fff; font-size: 12px; font-style: italic; }
  @media (min-width: 900px) { .msg { box-shadow: none; background: var(--surface); } .msg.sistema { background: transparent; color: var(--ink-muted); } }
  .riga { display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px 0; scrollbar-width: none; }
  .riga::-webkit-scrollbar { display: none; }
  .riga button { flex: none; height: 34px; padding: 0 12px; border-radius: var(--radius-pill); border: 0; background: rgba(255,255,255,.94); font: 600 13px/1 var(--font-sans); color: var(--ink); cursor: pointer; box-shadow: 0 2px 0 rgba(31,42,58,.12); }
  .riga.emote button { background: var(--tufo); color: var(--on-tufo); font-weight: 700; }
  @media (min-width: 900px) { .riga button { box-shadow: none; border: 1px solid var(--line); } .riga.emote button { border-color: var(--tufo); } }
  form.scrivi { display: flex; gap: 8px; padding: 8px 12px 10px; }
  form.scrivi input { flex: 1; min-width: 0; height: 46px; border-radius: var(--radius-pill); border: 0; padding: 0 16px; font: 500 16px/1 var(--font-sans); background: rgba(255,255,255,.96); color: var(--ink); box-shadow: 0 2px 0 rgba(31,42,58,.15); }
  @media (min-width: 900px) { form.scrivi input { border: 1.5px solid var(--line); box-shadow: none; } }
  form.scrivi input:focus { outline: 2px solid var(--mare); }
  form.scrivi button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--mare); color: var(--on-mare); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: 0 2px 0 rgba(31,42,58,.2); }
  .hud-dx { position: absolute; right: 12px; top: calc(64px + env(safe-area-inset-top)); display: grid; gap: 8px; justify-items: end; pointer-events: none; }
  .hud-dx > * { pointer-events: auto; }
  @media (min-width: 900px) { .hud-dx { right: 432px; top: 16px; } }
  .pill { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: var(--radius-pill); border: 0; background: rgba(255,255,255,.94); color: var(--ink); font: 700 14px/1 var(--font-sans); box-shadow: 0 2px 0 rgba(31,42,58,.15); cursor: pointer; text-decoration: none; }
  .pill.lire { background: var(--tufo); color: var(--on-tufo); font-family: var(--font-display); font-weight: 800; font-size: 16px; cursor: default; }
  .pill.lavora { background: var(--mare); color: var(--on-mare); }
  .benv { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); text-align: center; color: #fff; text-shadow: 0 2px 0 rgba(31,42,58,.5), 0 0 24px rgba(31,42,58,.4); pointer-events: none; transition: opacity .6s; }
  .benv b { display: block; font: 800 clamp(34px, 9vw, 60px)/1 var(--font-display); }
  .benv span { font: 700 16px/1.4 var(--font-sans); }
  .bisogni { display: grid; gap: 4px; background: rgba(255,255,255,.94); padding: 8px 10px; border-radius: 14px; box-shadow: 0 2px 0 rgba(31,42,58,.15); width: 132px; }
  .bisogni div { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; font: 700 11px/1 var(--font-sans); }
  .bisogni i { display: block; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
  .bisogni i b { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
  .entra { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(230px + env(safe-area-inset-bottom)); z-index: 3; height: 50px; padding: 0 22px; border-radius: 99px; border: 0; background: var(--ink); color: #fff; font: 700 16px/1 var(--font-sans); box-shadow: 0 4px 0 rgba(0,0,0,.25); cursor: pointer; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; animation: pop .2s ease-out; }
  @media (min-width: 900px) { .entra { bottom: 40px; left: calc(50% - 200px); } }
  .lista-loc { display: grid; gap: 8px; }
  .lista-loc button { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font: 600 15px/1.2 var(--font-sans); color: var(--ink); cursor: pointer; text-align: left; }
  .lista-loc small { display: block; color: var(--ink-muted); font-weight: 500; font-size: 12px; }
  .mappa { position: fixed; inset: 0; z-index: 55; background: rgba(31,42,58,.6); display: grid; place-items: center; padding: 12px; }
  .mappa > div { background: var(--surface); border-radius: 24px; padding: 16px; width: 100%; max-width: 560px; display: grid; gap: 12px; max-height: 92dvh; overflow: auto; }
  .griglia-m { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .griglia-m button { aspect-ratio: 1.2; border: 0; border-radius: 12px; cursor: pointer; display: grid; place-content: center; gap: 2px; font: 800 13px/1.05 var(--font-display); color: var(--ink); padding: 4px; box-shadow: inset 0 0 0 2px rgba(31,42,58,.08); }
  .griglia-m button small { font: 600 9px/1.1 var(--font-sans); color: var(--ink-muted); }
  .griglia-m button.qui { box-shadow: inset 0 0 0 3px var(--mare); }
  .griglia-m button.casa::after { content: "casa tua"; font: 700 9px/1 var(--font-sans); color: var(--mare); }
  .mare-m { height: 34px; border-radius: 12px; background: var(--mare); color: #fff; border: 0; font: 700 13px/1 var(--font-sans); cursor: pointer; }
  .aiuto { position: absolute; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); background: rgba(31,42,58,.82); color: #fff; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-pill); pointer-events: none; transition: opacity .5s; white-space: nowrap; }

  .foglio-bg { position: fixed; inset: 0; background: rgba(31,42,58,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
  .foglio { background: var(--surface-raised); width: 100%; max-width: 440px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-6) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom)); display: grid; gap: var(--space-3); }
  @media (min-width: 600px) { .foglio-bg { align-items: center; } .foglio { border-radius: var(--radius-lg); } }
  .foglio .chi { display: flex; gap: var(--space-4); align-items: center; }
  .foglio .chi svg { width: 72px; height: auto; background: var(--mare-soft); border-radius: var(--radius-md); }
  .foglio .chi b { font: 800 22px/1.1 var(--font-display); display: block; }
  .cancello { position: fixed; inset: 0; z-index: 60; background: var(--surface); display: grid; place-items: center; padding: var(--space-6); text-align: center; }
  .cancello > div { display: grid; gap: var(--space-4); justify-items: center; max-width: 380px; }
  .carica { position: fixed; inset: 0; z-index: 40; background: var(--surface); display: grid; place-items: center; transition: opacity .4s; }
  .carica img { width: 72px; height: 72px; animation: rimb 1s ease-in-out infinite alternate; }
  @keyframes rimb { to { transform: translateY(-10px); } }

  /* ——— Chat a scomparsa: sui telefoni resta piccola per lasciare spazio al tocco ——— */
  .tondo.piccolo { width: 46px; height: 46px; flex: none; font: 700 12px/1 var(--font-sans); }
  @media (max-width: 899px) {
    .hud-bot.chiusa .riga, .hud-bot.chiusa form.scrivi input, .hud-bot.chiusa form.scrivi button[type=submit] { display: none; }
    .hud-bot.chiusa .messaggi { max-height: 64px; pointer-events: none; }
    .hud-bot.chiusa form.scrivi { padding-top: 0; }
    .hud-bot:not(.chiusa) .tondo.piccolo { background: var(--ink); color: #fff; }
    .hud-bot { pointer-events: none; }
    .hud-dx .pill { height: 36px; padding: 0 12px; font-size: 13px; }
    .hud-dx .bisogni { width: 118px; padding: 6px 8px; }
  }
  @media (min-width: 900px) { .tondo.piccolo { display: none; } }
  .msg.giallo { background: rgba(242,181,58,.95) !important; color: #1F2A3A !important; font-style: normal !important; }
  .azioni-basso { position: absolute; left: 0; right: 0; bottom: calc(132px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 0 70px 0 12px; z-index: 3; pointer-events: none; }
  .azioni-basso > * { pointer-events: auto; }
  .hud-bot:not(.chiusa) ~ .azioni-basso, body:has(.hud-bot:not(.chiusa)) .azioni-basso { bottom: calc(230px + env(safe-area-inset-bottom)); }
  @media (min-width: 900px) { .azioni-basso { bottom: 24px; right: 420px; padding: 0 12px; } body:has(.hud-bot:not(.chiusa)) .azioni-basso { bottom: 24px; } }
  .azioni-basso .pill[disabled] { opacity: .55; }
  .barra-posa { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 20; display: flex; gap: 8px; align-items: center; background: rgba(31,42,58,.88); color: #fff; padding: 8px 10px; border-radius: 99px; font-weight: 700; font-size: 14px; flex-wrap: wrap; justify-content: center; max-width: 94vw; }
  .griglia-mob { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
  .griglia-mob .btn { flex-direction: column; gap: 2px; height: auto; min-height: 52px; padding: 6px; font-size: 13px; }
  .griglia-mob small { font-weight: 600; color: var(--ink-muted); }
  .foglio { max-height: 88dvh; overflow: auto; }

  /* Menu laterale compatto sui telefoni */
  .menu-btn { display: none; }
  @media (max-width: 899px) {
    .menu-btn { display: inline-flex; }
    .hud-dx:not(.aperto) .sec { display: none; }
    .hud-dx.aperto .menu-btn { background: var(--ink); color: #fff; }
  }

/* ——— Notifiche (citofono, multe, Comune) ——— */
.toasts { position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; width: min(420px, 94vw); pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; border-radius: 18px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: pop .2s ease-out; font: 600 15px/1.3 var(--font-sans); }
.toast b { color: var(--tufo); }
.toast .sp { flex: 1; }
.toast a, .toast button { flex: none; background: #fff; color: var(--ink); border: 0; border-radius: 99px; padding: 8px 14px; font: 700 14px/1 var(--font-sans); text-decoration: none; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; }
.toast.multa { background: var(--terracotta); }
.toast.multa b { color: #fff; }
.citofono-lista { display: grid; gap: 8px; }
.citofono-lista > div { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line, rgba(31,42,58,.12)); border-radius: 16px; padding: 10px 12px; }
.citofono-lista .n { width: 34px; height: 34px; flex: none; border-radius: 10px; background: #D4A73A; color: var(--ink); display: grid; place-items: center; font: 800 16px/1 var(--font-display); }
.citofono-lista .t { flex: 1; min-width: 0; }
.citofono-lista .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citofono-lista .t small { color: var(--muted, #667); font-size: 13px; }
.citofono-lista .btn { min-height: 44px; padding: 0 14px; }
/* ——— Guida ——— */
.guida { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 4; display: flex; gap: 8px; align-items: center; background: rgba(31,42,58,.85); color: #fff; padding: 8px; border-radius: 99px; }
.guida button { height: 46px; min-width: 46px; padding: 0 14px; border-radius: 99px; border: 0; font: 700 14px/1 var(--font-sans); background: #fff; color: var(--ink); cursor: pointer; }
.guida button.on { background: var(--tufo); }
.guida .tachi { font: 800 20px/1 var(--font-display); min-width: 74px; text-align: center; }
.guida .tachi small { display: block; font: 600 11px/1 var(--font-sans); opacity: .7; }
@media (min-width: 900px) { .guida { bottom: 100px; } }
.etic .divisa { display: inline-block; margin-left: 4px; font-size: 10px; padding: 2px 6px; border-radius: 99px; background: var(--mare); color: #fff; vertical-align: middle; }
.etic .divisa.sindaco { background: var(--basilico); }
.etic .divisa.admin { background: var(--terracotta); }
.semaforo-avviso { position: fixed; inset: 0; z-index: 60; pointer-events: none; background: #fff; opacity: 0; transition: opacity .5s; }
/* ——— Pad di guida ——— */
.pad { position: absolute; left: 0; right: 0; bottom: calc(210px + env(safe-area-inset-bottom)); z-index: 4; display: flex; justify-content: space-between; padding: 0 12px; pointer-events: none; }
.pad > div { display: flex; gap: 10px; pointer-events: auto; }
.pad .pedali { flex-direction: column; }
.pad button { width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(255,255,255,.88); color: var(--ink); font-size: 22px; box-shadow: 0 4px 0 rgba(0,0,0,.25); touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.pad button.gas { background: var(--basilico); color: #fff; }
.pad button.on { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); filter: brightness(.9); }
@media (hover: hover) and (pointer: fine) { .pad { display: none !important; } } /* col mouse si guida con le frecce */
a.entra { display: inline-flex; align-items: center; text-decoration: none; }
/* ——— Livelli ——— */
.livello-su { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 80; background: var(--tufo); color: var(--ink); border-radius: 28px; padding: 18px 28px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.3); animation: livelloSu 3.8s ease-out forwards; pointer-events: none; }
.livello-su small { display: block; font: 700 14px/1 var(--font-sans); text-transform: uppercase; letter-spacing: .1em; }
.livello-su b { display: block; font: 800 72px/1 var(--font-display); }
.livello-su span { font: 600 15px/1.2 var(--font-sans); }
@keyframes livelloSu { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 20% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%); } }
.toast.premio { background: var(--basilico, #2E7D52); }
.toast.premio b { color: #fff; }
.lv { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px 0 6px; border-radius: 99px; background: rgba(255,255,255,.92); color: var(--ink); font: 800 15px/1 var(--font-display); text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.lv i { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--mare); color: #fff; font-style: normal; font-size: 13px; }
.lv .barretta { width: 46px; height: 6px; border-radius: 9px; background: rgba(31,42,58,.12); overflow: hidden; }
.lv .barretta span { display: block; height: 100%; background: var(--tufo); }
.etic .lvl { font-size: 10px; opacity: .8; margin-left: 4px; }
.tappa-hud { position: absolute; top: calc(120px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 5; background: var(--ink); color: #fff; border-radius: 99px; padding: 10px 18px; font: 700 15px/1 var(--font-sans); }

/* ——— Pulsanti del gioco: targhe smaltate (come il sito) ——— */
.pill { height: 44px; padding: 0 16px; border-radius: 6px; background: #fff; color: var(--mare); font: 700 18px/1 var(--font-display);
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px var(--mare), 0 2px 0 rgba(28,34,48,.3); }
.pill:active { transform: translateY(1px); box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px var(--mare), 0 1px 0 rgba(28,34,48,.3); }
.pill.sec { background: #fff; color: var(--mare); }
.pill { white-space: nowrap; }
.pill.lavora { background: var(--mare); color: #fff; box-shadow: inset 0 0 0 4px var(--mare), inset 0 0 0 6px #fff, 0 2px 0 #0E1F4D; }
.pill.lire { background: var(--tufo); color: var(--ink); font-size: 19px; box-shadow: inset 0 0 0 3px var(--tufo), inset 0 0 0 5px var(--ink), 0 2px 0 #7A5F0F; }
.tondo { width: 44px; height: 44px; border-radius: 6px; background: #fff; color: var(--mare); font: 800 20px/1 var(--font-display); box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px var(--mare), 0 2px 0 rgba(28,34,48,.3); }
.entra, #entra { border-radius: 6px !important; background: var(--tufo) !important; color: var(--ink) !important; font: 800 20px/1 var(--font-display) !important; box-shadow: inset 0 0 0 4px var(--tufo), inset 0 0 0 6px var(--ink), 0 3px 0 #7A5F0F !important; }
