/* ===== Connect Four – Neon Pro (FINAL) ===== */
.gh-connect4{
  --panel: rgba(16,22,46,.6);
  --stroke: rgba(255,255,255,.08);
  --text: #e8ecff;
  --muted: #a9b7ff;
  --accent: #6c7cff;
  --accent2: #33e0ff;
  --p1: #7affd9;
  --p2: #ffd866;
  --winSolid: #ff4757; /* RED for winning discs */
  --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%);
  --pad: 12px;
  color: var(--text);
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  position:relative; overflow:hidden; overflow-x:hidden;
}

/* aurora bg */
.gh-connect4 .c4-aurora{
  position:absolute; inset:-20% -10% -20% -10%; z-index:0; pointer-events:none;
  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%);
}

/* shell */
.gh-connect4 .c4-shell{
  position:relative; z-index:1; width:100%;
  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;
  max-width:1200px;
}

/* header/title + back (back on the LEFT) */
.gh-connect4 .c4-header{ display:grid; grid-template-columns:1fr auto; gap:14px; align-items:center; }
.gh-connect4 .c4-titlebar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.gh-connect4 .c4-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;
}
.gh-connect4 .c4-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-connect4 .c4-home .txt{ display:none; }
.gh-connect4 .c4-home .ico{ width:20px; height:20px; flex:0 0 20px; }
@media (hover:hover){
  .gh-connect4 .c4-home:hover{ transform:translateY(-1px); filter:brightness(1.05); box-shadow:0 12px 32px rgba(122,255,217,.34); }
}
.gh-connect4 .c4-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-connect4 .c4-home .txt{ display:inline; } }

/* controls */
.gh-connect4 .c4-actions{
  display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; align-items:center;
}
.gh-connect4 .c4-field{ display:flex; flex-direction:column; gap:6px; color:#a9b7ff; font-size:13px; }
.gh-connect4 .select-wrap{ position:relative; }
.gh-connect4 .select-wrap .chev{ position:absolute; right:12px; top:50%; transform:translateY(-50%); font-size:12px; color:#a9b7ff; pointer-events:none; }
.gh-connect4 select{
  appearance:none; width:170px; 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-connect4 select option{ background-color:#0e1537; color:#fff; }

.gh-connect4 .c4-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 .16s ease;
}
.gh-connect4 .c4-btn:hover,.gh-connect4 .c4-btn:focus{ transform:translateY(-1px); filter:brightness(1.06); }
.gh-connect4 .c4-btn.ghost{ background:transparent; color:#fff; border:1px solid rgba(255,255,255,.16); }
.gh-connect4 .c4-btn[disabled]{ opacity:.6; pointer-events:none; }

.gh-connect4 .c4-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-connect4 .c4-sound .ico{ width:22px; height:22px; display:block; }
.gh-connect4 .c4-sound .off{ display:none; }
.gh-connect4 .c4-sound.is-muted{ color:#d2dae9; border-color:rgba(255,255,255,.12); }
.gh-connect4 .c4-sound.is-muted .on{ display:none; }
.gh-connect4 .c4-sound.is-muted .off{ display:block; }

/* turn pills */
.gh-connect4 .c4-turn{
  display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:12px;
  background:rgba(255,255,255,.06); border:1px solid var(--stroke); box-shadow:var(--inner);
}
.gh-connect4 .c4-turn .lab{ color:#a9b7ff; font-size:12px; }
.gh-connect4 .c4-turn .disc{ width:18px; height:18px; border-radius:50%; border:1px solid rgba(255,255,255,.2); box-shadow:0 0 0 3px rgba(255,255,255,.06) inset; opacity:.35; }
.gh-connect4 .c4-turn .disc.p1{ background:var(--p1); }
.gh-connect4 .c4-turn .disc.p2{ background:var(--p2); }
.gh-connect4 .c4-turn .disc.active{ opacity:1; box-shadow:0 0 18px rgba(122,255,217,.18); }

/* stage */
.gh-connect4 .c4-stage{
  position:relative; border-radius:var(--radius);
  padding:14px clamp(8px, 3.5vw, 22px);
}

/* board wrapper: widen, centered; iPhone gets extra width */
.gh-connect4 .c4-board-wrap{
  position:relative;
  width: min(980px, 98vw);
  margin: 8px auto 12px;
  padding-inline: clamp(4px, 2vw, 12px);
  box-sizing: border-box;
}
/* iOS-specific bump (fills area better on iPhone Safari) */
@supports (-webkit-touch-callout: none){
  .gh-connect4 .c4-board-wrap{ width: min(1040px, 99vw); }
}

/* board */
.gh-connect4 .c4-board{
  aspect-ratio: 7 / 6; width:100%;
  margin:0 auto;
  position:relative; display:grid; grid-template-columns:repeat(7,1fr);
  gap: clamp(8px, 2vw, 12px);
  padding: clamp(10px, 2.4vw, 16px);
  border-radius:18px; box-shadow:var(--inner);
  background:linear-gradient(180deg, rgba(20,28,58,.9), rgba(11,18,42,.9));
  border:1px solid rgba(255,255,255,.08);
}
.gh-connect4 .c4-topmask{
  position:absolute; inset:0; pointer-events:none; border-radius:18px;
  box-shadow:0 0 0 1px rgba(255,255,255,.12), inset 0 0 28px rgba(0,0,0,.28);
}

/* grid & slots */
.gh-connect4 .col{ position:relative; display:grid; grid-template-rows:repeat(6,1fr); gap: clamp(8px, 2vw, 12px); }
.gh-connect4 .slot{
  position:relative; display:grid; place-items:center; border-radius:12px;
  background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.10); overflow:hidden;
}
.gh-connect4 .slot::after{
  content:""; position:absolute; inset: clamp(6px, 1.8vw, 8px); border-radius:50%;
  background:radial-gradient(circle at 50% 40%, rgba(255,255,255,.15), rgba(0,0,0,.3));
}

/* discs (larger for phones) */
.gh-connect4 .disc-el{
  position:absolute; width: clamp(72%, 9.6vw, 80%); aspect-ratio:1/1; border-radius:50%;
  border:1px solid rgba(255,255,255,.25);
  box-shadow:inset 0 12px 24px rgba(255,255,255,.2), inset 0 -14px 28px rgba(0,0,0,.35), 0 10px 26px rgba(0,0,0,.25);
  transform:translateY(-140%); opacity:0; transition:transform .26s ease, opacity .26s ease, box-shadow .2s ease;
}
.gh-connect4 .disc-el.p1{ background:radial-gradient(120% 120% at 30% 25%, #bfffe9, var(--p1)); }
.gh-connect4 .disc-el.p2{ background:radial-gradient(120% 120% at 30% 25%, #fff0b0, var(--p2)); }
.gh-connect4 .disc-el.drop{ transform:translateY(0%); opacity:1; }

/* last move pulse */
.gh-connect4 .disc-el.last{
  box-shadow:inset 0 12px 24px rgba(255,255,255,.22), inset 0 -14px 28px rgba(0,0,0,.38), 0 0 0 3px rgba(51,224,255,.35);
  animation:c4-pulse 1.2s ease-out 1;
}
@keyframes c4-pulse{
  0%{ box-shadow:inset 0 12px 24px rgba(255,255,255,.22), inset 0 -14px 28px rgba(0,0,0,.38), 0 0 0 0 rgba(51,224,255,.55); }
  100%{ box-shadow:inset 0 12px 24px rgba(255,255,255,.22), inset 0 -14px 28px rgba(0,0,0,.38), 0 0 0 16px rgba(51,224,255,0); }
}

/* WINNING (solid red + glow) */
.gh-connect4 .disc-el.win{
  background: var(--winSolid) !important;
  border-color: rgba(255,255,255,.8);
  box-shadow:
    inset 0 12px 24px rgba(255,255,255,.18),
    inset 0 -18px 32px rgba(0,0,0,.38),
    0 0 22px rgba(255,71,87,.65),
    0 0 36px rgba(255,120,140,.35);
}

/* hint arrow */
.gh-connect4 .col.hint .slot:nth-child(1)::before{
  content:""; position:absolute; top:6px; left:50%; width:0; height:0; transform:translateX(-50%);
  border-left:8px solid transparent; border-right:8px solid transparent; border-bottom:10px solid var(--accent2);
  filter:drop-shadow(0 4px 10px rgba(51,224,255,.4));
}

/* overlays */
.gh-connect4 .c4-confetti{ position:absolute; inset:var(--pad); width:calc(100% - var(--pad)*2); height:calc(100% - var(--pad)*2); border-radius:18px; pointer-events:none; }
.gh-connect4 .c4-overlay{
  position:absolute; inset:0; display:grid; place-items:center; z-index:5;
  background:rgba(5,10,22,.55); border-radius:18px;
}
.gh-connect4 .c4-card{
  position:relative;
  width:min(540px,92vw); background:rgba(19,26,56,.92); border:1px solid var(--stroke); border-radius:18px;
  backdrop-filter:var(--glass); box-shadow:var(--glow), var(--inner); padding:18px 18px 20px; text-align:center; color:#e8ecff;
}
.gh-connect4 .c4-close{
  position:absolute; top:10px; right:10px;
  width:36px; height:36px; border-radius:10px; border:1px solid rgba(255,255,255,.2);
  background:rgba(255,255,255,.08); color:#fff; font-size:20px; line-height:1; cursor:pointer;
  display:grid; place-items:center;
}
.gh-connect4 .c4-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-connect4 .c4-summary{ color:var(--muted); display:grid; gap:6px; margin:10px 0 14px; }
.gh-connect4 .c4-card-actions{ display:flex; justify-content:center; gap:10px; margin-top:10px; }

/* stats */
.gh-connect4 .c4-stats{ display:flex; gap:10px; justify-content:space-between; margin:8px 0 10px; }
.gh-connect4 .c4-stats .stat{ flex:1; text-align:center; background:rgba(255,255,255,.06); border:1px solid var(--stroke); border-radius:12px; padding:10px; box-shadow:var(--inner); }
.gh-connect4 .c4-stats .n{ display:block; font-size:22px; font-weight:900; color:#fff; }
.gh-connect4 .c4-stats .l{ display:block; color:#a9b7ff; font-size:12px; }

/* how-to */
.gh-connect4 .c4-howto{ margin-top:14px; background:rgba(255,255,255,.06); border:1px solid var(--stroke); border-radius:12px; padding:10px 12px; }
.gh-connect4 .c4-inline-toggle{ background:transparent; color:#a9b7ff; font-weight:900; border:none; cursor:pointer; }
.gh-connect4 .c4-howto-content[hidden]{ display:none !important; }
.gh-connect4 .c4-howto-grid{ display:grid; gap:12px; align-items:start; }
@media (min-width:760px){
  .gh-connect4 .c4-howto-grid{ grid-template-columns:1.3fr 1fr; }
}
.gh-connect4 .c4-howto-text ol{ margin:0; padding-left:18px; }
.gh-connect4 .c4-howto-diagram svg{ width:100%; height:auto; display:block; border-radius:12px; box-shadow:var(--inner); }

/* responsive tweaks */
@media (max-width:900px){ .gh-connect4 .c4-header{ grid-template-columns:1fr; } }

/* fallback if aspect-ratio unsupported */
@supports not (aspect-ratio: 1 / 1){
  .gh-connect4 .c4-board{ position:relative; height: calc(99vw * (6/7)); max-height: 780px; }
  .gh-connect4 .col{ height: 100%; }
}
/* --- Connect Four board sizing & centering fix (final) --- */
.gh-connect4 .c4-board-wrap {
  /* Hard cap for desktop, softer width on mobile */
  width: min(92vw, 700px) !important;
  /* Perfect centering */
  margin: 8px auto 12px !important;
  /* Respect notches / safe areas and keep even side padding */
  padding-inline: max(10px, env(safe-area-inset-left))
                  max(10px, env(safe-area-inset-right)) !important;
  box-sizing: border-box;
}

/* Use aspect-ratio to control height; remove vw-based height expansion */
.gh-connect4 .c4-board {
  width: 100% !important;
  height: auto !important;         /* cancel calc(99vw * (6/7)) */
  aspect-ratio: 7 / 6 !important;  /* keeps shape */
  max-height: 70vh;                /* prevents overflow on small screens */
  margin: 0 auto !important;
  /* So discs/gaps don’t balloon on wider screens */
  gap: clamp(6px, 1.4vw, 10px) !important;
  padding: clamp(8px, 1.6vw, 14px) !important;
}

/* Desktop cap so it never feels oversized on laptops/desktops */
@media (min-width: 1024px) {
  .gh-connect4 .c4-board-wrap { width: 680px !important; }
}

/* Extra-small phones: allow just a touch more width while balanced */
@media (max-width: 360px) {
  .gh-connect4 .c4-board-wrap { width: 94vw !important; }
}
