html, body { height: 100%; overflow: hidden; }
.game {
  height: 100%; display: flex; flex-direction: column; gap: 10px;
  max-width: 640px; margin: 0 auto;
  padding: calc(8px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
}
.top { display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; gap: 10px; flex: none; }
.title {
  justify-self: center; height: 46px; padding: 0 18px 0 20px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 17px; font-weight: 700; letter-spacing: .005em;
  transition: transform .35s var(--spring);
}
.title:active { transform: scale(.94); transition-duration: .08s; }
.title svg { width: 16px; height: 16px; opacity: .7; }

/* Barra con vite, tempo, frecce rimaste */
.hud {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 58px; padding: 0 18px; border-radius: 22px;
}
.hearts { display: flex; gap: 6px; }
.hearts svg { width: 22px; height: 22px; transition: transform .3s var(--spring), opacity .3s, filter .3s;  }
.hearts svg.lost { opacity: .18; transform: scale(.78); filter: none; }
.hearts svg.pop { animation: heartpop .5s; }
@keyframes heartpop { 30% { transform: scale(1.3); } 100% { transform: scale(.78); } }
.timer { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; letter-spacing: .01em; }
.timer.run { color: var(--text); }
.left { text-align: right; color: var(--muted); font-size: 14px; font-weight: 500; }
.left span { color: var(--text); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 3px; }

/* La griglia: vetro scuro, le frecce sono l'unica luce */
.board {
  flex: 1; position: relative; min-height: 0; border-radius: 32px; overflow: hidden;
  background: linear-gradient(170deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, .4));
  -webkit-backdrop-filter: blur(26px) saturate(130%); backdrop-filter: blur(26px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, .85);
  box-shadow: inset 0 1px 0 #fff, 0 14px 36px rgba(110, 84, 48, .1);
}
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board.shake { animation: shake .34s; }
.board.hit { box-shadow: inset 0 1px 0 #fff, inset 0 0 50px rgba(214, 80, 93, .12), 0 14px 36px rgba(110, 84, 48, .1); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.bottom { flex: none; display: flex; justify-content: center; }
.bottom .btn { min-width: 160px; }
.badge {
  min-width: 24px; height: 24px; border-radius: 12px; padding: 0 7px;
  background: var(--amber); color: #fff; font-size: 13px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.badge.empty { background: var(--faint); color: var(--muted); box-shadow: none; }

/* ---------- Finestre ---------- */
.demo { width: 170px; margin: -4px auto 12px; }
.demo-arrow { animation: demo 2.6s cubic-bezier(.55, 0, .8, .4) infinite; }
@keyframes demo { 0%, 35% { transform: none; opacity: 1; } 70% { transform: translateX(80px); opacity: 0; } 71% { transform: none; opacity: 0; } 100% { opacity: 1; } }

.stars { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: -6px 0 14px; filter: drop-shadow(0 3px 6px rgba(110, 84, 48, .15)); }
.stars i {
  width: 46px; height: 46px; background: rgba(44, 49, 64, .1);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  transform: scale(.6) rotate(-20deg); transition: transform .55s var(--spring), background .2s, filter .3s;
}
.stars i:nth-child(2) { width: 60px; height: 60px; }
.stars i.on { background: var(--amber); transform: none; }

.result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 6px; }
.result div { border-radius: 18px; padding: 12px 4px; background: rgba(245, 239, 227, .7); box-shadow: inset 0 0 0 1px rgba(110, 84, 48, .08); }
.result small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.result b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result .rec b { color: var(--cyan); }
.lock { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 35%, transparent); }

.levels-card { max-height: calc(100dvh - 48px); display: flex; flex-direction: column; }
.daily {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  border: 1px solid rgba(255, 255, 255, .4); border-radius: 22px; padding: 16px 18px; margin: 14px 0 16px; cursor: pointer;
  background: var(--violet); color: #fff; text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 20px color-mix(in srgb, var(--violet) 30%, transparent);
  transition: transform .35s var(--spring);
}
.daily:active { transform: scale(.96); transition-duration: .08s; }
.daily b { font-size: 17px; }
.daily small { display: block; opacity: .85; font-size: 13.5px; }
.level-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  overflow-y: auto; padding: 4px; margin: 0 -4px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.level-grid button {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 16px; cursor: pointer;
  background: rgba(245, 239, 227, .8); box-shadow: inset 0 0 0 1px rgba(110, 84, 48, .08);
  font-weight: 700; font-size: 18px; display: grid; place-items: center; align-content: center;
  transition: transform .3s var(--spring);
}
.level-grid button:active { transform: scale(.9); transition-duration: .06s; }
.level-grid button small { font-size: 9px; letter-spacing: 1px; color: var(--amber); line-height: 1; height: 10px; }
.level-grid button.done { background: color-mix(in srgb, var(--cyan) 14%, #fff); }
.level-grid button.current { background: var(--cyan); color: #fff; }
.level-grid button.current small { color: #fff; }
.level-grid button[disabled] { opacity: .3; }

/* i livelli entrano a cascata quando si apre l'elenco */
.overlay.show .level-grid button { animation: rise .45s cubic-bezier(.2, .9, .25, 1.05) backwards; animation-delay: calc(var(--i, 0) * 18ms + 120ms); }
