[hidden] { display: none !important; }
:root { --ink: #5b4636; --cream: #fffaf0; --cream2: #fbefd5; --line: #e2c88f; --green: #7bc67b; --greend: #5aa65a; --yellow: #ffd166; --yellowd: #e8b04a; --pink: #ff9ebb; --sky: #cfeaf2; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Trebuchet MS", "Varela Round", "Segoe UI", system-ui, sans-serif; background: var(--sky); color: var(--ink); overscroll-behavior: none; }
button, input, select { font: inherit; }
button { position: relative; background: var(--cream2); color: var(--ink); border: 2px solid var(--line); border-radius: 14px; padding: 7px 13px; cursor: pointer; font-weight: 700; box-shadow: 0 3px 0 var(--line); transition: transform .06s, box-shadow .06s, filter .15s; }
button:hover { filter: brightness(1.04); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--green); border-color: var(--greend); color: #fff; box-shadow: 0 3px 0 #4a8f4a; text-shadow: 0 1px 0 rgba(0,0,0,.18); }
button.primary:active { box-shadow: 0 1px 0 #4a8f4a; }
button.gold { background: var(--yellow); border-color: var(--yellowd); color: #6a4300; box-shadow: 0 3px 0 #c9922e; }
button.small { padding: 3px 10px; font-size: 12px; border-radius: 10px; }
button.sel, button.on { background: var(--yellow); border-color: var(--yellowd); box-shadow: 0 3px 0 #c9922e; }
.tabs button.sel { background: var(--green); border-color: var(--greend); color: #fff; box-shadow: 0 3px 0 #4a8f4a; }
input, select { background: #fff; color: var(--ink); border: 2px solid var(--line); border-radius: 14px; padding: 9px 12px; width: 100%; outline: none; }
input:focus, select:focus { border-color: var(--green); }
::placeholder { color: #b7a589; }

.overlay { position: fixed; inset: 0; background: rgba(130,110,75,.45); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 12px; }
#auth { background: #6ec6f0; backdrop-filter: none; overflow: hidden; }
#bgCanvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; z-index: 0; }
#authForm { position: relative; z-index: 1; background: rgba(255,250,236,.93); backdrop-filter: blur(3px); animation: cardIn .6s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(.96); } }
#authForm h1 { text-shadow: 0 2px 0 #fff, 0 4px 0 rgba(150,120,70,.25); }
.logo { display: inline-block; animation: bob 2.6s ease-in-out infinite; } @keyframes bob { 50% { transform: translateY(-5px) rotate(-6deg); } }
.pw { position: relative; } .pw input { padding-right: 44px; } .eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; box-shadow: none; padding: 4px 8px; font-size: 17px; opacity: .6; cursor: pointer; } .eye:hover { opacity: 1; }
.remember { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; cursor: pointer; user-select: none; color: #6b5a48; }
.remember input { width: 19px; height: 19px; accent-color: #5cb85c; margin: 0; cursor: pointer; }
.card { background: var(--cream); border: 3px solid var(--line); border-radius: 24px; padding: 22px; width: min(390px, 100%); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 18px 50px rgba(90,70,40,.35), inset 0 0 0 4px var(--cream), inset 0 0 0 6px #efdcae; }
.card.wide { width: min(700px, 100%); max-height: 90vh; overflow: auto; }
.card.wide:has(.creator) { width: min(900px, 100%); }
.card h1, .card h2 { margin: 0; } .card h1 { font-size: 30px; text-align: center; }
.sub { margin: 0 0 6px; opacity: .75; }
.err { color: #d4524f; min-height: 1.2em; font-size: 14px; font-weight: 700; }
.row { display: flex; gap: 8px; } .row button { flex: 1; }
.mhead { display: flex; justify-content: space-between; align-items: center; }

#app { display: flex; flex-direction: column; height: 100%; }
#app[hidden] { display: none; }
#hud { display: flex; align-items: center; gap: 14px; padding: 7px 12px; background: linear-gradient(#fffaf0, #fbefd5); border-bottom: 3px solid #cfe9b8; flex-wrap: wrap; z-index: 20; box-shadow: 0 3px 10px rgba(90,70,40,.15); }
.who { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.who canvas { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--green); background: #d9f1ff; }
.coins { font-weight: 700; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.rname { flex: 1; text-align: center; min-width: 120px; } #roomName { font-weight: 800; font-size: 17px; } .rname small { opacity: .65; }
#hud nav { display: flex; gap: 7px; flex-wrap: wrap; }

main { position: relative; flex: 1; min-height: 0; background: var(--sky); overflow: hidden; }
main::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 62%, rgba(90,70,40,.22)); }
#view { width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
#editBar { position: absolute; top: 10px; left: 0; right: 0; margin: 0 auto; width: fit-content; background: var(--cream); border: 3px solid var(--yellowd); padding: 8px 12px; border-radius: 16px; display: flex; align-items: center; gap: 10px; font-size: 14px; z-index: 3; flex-wrap: wrap; justify-content: center; max-width: 94%; font-weight: 700; }
#zoomBox { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
#zoomBox button { width: 36px; height: 36px; padding: 0; }

#chatlog { position: absolute; left: 10px; bottom: 8px; width: min(470px, 72%); max-height: 150px; overflow-y: auto; font-size: 14px; z-index: 3; mask-image: linear-gradient(transparent, #000 25%); scrollbar-width: none; pointer-events: none; font-weight: 600; }
#chatlog div { padding: 3px 11px; margin-top: 3px; background: rgba(255,250,240,.9); border: 2px solid #ecd9ad; border-radius: 14px; width: fit-content; max-width: 100%; word-wrap: break-word; }
#chatlog b { color: var(--nc, #3a7a9a); } #chatlog .sys { color: #b8761a; font-style: italic; }
#bottom { display: flex; gap: 8px; padding: 8px 12px; background: linear-gradient(#fbefd5, #fffaf0); border-top: 3px solid #cfe9b8; align-items: center; }
#btnEmote { font-size: 22px; line-height: 1.1; padding: 5px 12px; }
.dd { position: relative; }
.pop { position: absolute; z-index: 30; background: var(--cream); border: 3px solid var(--line); border-radius: 18px; padding: 10px; box-shadow: 0 12px 30px rgba(90,70,40,.35); }
.pop.right { right: 0; top: calc(100% + 8px); min-width: 210px; }
.pop.left { left: 0; bottom: calc(100% + 10px); display: flex; gap: 6px; }
.pop[hidden] { display: none; }
.grp { display: grid; gap: 4px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 2px dashed #ecd9ad; } .grp:last-child { border: 0; margin: 0; padding: 0; }
.grp h4 { margin: 0 0 2px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; }
.pop.right button { text-align: left; width: 100%; box-shadow: none; border-color: transparent; background: transparent; padding: 8px 10px; }
.pop.right button:hover { background: #fff2cf; border-color: var(--line); filter: none; }
.pop.right button.on { background: var(--yellow); }
.pop.left button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 10px; } .pop.left b { font-size: 26px; font-weight: 400; line-height: 1.1; } .pop.left small { font-size: 11px; }
#chatForm { flex: 1; display: flex; gap: 6px; }

.tabs { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; }
.tile { background: #fff; border: 2px solid #ecd9ad; border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.tile canvas { background: linear-gradient(#dff4ff, #d2f0d0); border-radius: 12px; width: 100%; height: 100px; }
.tile small { opacity: .7; } .tile .btns { display: flex; gap: 6px; flex-wrap: wrap; }
.roomrow { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 2px solid #ecd9ad; border-radius: 16px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; transition: transform .1s; }
.roomrow:hover { transform: translateX(3px); border-color: var(--green); } .roomrow.mine { border-color: var(--yellowd); background: #fff8e0; }
.form { display: grid; gap: 10px; } .form label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=color] { width: 64px; padding: 2px; height: 36px; cursor: pointer; }
.sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.pcard { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pcard canvas { background: linear-gradient(#dff4ff, #cfeecb); border-radius: 18px; }
.pcard .tag { font-size: 13px; background: #fff2cf; border: 2px solid var(--line); border-radius: 12px; padding: 3px 10px; font-weight: 700; }

/* --- creatore di personaggi --- */
.creator { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.cleft { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.cprev { width: 100%; max-width: 300px; aspect-ratio: 360 / 430; background: linear-gradient(#cfeeff 0%, #e6f7e2 70%, #c9ecb8 100%); border-radius: 22px; border: 3px solid #ecd9ad; }
.cpanel { background: #fff; border: 2px solid #ecd9ad; border-radius: 18px; padding: 12px; min-height: 290px; display: flex; flex-direction: column; gap: 12px; }
.cgroup { display: grid; gap: 6px; } .clabel { font-weight: 800; font-size: 13px; opacity: .8; }
.choices { display: flex; gap: 7px; flex-wrap: wrap; } .choices button { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.spgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; } .spbtn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; font-size: 13px; }
.sw { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.swb { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line), 0 2px 0 var(--line); }
.swb.sel { box-shadow: 0 0 0 3px var(--ink), 0 2px 0 var(--ink); background-clip: padding-box; }
.crow { display: flex !important; align-items: center; gap: 6px; }
.crow input[type=color] { width: 44px; height: 32px; }

/* --- amici / notifiche --- */
.badge { position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #ff5d73; color: #fff; font: 800 11px/16px "Trebuchet MS", system-ui; font-style: normal; text-align: center; border: 2px solid #fff; }
.frow { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid #ecd9ad; border-radius: 16px; padding: 10px; margin-bottom: 8px; }
.frow canvas { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); }
.frow.best { border-color: var(--yellowd); background: #fff8e0; }
.fname { font-weight: 800; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c9bda6; display: inline-block; } .dot.on { background: #43c96a; box-shadow: 0 0 0 3px rgba(67,201,106,.25); }
.lvl { font-size: 11px; font-weight: 800; background: #fff2cf; border: 1.5px solid var(--line); border-radius: 10px; padding: 1px 8px; }
.bar { height: 9px; background: #f1e6cc; border-radius: 5px; overflow: hidden; margin: 5px 0 3px; } .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff9ebb, #ffc15a); border-radius: 5px; transition: width .4s; }
.fmeta { font-size: 12px; opacity: .75; }
.facts { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; } .facts button { padding: 4px 9px; font-size: 14px; }
.info { background: #f1fbe8; border: 2px dashed #b9dca0; border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin-bottom: 10px; }
.dmlist { height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 10px; background: #fff; border: 2px solid #ecd9ad; border-radius: 16px; }
.dmmsg { max-width: 78%; padding: 7px 12px; border-radius: 16px; word-wrap: break-word; font-size: 14px; background: #e8f4ff; align-self: flex-start; border: 2px solid #cfe5f7; }
.dmmsg.mine { align-self: flex-end; background: #dff5d6; border-color: #b9dca0; } .dmmsg small { display: block; opacity: .55; font-size: 10px; margin-top: 2px; }
.nrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 2px solid #ecd9ad; border-radius: 16px; padding: 10px 12px; margin-bottom: 8px; font-weight: 600; }
.nrow.unread { border-color: var(--green); background: #f1fbe8; } .nrow small { opacity: .6; display: block; margin-top: 2px; font-weight: 500; }

#toast { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); background: var(--cream); color: var(--ink); border: 3px solid var(--line); font-weight: 700; padding: 9px 18px; border-radius: 18px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 20; max-width: 90%; text-align: center; box-shadow: 0 6px 20px rgba(90,70,40,.3); }
#toast.show { opacity: 1; }
@media (max-width: 760px) {
  #hud nav > button span, #btnMenu span { display: none; } .rname { order: 3; flex-basis: 100%; }
  .creator { grid-template-columns: 1fr; } .cprev { max-width: 240px; } #emotes button { padding: 3px 6px; } .spgrid { grid-template-columns: repeat(4, 1fr); }
}


#blockScreen{position:fixed;inset:0;z-index:999;background:linear-gradient(#bfe6ff,#fdf0d5);display:flex;align-items:center;justify-content:center;padding:20px}
#blockScreen[hidden]{display:none}
.blockbox{background:#fffaf0;border:3px solid #e2cfa5;border-radius:24px;padding:28px 32px;max-width:420px;text-align:center;box-shadow:0 10px 30px rgba(0,0,0,.15);display:grid;gap:8px}
.blockbox .bigemoji{font-size:56px}.blockbox h2{margin:0;color:#5b4636}.blockbox p{margin:0;color:#6b5a48}.blockbox .eta{font-weight:700}
#annBar{position:fixed;top:-60px;left:50%;transform:translateX(-50%);background:#ffe9a8;border:2px solid #e8a838;color:#5b4636;font-weight:700;padding:8px 20px;border-radius:0 0 16px 16px;z-index:200;transition:top .35s;max-width:90%;text-align:center}
#annBar.show{top:0}
.btnlink{display:block;text-decoration:none;color:inherit;padding:8px 12px;border-radius:10px;text-align:left}.btnlink:hover{background:rgba(0,0,0,.06)}

#shiftBar { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 15; background: var(--cream); border: 3px solid var(--line); border-radius: 16px; padding: 6px 14px; font-weight: 800; text-align: center; min-width: 220px; box-shadow: 0 4px 14px rgba(90,70,40,.3); }
#shiftBar .sbar { height: 10px; background: #e7d9bd; border-radius: 6px; margin-top: 4px; overflow: hidden; }
#shiftFill { height: 100%; width: 0; background: linear-gradient(90deg, #7bc67b, #ffd166); transition: width .5s linear; }
.jobbox p { margin: 6px 0; } .jobbox button { margin-top: 10px; width: 100%; }

.choices .lock, .lock { color: #b5651d; font-weight: 800; font-size: 11px; }
.cart { margin: 8px 0; text-align: center; } .chip { display: inline-block; background: #fff1c9; border: 2px solid var(--line); border-radius: 12px; padding: 2px 8px; margin: 2px; font-size: 12px; font-weight: 700; }
.bank { text-align: center; display: grid; gap: 8px; } .bbal { background: #fff1c9; border: 3px solid var(--line); border-radius: 16px; padding: 10px; } .bbal b { display: block; font-size: 30px; }
.bamt { width: 120px; padding: 6px; border-radius: 10px; border: 2px solid var(--line); font-weight: 700; text-align: center; }

.npcsay { font-weight: 700; font-style: italic; margin: 8px 4px; min-height: 40px; }
/* palazzi: elenco appartamenti */
.apts { max-height: 62vh; overflow: auto; min-width: min(520px, 86vw); }
.aptfloor { margin: 8px 0; border-left: 3px solid #c9b8e6; padding-left: 8px; }
.aflabel { font-size: 12px; font-weight: 800; color: #7a6a9a; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
.aptrow { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 10px; background: #f6f3fb; margin-bottom: 4px; font-size: 14px; }
.aptrow.sale { background: #eaf7ec; } .aptrow.npc { background: #f3efe6; color: #6b6150; }
.aptrow .asz { color: #5b5470; } .aptrow .apr { font-weight: 700; white-space: nowrap; }
/* ascensore */
.lift { min-width: min(360px, 84vw); max-height: 66vh; overflow: auto; }
.liftgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.liftbtn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 12px; background: #f1ecfa; border: 2px solid #d6c9ee; cursor: pointer; font: inherit; color: #3d3350; }
.liftbtn small { font-size: 11px; color: #3c8a4a; font-weight: 700; } .liftbtn.here { background: #ffe9a8; border-color: #e2b84a; cursor: default; }
.liftbtn.terr { grid-column: 1 / -1; background: linear-gradient(#ffd9c0, #bfe3ff); border-color: #8fb8dd; }
.liftbtn:not(.here):hover { background: #e4dbf5; }
.apts select { width: auto; flex: 1 1 30%; min-width: 0; }

.citi { display: grid; gap: 8px; max-width: 640px; } .cstat { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; } .cstat div { background: #fff1c9; border: 2px solid var(--line); border-radius: 12px; padding: 5px 2px; } .cstat b { display: block; font-size: 15px; } .cstat small { font-size: 10px; }
.ctabs { justify-content: center; } .clist { display: grid; gap: 6px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.crow2 { display: flex; gap: 8px; align-items: center; background: #fffaf0; border: 2px solid var(--line); border-radius: 14px; padding: 5px 8px; }
.cthumb { width: 48px; height: 48px; flex: none; background: #e8f4ff; border-radius: 12px; } .cinfo { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; } .cinfo small { font-size: 11px; opacity: .8; }
.ctitle { font-size: 12px; color: #7a5a2a; } .cbar { height: 6px; background: #ead9b8; border-radius: 6px; overflow: hidden; } .cbar i { display: block; height: 100%; background: linear-gradient(90deg, #7bc67b, #f1c40f); }
.cmoney { display: grid; gap: 3px; justify-items: end; font-size: 13px; }
.clog { display: grid; gap: 4px; max-height: 52vh; overflow: auto; } .clrow { display: flex; gap: 8px; align-items: baseline; background: #fffaf0; border-radius: 10px; padding: 5px 8px; border: 1px solid #e8d7b5; } .clrow small { flex: none; width: 58px; opacity: .6; }
@media (max-width: 520px) { .cstat { grid-template-columns: repeat(3, 1fr); } }
.crow2.dead { filter: grayscale(.6); opacity: .85; }

/* ===== v126: ogni browser e ogni telefono ===== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; } @supports (height: 100dvh) { html, body { height: 100dvh; } }
body { position: fixed; inset: 0; width: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }
#view { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; outline: none; }
#hud, #bottom, #zoomBox, #editBar, #shiftBar { -webkit-user-select: none; user-select: none; }
.overlay { -webkit-backdrop-filter: blur(4px); }
#hud { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); padding-top: max(7px, env(safe-area-inset-top)); }
#bottom { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
#zoomBox { right: max(10px, env(safe-area-inset-right)); }
.card, .card.wide { max-width: 100%; }
.card.wide, #mBody { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
img, canvas { max-width: 100%; }
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }      /* sotto i 16px iOS ingrandisce la pagina quando si scrive */
  button { min-height: 40px; } button.small { min-height: 34px; padding: 5px 12px; }
  #zoomBox button { width: 46px; height: 46px; font-size: 20px; }
  #hud nav > button, #btnMenu { min-width: 44px; }
  .pop button, .grp button, .btnlink { min-height: 44px; }
}
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: 0; }
  .overlay > .card, .overlay > .card.wide { width: 100%; max-height: 90dvh; max-height: 90vh; border-radius: 22px 22px 0 0; overflow: auto; margin: 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  #auth.overlay { align-items: center; padding: 12px; } #auth.overlay > .card { width: 100%; max-width: 420px; border-radius: 22px; max-height: 96dvh; }
  #hud { gap: 8px; } #hudName { font-size: 14px; } .rname { text-align: center; } #roomName { font-size: 15px; }
  #chatlog { max-width: 88vw; font-size: 13px; }
  .apts, .lift { min-width: 0; max-height: 60dvh; } .liftgrid { grid-template-columns: 1fr 1fr; }
  .aptrow { grid-template-columns: 38px 1fr auto; } .aptrow .apr { grid-column: 1 / -1; }
  .list, .nrow { min-width: 0; } .nrow { flex-wrap: wrap; }
  .pop { max-width: 92vw; } #menuPanel { max-height: 70dvh; overflow: auto; }
  #toast { max-width: 90vw; text-align: center; bottom: calc(100px + env(safe-area-inset-bottom)); }
  table { display: block; overflow-x: auto; }
}
@media (max-height: 480px) and (orientation: landscape) {
  #hud { padding-top: max(3px, env(safe-area-inset-top)); padding-bottom: 3px; gap: 8px; flex-wrap: nowrap; } .rname { order: 0; flex-basis: auto; } .rname small { display: none; }
  #bottom { padding-top: 4px; padding-bottom: max(4px, env(safe-area-inset-bottom)); } #shiftBar { top: 52px; } .overlay > .card { max-height: 96dvh; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- Finestre proporzionate allo schermo (v127) ---- */
:root { --ui: 1; }
.overlay { overflow: auto; overscroll-behavior: contain; }
.overlay > .card, .overlay > .card.wide { max-height: calc((100vh - 24px) / var(--ui)); max-height: calc((100dvh - 24px) / var(--ui)); overflow: auto; }
@media (min-width: 601px) { .overlay > .card { zoom: var(--ui); } }          /* su schermi piccoli (13" e meno) le finestre si riducono in proporzione */
@media (max-width: 600px) { .overlay > .card, .overlay > .card.wide { max-height: 92dvh; } }
@media (max-height: 760px) { .card { padding: 16px; gap: 8px; } .card h1 { font-size: 24px; } .dmlist { height: 38vh; } .cpanel { min-height: 0; } .apts, .clist, .clog, .lift { max-height: 46vh; } }
@media (max-height: 560px) { .card { padding: 12px; gap: 6px; } .apts, .clist, .clog, .lift { max-height: 38vh; } }

/* ---- Menu a finestra (v127) ---- */
#menuBack { position: fixed; inset: 0; background: rgba(90,70,40,.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 28; } #menuBack[hidden] { display: none; }
#menuPanel.menuwin { position: fixed; z-index: 30; left: 50%; top: 168px; right: auto; bottom: auto; transform: translateX(-50%); width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 180px); max-height: calc(100dvh - 180px); overflow: auto; padding: 14px 16px 12px; border-radius: 24px; min-width: 0; zoom: var(--ui); }
#menuPanel.menuwin .menuhead { display: flex; align-items: center; justify-content: space-between; font-size: 20px; margin-bottom: 8px; position: sticky; top: -14px; background: var(--cream); padding: 2px 0 6px; z-index: 1; }
#menuPanel.menuwin .grp { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding-bottom: 12px; margin-bottom: 12px; }
#menuPanel.menuwin .grp h4 { grid-column: 1 / -1; margin: 0 0 0 2px; font-size: 12px; }
#menuPanel.menuwin button, #menuPanel.menuwin .btnlink { text-align: center; min-height: 46px; background: #fff; border: 2px solid #ecd9ad; border-radius: 14px; box-shadow: 0 2px 0 #ecd9ad; padding: 10px 8px; font-size: 15px; display: flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
#menuPanel.menuwin .menuhead button { min-height: 0; width: 34px; height: 34px; padding: 0; border-radius: 50%; }
#menuPanel.menuwin button:hover, #menuPanel.menuwin .btnlink:hover { background: #fff2cf; border-color: var(--line); }
#menuPanel.menuwin button:active { transform: translateY(1px); box-shadow: none; }
#menuPanel.menuwin[hidden] { display: none; }
@media (max-width: 600px) { #menuPanel.menuwin { zoom: 1; top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 88dvh; border-radius: 22px 22px 0 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); } #menuPanel.menuwin .grp { grid-template-columns: 1fr 1fr; } }

/* ---- Joystick virtuale (v127) ---- */
#joy { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(86px + env(safe-area-inset-bottom)); width: 124px; height: 124px; border-radius: 50%; background: rgba(255,248,231,.55); border: 3px solid rgba(207,170,110,.85); box-shadow: 0 6px 18px rgba(90,70,40,.25), inset 0 0 0 6px rgba(255,255,255,.35); z-index: 6; touch-action: none; user-select: none; -webkit-user-select: none; display: grid; place-items: center; backdrop-filter: blur(2px); }
#joy[hidden] { display: none; }
#joy .joyknob { width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6dc, #f1c46a); border: 3px solid #cfa24a; box-shadow: 0 3px 8px rgba(90,70,40,.35); pointer-events: none; transition: transform .06s linear; }
body:has(.overlay:not([hidden])) #joy, body:has(#menuPanel:not([hidden])) #joy { display: none; }
@media (max-height: 480px) and (orientation: landscape) { #joy { width: 100px; height: 100px; bottom: calc(60px + env(safe-area-inset-bottom)); } #joy .joyknob { width: 44px; height: 44px; } }

/* ---- Smartphone in orizzontale e tablet (v127) ---- */
html { background: #fbefd5; }
@media (max-height: 520px) and (orientation: landscape) {
  #hud { padding-top: max(2px, env(safe-area-inset-top)); padding-bottom: 2px; gap: 8px; }
  #hud .who canvas { width: 30px; height: 30px; border-width: 2px; } #hudName { font-size: 13px; } .coins { font-size: 12px; gap: 4px; }
  #hud button, #hud nav > button, #btnMenu { min-height: 34px; padding: 2px 10px; font-size: 14px; } #btnBonus { min-height: 28px; padding: 1px 8px; font-size: 12px; }
  #roomName { font-size: 14px; } .rname { min-width: 0; }
  #bottom { padding-top: 3px; padding-bottom: max(3px, env(safe-area-inset-bottom)); gap: 6px; }
  #bottom button { min-height: 34px; padding: 2px 12px; } #btnEmote { font-size: 20px; padding: 2px 10px; } #chatInput { height: 34px; padding-top: 0; padding-bottom: 0; }
  #zoomBox { right: auto; left: max(10px, env(safe-area-inset-left)); top: 8px; gap: 5px; } #zoomBox button { width: 38px; height: 38px; font-size: 18px; min-height: 0; }
  #chatlog { left: max(10px, env(safe-area-inset-left)); width: min(44vw, 420px); max-height: 70px; font-size: 12px; } #chatlog div { padding: 1px 9px; margin-top: 2px; }
  #joy { width: 96px; height: 96px; right: max(14px, env(safe-area-inset-right)); bottom: calc(52px + env(safe-area-inset-bottom)); } #joy .joyknob { width: 42px; height: 42px; }
  #toast { bottom: calc(56px + env(safe-area-inset-bottom)); }
}
/* tablet: tasti e finestre comodi da toccare */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 600px) {
  #zoomBox button { width: 50px; height: 50px; font-size: 22px; } #joy { width: 140px; height: 140px; } #joy .joyknob { width: 60px; height: 60px; }
  #chatlog { font-size: 15px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #menuPanel.menuwin { padding: 10px 14px 8px; } #menuPanel.menuwin .menuhead { font-size: 17px; margin-bottom: 2px; top: -10px; }
  #menuPanel.menuwin .grp { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; padding-bottom: 8px; margin-bottom: 8px; }
  #menuPanel.menuwin button, #menuPanel.menuwin .btnlink { min-height: 38px; padding: 4px 6px; font-size: 14px; }
  #menuPanel.menuwin .menuhead button { width: 32px; height: 32px; min-height: 0; }
}

/* Area ai lati del notch: stesso colore della barra (non il celeste del cielo) su html e body */
html, body { background: #fbefd5 !important; background-color: #fbefd5 !important; }
#app { background: #fbefd5; }

/* Se il browser tiene già il notch fuori dalla pagina, niente margine di sicurezza doppio ai lati */
html.noext #hud, html.noext #bottom { padding-left: 12px; padding-right: 12px; }
html.noext #zoomBox { right: 10px; } html.noext #joy { right: 14px; }
@media (max-height: 520px) and (orientation: landscape) { html.noext #zoomBox { left: 10px; right: auto; } html.noext #chatlog { left: 10px; } }

/* ---- Scorciatoie da tastiera (v127) ---- */
kbd { font: 700 11px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: #fff; color: #7a5a2a; border: 1px solid #d9c7a1; border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; min-width: 18px; text-align: center; display: inline-block; }
#menuPanel.menuwin button { position: relative; }
#menuPanel.menuwin button kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); opacity: .75; }
.keygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; margin: 8px 0; } .keyrow { display: flex; align-items: center; gap: 10px; } .keyrow kbd { min-width: 54px; font-size: 12px; padding: 5px 7px; }
@media (hover: none) { #menuPanel.menuwin button kbd { display: none; } }
#menuPanel.menuwin button:has(kbd) { padding-left: 30px; padding-right: 30px; }

/* ---- Finestre di arredo (catalogo, inventario, aspetto stanza, riquadro mobile) nel nostro stile crema ---- */
.hwin, #hinfo { position: fixed; z-index: 40; background: var(--cream); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 14px 38px rgba(90,70,40,.32), inset 0 0 0 4px var(--cream), inset 0 0 0 6px #efdcae; font-size: 14px; color: var(--ink); max-width: calc(100vw - 16px); display: flex; flex-direction: column; overflow: hidden; }
.hwin { max-height: calc(100dvh - 150px); }
.hbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 4px 18px; cursor: grab; user-select: none; touch-action: none; }
.htitle { font-weight: 800; font-size: 19px; color: var(--ink); }
.hx { all: unset; box-sizing: border-box; width: 30px; height: 30px; display: grid; place-items: center; background: #fff; border: 2px solid var(--line); border-radius: 50%; color: var(--ink); font-weight: 900; font-size: 13px; cursor: pointer; box-shadow: 0 2px 0 var(--line); }
.hx:hover { background: #ffe9e4; border-color: #e8a090; }
.hbody { padding: 6px 16px 16px; overflow: auto; min-height: 0; }
.hcat { display: flex; gap: 10px; min-height: 280px; } .hcat.inv { min-height: 300px; }
.hnav { display: flex; flex-direction: column; gap: 4px; width: 128px; flex: none; }
.hnavb { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; cursor: pointer; font-weight: 700; color: var(--ink); border: 2px solid transparent; }
.hnavb:hover { background: var(--cream2); } .hnavb.sel { background: var(--green); border-color: var(--greend); color: #fff; box-shadow: 0 3px 0 #4a8f4a; text-shadow: 0 1px 0 rgba(0,0,0,.18); }
.hmain { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hgrid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); grid-auto-rows: 66px; gap: 8px; align-content: start; background: var(--cream2); border: 2px solid #efdcae; border-radius: 16px; padding: 8px; overflow: auto; min-height: 120px; max-height: 250px; }
.hcell { all: unset; box-sizing: border-box; position: relative; height: 66px; background: #fff; border: 2px solid #ecd9ad; border-radius: 14px; cursor: pointer; display: grid; place-items: center; overflow: hidden; }
.hcell:hover { border-color: var(--yellowd); } .hcell.sel { border-color: var(--yellowd); background: #fff6d8; box-shadow: 0 0 0 3px rgba(255,209,102,.5); }
.hcell canvas { width: 100%; height: 100%; object-fit: contain; background: none; border-radius: 0; }
.hprice, .hcount { position: absolute; right: 4px; bottom: 3px; font-size: 11px; font-weight: 800; border-radius: 10px; padding: 0 6px; }
.hprice { color: #6a4300; background: var(--yellow); } .hcount { color: #fff; background: var(--greend); }
.hempty { grid-column: 1 / -1; text-align: center; opacity: .6; padding: 24px 8px; }
.hdetail { background: #fff; border: 2px solid #ecd9ad; border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 7px; align-items: stretch; }
.hprev { background: linear-gradient(#dff4ff, #d2f0d0); border-radius: 12px; display: grid; place-items: center; height: 118px; overflow: hidden; } .hprev.sm { height: 64px; width: 100px; flex: none; }
.hprev canvas { height: 118px !important; width: auto !important; max-width: 100%; object-fit: contain; background: none; border-radius: 0; } .hprev.sm canvas { height: 64px !important; }
.hname { font-weight: 800; font-size: 17px; } .hsub { opacity: .7; font-size: 12px; } .hnote { color: #b0563e; font-size: 12px; font-weight: 700; }
.hbuy { display: flex; align-items: center; justify-content: space-between; gap: 8px; } .hcoin { font-weight: 800; font-size: 16px; color: #8a5a00; }
.hbtn { all: unset; box-sizing: border-box; text-align: center; padding: 7px 14px; background: var(--cream2); border: 2px solid var(--line); border-radius: 14px; font-weight: 700; cursor: pointer; color: var(--ink); box-shadow: 0 3px 0 var(--line); }
.hbtn:hover { filter: brightness(1.04); } .hbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.hbtn.green { background: var(--green); border-color: var(--greend); color: #fff; box-shadow: 0 3px 0 #4a8f4a; text-shadow: 0 1px 0 rgba(0,0,0,.18); }
.hbtn.red { background: #ffe1da; border-color: #e8a090; color: #8a3a28; box-shadow: 0 3px 0 #d98b78; }
.hbtn:disabled, .hbtn.off { opacity: .55; cursor: default; }
.hrow { display: flex; gap: 10px; align-items: center; } .hrow.end { justify-content: flex-end; margin-top: 6px; }
.hstyle { display: flex; flex-direction: column; gap: 10px; }
.hsec { background: #fff; border: 2px solid #ecd9ad; border-radius: 16px; padding: 8px 10px; } .hsech { font-weight: 800; margin-bottom: 6px; }
.hsw { display: grid; grid-template-columns: repeat(auto-fill, 32px); gap: 6px; }
.hsb { all: unset; box-sizing: border-box; width: 32px; height: 32px; border: 2px solid var(--line); border-radius: 50%; cursor: pointer; position: relative; display: grid; place-items: center; font-weight: 900; background: #fff; box-shadow: 0 2px 0 var(--line); }
.hsb.sel { outline: 3px solid var(--yellowd); outline-offset: 1px; } .hsb input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; }
.hpats { display: flex; gap: 8px; flex-wrap: wrap; } .hpat { all: unset; box-sizing: border-box; padding: 7px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--cream2); font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 var(--line); } .hpat.sel { background: var(--yellow); border-color: var(--yellowd); box-shadow: 0 3px 0 #c9922e; }
#hinfo { left: 12px; top: 84px; width: 280px; z-index: 35; } #hinfo[hidden] { display: none; }
.hactions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
@media (max-width: 700px) {
  .hwin { left: 8px !important; right: 8px !important; width: auto !important; top: 64px !important; max-height: calc(100dvh - 140px); }
  .hcat { flex-direction: column; } .hnav { flex-direction: row; width: auto; flex-wrap: wrap; } .hnavb { padding: 6px 8px; font-size: 12px; }
  #hinfo { left: 8px; right: 8px; width: auto; top: auto; bottom: 150px; }
}
@media (max-height: 520px) and (orientation: landscape) { .hwin { top: 52px !important; max-height: calc(100dvh - 90px); } .hgrid { max-height: 150px; } .hprev, .hprev canvas { height: 80px !important; } #hinfo { top: 52px; } }

/* finestre del gioco in stile arredamento */
.hwin .mwin { min-width: 0; }
.hwin .mwin .form, .hwin .mwin .apts { max-width: 100%; }
.hwin #menuPanel.inwin { position: static; transform: none; width: auto; max-height: calc(100dvh - 190px); overflow: auto; box-shadow: none; border: 0; background: none; padding: 0; margin: 0; display: block; }
.hwin #menuPanel.inwin[hidden] { display: block; }
.hwin #menuPanel.inwin .grp { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding-bottom: 12px; margin-bottom: 12px; }
#menuBack { display: none !important; }

/* autoplay */
.apbar { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 9500; display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: rgba(255,248,230,.96); border: 2px solid #e0b96a; border-radius: 22px; box-shadow: 0 3px 10px rgba(0,0,0,.25); font-weight: 700; font-size: 13px; max-width: 92vw; }
.apbar[hidden] { display: none; }
.apdot { width: 10px; height: 10px; border-radius: 50%; background: #3cb054; box-shadow: 0 0 0 0 rgba(60,176,84,.6); animation: apPulse 1.6s infinite; }
@keyframes apPulse { 70% { box-shadow: 0 0 0 8px rgba(60,176,84,0); } 100% { box-shadow: 0 0 0 0 rgba(60,176,84,0); } }
.cfam { display: block; color: #8a5a22; }
#zAuto.apon { background: #7fd68f; border-color: #3cb054; box-shadow: 0 0 0 3px rgba(60,176,84,.35); }

/* dock "La mia stanza" in basso a sinistra */
.rdock { position: fixed; left: max(10px, env(safe-area-inset-left)); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.rdock[hidden], .rdockpop[hidden] { display: none; }
.rdock > button { padding: 8px 14px; border-radius: 20px; font-weight: 800; box-shadow: 0 3px 10px rgba(90,70,40,.3); }
.rdockpop { background: var(--cream, #fff8e6); border: 3px solid var(--line, #e6d3a8); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 190px; box-shadow: 0 8px 24px rgba(90,70,40,.35); }
.rdockpop h4 { margin: 0 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .65; }
.rdockpop button { text-align: left; }

@media (max-width: 700px) { #editBar { left: 8px; right: auto; margin: 0; max-width: calc(100% - 64px); width: auto; } }      /* da telefono la barra arredo non copre i tasti dello zoom */

/* finestra "Il tuo personaggio" / Armadio: niente più schede e griglie tagliate */
.creator > * { min-width: 0; }
.creator { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); }
.cright { min-width: 0; }
.cright .tabs { gap: 6px; } .cright .tabs button { padding: 6px 12px; }
.cpanel { overflow: visible; }
.spgrid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
.hwin .mwin { overflow-x: hidden; }
.hwin .cprev { max-height: 52vh; width: auto; margin: 0 auto; }
@media (max-width: 700px) { .creator { grid-template-columns: 1fr; } .hwin .cprev { max-height: 34vh; } }

/* ===== HUD v2 (layout "C") =====
   Grande (>=900 x >=560): barra fluttuante, scheda giocatore, colonna funzioni, zoom in pillola.
   Piccolo (telefono, schermi stretti o bassi): resta la barra di prima.
   In entrambi: avvisi in alto (Mi piace, autoplay, turno, modifica) impilati in #topStack, quindi non si sovrappongono mai. */
#hudNeeds, #hudCardBtn, #hudCard, .frail, #zLevel { display: none; }
#topStack { position: absolute; left: 0; right: 0; top: 10px; z-index: 9500; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#topStack > * { position: static !important; transform: none !important; margin: 0 !important; pointer-events: auto; max-width: 100%; box-sizing: border-box; }
#topStack > [hidden] { display: none !important; }
#chatlog { max-height: min(150px, calc(100% - 20px)); }
body:has(#roomDock:not([hidden])) #chatlog { left: 66px; width: min(470px, calc(100% - 76px)); }
@media (max-width: 600px) { #btnRoomDock { font-size: 0; padding: 8px 12px; } #btnRoomDock::before { content: "\1F3E0"; font-size: 20px; } }
@media (min-width: 601px) { body:has(#roomDock:not([hidden])) #chatlog { left: 232px; width: min(470px, calc(100% - 242px)); } }
@media (min-width: 900px) and (min-height: 560px) {
  #hud { position: absolute; top: 0; left: 0; right: 0; background: none; border: 0; box-shadow: none; padding: 14px; flex-wrap: nowrap; align-items: flex-start; pointer-events: none; gap: 12px; }
  #hud > *, #hud nav { pointer-events: auto; }
  .who { position: relative; background: var(--cream); border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line), 0 8px 18px rgba(60,40,20,.18); padding: 8px 10px 8px 8px; gap: 12px; }
  .who canvas { width: 48px; height: 48px; }
  #hudNeeds { display: flex; gap: 3px; margin-top: 4px; }
  .nbar { display: block; width: 30px; height: 8px; border-radius: 4px; background: #efe3c6; border: 1px solid var(--line); overflow: hidden; }
  .nbar > i { display: block; height: 100%; }
  .nbar.big { width: auto; height: 12px; border-radius: 7px; border-width: 1.5px; margin: 3px 0 9px; }
  #hudCardBtn { display: block; width: 32px; height: 32px; padding: 0; border-radius: 10px; margin-left: 2px; }
  #hudCard { display: block; position: absolute; left: 0; top: calc(100% + 8px); width: 330px; max-width: calc(100vw - 28px); background: var(--cream); border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line), 0 12px 26px rgba(60,40,20,.25); padding: 12px 14px 14px; z-index: 40; font-weight: 700; }
  #hudCard[hidden] { display: none; }
  #hudCard h4 { margin: 4px 2px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
  #hudCard .hrow { display: flex; justify-content: space-between; font-size: 14px; }
  #hudCard .hrow b { opacity: .7; }
  #hudCard .hhint { margin: -3px 0 8px; font-size: 12.5px; font-weight: 600; opacity: .7; }
  #hudCard .hgo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
  #hudCard .hgo button { text-align: left; padding: 8px 10px; }
  .rname { position: absolute; left: 50%; transform: translateX(-50%); top: 14px; flex: none; min-width: 0; max-width: calc(100vw - 600px); background: var(--cream); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--line), 0 8px 18px rgba(60,40,20,.18); padding: 6px 20px; pointer-events: auto; }
  #roomName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rname small { display: block; font-size: 12px; line-height: 1.35; }
  #hud nav { margin-left: auto; flex-wrap: nowrap; }
  #hud nav > button span, #btnMenu span { display: none; }
  .frail { display: flex; flex-direction: column; gap: 6px; position: absolute; right: 14px; top: 84px; z-index: 3; }
  .frail button { width: 56px; height: 50px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border-radius: 14px; }
  .frail b { font-size: 20px; line-height: 1.1; } .frail small { font-size: 10.5px; font-weight: 800; }
  #zoomBox { right: 14px; top: auto; bottom: 14px; width: 56px; align-items: center; gap: 2px; padding: 6px 0; background: var(--cream); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--line), 0 8px 18px rgba(60,40,20,.18); }
  #zoomBox button { width: 42px; height: 42px; }
  #zoomBox #zReset { margin-top: 6px; background: #ffe9a8; }
  #zLevel { display: block; border: 0; background: transparent; box-shadow: none; font-size: 13px; font-weight: 800; height: 26px; width: 100%; padding: 0; min-height: 0; opacity: .75; }
  main > #zAuto { position: absolute; right: 78px; bottom: 14px; width: 56px; height: 56px; padding: 0; border-radius: 16px; z-index: 3; box-shadow: 0 4px 0 var(--line), 0 8px 18px rgba(60,40,20,.18); }
  main > #zAuto.apon { background: #bfe8bf; border-color: #4fb04f; }
  #topStack { top: 112px; left: 150px; right: 90px; }
  body > #btnLike { top: 108px !important; left: 14px !important; right: auto !important; width: auto !important; }
}
@media (min-width: 900px) and (min-height: 560px) and (min-width: 1200px) {
  #hud nav > button span, #btnMenu span { display: inline; }
  .rname { max-width: calc(100vw - 780px); }
}
/* schermi bassi: zoom in orizzontale */
@media (min-width: 900px) and (min-height: 560px) and (max-height: 759px) {
  #zoomBox { flex-direction: row; width: auto; height: 56px; padding: 0 6px; }
  #zLevel { width: 52px; height: 42px; }
  #zoomBox #zReset { margin: 0 0 0 6px; }
  main > #zAuto { right: 228px; }
}
/* joystick acceso (tocco): zoom e autoplay si spostano a sinistra del joystick; sugli schermi bassi la colonna funzioni cede il posto */
@media (min-width: 900px) and (min-height: 560px) {
  body:has(#joy:not([hidden])) #zoomBox { right: 160px; }
  body:has(#joy:not([hidden])) main > #zAuto { right: 224px; }
}
@media (min-width: 900px) and (min-height: 560px) and (max-height: 759px) {
  body:has(#joy:not([hidden])) main > #zAuto { right: 374px; }
  body:has(#joy:not([hidden])) .frail { display: none; }
}
/* telefono in orizzontale (schermi molto bassi): "La mia stanza" scende sopra la chat e il registro chat si accorcia */
@media (max-height: 520px) { .rdock { bottom: calc(50px + env(safe-area-inset-bottom)); } #chatlog { max-height: min(80px, calc(100% - 20px)); } }
@media (max-height: 400px) { #zoomBox { gap: 3px; } #zoomBox button { width: 34px !important; height: 34px !important; font-size: 16px !important; } .rdock { bottom: calc(46px + env(safe-area-inset-bottom)); } #btnRoomDock { padding: 5px 10px; } }
/* joystick acceso: il registro chat non gli passa sotto */
body:has(#joy:not([hidden])) #chatlog { width: min(470px, calc(100% - 170px)); }
body:has(#joy:not([hidden])):has(#roomDock:not([hidden])) #chatlog { width: min(470px, calc(100% - 240px)); }
@media (min-width: 601px) { body:has(#joy:not([hidden])):has(#roomDock:not([hidden])) #chatlog { width: min(470px, calc(100% - 400px)); } }
@media (min-width: 900px) and (min-height: 560px) { body:has(#joy:not([hidden])) #chatlog, body:has(#joy:not([hidden])):has(#roomDock:not([hidden])) #chatlog { width: min(470px, calc(100% - 700px)); } }

/* ===== HUD v2 su telefono e schermi piccoli: stessa scheda e stessa pillola della stanza, ma compatte ===== */
@media (max-width: 899px), (max-height: 559px) {
  #hud { position: absolute; top: 0; left: 0; right: 0; background: none; border: 0; box-shadow: none; flex-wrap: nowrap; align-items: flex-start; pointer-events: none; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); }
  #hud > *, #hud nav { pointer-events: auto; }
  .who { position: relative; background: var(--cream); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 3px 0 var(--line), 0 6px 14px rgba(60,40,20,.18); padding: 6px 8px 6px 6px; gap: 8px; }
  .who canvas { width: 40px; height: 40px; border-width: 2px; }
  #hudName { font-size: 14px; line-height: 1.1; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .coins { font-size: 12px; gap: 4px; } #btnBonus { min-height: 24px; padding: 0 7px; font-size: 11px; }
  #hudNeeds { display: flex; gap: 3px; margin-top: 3px; }
  .nbar { display: block; width: 22px; height: 7px; border-radius: 4px; background: #efe3c6; border: 1px solid var(--line); overflow: hidden; }
  .nbar > i { display: block; height: 100%; }
  .nbar.big { width: auto; height: 12px; border-radius: 7px; border-width: 1.5px; margin: 3px 0 9px; }
  #hudCardBtn { display: block; width: 30px; height: 30px; min-height: 0 !important; padding: 0 !important; border-radius: 10px; }
  #hudCard { display: block; position: absolute; left: 0; top: calc(100% + 8px); width: 320px; max-width: calc(100vw - 16px); background: var(--cream); border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line), 0 12px 26px rgba(60,40,20,.25); padding: 12px 14px 14px; z-index: 40; font-weight: 700; max-height: calc(100dvh - 120px); overflow: auto; }
  #hudCard[hidden] { display: none; }
  #hudCard h4 { margin: 4px 2px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
  #hudCard .hrow { display: flex; justify-content: space-between; font-size: 14px; } #hudCard .hrow b { opacity: .7; }
  #hudCard .hhint { margin: -3px 0 8px; font-size: 12.5px; font-weight: 600; opacity: .7; }
  #hudCard .hgo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; } #hudCard .hgo button { text-align: left; padding: 8px 10px; min-height: 40px; }
  #hud nav { margin-left: auto; flex-wrap: nowrap; gap: 5px; }
  #hud nav > button, #btnMenu { min-width: 40px; min-height: 40px; padding: 4px 8px; } #hud nav > button span, #btnMenu span { display: none; }
  .rname { position: absolute; left: 50%; transform: translateX(-50%); top: max(90px, calc(env(safe-area-inset-top) + 82px)); flex: none; min-width: 0; max-width: calc(100vw - 16px); background: var(--cream); border: 2px solid var(--line); border-radius: 14px; box-shadow: 0 3px 0 var(--line), 0 6px 14px rgba(60,40,20,.18); padding: 3px 14px; pointer-events: auto; white-space: nowrap; }
  #roomName { font-size: 14px; overflow: hidden; text-overflow: ellipsis; } .rname small { display: block; font-size: 11px; line-height: 1.25; opacity: .7; }
  #topStack { top: max(152px, calc(env(safe-area-inset-top) + 144px)); }
  #zoomBox { top: max(152px, calc(env(safe-area-inset-top) + 144px)); }
  .frail { display: none; }
}
/* telefono in orizzontale: la pillola della stanza sta tra la scheda e i pulsanti */
@media (max-height: 559px) and (orientation: landscape) {
  .rname { position: static; transform: none; flex: 1 1 0; min-width: 0; max-width: none; margin-top: 4px; } .rname small { display: none; } #roomName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #topStack { top: 92px; } #zoomBox { top: 92px; }
}

/* voci del Menu che ora stanno nella colonna a destra: si nascondono (restano nel Menu sugli schermi dove la colonna non c'è, i tasti rapidi funzionano sempre) */
@media (min-width: 900px) and (min-height: 560px) {
  #menuPanel #btnShop, #menuPanel #btnCiti, #menuPanel #btnBag, #menuPanel #btnMissions, #menuPanel #btnMap, #menuPanel #btnHouses { display: none; }
  #menuPanel #btnAvatar, #menuPanel #btnCareer, #menuPanel #btnJobs, #menuPanel #btnNeeds { display: none; }   /* stanno nella scheda del giocatore */
  #menuPanel .grp:has(#btnAvatar) { display: none; }   /* gruppo "Il mio personaggio": ora tutto in scheda e colonna */
}
@media (min-width: 900px) and (min-height: 560px) and (max-height: 759px) {
  body:has(#joy:not([hidden])) #menuPanel :is(#btnShop, #btnCiti, #btnBag, #btnMissions, #btnMap, #btnHouses) { display: block; }
}
/* Zaino: schede Arredi / Oggetti */
.ztabs { display: flex; gap: 8px; margin: 0 0 8px; } .ztabs button { flex: 1; padding: 5px 10px; font-weight: 800; font-size: 14px; }
.ztabs button.sel { background: var(--green, #7bc67b); border-color: var(--greend, #5aa65a); color: #fff; }

/* Zaino: griglia unica e menu a tendina accanto all'oggetto cliccato */
.zgrid { max-height: min(56vh, 460px); overflow-y: auto; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); grid-auto-rows: 74px; min-height: 120px; } .zgrid .hcell { height: 74px; }
.zmenu { position: fixed; width: 240px; background: var(--cream); border: 3px solid var(--line); border-radius: 16px; box-shadow: 0 10px 28px rgba(60,40,20,.38); padding: 10px; display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.zmhead { display: flex; align-items: center; gap: 10px; } .zmhead small { font-weight: 600; opacity: .7; font-size: 12px; line-height: 1.3; }
.zmprev { width: 74px; height: 52px; flex: none; background: linear-gradient(#e2f3ff, #e3f6d9); border-radius: 10px; overflow: hidden; } .zmprev canvas { width: 100%; height: 100%; object-fit: contain; }
.zmask { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin: 2px 2px 0; } .zmnote { margin: 0; font-size: 13px; font-weight: 600; opacity: .8; }
.zmbtn { text-align: left; padding: 9px 12px; font-weight: 800; } .zmbtn.green { background: var(--green, #7bc67b); border-color: var(--greend, #5aa65a); color: #fff; }

.zgrid { grid-template-columns: repeat(5, 1fr); grid-auto-rows: 92px; gap: 8px; min-height: 0; }
.zgrid .hcell { height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 4px 3px 3px; }
.zprev { display: block; width: 100%; height: 56px; text-align: center; } .zprev canvas { width: 100%; height: 100%; object-fit: contain; }
.zname { display: block; width: 100%; font-size: 11px; font-weight: 800; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.zslot { border: 2px dashed #e3d2a8; border-radius: 14px; background: rgba(255,255,255,.35); }
@media (max-width: 600px) { .zgrid { grid-template-columns: repeat(4, 1fr); } }
.zgrid .hcount { top: 4px; bottom: auto; right: 5px; }

.zbar { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.zfbtn { padding: 7px 14px; font-weight: 800; white-space: nowrap; } .zfbtn.on { background: var(--green, #7bc67b); border-color: var(--greend, #5aa65a); color: #fff; }
.zfclr { padding: 6px 10px; font-weight: 800; }
.zfilter { width: 220px; max-height: 70vh; overflow-y: auto; } .zfilter .zmbtn { display: flex; justify-content: space-between; align-items: center; }

/* ---- Modalità Costruttore (solo Founder) ---- */
#btnBuild { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: 46px; z-index: 31; padding: 8px 14px; border-radius: 20px; font-weight: 800; box-shadow: 0 3px 10px rgba(90,70,40,.3); background: #fff1d6; border: 2px solid #e8a838; color: #7a4a10; cursor: pointer; }
#btnBuild[hidden] { display: none; } #btnBuild.on { background: #e8a838; color: #fff; }
#bldBar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 40; max-width: calc(100vw - 20px); background: var(--cream); border: 3px solid #e8a838; border-radius: 16px; padding: 8px 10px; box-shadow: 0 6px 18px rgba(90,70,40,.35); display: flex; flex-direction: column; gap: 6px; align-items: center; }
#bldBar[hidden] { display: none; } #bldBar .bi { font-weight: 800; font-size: 13px; text-align: center; } #bldBar .br { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
#bldBar button.off { opacity: .4; } #bldBar button.on { background: #e8a838; color: #fff; } #bldBar button.danger { background: #fde4e0; border-color: #e0867a; }

/* Arreda: stesso aspetto del Costruttore (barra in basso, bordo ambra, griglia sulla mappa) */
#editBar { position: fixed; top: auto; bottom: calc(64px + env(safe-area-inset-bottom)); left: 50%; right: auto; transform: translateX(-50%); margin: 0; width: fit-content; max-width: calc(100vw - 20px); z-index: 40; background: var(--cream); border: 3px solid #e8a838; border-radius: 16px; padding: 8px 10px; box-shadow: 0 6px 18px rgba(90,70,40,.35); flex-direction: column; gap: 6px; font-size: 13px; font-weight: 800; text-align: center; }
#editBar[hidden] { display: none; } #editBar button { padding: 5px 10px; border-radius: 12px; font-weight: 800; font-size: 13px; cursor: pointer; background: #fff1d6; border: 2px solid #e8a838; color: #7a4a10; } #editBar #btnCancel { background: #e8a838; color: #fff; }
#btnEdit.on { background: #e8a838; color: #fff; }
@media (max-width: 700px) { #editBar { left: 50%; right: auto; margin: 0; max-width: calc(100vw - 20px); width: fit-content; } }
#editBar .br { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
/* con la barra di Arreda/Costruttore aperta, l'avviso compare sopra la barra senza coprirla */
body.arrOn #toast, body.bldOn #toast { bottom: calc(64px + 110px + 14px + env(safe-area-inset-bottom)); }

@media (max-height: 520px) { #btnBuild { bottom: 34px; padding: 5px 10px; } }

/* v252/253: pannello delle emozioni compatto: solo icone (il nome compare passando il mouse / tenendo premuto), va a capo e occupa poco spazio */
#emotes.pop.left { flex-wrap: wrap; justify-content: flex-start; gap: 3px; padding: 6px; border-width: 2px; border-radius: 14px; width: min(96vw, 452px); max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; box-shadow: 0 6px 18px rgba(90,70,40,.28); }
#emotes.pop.left button { flex: 0 0 auto; width: 40px; height: 40px; min-width: 0; padding: 0; border-radius: 10px; justify-content: center; }
#emotes.pop.left b { font-size: 22px; }
#emotes.pop.left small { display: none; }
