/* ===============================================================
   BASE — carattere, colori, pagina, tipografia, elementi comuni
   a menu e minigiochi. Le schermate dei menu stanno in menu.css,
   i minigiochi in games.css.

   Restyling v1.0 (22/09/2026): palette più colorata e leggibile,
   card piene (niente vetro sfocato), scala tipografica chiara,
   sfondo disegnato da codice (macchie di colore), pulsanti grandi.
   =============================================================== */

/* Carattere del gioco: Fredoka (SIL Open Font License, vedi fonts/OFL.txt) */
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/fredoka-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/fredoka-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------------------------------------------------------------
   Colori e misure. --accent cambia col tema (theme.js); i derivati
   (--accent-dark/-light/-glow) seguono da soli.
   --------------------------------------------------------------- */
:root {
  --bg: #141a38;
  --bg-2: #1f2650;
  --card: #232b5a;
  --card-2: #2b3470;
  --text: #ffffff;
  --muted: #c7cbef;
  --accent: #ffb703;
  --accent-2: #fb5607;
  --ok: #3ddc84;
  --danger: #ff5d7a;
  --info: #4cc9f0;
  --violet: #8f6bff;
  --pink: #f15bb5;
  --teal: #36cfc9;
  --ink: #161233;                 /* testo scuro sui pulsanti chiari */
  --radius: 20px;
  --radius-s: 14px;

  --accent-dark: color-mix(in srgb, var(--accent) 72%, #000);
  --accent-light: color-mix(in srgb, var(--accent) 80%, #fff);
  --accent-glow: color-mix(in srgb, var(--accent) 45%, transparent);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --solid: rgba(20, 26, 56, 0.96);         /* elementi coprenti (barra fissa della scelta) */
  --glass: var(--card);                    /* (nome storico) card piena */
  --glass-2: var(--card-2);
  --gradient-accent: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 50%, var(--accent-dark) 100%);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* ---------------------------------------------------------------
   Pagina
   --------------------------------------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  /* La pagina non scorre mai: scorre solo #app, e solo se il contenuto è più lungo dello schermo */
  overflow: hidden;
  position: fixed;
  inset: 0;
}

/* Sfondo disegnato da codice: macchie di colore morbide sul blu profondo; un tema stagionale
   può metterci sopra la sua immagine (--bg-image). I minigiochi lo coprono con la loro area. */
body {
  background-color: var(--bg);
  background-image:
    var(--bg-image, none),
    radial-gradient(60% 40% at 15% 10%, color-mix(in srgb, var(--violet) 55%, transparent), transparent 70%),
    radial-gradient(50% 35% at 90% 20%, color-mix(in srgb, var(--teal) 40%, transparent), transparent 70%),
    radial-gradient(55% 40% at 70% 95%, color-mix(in srgb, var(--pink) 35%, transparent), transparent 70%),
    radial-gradient(45% 35% at 10% 80%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 70%);
  background-size: cover, auto, auto, auto, auto;
  background-position: center top, 0 0, 0 0, 0 0, 0 0;
  background-repeat: no-repeat;
}

#app {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

#version {
  position: fixed;
  right: 8px;
  bottom: calc(4px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--muted);
  opacity: 0.65;
  pointer-events: none;
}

/* ---------------------------------------------------------------
   Tipografia e testi comuni
   --------------------------------------------------------------- */
h1 {
  margin: 12px 0 2px;
  font-size: 46px;
  line-height: 1;
  text-align: center;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff6d5 0%, var(--accent) 50%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 14px var(--accent-glow));
}
h2 { margin: 0; font-size: 22px; line-height: 1.2; text-align: center; font-weight: 700; }
p { margin: 0; color: var(--muted); text-align: center; line-height: 1.4; }
p.small, .small { font-size: 14px; }
.label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1.2px; margin-top: 4px; }
.status { font-size: 14px; color: var(--muted); text-align: center; min-height: 1.4em; }
.error { color: var(--danger); }
.spacer { flex: 1; }

/* ---------------------------------------------------------------
   Pulsanti e campi: aspetto di base (valido anche nei minigiochi).
   L'aspetto "con luce" dei menu è in menu.css.
   --------------------------------------------------------------- */
button {
  font: inherit;
  font-size: 19px;
  font-weight: 700;
  padding: 15px 16px;
  border: none;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; }

input[type="text"] {
  width: 100%;
  font-size: 19px;
  padding: 13px 16px;
  border-radius: var(--radius-s);
  border: 2px solid var(--line-strong);
  background: rgba(10, 14, 36, 0.7);
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
input[type="range"] { accent-color: var(--accent); }

/* ---------------------------------------------------------------
   Icone dei minigiochi (immagine disegnata o emoji di riserva)
   --------------------------------------------------------------- */
img.game-icon { width: 46px; height: 46px; border-radius: 12px; display: block; }
.game-icon.emoji { font-size: 27px; text-align: center; }
img.heading-icon { width: 36px; height: 36px; border-radius: 9px; }
.heading-icon.emoji { font-size: 22px; }
img.list-icon { width: 28px; height: 28px; border-radius: 7px; flex: 0 0 auto; }
.list-icon.emoji { font-size: 18px; }
img.info-icon { width: 124px; height: 124px; border-radius: 28px; box-shadow: var(--shadow); }
.info-icon.emoji { font-size: 64px; }
img.countdown-icon { width: 128px; height: 128px; border-radius: 30px; margin: 8px 0 4px; box-shadow: var(--shadow); }
.countdown-icon.emoji { font-size: 72px; }
img.game-icon, img.list-icon, img.heading-icon { box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.with-icon { display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
h2.with-icon { width: 100%; }

/* ---------------------------------------------------------------
   Sovrapposizioni: avviso breve, coriandoli
   --------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: calc(100% - 48px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i {
  position: absolute;
  top: -14px;
  width: 9px; height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* Animazioni comuni */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.shake { animation: shake 0.25s; }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes bump { 50% { transform: scale(1.18); } }
@keyframes award-in { from { opacity: 0; transform: translateX(-16px) scale(0.96); } to { opacity: 1; transform: none; } }

/* Meno movimento per chi lo chiede nelle impostazioni del telefono o in home */
@media (prefers-reduced-motion: reduce) {
  .screen, .code-big, .podium-trophy, .confetti i, .award { animation: none !important; }
  button, .chip { transition: none; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation: none !important; transition: none !important; }
html.high-contrast { --text: #ffffff; --muted: #eef0ff; --line: rgba(255,255,255,0.3); --line-strong: rgba(255,255,255,0.45); --card: #1a2048; --card-2: #232b5a; }
html.high-contrast body { background-image: none; }
html.onehand .game-body { justify-content: flex-end; padding-bottom: 8px; }
