/* ====== 2048 Neon Pro (mobile-fixed) ====== */
.gh-2048{
  --panel: rgba(16,22,46,.6);
  --stroke: rgba(255,255,255,.08);
  --text: #e8ecff;
  --muted: #a9b7ff;
  --accent: #6c7cff;
  --accent2: #33e0ff;
  --success: #17d490;
  --radius: 16px;
  --glow: 0 10px 30px rgba(51,224,255,.25);
  --inner: inset 0 0 0 1px rgba(255,255,255,.05);
  --glass: blur(10px) saturate(120%);
  --speed: .16s;

  /* Board geometry (shared with JS) */
  --pad: 12px;   /* inner padding around grid */
  --gap: 12px;   /* space between cells */

  color: var(--text);
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  position: relative;
  overflow: hidden;
}

/* Disable page scrolling while swiping inside the board */
.gh-2048 .g2048-board {
  touch-action: none;
  overscroll-behavior: contain;
}

/* aurora */
.gh-2048 .g2048-aurora{
  position:absolute; inset:-20% -10% -20% -10%; z-index:0;
  background:
    radial-gradient(800px 600px at 20% 10%, rgba(108,124,255,.35), transparent 60%),
    radial-gradient(800px 600px at 80% 20%, rgba(51,224,255,.35), transparent 60%),
    radial-gradient(700px 700px at 50% 90%, rgba(255,183,3,.20), transparent 65%),
    linear-gradient(180deg,#070c1b 0%, #060912 100%);
  pointer-events:none;
}

/* shell */
.gh-2048 .g2048-shell{
  position:relative; z-index:1;
  width:min(1100px, 100vw); margin:32px auto 46px;
  background:var(--panel); backdrop-filter:var(--glass);
  border:1px solid var(--stroke); border-radius:var(--radius);
  box-shadow:var(--glow), var(--inner);
  padding:clamp(12px, 2.5vw, 18px);
  box-sizing:border-box;
}

/* header */
.gh-2048 .g2048-header{ display:grid; grid-template-columns:1fr auto; gap:14px; align-items:center; }
.gh-2048 .g2048-titlebar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.gh-2048 .g2048-title{
  margin:0; font-size:34px; font-weight:900;
  background:linear-gradient(90deg,var(--accent),var(--accent2)); -webkit-background-clip:text; background-clip:text; color:transparent;
}

/* Back-to-home glossy pill (same as TTT) */
.gh-2048 .g2048-home{
  display:inline-flex; align-items:center; gap:8px; text-decoration:none; font-weight:900;
  padding:10px 14px; min-height:44px; border-radius:999px; color:#0a0e21;
  background:linear-gradient(90deg,#ffe87c,#7affd9);
  box-shadow:0 10px 28px rgba(122,255,217,.25);
  border:1px solid rgba(255,255,255,.18);
  white-space:nowrap; transform:translateZ(0);
  transition:transform .12s ease, filter .18s ease, box-shadow .18s ease;
}
.gh-2048 .g2048-home .txt{ display:none; }
.gh-2048 .g2048-home .ico{ width:20px; height:20px; flex:0 0 20px; transition:transform .18s ease; }
@media (hover:hover){
  .gh-2048 .g2048-home:hover{ transform:translateY(-1px); filter:brightness(1.05); box-shadow:0 12px 32px rgba(122,255,217,.34); }
  .gh-2048 .g2048-home:hover .ico{ transform:translateX(3px); }
}
.gh-2048 .g2048-home:focus-visible{
  outline:none;
  box-shadow:0 0 0 2px rgba(255,255,255,.65), 0 0 0 6px rgba(51,224,255,.35), 0 10px 28px rgba(122,255,217,.25);
}
@media (min-width:680px){ .gh-2048 .g2048-home .txt{ display:inline; } }

/* meters */
.gh-2048 .g2048-meters{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.gh-2048 .g2048-meter{
  background:rgba(255,255,255,.06); border:1px solid var(--stroke);
  border-radius:12px; padding:8px 12px; min-width:90px; text-align:center; box-shadow:var(--inner);
}
.gh-2048 .g2048-meter .label{ display:block; color:var(--muted); font-size:12px; }
.gh-2048 .g2048-meter .value{ display:block; font-size:18px; font-weight:900; color:#fff; }

/* controls */
.gh-2048 .g2048-controls{ display:grid; grid-template-columns:1fr auto; gap:12px; align-items:center; margin:16px 0 18px; }
.gh-2048 .g2048-selects{ display:flex; gap:10px; flex-wrap:wrap; }
.gh-2048 .g2048-field{ display:flex; flex-direction:column; gap:6px; color:var(--muted); font-size:13px; }
.gh-2048 .select-wrap{ position:relative; }
.gh-2048 .select-wrap .chev{ position:absolute; right:12px; top:50%; transform:translateY(-50%); font-size:12px; color:var(--muted); pointer-events:none; }
.gh-2048 select{
  appearance:none; width:190px; color-scheme: dark;
  background:rgba(255,255,255,.06); border:1px solid var(--stroke); border-radius:12px;
  color:#fff; padding:10px 34px 10px 12px; outline:none; box-shadow:var(--inner);
}
.gh-2048 select option, .gh-2048 select optgroup{ background-color:#0e1537; color:#fff; }

/* actions */
.gh-2048 .g2048-actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.gh-2048 .g2048-btn{
  background:linear-gradient(90deg,var(--accent),var(--accent2));
  color:#0a0e21; border:none; border-radius:12px; padding:10px 16px; font-weight:900; letter-spacing:.2px; cursor:pointer;
  box-shadow:var(--glow); transition:transform .08s ease, filter var(--speed);
}
.gh-2048 .g2048-btn:hover,.gh-2048 .g2048-btn:focus{ transform:translateY(-1px); filter:brightness(1.06); }
.gh-2048 .g2048-btn.ghost{ background:transparent; color:#fff; border:1px solid rgba(255,255,255,.16); }

/* sound button */
.gh-2048 .g2048-sound{
  width:42px; height:42px; border-radius:12px; border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.06); color:#fff; cursor:pointer; outline:none;
  display:grid; place-items:center; box-shadow:var(--inner); transition:filter .16s, transform .08s;
}
.gh-2048 .g2048-sound:hover{ transform:translateY(-1px); filter:brightness(1.1); }
.gh-2048 .g2048-sound .ico{ width:22px; height:22px; display:block; }
.gh-2048 .g2048-sound .off{ display:none; }
.gh-2048 .g2048-sound.is-muted{ color:#d2dae9; border-color:rgba(255,255,255,.12); }
.gh-2048 .g2048-sound.is-muted .on{ display:none; }
.gh-2048 .g2048-sound.is-muted .off{ display:block; }

/* stage & board */
.gh-2048 .g2048-stage{ position:relative; border-radius:var(--radius); padding:14px 10px; }

/* Perfect square board that never exceeds container width */
.gh-2048 .g2048-board{
  position:relative; width:min(560px, 100%); aspect-ratio:1/1; height:auto; margin:0 auto; box-sizing:border-box;
}

/* grid frame uses CSS vars for pad/gap */
.gh-2048 .g2048-grid{
  position:absolute; inset:0; display:grid; gap:var(--gap);
  padding:var(--pad); border-radius:18px; background:transparent; box-sizing:border-box;
}
.gh-2048 .g2048-grid::before{
  content:""; position:absolute; inset:calc(var(--pad) * -0.5);
  border-radius:22px; background:linear-gradient(90deg,var(--accent),var(--accent2));
  filter:blur(22px); opacity:.28; z-index:-1;
}
.gh-2048 .g2048-grid::after{
  content:""; position:absolute; inset:0; border-radius:18px;
  box-shadow:0 0 0 1px rgba(255,255,255,.12), inset 0 0 28px rgba(0,0,0,.28); pointer-events:none;
}
.gh-2048 .g2048-cell{
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.25));
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  box-sizing:border-box;
}

/* tiles layer uses the same padding */
.gh-2048 .g2048-tiles{ position:absolute; inset:var(--pad); box-sizing:border-box; }
.gh-2048 .tile{
  position:absolute; border-radius:12px; display:flex; align-items:center; justify-content:center;
  font-weight:900; color:#0a0e21; text-shadow:0 1px 0 rgba(255,255,255,.35);
  transition: left var(--speed) ease, top var(--speed) ease, background var(--speed) ease, transform var(--speed) ease;
  will-change: left, top, transform;
  box-shadow:0 10px 20px rgba(0,0,0,.25), var(--inner);
}
.gh-2048 .tile .v{ font-size: clamp(20px, 6vw, 32px); }

/* tile colors */
.gh-2048 .v2    { background:linear-gradient(135deg,#9bb2ff,#6f90ff); }
.gh-2048 .v4    { background:linear-gradient(135deg,#7fa3ff,#4f7fff); }
.gh-2048 .v8    { background:linear-gradient(135deg,#63d2ff,#33b1ff); }
.gh-2048 .v16   { background:linear-gradient(135deg,#00d1a0,#29f1bb); }
.gh-2048 .v32   { background:linear-gradient(135deg,#00c07a,#17d490); }
.gh-2048 .v64   { background:linear-gradient(135deg,#f39c12,#ffb347); }
.gh-2048 .v128  { background:linear-gradient(135deg,#ff7f50,#ffb199); color:#121939; }
.gh-2048 .v256  { background:linear-gradient(135deg,#ff6f61,#ffa07a); color:#121939; }
.gh-2048 .v512  { background:linear-gradient(135deg,#ff5a5f,#ff8a80); color:#121939; }
.gh-2048 .v1024 { background:linear-gradient(135deg,#ff3b58,#ff7b9e); color:#121939; }
.gh-2048 .v2048 { background:linear-gradient(135deg,#ffd700,#ffe87c); color:#121939; }
.gh-2048 .v4096 { background:linear-gradient(135deg,#c0392b,#ff6b6b); color:#fff; }

.gh-2048 .tile.pop { animation: pop .2s ease; }
@keyframes pop { 0%{transform:scale(.8); opacity:.7;} 100%{transform:scale(1); opacity:1;} }

/* overlays */
.gh-2048 .g2048-overlay{
  position:absolute; inset:0; display:grid; place-items:center; z-index:4; background:rgba(5,10,22,.55);
}
.gh-2048 .g2048-card{
  width:min(460px,92vw); background:rgba(19,26,56,.85); border:1px solid var(--stroke); border-radius:18px;
  backdrop-filter:var(--glass); box-shadow:var(--glow), var(--inner); padding:16px 16px 18px; text-align:center; color:var(--text);
}
.gh-2048 .g2048-card-title{
  margin:0 0 8px; font-size:26px; font-weight:900;
  background:linear-gradient(90deg,var(--accent),var(--accent2)); -webkit-background-clip:text; background-clip:text; color:transparent;
}
.gh-2048 .g2048-summary{ color:var(--muted); display:grid; gap:6px; margin:10px 0 14px; }
.gh-2048 .g2048-card-actions{ display:flex; justify-content:center; gap:10px; }

/* how-to */
.gh-2048 .g2048-howto{ margin-top:14px; background:rgba(255,255,255,.06); border:1px solid var(--stroke); border-radius:12px; padding:10px 12px; }
.gh-2048 .g2048-inline-toggle{ background:transparent; color:var(--accent2); font-weight:900; border:none; cursor:pointer; }
.gh-2048 .g2048-howto-content{ display:none; color:var(--muted); margin-top:6px; }

/* tighter spacing on very small phones */
@media (max-width:480px){ .gh-2048{ --pad: 10px; --gap: 10px; } }
@media (max-width:360px){ .gh-2048{ --pad: 8px; --gap: 8px; } }

/* responsive */
@media (max-width:900px){ .gh-2048 .g2048-header{ grid-template-columns:1fr; } .gh-2048 .g2048-meters{ justify-content:space-between; } }
@media (max-width:680px){
  .gh-2048 .g2048-controls{ grid-template-columns:1fr; }
  .gh-2048 select{ width:100%; }
  .gh-2048 .g2048-actions{ justify-content:stretch; }
  .gh-2048 .g2048-actions .g2048-btn{ flex:1; }
}
