:root {
  --page: #efe8d2;
  --panel: #fbf7e8;
  --ink: #1d1812;
  --ink-soft: #6a5d49;
  --blue: #63b4ff;
  --blue-d: #2f6fdb;
  --gold: #f2c744;
  --danger: #c0392b;
  --shadow: 4px 4px 0 rgba(0, 0, 0, .38);
  --f-ui: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-display: 'Almendra SC', Georgia, 'Times New Roman', serif;
  --f-label: 'Oswald', 'Arial Narrow', Impact, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page); color: var(--ink); font-family: var(--f-ui);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue-d); outline-offset: 2px; }

/* ---------- barra: lingue a sinistra, titolo + versione al centro, avanzamento a destra ---------- */
.bar { position: relative; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding: 8px 18px; background: var(--panel); border-bottom: 3px solid var(--ink); flex: none; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
h1 { font: 400 clamp(21px, 2.6vw, 30px)/1 var(--f-display); margin: 0; letter-spacing: .02em; white-space: nowrap; }
.ver { flex: none; font: 600 14px/1 var(--f-label); letter-spacing: .06em; padding: 5px 9px 4px; background: var(--gold); border: 2px solid var(--ink); border-radius: 6px; box-shadow: 2px 2px 0 rgba(0,0,0,.35); }
.ver:empty { display: none; }
.langmenu { justify-self: start; position: relative; z-index: 30; }
.langbtn { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 9px; background: #fff; border: 3px solid var(--ink); border-radius: 10px; box-shadow: 3px 3px 0 rgba(0,0,0,.35);
  font: 800 13px/1 var(--f-ui); transition: transform 90ms ease-out, box-shadow 90ms ease-out; }
.langbtn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(0,0,0,.35); }
.langbtn[aria-expanded="true"] { background: var(--gold); transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.langbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.langbtn .chev { width: 16px; height: 16px; stroke-width: 3.2; }
.langbtn b { font: 600 14px/1 var(--f-label); letter-spacing: .08em; }
.langbtn span { font-weight: 700; }
.langlist { position: absolute; top: calc(100% + 8px); left: 0; min-width: 210px; margin: 0; padding: 6px; list-style: none; background: var(--panel); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); }
.langlist[hidden] { display: none; }
.langlist li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font: 700 16px/1 var(--f-ui); }
.langlist li + li { margin-top: 4px; }
.langlist li:hover { background: #fff; outline: 2px solid var(--ink); }
.langlist li b { flex: none; width: 34px; padding: 5px 0 4px; text-align: center; background: var(--ink); color: #fff; border-radius: 6px; font: 600 14px/1 var(--f-label); letter-spacing: .08em; }
.langlist li span { flex: 1; }
.langlist li i { font-style: normal; font-weight: 800; color: var(--blue-d); visibility: hidden; }
.langlist li[aria-selected="true"] { background: var(--gold); outline: 2px solid var(--ink); }
.langlist li[aria-selected="true"] i { visibility: visible; color: var(--ink); }
.chip { justify-self: end; font: 800 13px var(--f-ui); padding: 4px 11px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; box-shadow: 2px 2px 0 rgba(0,0,0,.3); }
.dlg a { color: var(--blue-d); font-weight: 700; }

/* ---------- impaginazione ---------- */
main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 460px) minmax(0, 1fr) 184px; }
.cards { overflow-y: auto; padding: 14px 14px 22px; background: var(--panel); border-right: 3px solid var(--ink); scrollbar-width: thin; }
.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 12px; align-items: start; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; }
.frame { margin: auto; display: grid; grid-template-columns: var(--lab, 26px) var(--bs, 600px); grid-template-rows: var(--bs, 600px) var(--lab, 26px); flex: none; }
.status { margin: 0; padding: 7px 14px; font-size: 13px; text-align: center; color: var(--ink-soft); border-top: 2px solid rgba(0,0,0,.12); min-height: 34px; }
.status b { color: var(--ink); }
.tools { padding: 14px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; overflow-y: auto;
  background: repeating-linear-gradient(180deg, transparent 0 46px, rgba(0,0,0,.28) 46px 48px), linear-gradient(90deg, #7a4d2b, #8a5a33 40%, #74482a);
  border-left: 3px solid var(--ink); }
/* ---------- numeri riga e colonna ---------- */
.rownums { display: grid; grid-template-rows: repeat(24, 1fr); }
.colnums { display: grid; grid-template-columns: repeat(24, 1fr); }
.rownums span, .colnums span { font: 700 calc(var(--cs, 24px) * .34)/1 var(--f-ui); color: #8b7e68; display: flex; align-items: center; justify-content: center; transition: color .1s; }
.rownums span.on, .colnums span.on { color: var(--ink); font-weight: 800; }

/* ---------- mappa ---------- */
.board { position: relative; width: var(--bs); height: var(--bs); font-size: calc(var(--bs) / 100); border-radius: 3px; box-shadow: 6px 6px 0 rgba(0, 0, 0, .28); }
.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.pills { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pill {
  position: absolute; transform: translate(-50%, -50%); width: calc(var(--w) * 1%); height: calc(var(--h) * 1%);
  display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden;
  background: #fff; border: calc(var(--bs) * .0026) solid var(--ink); border-radius: 999px;
  font: 600 calc(var(--fs) * 1em)/1 var(--f-label); text-transform: uppercase; letter-spacing: .02em; color: var(--ink);
  transition: background .12s;
}
.pill.hot { background: #cfe6ff; }
.grid { position: absolute; inset: .356%; display: grid; grid-template: repeat(24, 1fr) / repeat(24, 1fr); touch-action: pan-x pan-y; }
body.picking .grid { cursor: copy; }
body.xmode .grid { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32' fill='none' stroke-linecap='round'%3E%3Cpath d='M8 8L24 24M24 8L8 24' stroke='%231d1812' stroke-width='10'/%3E%3Cpath d='M8 8L24 24M24 8L8 24' stroke='%23e0462f' stroke-width='5'/%3E%3C/svg%3E") 16 16, crosshair; }   /* il cursore diventa lo strumento attivo */
body.emode .grid { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg transform='rotate(-40 16 16)'%3E%3Crect x='3' y='9.5' width='26' height='13' rx='3' fill='%23f07a9a' stroke='%231d1812' stroke-width='2.5'/%3E%3Cpath d='M11.5 9.5v13' stroke='%231d1812' stroke-width='2.5'/%3E%3Crect x='3' y='9.5' width='8.5' height='13' rx='3' fill='%23fff8dc' stroke='%231d1812' stroke-width='2.5'/%3E%3C/g%3E%3C/svg%3E") 6 24, cell; }

/* ---------- caselle ---------- */
.cell { position: relative; }
.cell.blk { background: rgba(0, 0, 0, .12); }
.cell:hover { background: rgba(255, 255, 255, .12); }
.cell.blk:hover { background: rgba(0, 0, 0, .18); }
.cell.room { background: rgba(60, 130, 235, .08); }
/* contorno blu dell'area: usa i bordi calcolati sulla mappa */
.cell.rm.et { box-shadow: inset 0 calc(var(--cs) * .07) 0 var(--blue-d); }
.cell.rm.eb { box-shadow: inset 0 calc(var(--cs) * -.07) 0 var(--blue-d); }
.cell.rm.el { box-shadow: inset calc(var(--cs) * .07) 0 0 var(--blue-d); }
.cell.rm.er { box-shadow: inset calc(var(--cs) * -.07) 0 0 var(--blue-d); }
.cell.rm.et.el { box-shadow: inset 0 calc(var(--cs) * .07) 0 var(--blue-d), inset calc(var(--cs) * .07) 0 0 var(--blue-d); }
.cell.rm.et.er { box-shadow: inset 0 calc(var(--cs) * .07) 0 var(--blue-d), inset calc(var(--cs) * -.07) 0 0 var(--blue-d); }
.cell.rm.eb.el { box-shadow: inset 0 calc(var(--cs) * -.07) 0 var(--blue-d), inset calc(var(--cs) * .07) 0 0 var(--blue-d); }
.cell.rm.eb.er { box-shadow: inset 0 calc(var(--cs) * -.07) 0 var(--blue-d), inset calc(var(--cs) * -.07) 0 0 var(--blue-d); }
.cell.hla { background: rgba(60, 130, 235, .15); }
.cell.hlo { background: rgba(40, 110, 240, .42); outline: calc(var(--cs) * .05) solid #fff; outline-offset: calc(var(--cs) * -.05); z-index: 3; }
.cell.hld { background: rgba(40, 110, 240, .38); outline: calc(var(--cs) * .06) dashed #fff; outline-offset: calc(var(--cs) * -.06); z-index: 3; }
.cell.hlp { background: rgba(40, 110, 240, .32); outline: calc(var(--cs) * .08) solid var(--blue-d); outline-offset: calc(var(--cs) * -.08); z-index: 3; }
.cell.sel { background: rgba(99, 180, 255, .28); }
.cell.last { background: rgba(242, 199, 68, .5); outline: calc(var(--cs) * .1) solid var(--gold); outline-offset: calc(var(--cs) * -.1); animation: glow 1s ease-in-out infinite; z-index: 3; }
.cell.bad { background: rgba(192, 57, 43, .45); }
.cell.shake { animation: shake .3s; }
@keyframes glow { 50% { filter: brightness(1.3); } }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes pop { 0% { transform: scale(.3); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* note: lettere colorate con contorno nero */
.notes { position: absolute; top: 2px; left: 2px; right: 2px; display: flex; flex-wrap: wrap; gap: 0 1px; pointer-events: none; z-index: 7; }
.notes i {
  font: normal 800 calc(var(--cs) * .27)/1 var(--f-ui); width: calc(var(--cs) * .3); height: calc(var(--cs) * .3);
  display: flex; align-items: center; justify-content: center; color: var(--c);
  -webkit-text-stroke: calc(var(--cs) * .13) #000; paint-order: stroke fill;
}
/* X: due pennellate d'inchiostro con alone bianco, la casella resta leggibile */
.xm { position: absolute; inset: 0; display: none; pointer-events: none; z-index: 5; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke-linecap='round'%3E%3Cg stroke='%23fff' stroke-opacity='.9' stroke-width='27'%3E%3Cpath d='M23 22Q47 46 77 79'/%3E%3Cpath d='M78 23Q54 50 22 78'/%3E%3C/g%3E%3Cg stroke='%23241c14' stroke-width='16'%3E%3Cpath d='M23 22Q47 46 77 79'/%3E%3Cpath d='M78 23Q54 50 22 78'/%3E%3C/g%3E%3C/svg%3E") center / 82% no-repeat; }
.cell.x .xm { display: block; }
/* sugli oggetti non occupabili la X e' un segno piccolo in un angolo: l'oggetto resta visibile */
.cell.blk.x .xm { background-size: 42%; background-position: 94% 6%; }
/* personaggio posizionato: figurina con contorno nero */
.tok { position: absolute; inset: 7%; display: none; pointer-events: none; z-index: 8; }
.tok.on { display: block; }
.tok img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  filter: drop-shadow(calc(var(--cs) * .045) 0 0 #000) drop-shadow(calc(var(--cs) * -.045) 0 0 #000) drop-shadow(0 calc(var(--cs) * .045) 0 #000) drop-shadow(0 calc(var(--cs) * -.045) 0 #000);
}
.tok b { position: absolute; left: -9%; top: -14%; font: 800 calc(var(--cs) * .36)/1 var(--f-ui); color: var(--c); -webkit-text-stroke: calc(var(--cs) * .1) #000; paint-order: stroke fill; }
.tok.pop { animation: pop .28s ease-out; }
.tok.tre img { filter: drop-shadow(calc(var(--cs) * .045) 0 0 #000) drop-shadow(calc(var(--cs) * -.045) 0 0 #000) drop-shadow(0 calc(var(--cs) * .045) 0 #000) drop-shadow(0 calc(var(--cs) * -.045) 0 #000) drop-shadow(0 0 calc(var(--cs) * .2) #ffe066); }
/* goccia d'acqua: le X si propagano dal personaggio posato (36 ms a casella, vedi dropWave in app.js) */
.cell.x.drop .xm { animation: xdrop .36s cubic-bezier(.2, 1.5, .4, 1) calc(var(--d) * 36ms) backwards; }
@keyframes xdrop { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 55% { transform: scale(1.3) rotate(4deg); opacity: 1; } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .cell.last, .tok.pop { animation: none; } .cell.x.drop .xm { animation: none; } }

/* ---------- carte ---------- */
.card { min-width: 0; display: flex; flex-direction: column; gap: 7px; padding: 0; border: 0; background: none; text-align: center; border-radius: 12px; transition: transform .1s cubic-bezier(.34, 1.56, .64, 1); position: relative; }
.shot {
  position: relative; display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
  aspect-ratio: 1 / .95; background: linear-gradient(#fffef2, #f7f0d4); border: 3px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow);
}
.shot img { width: 100%; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; object-position: bottom; display: block; pointer-events: none; }
.card.treasure .shot img { height: 78%; width: auto; margin-bottom: 20%; }
.plank { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); padding: 4px 16px; background: #d9b99b; border: 2px solid #8c6b4f; border-radius: 4px; font: 400 15px/1 var(--f-display); letter-spacing: .06em; text-transform: uppercase; }
.g { position: absolute; right: 5px; top: 5px; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; background: #cfe3f7; border: 2px solid var(--ink); }
.g1 { background: #f7cfe3; }
.lt { position: absolute; left: 5px; top: 5px; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 800 14px var(--f-ui); color: var(--c); -webkit-text-stroke: 3px #000; paint-order: stroke fill; background: rgba(255, 255, 255, .85); border: 2px solid var(--ink); }
.where { position: absolute; left: 50%; top: 5px; transform: translateX(-50%); font: 800 10px var(--f-ui); background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 8px; display: none; white-space: nowrap; }
.card.placed .where { display: block; }
.clue { display: block; background: var(--paper); border: 3px solid var(--ink); border-radius: 10px; padding: 8px 8px 9px; font: 500 12.5px/1.32 var(--f-ui); box-shadow: var(--shadow); min-height: 62px; }
.clue b { font-weight: 800; cursor: help; }
.card .shot, .card .clue { transition: opacity .15s, filter .15s, outline-color .1s; outline: 4px solid transparent; outline-offset: -1px; }
.card:hover .shot, .card:hover .clue { outline-color: var(--blue); }
.card:active { transform: scale(.98); }
.card.placed .shot, .card.placed .clue { opacity: .42; filter: grayscale(.75); }
.card.placed:hover .shot, .card.placed:hover .clue { outline-color: transparent; }
.card.sel .shot, .card.sel .clue { outline-color: var(--blue-d); outline-width: 5px; background-color: #e3f1ff; opacity: 1; filter: none; animation: selpop .6s cubic-bezier(.15, .9, .3, 1); }
.card.sel .shot { background: linear-gradient(#e3f1ff, #cfe6ff); }
.card.kp .shot, .card.kp .clue { outline-color: var(--blue); outline-width: 5px; opacity: 1; filter: none; }
.card.bad .shot, .card.bad .clue { outline-color: var(--danger); outline-width: 5px; opacity: 1; filter: none; }
@keyframes selpop { 0% { transform: scale(.94); filter: brightness(1.3); } 100% { transform: scale(1); } }

/* ---------- strumenti: tavola di legno, targhe di pergamena, monete colorate ---------- */
.tools-h { grid-column: 1 / -1; justify-self: center; margin: 0 0 4px; padding: 5px 20px 4px; background: #d9b99b; border: 3px solid var(--ink); border-radius: 4px; transform: rotate(-1.5deg);
  font: 400 19px/1 var(--f-display); letter-spacing: .08em; text-transform: uppercase; box-shadow: var(--shadow); }
.tool, .stamp {
  width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 84px; padding: 8px 4px 7px;
  background: #fff8dc; border: 3px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow);
  font: 800 14px/1.1 var(--f-ui); position: relative; overflow: hidden;
  transition: transform 90ms ease-out, box-shadow 90ms ease-out, background-color .12s;
}
.tool:hover:not(:disabled), .stamp:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 rgba(0, 0, 0, .38); }
.tool:active:not(:disabled), .stamp:active:not(:disabled), .tool[aria-pressed="true"] { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .38); }
.tool:disabled { filter: grayscale(.7) brightness(.85); cursor: default; }
.tool small { display: block; margin-top: 2px; font: 500 10px/1.1 var(--f-ui); letter-spacing: 0; text-transform: none; color: var(--ink-soft); }
.tool .lb { display: block; text-align: center; font: 600 14px/1 var(--f-label); letter-spacing: .07em; text-transform: uppercase; }
.coin { --c: #fff; flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--c); border: 3px solid var(--ink); display: grid; place-items: center; color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.22), 0 2px 0 rgba(0,0,0,.18); }
.coin svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.t-x .coin { --c: #e0462f; }
.t-e .coin { --c: #f07a9a; }
.t-u .coin { --c: #4f9be8; }
.t-c .coin { --c: #4a3d2e; }
.t-l .coin { --c: #4aa58a; }
.tool.big { grid-column: 1 / -1; min-height: 104px; gap: 8px; }
.tool.big .coin { width: 60px; height: 60px; }
.tool.big .coin svg { width: 34px; height: 34px; stroke-width: 3.5; }
.tool.big .lb { font-size: 18px; }
.tool[aria-pressed="true"] { background: var(--gold); }
.tool[aria-pressed="true"] .coin { box-shadow: inset 0 3px 0 rgba(0,0,0,.25); }
.tool.submit, .stamp.submit { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 10px; background: var(--gold); min-height: 72px; padding: 8px 10px; font-size: 17px; margin-top: 8px; }
.tool.submit .coin { --c: #fff3b0; color: var(--ink); width: 46px; height: 46px; }
.tool.submit .lb { text-align: left; font-size: 18px; }
.tool.submit:disabled { background: #d8c9a0; }
.stamp.submit { margin-top: 16px; }
.tool .fill { position: absolute; left: 0; bottom: 0; height: 100%; width: 0; background: rgba(192, 57, 43, .3); }
.tool.holding .fill { width: 100%; transition: width .8s linear; }
.tool.sm { min-height: 42px; width: 46px; font-size: 24px; line-height: 1; padding: 0; border-radius: 50%; background: var(--gold); }
.zoom { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 4px; font: 600 15px var(--f-label); letter-spacing: .06em; color: #fff8dc; text-shadow: 0 2px 0 rgba(0,0,0,.45); }

/* ---------- suggerimenti, finestre, avvisi ---------- */
#tip { position: fixed; z-index: 40; max-width: 260px; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.35; box-shadow: 3px 3px 0 rgba(0,0,0,.3); pointer-events: none; opacity: 0; transform: translateY(4px); transition: .12s; }
#tip.on { opacity: 1; transform: none; }
#tip b { display: block; color: var(--blue-d); font-size: 12px; margin-bottom: 2px; }
.veil { position: fixed; inset: 0; background: rgba(29, 24, 18, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dlg { background: var(--panel); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 6px 6px 0 rgba(0,0,0,.4); max-width: 580px; width: 100%; max-height: 88vh; overflow: auto; padding: 20px; user-select: text; -webkit-user-select: text; }
.dlg h2 { font: 400 28px/1.1 var(--f-display); margin: 0 0 12px; }
.dlg h3 { font: 800 12px var(--f-ui); text-transform: uppercase; letter-spacing: .08em; margin: 16px 0 8px; color: var(--ink-soft); }
.dlg ul { margin: 0; padding-left: 18px; }
.dlg li { margin: 0 0 7px; line-height: 1.4; font-size: 14px; }
.dlg .legend { list-style: none; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px 6px; border: 3px solid var(--ink); border-radius: 12px; }
.dlg .legend.rose { background: #c4958a; }
.dlg .legend.teal { background: #a7cbbd; }
.dlg .legend li { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; margin: 0; text-transform: capitalize; }
.dlg .legend img { height: 46px; width: auto; max-width: 80px; object-fit: contain; }
.dlg .win { font-size: 20px; }
.dlg .errs li { color: var(--danger); font-weight: 700; }
.dlg .ok { margin-top: 16px; position: sticky; bottom: 0; }
.dlg .langs { display: flex; gap: 8px; margin: 0 0 4px; }
.dlg .langs button { flex: 1; padding: 9px 6px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; font: 800 14px var(--f-ui); box-shadow: 2px 2px 0 rgba(0,0,0,.3); }
.dlg .langs button[aria-pressed="true"] { background: var(--gold); transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(0,0,0,.3); }
.dlg a.go { margin-top: 16px; text-decoration: none; color: inherit; }
.dlg a.go + .ok { margin-top: 10px; background: #fff; min-height: 46px; font-size: 14px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--blue-d); color: #fff; padding: 11px 16px; border: 2px solid var(--ink); border-radius: 10px; font-size: 14px; font-weight: 500; max-width: min(90vw, 460px); opacity: 0; pointer-events: none; transition: .2s; z-index: 60; text-align: center; box-shadow: 3px 3px 0 rgba(0,0,0,.35); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- telefono: mappa e strumenti fissi, carte che scorrono ---------- */
@media (max-width: 900px) {
  body { height: 100dvh; }
  .bar { padding: 6px 12px; gap: 8px; border-bottom-width: 2px; grid-template-columns: auto 1fr auto; }
  h1 { font-size: 16px; line-height: 1.05; }
  .brand { gap: 7px; }
  .ver { font-size: 12px; padding: 4px 6px 3px; }
  .langbtn { padding: 5px 7px; gap: 5px; border-width: 2px; box-shadow: 2px 2px 0 rgba(0,0,0,.35); }
  .langbtn #langName { display: none; }
  .langbtn .globe { display: none; }
  .chip { font-size: 12px; padding: 3px 8px; }
  main { display: flex; flex-direction: column; min-height: 0; }
  .stage { order: 1; height: min(100vw + 34px, 48dvh); flex: none; }
  .scroll { padding: 4px; }
  .status { padding: 4px 10px; font-size: 11.5px; min-height: 0; }
  .tools { order: 2; flex: none; display: flex; flex-direction: row; align-items: stretch; gap: 6px; padding: 7px; border-left: 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); overflow-x: auto; overflow-y: hidden; }
  .tools-h { display: none; }
  .tool { width: auto; flex: 1 1 0; min-width: 0; min-height: 46px; padding: 3px; border-width: 2px; border-radius: 9px; box-shadow: 2px 2px 0 rgba(0,0,0,.38); }
  .tool .coin, .tool.big .coin { width: 32px; height: 32px; border-width: 2px; }
  .tool .coin svg, .tool.big .coin svg { width: 19px; height: 19px; }
  .tool .lb { display: none; }
  .tool small, #zoomLabel { display: none; }
  .tool.big { flex: 1 1 0; min-height: 46px; }
  .tool.submit { flex: 1.7 1 0; margin-top: 0; min-height: 46px; padding: 3px 6px; }
  .tool.submit .coin { display: none; }
  .tool.submit .lb { display: block; font-size: 13px; text-align: center; white-space: nowrap; }
  .zoom { flex: 0 0 auto; flex-direction: column; justify-content: center; padding: 0; gap: 3px; }
  .tool.sm { width: 38px; height: 21px; min-height: 0; flex: none; border-radius: 8px; font-size: 16px; padding: 0; }
  .cards { order: 3; flex: 1; min-height: 0; border-right: 0; padding: 10px; }
  .clue { font-size: 11.5px; }
}
/* ---------- telefono, ritocchi ---------- */
.txt { display: contents; }
.nm { display: none; }
body { touch-action: manipulation; }
.grid, .cards, .tools { -webkit-touch-callout: none; }
@media (max-width: 900px) {
  .bar { padding-top: max(6px, env(safe-area-inset-top)); }
  .stage { height: min(100vw + 30px, 50dvh); }
  .cards { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .cards-grid { grid-template-columns: 1fr; gap: 8px; }
  .card { flex-direction: row; align-items: stretch; gap: 8px; text-align: left; }
  .card .shot { flex: 0 0 74px; aspect-ratio: auto; height: 74px; }
  .card.treasure .shot img { margin-bottom: 8%; }
  .plank, .g { display: none; }
  .lt { width: 20px; height: 20px; font-size: 12px; left: 3px; top: 3px; }
  .where { font-size: 9px; padding: 1px 6px; top: auto; bottom: 3px; }
  .txt { display: flex; flex-direction: column; justify-content: center; gap: 3px; flex: 1; min-width: 0; }
  .nm { display: block; font: 400 17px/1 var(--f-display); letter-spacing: .03em; }
  .clue { min-height: 0; padding: 7px 9px; font-size: 13px; text-align: left; }
}
.foot { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 3px 12px calc(3px + env(safe-area-inset-bottom)); font-size: 11px; line-height: 1.3; color: var(--ink-soft); background: var(--panel); border-top: 2px solid rgba(0,0,0,.12); min-width: 0; }
.foot span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot button { flex: none; background: none; border: 0; padding: 4px 2px; font: 700 11px var(--f-ui); color: var(--blue-d); text-decoration: underline; cursor: pointer; }
@media print { .tools, .cards, .bar .chip, .bar .langmenu, .status, .foot { display: none; } body { overflow: visible; } }
