/* ==========================================================================
   Sala giochi (js/giochi.js): la pagina con le schede e il gioco a tutto schermo
   ========================================================================== */

/* ---------- pagina ---------- */
/* stessi margini delle altre pagine (.content.wide in style.css) */
.gx-hub { max-width: 1180px; margin: 0 auto; padding: 56px 48px 120px; }
@media (max-width: 980px) { .gx-hub { padding: 36px 20px 100px; } }
.gx-head { margin-bottom: 26px; }
.gx-kicker { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.gx-head h1 { margin: 0; font-family: var(--font-display); font-weight: 650; letter-spacing: -0.025em; color: var(--ink); }
.gx-sub { margin: 8px 0 0; color: var(--ink-2); font-size: 15px; max-width: 46ch; }

.gx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; perspective: 1100px; }
.gx-card {
  --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 0%;
  position: relative; display: flex; flex-direction: column; min-height: 268px;
  border-radius: 22px; overflow: hidden; text-decoration: none; color: #fff;
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--b) 55%, transparent), transparent 70%),
    linear-gradient(160deg, var(--a), color-mix(in srgb, var(--a) 45%, #141018));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 18px 40px -22px color-mix(in srgb, var(--a) 70%, #000), 0 2px 6px rgba(0, 0, 0, 0.12);
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
  animation: gxRise 0.5s var(--ease) both; animation-delay: calc(var(--i) * 45ms);
}
.gx-card::after { /* riflesso che segue il puntatore */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 50% at var(--mx) var(--my), rgba(255, 255, 255, 0.22), transparent 70%);
  opacity: 0; transition: opacity 0.3s;
}
.gx-card:hover::after { opacity: 1; }
.gx-card:hover { transition-duration: 0.12s; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 26px 50px -22px color-mix(in srgb, var(--a) 80%, #000), 0 2px 6px rgba(0, 0, 0, 0.12); }
.gx-card:active { transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(0.98); }
.gx-card:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.gx-art { flex: 1; display: grid; place-items: center; padding: 22px 26px 6px; transform: translateZ(30px); }
.gx-art svg { width: 100%; max-width: 190px; height: 132px; filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.28)); transition: transform 0.5s var(--ease); }
.gx-card:hover .gx-art svg { transform: translateY(-4px) scale(1.03); }
.gx-meta { display: flex; flex-direction: column; gap: 2px; padding: 0 18px 16px; transform: translateZ(18px); }
.gx-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.18); }
.gx-tag { font-size: 13px; opacity: 0.86; }
.gx-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.22); font-size: 12px; }
.gx-best { opacity: 0.9; }
.gx-best b { font-variant-numeric: tabular-nums; }
.gx-top { opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.gx-top span { font-weight: 700; }

.gx-board { margin-top: 34px; padding: 20px; border-radius: var(--r-tray); background: var(--fill); border: 1px solid var(--stroke); }
.gx-board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gx-board-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; letter-spacing: -0.015em; color: var(--ink); }
.gx-status { font-size: 12px; color: var(--ink-3); }
.gx-offline .gx-status { color: var(--hint); }
.gx-tabs { display: flex; gap: 6px; margin: 14px 0 10px; overflow-x: auto; scrollbar-width: none; }
.gx-tab { flex: none; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--stroke-2); background: transparent; color: var(--ink-2); font: 600 13px var(--font); cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.gx-tab[aria-selected="true"] { background: var(--a); border-color: var(--a); color: #fff; }
.gx-list { list-style: none; margin: 0; padding: 0; }
.gx-row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; color: var(--ink); font-size: 15px; }
.gx-row + .gx-row { border-top: 1px solid var(--stroke); }
.gx-row.me { background: var(--fill-2); border-top-color: transparent; }
.gx-row.me + .gx-row { border-top-color: transparent; }
.gx-row.gx-gap { margin-top: 10px; border-top: 0; }
.gx-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.gx-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-pos, .gx-medal { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.gx-medal { color: #3b2a00; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 4px rgba(0, 0, 0, 0.18); }
.gx-medal.m1 { background: linear-gradient(160deg, #ffe58a, #e6b62f); }
.gx-medal.m2 { background: linear-gradient(160deg, #f1f3f6, #b9c0ca); color: #2c3138; }
.gx-medal.m3 { background: linear-gradient(160deg, #f4c69b, #c98650); color: #3a2010; }
.gx-unit { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); text-align: right; }
.gx-empty { margin: 14px 4px; color: var(--ink-3); font-size: 14px; }

@keyframes gxRise { from { opacity: 0; transform: translateY(14px) rotateX(8deg); } }

/* ---------- gioco a tutto schermo ---------- */
html.gx-open, html.gx-open body { overflow: hidden; overscroll-behavior: none; }
.gx-play {
  position: fixed; inset: 0; z-index: 3000; overflow: hidden;
  background: radial-gradient(140% 90% at 50% 0%, color-mix(in srgb, var(--b) 40%, #16121e), #0d0b12 75%);
  color: #fff; font-family: var(--font);
  opacity: 0; transform: scale(1.02); transition: opacity 0.26s ease, transform 0.36s var(--ease);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.gx-play.in { opacity: 1; transform: none; }
.gx-stage { position: absolute; inset: 0; touch-action: none; }
.gx-stage canvas { display: block; width: 100% !important; height: 100% !important; }

.gx-hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2; pointer-events: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: calc(12px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) 0 calc(14px + env(safe-area-inset-left, 0px));
}
.gx-hud-r { justify-self: end; display: flex; gap: 8px; }
.gx-btn {
  pointer-events: auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(20, 16, 28, 0.32); color: #fff; cursor: pointer;
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  transition: transform 0.15s, background 0.2s;
}
.gx-btn:hover { background: rgba(20, 16, 28, 0.5); }
.gx-btn:active { transform: scale(0.92); }
.gx-btn svg { width: 20px; height: 20px; }
.gx-pause { visibility: hidden; }
.gx-play.playing .gx-pause { visibility: visible; }
.gx-score { text-align: center; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35); }
.gx-score b { display: block; font-family: var(--font-display); font-size: clamp(40px, 9vw, 64px); font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.gx-score b.bump { animation: gxBump 0.28s var(--ease); }
.gx-score span { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; opacity: 0.75; letter-spacing: 0.02em; }
@keyframes gxBump { 40% { transform: scale(1.16); } }

.gx-card-over {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(80% 60% at 50% 55%, rgba(10, 8, 16, 0.25), rgba(10, 8, 16, 0.6));
  opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0s 0.3s;
}
.gx-card-over.show { opacity: 1; visibility: visible; transition: opacity 0.3s ease; }
.gx-panel {
  width: min(360px, 100%); padding: 26px 24px 20px; border-radius: 26px; text-align: center;
  background: rgba(24, 20, 32, 0.55); border: 1px solid rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.12) inset;
  transform: translateY(12px) scale(0.97); transition: transform 0.4s var(--ease);
  max-height: calc(100dvh - 48px); overflow-y: auto;
}
.gx-card-over.show .gx-panel { transform: none; }
.gx-panel .gx-kicker { color: rgba(255, 255, 255, 0.6); }
.gx-panel h2 { margin: 0 0 10px; font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -0.03em;
  background: linear-gradient(120deg, #fff, color-mix(in srgb, var(--b) 60%, #fff)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gx-hint { margin: 0 0 18px; font-size: 14px; line-height: 1.45; color: rgba(255, 255, 255, 0.78); }
.gx-loading { margin: 6px 0 4px; font-size: 14px; color: rgba(255, 255, 255, 0.7); }
.gx-keys { margin: 10px 0 0; font-size: 11px; color: rgba(255, 255, 255, 0.45); }
@media (hover: none) { .gx-keys { display: none; } }
.gx-go, .gx-ghost { display: block; width: 100%; padding: 13px; border-radius: 14px; font: 700 16px var(--font); cursor: pointer; transition: transform 0.15s, filter 0.2s; }
.gx-go { border: 0; color: #fff; background: linear-gradient(135deg, var(--a), var(--b)); box-shadow: 0 10px 24px -10px var(--a), 0 1px 0 rgba(255, 255, 255, 0.35) inset; }
.gx-go:hover { filter: brightness(1.08); }
.gx-go:active, .gx-ghost:active { transform: scale(0.97); }
.gx-ghost { margin-top: 8px; border: 1px solid rgba(255, 255, 255, 0.16); background: transparent; color: rgba(255, 255, 255, 0.85); }
.gx-final { font-family: var(--font-display); font-size: 68px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.gx-final.rec { background: linear-gradient(120deg, #fff3b0, var(--b), var(--a)); -webkit-background-clip: text; background-clip: text; color: transparent; animation: gxRec 0.7s var(--ease) both; }
@keyframes gxRec { from { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); } }
.gx-sub2 { margin: 8px 0 14px; font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.gx-mini { margin: 0 0 16px; text-align: left; }
.gx-mini .gx-row { color: #fff; font-size: 14px; padding: 7px 8px; }
.gx-mini .gx-row + .gx-row { border-top-color: rgba(255, 255, 255, 0.08); }
.gx-mini .gx-row.me { background: rgba(255, 255, 255, 0.1); }
.gx-mini .gx-pos { color: rgba(255, 255, 255, 0.5); }
.gx-mini .gx-empty, .gx-mini .gx-unit { color: rgba(255, 255, 255, 0.5); }
.gx-mini .gx-unit { display: none; }

@media (max-width: 560px) {
  .gx-hub { padding: 28px 16px 90px; }
  .gx-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .gx-card { min-height: 220px; border-radius: 18px; }
  .gx-art { padding: 14px 12px 2px; }
  .gx-art svg { height: 96px; }
  .gx-meta { padding: 0 12px 12px; }
  .gx-title { font-size: 18px; }
  .gx-tag { font-size: 12px; min-height: 2.9em; }
  .gx-foot { flex-direction: column; gap: 2px; }
  .gx-top { max-width: 100%; }
  .gx-board { padding: 16px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .gx-card, .gx-card-over, .gx-panel, .gx-play { animation: none; transition: none; }
}
