:root {
  --ink: #2b2233;
  --paper: #fff7e6;
  --accent: #ff7a59;
  --wall: #ffe9b8;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: #ffd9a8 radial-gradient(#ffc27a 18%, transparent 20%) 0 0 / 28px 28px;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#app { max-width: 640px; min-height: 100dvh; margin: 0 auto; background: var(--paper); border-inline: 4px solid var(--ink); }
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }

/* Grafica SVG a fumetto: contorni spessi uguali per tutto (.n = senza contorno, .t = sottile) */
.art :is(path, rect, circle, ellipse, polygon, polyline, line) { stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.art .n { stroke: none; }
.art .t { stroke-width: 2; }
.art text { stroke: none; font-family: inherit; font-weight: 900; }
.art .hit { fill: transparent; stroke: none; }
.icon { width: 1.2em; height: 1.2em; vertical-align: -0.2em; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* Pulsanti */
.btn {
  min-height: 48px; padding: 0.5em 1em;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  font-weight: 800; cursor: pointer;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.3em 0.7em; background: #fff; border: 3px solid var(--ink); border-radius: 999px; font-weight: 800; }
.btn.chip { min-height: 44px; }

/* Menu e negozio */
.menu, .shop, .win { display: flex; flex-direction: column; gap: 14px; padding: calc(20px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.menu h1 { font-size: 3rem; text-align: center; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); transform: rotate(-3deg); }
.tagline { text-align: center; font-weight: 700; }
.world { font-size: 1.25rem; margin-top: 8px; }
.install { width: min(100%, 360px); margin-inline: auto; display: grid; gap: 8px; padding: 14px; text-align: left; background: #fff; border: 3px solid var(--ink); border-radius: 18px; font-weight: 700; }
.install h3 { margin: 0; font-size: 1.2rem; }
.steps { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 10px; }
.steps .icon { flex: none; width: 2.4rem; height: 2.4rem; }
.toggles { display: flex; gap: 10px; justify-content: center; }
.bar { display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; gap: 12px; }
@media (min-width: 520px) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; row-gap: 2px; text-align: left;
  padding: 12px; background: #fff; border: 4px solid var(--ink); border-radius: 22px 18px 24px 16px; box-shadow: 0 5px 0 var(--ink); cursor: pointer;
}
.card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.card .badge { grid-row: span 2; display: grid; place-items: center; width: 48px; height: 48px; background: var(--accent); border: 3px solid var(--ink); border-radius: 50%; font-size: 1.4rem; }
.card .name { font-weight: 900; font-size: 1.1rem; }
.card small { font-weight: 700; }
.card.buy, .card.blocked { background: #ece4d4; }
.card.blocked { opacity: 0.7; cursor: default; box-shadow: none; }
.shop h2, .win h2 { font-size: 2rem; text-align: center; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; }
.row div { display: grid; gap: 2px; }

/* Stanza */
.room { display: flex; flex-direction: column; min-height: 100dvh; background: var(--wall); padding-bottom: env(safe-area-inset-bottom); }
.room.done { pointer-events: none; }
.top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; background: var(--paper); border-bottom: 4px solid var(--ink); }
.top h2 { flex: 1; min-width: 0; font-size: 0.95rem; line-height: 1.1; }
.top #timer { font-weight: 800; font-variant-numeric: tabular-nums; }
.icon-btn { min-width: 48px; padding: 0; }
.goal { padding: 6px 12px; background: #fff6c9; border-bottom: 4px solid var(--ink); font-size: 0.95rem; font-weight: 700; line-height: 1.25; }
.scene { background: var(--accent); border-bottom: 4px solid var(--ink); }
.scene svg { display: block; width: 100%; height: auto; }
.hot { cursor: pointer; }
.hot.bounce { transform-box: fill-box; transform-origin: 50% 100%; animation: bounce 0.5s; }
.bubble {
  position: relative; flex: 1; display: flex; align-items: center; margin: 18px 12px 6px; padding: 0.7em 1em; min-height: 3.4em;
  background: #fff; border: 3px solid var(--ink); border-radius: 20px; font-weight: 700; font-size: clamp(1rem, 2.6dvh, 1.5rem);
}
.bubble::before { content: ""; position: absolute; top: -13px; left: 28px; width: 20px; height: 20px; background: #fff; border-left: 3px solid var(--ink); border-top: 3px solid var(--ink); transform: rotate(45deg); }
.inventory { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: auto; padding: 10px 8px; background: var(--paper); border-top: 4px solid var(--ink); }
.slot { aspect-ratio: 1; padding: 2px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; cursor: pointer; }
.slot.empty { background: transparent; border-style: dashed; opacity: 0.35; cursor: default; }
.slot.selected { background: var(--accent); transform: translateY(-6px); box-shadow: 0 4px 0 var(--ink); }
.slot svg { display: block; width: 100%; height: 100%; }

/* Finestre */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(43, 34, 51, 0.65); }
.dialog { display: grid; gap: 14px; justify-items: center; width: min(100%, 420px); max-height: 100%; overflow: auto; padding: 18px; text-align: center; background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; }
.dialog .view { width: 100%; }
.dialog input { width: 100%; padding: 0.5em 0.7em; font: inherit; font-size: 1rem; font-weight: 700; background: #fff; border: 3px solid var(--ink); border-radius: 14px; }
.dialog .view svg { display: block; width: 100%; height: auto; }
.paper { padding: 14px; background: #f3dfa8; border: 3px solid var(--ink); border-radius: 10px 16px 12px 18px; font-size: 1.2rem; font-weight: 800; }
.paper p + p { margin-top: 0.6em; }
.sim { padding: 0.4em 0.8em; background: #ffd23f; border: 3px solid var(--ink); border-radius: 12px; font-weight: 900; }
.price { font-size: 2rem; font-weight: 900; }
.actions { display: flex; gap: 10px; }
.lock { display: grid; gap: 14px; justify-items: center; }
.note { font-weight: 700; min-height: 1.4em; }
.wheels { display: flex; gap: 10px; justify-content: center; }
.wheel { display: grid; gap: 8px; }
.wheel .btn { min-width: 60px; }
.wheel .label { font-size: 1.3rem; }
.face { display: grid; place-items: center; height: 76px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; font-size: 2.6rem; font-weight: 900; }
.face svg { width: 56px; height: 56px; }
.open { margin-top: 14px; }
.dots { margin-bottom: 10px; font-size: 1.6rem; letter-spacing: 0.2em; }
.keys { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.key { height: 84px; padding: 4px; }
.key svg { width: 100%; height: 100%; }

/* Vittoria */
.win { align-items: center; min-height: 100dvh; justify-content: center; text-align: center; background: var(--accent); }
.win .btn { width: min(100%, 360px); }
.win .btn.primary { background: #ffd23f; }
.outro { font-weight: 800; font-size: 1.1rem; }
.boards { display: grid; gap: 12px; justify-items: center; width: min(100%, 560px); font-weight: 700; }
.boards:empty { display: none; }
.board-pair { display: grid; gap: 12px; width: 100%; }
@media (min-width: 560px) { .board-pair { grid-template-columns: 1fr 1fr; } }
.board { min-width: 0; padding: 10px 12px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; text-align: left; }
.board h3 { margin: 0 0 6px; font-size: 1.1rem; }
.board ol { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.board li { display: grid; grid-template-columns: 2.5em 1fr auto; gap: 6px; padding: 2px 6px; border-radius: 8px; }
.board li.me { background: #ffd23f; font-weight: 900; }
.board .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big-stars { font-size: 3.4rem; color: #ffd23f; -webkit-text-stroke: 2px var(--ink); animation: pop 0.6s; }
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -30px; left: var(--x); color: var(--c); font-style: normal; font-size: 1.6rem; -webkit-text-stroke: 1px var(--ink); animation: fall 3s linear var(--d) infinite; }

@keyframes bounce { 0% { transform: scale(1); } 30% { transform: scale(1.12, 0.88); } 55% { transform: scale(0.94, 1.08); } 100% { transform: scale(1); } }
@keyframes shake { 20% { translate: -12px; } 40% { translate: 12px; } 60% { translate: -8px; } 80% { translate: 8px; } }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
@keyframes pop { 0% { transform: scale(0.3); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.shake { animation: shake 0.45s; }

/* Solo verticale: su telefono in orizzontale la scena non starebbe nello schermo */
.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  #app, .overlay { display: none; }
  .rotate { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 20px; padding: 16px; background: var(--accent); font-size: 1.6rem; font-weight: 900; text-align: center; }
  .rotate svg { width: 80px; flex: none; }
}

/* ---------- privacy ---------- */
.privacy { display: grid; gap: 14px; justify-items: start; max-width: 640px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); background: var(--paper); line-height: 1.5; user-select: text; -webkit-user-select: text; }
.privacy a:not(.btn) { color: inherit; font-weight: 800; }
.privacy .btn { display: inline-flex; align-items: center; color: inherit; text-decoration: none; }
.privacy-link { align-self: center; padding: 8px; font-size: 0.85rem; font-weight: 700; color: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}
