/* Connect 4 — Parlour Games */

[hidden] { display: none !important; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
.page-head .sub {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 14px;
  min-height: 1.4em;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.play {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* --- Setup screen --- */
.setup {
  max-width: 560px;
  margin: 8px auto;
  padding: 14px 4px;
}
.setup-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(20px, 2.8vw, 26px);
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.setup-lede {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 22px;
}
.setup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 14px 0;
  flex-wrap: wrap;
}
.setup-label {
  font: 600 13px 'Inter', sans-serif;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.seg {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.seg-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font: 600 13px 'Inter', sans-serif;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(31, 58, 95, 0.08), 0 6px 14px -10px rgba(31, 58, 95, 0.35);
}
.swatch {
  width: 12px; height: 12px; border-radius: 999px;
  display: inline-block;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
}
.swatch-red { background: #c0392b; }
.swatch-blue { background: #1f3a5f; }

.setup-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* --- Board --- */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.board-wrap {
  --cols: 7;
  --rows: 6;
  --gap: 8px;
  --cell: clamp(36px, 10.5vw, 72px);
  width: calc(var(--cols) * var(--cell) + (var(--cols) + 1) * var(--gap));
  max-width: 100%;
}

.header-row {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
  padding: var(--gap) var(--gap) 0;
}
.col-head {
  appearance: none;
  background: transparent;
  border: 0;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font: 600 11px 'Inter', sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 140ms ease, color 140ms ease;
}
.col-head:hover { background: var(--accent-soft); color: var(--ink); }
.col-head:disabled { opacity: 0.45; cursor: not-allowed; }
.col-head.is-hover { background: var(--accent-soft); color: var(--ink); }

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: var(--gap);
  padding: var(--gap);
  background: var(--accent);
  border-radius: 14px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.06),
    inset 0 -4px 12px rgba(0,0,0,0.22),
    0 18px 40px -22px rgba(31, 58, 95, 0.55);
  aspect-ratio: var(--cols) / var(--rows);
}
.slot {
  position: relative;
  background: radial-gradient(circle at 50% 50%, var(--bg) 60%, #e3d6b6 100%);
  border-radius: 999px;
  box-shadow:
    inset 0 4px 8px rgba(0,0,0,0.28),
    inset 0 -2px 4px rgba(255,255,255,0.18);
}
.col-hits {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
  padding: var(--gap);
  z-index: 3;
}
.col-hit {
  appearance: none;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 8px;
}
.col-hit:disabled { cursor: not-allowed; }
.col-hit:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -2px; }

/* Disc layer, overlaid on the grid */
.disc-layer {
  position: absolute;
  inset: var(--gap);
  pointer-events: none;
}
.disc {
  position: absolute;
  width: var(--cell);
  height: var(--cell);
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), rgba(255,255,255,0) 45%),
    var(--disc-color, #c0392b);
  box-shadow:
    inset 0 -6px 10px rgba(0,0,0,0.30),
    inset 0 4px 6px rgba(255,255,255,0.18),
    0 2px 4px rgba(0,0,0,0.22);
  transition: top 340ms cubic-bezier(0.45, 0.05, 0.55, 1);
  transform: translateZ(0);
}
.disc::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.18);
}

/* Landing flash — tiny satisfying pop when a disc reaches its slot */
@keyframes c4-land {
  0%   { transform: scaleY(1); }
  55%  { transform: scaleY(0.92) scaleX(1.06); }
  100% { transform: scaleY(1); }
}
.disc.is-landed {
  animation: c4-land 240ms ease-out;
  transform-origin: bottom center;
}
@media (prefers-reduced-motion: reduce) {
  .disc { transition: none; }
  .disc.is-landed { animation: none; }
}
.disc.red { --disc-color: #c0392b; }
.disc.blue { --disc-color: #1f3a5f; }
.disc.is-win {
  outline: 3px solid var(--accent-soft);
  outline-offset: -2px;
  animation: discPulse 1200ms ease-in-out infinite alternate;
}
@keyframes discPulse {
  from { box-shadow: inset 0 -6px 10px rgba(0,0,0,0.30), inset 0 4px 6px rgba(255,255,255,0.18), 0 0 0 0 rgba(244, 227, 178, 0.4); }
  to   { box-shadow: inset 0 -6px 10px rgba(0,0,0,0.30), inset 0 4px 6px rgba(255,255,255,0.18), 0 0 0 8px rgba(244, 227, 178, 0); }
}

/* Turn indicator integrated into status */
.turn-dot {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 999px;
  vertical-align: middle;
  margin: 0 6px 2px 0;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
}
.turn-dot.red { background: #c0392b; }
.turn-dot.blue { background: #1f3a5f; }

/* Win overlay */
.win-overlay {
  position: fixed; inset: 0; background: rgba(28, 42, 58, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.win-overlay[hidden] { display: none; }
.win-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 30px; text-align: center; box-shadow: var(--shadow-lift); max-width: 360px;
}
.win-eyebrow {
  font: 600 11px 'Inter', sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.win-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(26px, 4vw, 34px);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.win-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.win-actions { display: flex; justify-content: center; }

/* aside */
.aside-info { margin-top: 22px; }
.aside-info details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.aside-info summary {
  cursor: pointer;
  font: 700 14px 'Inter', sans-serif;
  color: var(--ink);
}
.aside-info .help-body {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.aside-info .help-body p { margin: 0 0 8px; }
.aside-info .help-body ul { margin: 0; padding-left: 18px; }
.aside-info .help-body li { margin: 4px 0; }

@media (max-width: 480px) {
  .setup-row { flex-direction: column; align-items: flex-start; }
  .seg { flex-wrap: wrap; }
}
