/* Font locali, ridotti ai soli caratteri usati dal gioco (44 KB in tutto) */
@font-face { font-family: 'Shrikhand'; src: url('fonts/shrikhand-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('fonts/figtree-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('fonts/figtree-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('fonts/figtree-800.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('fonts/figtree-900.woff2') format('woff2'); font-weight: 900; font-style: normal; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
/* Layout: un palcoscenico a schermo pieno; il nastro trasportatore taglia lo schermo, HUD in alto, pannelli sovrapposti al centro.
   Tema unico voluto: blu cobalto luminoso, leggibile anche al sole in piazza. */
:root {
  --blu: #1739B0;
  --blu-scuro: #0F2580;
  --blu-notte: #0A1A5C;
  --pasta: #F2B73A;
  --pasta-luce: #FFDD86;
  --pasta-ombra: #C9862A;
  --pesto: #35D663;
  --pesto-scuro: #17923C;
  --panna: #FFF7E6;
  --panna-dim: rgba(255, 247, 230, .72);
  --pomodoro: #FF5B3A;
  --oro: #FFE14D;
  --f-display: 'Shrikhand', Georgia, 'Times New Roman', serif;
  --f-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html {
  height: 100%; background: var(--blu-scuro);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-text-size-adjust: 100%;
}
body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--blu); color: var(--panna);
  font-family: var(--f-body); font-size: 16px;
}
#stage {
  position: relative; height: 100%; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Cielo: due livelli che si danno il cambio, opacità guidata da game.js (composizione GPU, niente ridisegno) */
.sky { position: absolute; inset: 0; pointer-events: none; background: var(--blu-scuro); }
.sky i { position: absolute; inset: 0; background: center 62% / cover no-repeat; }
#skyA { background-image: url(img/sky-day.webp); }
#skyB { opacity: 0; will-change: opacity; }
/* Veli per il contrasto al sole: in alto sotto l'HUD, in mezzo dietro al nastro, in basso sotto il suggerimento */
.sky .veil {
  background: linear-gradient(to bottom,
    rgba(10, 26, 92, .62) 0%, rgba(10, 26, 92, 0) 17%,
    rgba(10, 26, 92, 0) 33%, rgba(10, 26, 92, .5) 42%, rgba(10, 26, 92, .5) 66%,
    rgba(10, 26, 92, .15) 78%, rgba(10, 26, 92, .55) 100%);
}

/* HUD */
.hud {
  position: absolute; top: 0; left: 0; right: 0; pointer-events: none;
  padding-block: 12px 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 8px;
}
.hud-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.lbl {
  display: block; font-size: .7rem; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--panna-dim);
}
.num { font-weight: 900; font-size: 2.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.timer { text-align: right; }
.combo {
  align-self: center; display: flex; align-items: baseline; gap: 6px;
  background: var(--pasta); color: var(--blu-notte);
  padding: 4px 14px 6px; border-radius: 999px; box-shadow: 0 3px 0 var(--pasta-ombra);
}
.combo b { font-family: var(--f-display); font-weight: 400; font-size: 1.5rem; line-height: 1; }
.combo span { font-weight: 800; font-size: .8rem; }
.combo.bump { animation: bump .28s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); } }
.tbar { height: 7px; border-radius: 99px; background: rgba(255, 247, 230, .16); overflow: hidden; }
.tbar i { display: block; height: 100%; background: var(--panna); transform-origin: left center; }
.hud.low .tbar i { background: var(--pomodoro); }
.hud.low .timer .num { color: var(--pomodoro); }
.pesto {
  justify-self: center; margin: 2px 0 0; padding: 4px 14px 5px; border-radius: 999px;
  background: var(--oro); color: var(--blu-notte); font-weight: 900; font-size: .85rem;
  letter-spacing: .06em; text-transform: uppercase; animation: pulse .5s ease-in-out infinite;
}
.hud.pesto-on .tbar i { background: var(--oro); }

.hint {
  position: absolute; left: 0; right: 0; bottom: 22px; margin: 0; pointer-events: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  text-align: center; font-weight: 800; font-size: 1.05rem; color: var(--panna);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

/* Pannelli */
.panel {
  position: absolute; inset: 0; display: grid; place-items: center; overflow-y: auto;
  padding-block: 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(10, 26, 92, .58);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  touch-action: pan-y;
}
.card {
  width: min(100%, 420px); box-sizing: border-box;
  background: var(--blu-notte); border: 2px solid rgba(255, 247, 230, .14);
  border-radius: 24px; padding: 22px 20px; display: grid; gap: 14px;
}
.eyebrow { margin: 0; font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--pesto); }
h1 {
  margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 2.35rem; line-height: 1.02;
  color: var(--pasta-luce); text-wrap: balance;
}
.lead { margin: 0; font-size: 1rem; line-height: 1.45; color: var(--panna-dim); max-width: 60ch; }
.lead b { color: var(--panna); }

.demo { position: relative; display: grid; gap: 8px; padding: 26px 4px 6px; }
.demo-gauge { position: relative; height: 8px; border-radius: 99px; background: rgba(255, 247, 230, .16); }
.demo-zone { position: absolute; top: -2px; bottom: -2px; right: 60%; width: 16%; border-radius: 99px; background: var(--pesto); }
.demo-ptr {
  position: absolute; top: -12px; right: 0; width: 0; height: 0; transform: translateX(50%);
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 10px solid var(--panna);
  animation: ptr 2.6s ease-in infinite;
}
.demo-tube {
  position: relative; height: 34px; border-radius: 12px 17px 17px 12px; overflow: hidden;
  background: linear-gradient(var(--pasta-luce), var(--pasta) 45%, var(--pasta-ombra));
}
.demo-fill { position: absolute; top: 0; bottom: 0; right: 0; width: 0; background: var(--pesto); opacity: .85; animation: fill 2.6s ease-in infinite; }
.demo::after {
  content: 'Perfetto!'; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  font-family: var(--f-display); font-size: 1.05rem; color: var(--pesto); opacity: 0;
  animation: ok 2.6s infinite;
}
@keyframes fill { 0% { width: 0; } 55%, 85% { width: 68%; } 100% { width: 68%; opacity: 0; } }
@keyframes ptr { 0% { right: 0; } 55%, 85% { right: 68%; } 100% { right: 68%; opacity: 0; } }
@keyframes ok { 0%, 54% { opacity: 0; } 58%, 86% { opacity: 1; } 100% { opacity: 0; } }

.who {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 16px; background: rgba(255, 247, 230, .07);
}
.who strong { display: block; font-size: 1.15rem; font-weight: 900; color: var(--panna); }
button { font: inherit; cursor: pointer; }
.ghost {
  flex: none; border: 2px solid rgba(255, 247, 230, .3); background: transparent; color: var(--panna);
  border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: .85rem;
}
.cta {
  border: 0; border-radius: 999px; padding: 18px 20px; width: 100%;
  background: var(--pesto); color: var(--blu-notte); font-weight: 900; font-size: 1.2rem;
  box-shadow: 0 5px 0 var(--pesto-scuro); transition: transform .06s, box-shadow .06s;
}
.cta:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--pesto-scuro); }
.cta:disabled { opacity: .45; }
button:focus-visible { outline: 3px solid var(--pasta-luce); outline-offset: 3px; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: .9rem; color: var(--panna-dim); }
.foot b { color: var(--panna); font-variant-numeric: tabular-nums; }
.link { background: none; border: 0; color: var(--panna); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }

.rname { margin: 0; font-weight: 800; color: var(--panna-dim); }
.big {
  margin: 0; font-family: var(--f-display); font-size: 4rem; line-height: .95; color: var(--pasta-luce);
  font-variant-numeric: tabular-nums;
}
.near { margin: 0; font-weight: 800; font-size: 1.05rem; line-height: 1.35; color: var(--pesto); }
.stats { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: rgba(255, 247, 230, .07); border-radius: 14px; padding: 10px 12px; }
.stats dt { font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--panna-dim); }
.stats dd { margin: 2px 0 0; font-weight: 900; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.board .lbl em { font-style: normal; color: var(--pasta); letter-spacing: .06em; margin-left: 6px; }
.board ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.board li {
  display: grid; grid-template-columns: 1.6rem 1fr auto; gap: 8px; align-items: baseline;
  padding: 7px 10px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.board li span:first-child { color: var(--panna-dim); font-weight: 800; }
.board li span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li b { font-weight: 900; }
.board li.me { background: var(--pasta); color: var(--blu-notte); }
.board li.me span:first-child { color: var(--blu-notte); }
.pb { margin: 0; font-size: .9rem; color: var(--panna-dim); text-align: center; }
details { font-size: .85rem; color: var(--panna-dim); }
summary { cursor: pointer; font-weight: 700; }
pre {
  margin: 8px 0 0; padding: 10px; border-radius: 10px; background: rgba(0, 0, 0, .25);
  overflow-x: auto; font-size: .78rem; line-height: 1.4; color: var(--panna);
}

@media (prefers-reduced-motion: reduce) {
  .hint, .demo-fill, .demo-ptr, .demo::after, .combo.bump { animation: none; }
  .demo-fill { width: 68%; } .demo-ptr { right: 68%; } .demo::after { opacity: 1; }
}
