/* ===== Stile comune a tutto il sito ===== */
@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Rubik:wght@400;500;700&display=swap');

:root {
  --bg: #fff4dc;
  --ink: #1d1a17;
  --paper: #ffffff;
  --accent: #ff5a36;
  --accent-2: #2bb673;
  --accent-3: #ffc83d;
  --muted: #6f6659;
  --border: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Rubik', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ----- Intestazione ----- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: var(--border);
  background: var(--accent-3);
}

.logo {
  font-family: 'Bungee', sans-serif;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  text-decoration: none;
  letter-spacing: 0.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: 700 1rem 'Rubik', sans-serif;
  padding: 10px 18px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-green { background: var(--accent-2); color: #fff; }
.btn-small { padding: 6px 14px; font-size: .9rem; }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; }

/* ----- Homepage ----- */
.hero { text-align: center; margin: 12px 0 32px; }
.hero h1 {
  font-family: 'Bungee', sans-serif;
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  line-height: 1.1;
  margin: 0 0 10px;
}
.hero p { margin: 0 auto; max-width: 560px; color: var(--muted); font-size: 1.1rem; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
a.game-card:hover { transform: translate(-3px, -3px) rotate(-0.5deg); box-shadow: 8px 8px 0 var(--ink); }

.game-card .thumb {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  font-size: 3.4rem;
  border-bottom: var(--border);
}
.game-card .body { padding: 14px 16px 16px; }
.game-card h2 { font-family: 'Bungee', sans-serif; font-size: 1.15rem; margin: 0 0 4px; font-weight: 400; }
.game-card p { margin: 0; color: var(--muted); font-size: .95rem; }

.tag {
  display: inline-block;
  margin-top: 10px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--accent-3);
}

.game-card.soon { opacity: .6; }
.game-card.soon .tag { background: #e6dccb; }

/* ----- Piè di pagina ----- */
.site-footer {
  border-top: var(--border);
  padding: 20px 16px;
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
}
.site-footer .btn { margin-bottom: 10px; }

/* ----- Pagina di un gioco ----- */
.game-page main { display: flex; flex-direction: column; align-items: center; padding-top: 12px; }

.game-title {
  font-family: 'Bungee', sans-serif;
  font-weight: 400;
  font-size: clamp(1.3rem, 5vw, 2rem);
  margin: 0 0 12px;
  text-align: center;
}

.stage {
  position: relative;
  width: min(100%, 420px, calc((100dvh - 190px) * 2 / 3));
  aspect-ratio: 2 / 3;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #9fd8ff;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.stage canvas { display: block; width: 100%; height: 100%; }

/* campo più largo, per i giochi che scorrono in orizzontale */
.stage.wide {
  width: min(100%, 520px, calc((100dvh - 190px) * 4 / 5));
  aspect-ratio: 4 / 5;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(29, 26, 23, .55);
  color: #fff;
}
.overlay[hidden] { display: none; }
.overlay .card {
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  width: 100%;
  max-width: 320px;
}
.overlay h2 { font-family: 'Bungee', sans-serif; font-weight: 400; margin: 0 0 8px; font-size: 1.4rem; line-height: 1.15; }
.overlay p { margin: 0 0 10px; }
.overlay .big { font-size: 1.05rem; font-weight: 500; }
.overlay .small { font-size: .85rem; color: var(--muted); }
.overlay .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

.game-help { margin-top: 14px; color: var(--muted); font-size: .9rem; text-align: center; }

/* ----- Avviso a comparsa ----- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 500;
  transition: transform .25s;
  z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ----- Pagine di testo (privacy ecc.) ----- */
.text-page { max-width: 700px; }
.text-page h1 { font-family: 'Bungee', sans-serif; font-weight: 400; }
