:root {
  color-scheme: dark;
  --bg: #0e1114;
  --surface: #181d20;
  --surface-2: #22292d;
  --line: #334047;
  --text: #f7fbf7;
  --muted: #aab5b5;
  --accent: #27c3a2;
  --accent-2: #2f80ed;
  --danger: #eb5757;
  --focus: #f2c94c;
  --violet: #bb6bd9;
  --sport: #f2994a;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

html.light {
  color-scheme: light;
  --bg: #f0f6ff;
  --surface: #ffffff;
  --surface-2: #eaf2ff;
  --line: #c8d8eb;
  --text: #0f172a;
  --muted: #4d6178;
  --shadow: 0 18px 50px rgba(47, 128, 237, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(39, 195, 162, 0.08), transparent 32%),
    linear-gradient(215deg, rgba(242, 153, 74, 0.08), transparent 34%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 78px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

html.light body {
  background:
    linear-gradient(135deg, rgba(47, 128, 237, 0.10), transparent 32%),
    linear-gradient(215deg, rgba(39, 195, 162, 0.12), transparent 34%),
    repeating-linear-gradient(90deg, rgba(15,23,42,0.035) 0 1px, transparent 1px 78px),
    var(--bg);
}

a { color: inherit; text-decoration: none; }

main { min-height: calc(100vh - 72px); }

/* ── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  padding: 18px 24px;
  font-size: .78rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 40px;
}
.site-footer a:hover { color: var(--text); }
.site-footer-sep { color: var(--line); }

/* ── Cookie banner ──────────────────────────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: .82rem;
  color: var(--muted);
  box-shadow: var(--shadow);
  max-width: min(92vw, 560px);
  white-space: normal;
}

input, select, button {
  font: inherit;
}

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d1113;
  color: var(--text);
  padding: 11px 13px;
  outline: none;
}

html.light input, html.light select {
  background: #ffffff;
  color: var(--text);
}

input:focus, select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.16);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2.2rem, 6vw, 4.8rem); line-height: 0.92; margin-bottom: 14px; }
h2 { font-size: 1.2rem; margin-bottom: 16px; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 20, 0.92);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

html.light .topbar {
  background: rgba(255, 255, 255, 0.92);
}

.brand, .nav, .action-row, .inline-form {
  display: flex;
  align-items: center;
}

.brand { gap: 10px; font-weight: 900; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, var(--accent), var(--focus));
  color: #08110f;
  font-size: 0.86rem;
  box-shadow: 0 10px 24px rgba(39, 195, 162, 0.24);
}

html.light .brand-mark {
  color: #07110f;
}

.nav { gap: 12px; color: var(--muted); font-size: 0.95rem; }
.nav a:hover { color: var(--text); }

.lang-dropdown { position: relative; }
.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 29, 32, 0.72);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 0.76rem;
  font-weight: 900;
  box-shadow: none;
}
.lang-trigger img, .lang-option img {
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.14);
}
.lang-trigger:hover { color: var(--text); border-color: var(--accent); transform: none; }
.lang-trigger-code { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 0.68rem; }
.lang-chevron { transition: transform 160ms ease; }
.lang-dropdown.open .lang-chevron { transform: rotate(180deg); }
.lang-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 168px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 100;
}
.lang-dropdown.open .lang-menu { display: grid; gap: 2px; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}
.lang-option:hover {
  background: var(--surface-2);
  color: var(--text);
}
.lang-option--active { color: var(--accent-2); font-weight: 900; }
.lang-option-name { flex: 1; }
.lang-check { color: var(--accent-2); }

html.light .lang-trigger {
  background: rgba(255,255,255,0.78);
}

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #35dab8);
  color: #06110f;
  padding: 10px 18px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  box-shadow: 0 10px 22px rgba(39, 195, 162, 0.22);
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

/* Full-width buttons (inside .stack / .panel forms) don't clip */
.stack .button, .stack button {
  width: 100%;
  white-space: normal;
  word-break: break-word;
}

.button:hover, button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.button:disabled, button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-small { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; white-space: nowrap; }
.button-secondary { background: linear-gradient(135deg, var(--accent-2), #65a6ff); color: #f7fbff; box-shadow: 0 10px 22px rgba(47, 128, 237, 0.22); }
.button-danger { background: var(--danger); color: #fff; box-shadow: 0 8px 18px rgba(235,87,87,.22); }

.icon-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
}

.icon-button.is-off { color: var(--muted); }
html.light .icon-button { background: #ffffff; color: var(--text); }

.workspace {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 52px;
}

.hero-band, .section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.home-hero {
  min-height: 360px;
  align-items: center;
  padding: 22px 0 8px;
}

.hero-copy {
  flex: 1 1 560px;
  min-width: 0;
}

.hero-copy form {
  max-width: 610px;
  margin-top: 28px;
}

.hero-scene {
  position: relative;
  flex: 0 1 420px;
  min-height: 300px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--accent));
  border-radius: var(--radius);
  background:
    linear-gradient(150deg, rgba(47, 128, 237, 0.22), transparent 43%),
    linear-gradient(24deg, rgba(242, 201, 76, 0.22), transparent 48%),
    #151a1e;
  overflow: hidden;
  box-shadow: var(--shadow);
}

html.light .hero-scene {
  background:
    linear-gradient(150deg, rgba(47, 128, 237, 0.18), transparent 43%),
    linear-gradient(24deg, rgba(242, 201, 76, 0.24), transparent 48%),
    #ffffff;
}

.hero-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.86), transparent 95%);
}

.scene-board {
  position: absolute;
  inset: 42px 38px 62px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 54px;
  gap: 10px;
  transform: rotate(-7deg);
}

.scene-board span {
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cat) 80%, #fff 4%), color-mix(in srgb, var(--cat) 54%, #0d1113));
  border: 1px solid color-mix(in srgb, var(--cat) 78%, #fff);
  box-shadow: 0 14px 22px rgba(0,0,0,0.22);
}

.scene-dice {
  position: absolute;
  right: 34px;
  bottom: 34px;
  width: 86px;
  height: 86px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: #f7fbf7;
  box-shadow: 0 18px 32px rgba(0,0,0,0.32);
  transform: rotate(9deg);
}

html.light .scene-dice { background: #0f172a; }
html.light .scene-dice span { background: #ffffff; }

.scene-dice span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #111417;
}

.scene-dice span:nth-child(1) { grid-area: 1 / 1; }
.scene-dice span:nth-child(2) { grid-area: 1 / 3; }
.scene-dice span:nth-child(3) { grid-area: 2 / 2; }
.scene-dice span:nth-child(4) { grid-area: 3 / 1; }
.scene-dice span:nth-child(5) { grid-area: 3 / 3; }

.scene-token {
  position: absolute;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #07110f;
  font-weight: 900;
  border: 3px solid rgba(255,255,255,0.72);
  box-shadow: 0 14px 28px rgba(0,0,0,0.32);
}

.scene-token-one {
  left: 70px;
  top: 70px;
  background: var(--accent);
}

.scene-token-two {
  right: 136px;
  top: 128px;
  background: var(--focus);
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.16rem;
  line-height: 1.55;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.two-column, .three-column {
  display: grid;
  gap: 18px;
}

.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 18px 0; }

/* ── Pagina regolamento ───────────────────────────────────────────────────── */
.rules-page { padding-top: 40px; padding-bottom: 60px; }

.rules-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
}
.rules-hero-brand {
  font-size: 3.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.rules-hero-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 900; margin: 0 0 6px; }
.rules-hero-sub   { color: var(--muted); margin: 0; font-size: 1rem; }

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-bottom: 40px;
}

.rules-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px 22px 20px;
  position: relative;
  overflow: hidden;
}
.rules-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}
.rules-card--accent::before { background: var(--accent); }
.rules-card--danger::before { background: var(--danger); }
.rules-card--boss::before   { background: linear-gradient(90deg, var(--focus), var(--sport)); }
.rules-card--win::before    { background: linear-gradient(90deg, var(--accent-2), var(--violet)); }

.rules-card-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 10px;
}
.rules-card h2 { font-size: 1.15rem; font-weight: 800; margin: 0 0 10px; }
.rules-card p  { color: var(--muted); font-size: .9rem; line-height: 1.6; margin: 0; }

.rules-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.rules-cat-chip {
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
}

.rules-steps {
  padding-left: 20px;
  margin: 0;
  display: grid;
  gap: 8px;
}
.rules-steps li {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}
.rules-steps li strong { color: var(--text); }
.rules-steps--lg li { font-size: .95rem; }

.rules-guides {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  margin-bottom: 20px;
}
.rules-guide {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(47,128,237,.06), transparent 50%),
    var(--surface);
  padding: 24px;
}
.rules-guide-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 16px;
}

@media (max-width: 520px) {
  .rules-hero { flex-direction: column; text-align: center; }
  .rules-cats { justify-content: center; }
}

.panel, .player-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0)),
    var(--surface);
  padding: 22px;
  box-shadow: 0 14px 38px rgba(0,0,0,0.18);
}

.home-actions .panel {
  position: relative;
  /* overflow:hidden rimosso — clippava il testo dei bottoni */
}

.home-actions .panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--focus), var(--violet), var(--sport));
}

.stack { display: grid; gap: 14px; }
.inline-form { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 180px; min-width: 0; }
.inline-form button { flex: 0 0 auto; min-width: 130px; white-space: nowrap; }
.quick-code { min-width: min(420px, 100%); }

.auth-shell, .player-shell {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel { width: min(440px, 100%); }

.flash-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 0;
}

.flash {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}

.session-list { display: grid; gap: 10px; }
.session-row, .row-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.session-row span, .muted, small { color: var(--muted); }
.session-row strong { display: block; margin-bottom: 3px; }
.session-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.session-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 3px; }
.badge-code { font-family: monospace; font-weight: 700; color: var(--accent); }
.badge-status { font-size: .72rem; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.badge-status--lobby    { background: rgba(99,102,241,.18); color: #818cf8; }
.badge-status--playing  { background: rgba(34,197,94,.18); color: #4ade80; }
.badge-status--finished { background: rgba(148,163,184,.18); color: #94a3b8; }

.game-shell {
  display: grid;
  grid-template-columns: 310px 1fr;
  min-height: calc(100vh - 72px);
  background:
    linear-gradient(120deg, rgba(47, 128, 237, 0.06), transparent 34%),
    linear-gradient(280deg, rgba(39, 195, 162, 0.06), transparent 38%);
}

.host-side {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent),
    var(--surface);
  padding: 24px;
}

.host-side h1 { font-size: 1.9rem; line-height: 1.1; }

.code-box {
  display: grid;
  place-items: center;
  height: 82px;
  border: 1px solid color-mix(in srgb, var(--focus) 45%, var(--line));
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, rgba(242,201,76,0.08) 0 1px, transparent 1px 18px),
    #0f1316;
  margin: 18px 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

html.light .code-box {
  background:
    repeating-linear-gradient(90deg, rgba(47,128,237,0.08) 0 1px, transparent 1px 18px),
    #ffffff;
}

.code-box span {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.qr {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  box-shadow: 0 14px 28px rgba(0,0,0,0.22);
}

.copy-field { margin: 12px 0; font-size: 0.82rem; }
.control-stack { display: grid; gap: 10px; margin-top: 14px; }
.control-stack .button,
.control-stack button { width: 100%; white-space: normal; word-break: break-word; }

/* ── Bottone "next action" — lampeggio outline (non interferisce con box-shadow) */
@keyframes host-btn-pulse {
  0%   { outline-offset: 1px;  outline-color: rgba(39,195,162,.95); }
  50%  { outline-offset: 7px;  outline-color: rgba(39,195,162,.05); }
  100% { outline-offset: 1px;  outline-color: rgba(39,195,162,.95); }
}
@keyframes host-btn-pulse-blue {
  0%   { outline-offset: 1px;  outline-color: rgba(47,128,237,.95); }
  50%  { outline-offset: 7px;  outline-color: rgba(47,128,237,.05); }
  100% { outline-offset: 1px;  outline-color: rgba(47,128,237,.95); }
}
/* Verde (Start, Next, Boss) */
.control-stack .is-next-action {
  outline: 3px solid rgba(39,195,162,.95);
  animation: host-btn-pulse 1.1s ease-in-out infinite;
}
/* Blu (Roll Dice = button-secondary) */
.control-stack .button-secondary.is-next-action {
  outline: 3px solid rgba(47,128,237,.95);
  animation: host-btn-pulse-blue 1.1s ease-in-out infinite;
}

/* ── Avatar giocatore di turno nella status strip ────────────────────────── */
.host-player-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 10px 4px 5px;
  font-size: .9rem;
}
.host-player-token {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--surface-2);
  flex-shrink: 0;
}

.game-main { padding: 20px; overflow: hidden; }

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-strip span, .metric {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), transparent),
    var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--muted);
}

.status-strip strong, .metric strong { display: block; color: var(--text); font-size: 1.1rem; }

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(74px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 19, 0.54);
}

html.light .board { background: rgba(255,255,255,0.62); }

.cell {
  min-height: 86px;
  display: grid;
  align-content: space-between;
  border: 1px solid color-mix(in srgb, var(--cat) 82%, #000);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cat) 42%, #fff 3%), color-mix(in srgb, var(--cat) 22%, var(--surface)) 48%, var(--surface));
  padding: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 16px rgba(0,0,0,0.16);
}

.cell-index { color: var(--muted); font-size: 0.74rem; }
.cell strong { font-size: 0.86rem; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.25); }

.tokens { min-height: 24px; display: flex; gap: 4px; flex-wrap: wrap; }
.token {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  color: #06110f;
  font-weight: 900;
  font-size: 0.78rem;
  border: 2px solid rgba(255,255,255,0.72);
  box-shadow: 0 8px 14px rgba(0,0,0,0.26);
}

.play-area {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 16px;
}

.question-panel, .score-panel {
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0)),
    var(--surface);
  padding: 20px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.16);
}

.option-grid, .mobile-options { display: grid; gap: 10px; }
.question-media {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1316;
  overflow: hidden;
}
html.light .question-media { background: #ffffff; }
.question-media img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}
.mobile-media img { max-height: 160px; }
.option {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035), transparent),
    var(--surface-2);
}
.option.is-correct {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.result { font-size: 2rem; font-weight: 900; }
.correct { color: var(--accent); }
.wrong, .error { color: var(--danger); }

.score-list { display: grid; gap: 10px; }
.score-row, .self-score {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
}

.player-page .topbar { display: none; }

/* Footer e cookie banner non devono apparire sulla pagina di gioco mobile */
.player-page .site-footer,
.player-page .cookie-banner { display: none !important; }
.player-top-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Player shell — layout mobile corretto ────────────────────────────────── */
.player-shell {
  min-height: 100dvh;           /* dvh: esclude la toolbar del browser su iOS */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 56px 14px 20px;      /* 56px top: spazio per i controlli fissi */
  gap: 0;
  overflow-y: auto;
  background:
    linear-gradient(145deg, rgba(39, 195, 162, 0.12), transparent 34%),
    linear-gradient(310deg, rgba(242, 201, 76, 0.10), transparent 34%),
    var(--bg);
}
html.light .player-shell {
  background:
    linear-gradient(145deg, rgba(39, 195, 162, 0.14), transparent 34%),
    linear-gradient(310deg, rgba(242, 201, 76, 0.14), transparent 34%),
    var(--bg);
}

/* Join card — centrata verticalmente quando c'è spazio, scorrevole se non c'è */
#joinCard {
  width: min(460px, 100%);
  border-color: color-mix(in srgb, var(--line) 72%, var(--accent));
  margin: auto 0;    /* centra verticalmente solo quando il contenuto è più corto */
}

/* Game card — prende tutto lo spazio disponibile rimanente */
#playerGame {
  width: min(460px, 100%);
  border-color: color-mix(in srgb, var(--line) 72%, var(--accent));
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.player-card {
  width: min(480px, 100%);
  border-color: color-mix(in srgb, var(--line) 72%, var(--accent));
}
.hidden { display: none !important; }

/* ── Avatar picker (form join) ──────────────────────────────────────────────── */
.avatar-pick-label {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);   /* sempre 6 colonne — compatto su mobile */
  gap: 5px;
  margin-bottom: 4px;
}
.avatar-opt {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  font-size: 1.3rem;               /* leggermente più piccolo per stare su 6 colonne */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
  cursor: pointer;
}
.avatar-opt:hover,
.avatar-opt:active  { border-color: var(--accent); transform: scale(1.1); }
.avatar-opt.is-av-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.avatar-opt--random {
  grid-column: 1 / -1;      /* larghezza piena — riga dedicata ben tappabile */
  aspect-ratio: auto;
  font-size: .9rem;
  padding: 8px;
  font-weight: 700;
  letter-spacing: .02em;
}

.player-status {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(13, 17, 19, 0.58);
}

html.light .player-status { background: rgba(255,255,255,0.72); }

.mobile-question {
  flex: 1;          /* prende lo spazio disponibile nel game card flex */
  overflow-y: auto; /* scorre se la domanda è lunga */
  padding-bottom: 8px;
}
.mobile-question h2 { font-size: 1.3rem; line-height: 1.25; }
.mobile-options button {
  width: 100%;
  min-height: 56px;
  text-align: left;
  background:
    linear-gradient(90deg, rgba(47,128,237,0.16), transparent),
    var(--surface-2);
  color: var(--text);
  border: 2px solid var(--line);
  box-shadow: none;
  transition: border-color .2s, box-shadow .2s;
}

/* ── Animazioni turno / steal ─────────────────────────────────────────────── */
@keyframes pulse-active {
  0%, 100% { border-color: var(--accent);
              box-shadow: 0 0 0 0 rgba(39,195,162,.45); }
  50%       { border-color: #35dab8;
              box-shadow: 0 0 0 8px rgba(39,195,162,0); }
}
@keyframes pulse-steal {
  0%, 100% { border-color: var(--danger);
              box-shadow: 0 0 0 0 rgba(235,87,87,.45); }
  50%       { border-color: #ff7070;
              box-shadow: 0 0 0 8px rgba(235,87,87,0); }
}
@keyframes pulse-boss {
  0%, 100% { border-color: var(--focus);
              box-shadow: 0 0 0 0 rgba(242,201,76,.45); }
  50%       { border-color: #f2c94c;
              box-shadow: 0 0 0 8px rgba(242,201,76,0); }
}
@keyframes pulse-scale {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-options.is-active button {
  animation: pulse-active 1.4s ease-in-out infinite;
  background:
    linear-gradient(90deg, rgba(39,195,162,.18), transparent),
    var(--surface-2);
}
.mobile-options.is-steal button {
  animation: pulse-steal 1.1s ease-in-out infinite;
  background:
    linear-gradient(90deg, rgba(235,87,87,.14), transparent),
    var(--surface-2);
}
.mobile-options.is-boss button {
  animation: pulse-boss 1.2s ease-in-out infinite;
  background:
    linear-gradient(90deg, rgba(242,201,76,.14), transparent),
    var(--surface-2);
}

/* ── Banner "È il tuo turno" ─────────────────────────────────────────────── */
.my-turn-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--accent), #35dab8);
  color: #06110f;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 900;
  font-size: 1.05rem;
  text-align: center;
  margin-bottom: 16px;
  animation: slide-in .3s ease both;
}
.my-turn-banner.steal {
  background: linear-gradient(135deg, var(--danger), #ff7070);
  color: #fff;
}
.my-turn-banner.boss {
  background: linear-gradient(135deg, var(--focus), var(--sport));
  color: #111;
}

/* ── "Sta giocando" — chi è di turno visibile agli altri ─────────────────── */
.now-playing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px 20px;
  animation: slide-in .3s ease both;
}
.now-playing-token {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  background: var(--surface-2);
  animation: pulse-scale 2.2s ease-in-out infinite;
}
.now-playing-name {
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
}
.now-playing-hint {
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

/* ── Avatar piccolo nel banner (usato col my-turn) ───────────────────────── */
.turn-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(0,0,0,.12);
  flex-shrink: 0;
}

.mobile-score { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 920px) {
  .topbar { height: auto; align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .nav { flex-wrap: wrap; }
  .hero-band, .section-head { display: grid; }
  .home-hero { min-height: auto; }
  .hero-scene { min-height: 240px; width: 100%; }
  .scene-board { inset: 34px 28px 50px; grid-auto-rows: 42px; }
  .scene-dice { width: 70px; height: 70px; right: 26px; bottom: 26px; }
  .two-column, .three-column, .play-area, .metric-grid { grid-template-columns: 1fr; }
  .game-shell { grid-template-columns: 1fr; }
  .host-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .qr { max-width: 220px; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(4, minmax(70px, 1fr)); }
}

@media (max-width: 520px) {
  .workspace { width: min(100% - 20px, 1180px); padding: 22px 0; }
  .inline-form { display: grid; }
  .inline-form input, .inline-form button { width: 100%; min-width: 0; }
  .session-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .session-actions { width: 100%; }

  /* Player mobile compatto ─────────────────────────────────── */
  .player-shell { padding: 52px 10px 16px; }
  #joinCard, #playerGame { border-radius: 10px; }
  .panel.player-card, #joinCard, #playerGame { padding: 16px 14px; }
  .avatar-opt { font-size: 1.1rem; }
  .mobile-question h2 { font-size: 1.15rem; }
  .mobile-options button { min-height: 50px; font-size: .95rem; }
  .player-status { padding: 8px; font-size: .8rem; }
  .now-playing-token { width: 64px; height: 64px; font-size: 2rem; }
  .my-turn-banner { font-size: .95rem; padding: 10px 12px; }
  .hero-scene { min-height: 210px; }
  .scene-board { grid-template-columns: repeat(3, 1fr); }
  .scene-token { width: 38px; height: 38px; }
  .scene-token-one { left: 44px; top: 58px; }
  .scene-token-two { right: 104px; top: 96px; }
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cell { min-height: 78px; }
}

/* Lobby & Dice Additions */
.lobby-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
}
.lobby-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  padding: 8px 12px 8px 8px;
  border-radius: 30px;
  border: 1px solid var(--line);
  font-weight: bold;
}
.dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}
.dice-shake {
  animation: dice-shake 0.2s ease-in-out infinite alternate;
  text-shadow: 0 0 20px rgba(255,255,255,0.5);
}
.dice-final {
  animation: dice-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  text-shadow: 0 0 40px rgba(255,255,255,0.8);
}
@keyframes dice-shake {
  0% { transform: rotate(-15deg) scale(0.9); }
  100% { transform: rotate(15deg) scale(1.1); }
}
@keyframes dice-pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.visual-dice {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  padding: 18px;
  border-radius: var(--radius);
  background: #f7fbf7;
  box-shadow: 0 18px 32px rgba(0,0,0,0.32);
  width: 160px;
  height: 160px;
}
html.light .visual-dice { background: #0f172a; }
html.light .visual-dice span { background: #ffffff !important; }
