:root {
  --pitch: #06271d;
  --pitch-light: #0b3b2c;
  --paper: #f2eddc;
  --paper-bright: #fffdf4;
  --ink: #09241b;
  --muted: #5f7168;
  --line: #b9c2b8;
  --acid: #d8ff43;
  --orange: #ff633f;
  --cyan: #54cde7;
  --rose: #ff9397;
  --display: "Bebas Neue", "Haettenschweiler", "Franklin Gothic Condensed", sans-serif;
  --body: "DM Sans", "Avenir Next", "Gill Sans", sans-serif;
  --mono: "IBM Plex Mono", "Menlo", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }
html { color: var(--ink); background: var(--paper); font-family: var(--body); }
body { min-width: 320px; margin: 0; overflow-x: hidden; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: .45;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(9, 36, 27, .08) 50%, transparent 50.2%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(9, 36, 27, .055) 31px 32px),
    var(--paper);
  pointer-events: none;
}

.connections-site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 62px;
  padding: .7rem clamp(1rem, 4vw, 3.5rem);
  color: white;
  background: var(--pitch);
}
.connections-brand { display: inline-flex; align-items: center; gap: .55rem; color: inherit; font: 400 1.7rem var(--display); letter-spacing: .04em; text-decoration: none; }
.connections-brand img { width: 34px; height: 34px; }
.connections-site-header nav, .connections-site-footer nav { display: flex; flex-wrap: wrap; gap: .9rem 1.2rem; }
.connections-site-header nav a, .connections-site-footer nav a { color: inherit; font: 700 .66rem var(--mono); letter-spacing: .03em; text-decoration: none; text-transform: uppercase; }
.connections-site-header nav a:hover, .connections-site-footer nav a:hover { color: var(--acid); }
.connections-breadcrumbs { display: flex; gap: .55rem; width: min(1320px, calc(100% - 2rem)); margin: 1rem auto 0; color: var(--muted); font-size: .72rem; }
.connections-breadcrumbs a { color: var(--ink); }

.prototype-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 38px;
  padding: .55rem clamp(.75rem, 3vw, 2.5rem);
  color: var(--acid);
  background: var(--pitch);
  font: 700 .62rem var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.prototype-strip span:last-child { color: #a9c3ba; }

.app-shell { width: min(1320px, calc(100% - 2rem)); margin: 0 auto; }

.game-masthead {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-height: 280px;
  margin-top: clamp(1rem, 3vw, 2.5rem);
  overflow: hidden;
  border: 2px solid var(--pitch);
  background: var(--paper-bright);
  box-shadow: 14px 14px 0 var(--orange);
}
.game-masthead::after {
  position: absolute;
  right: 248px;
  bottom: -4.5rem;
  content: "4×4";
  color: rgba(9, 36, 27, .055);
  font: 400 clamp(9rem, 20vw, 18rem)/.75 var(--display);
  pointer-events: none;
}
.masthead-copy { position: relative; z-index: 1; padding: clamp(1.5rem, 4vw, 3.4rem); }
.eyebrow, .panel-kicker, .rule-card span, .solved-group span {
  margin: 0;
  color: #426a5c;
  font: 700 .64rem var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.game-masthead h1 {
  max-width: 760px;
  margin: .5rem 0 .8rem;
  font: 400 clamp(4.8rem, 10vw, 9rem)/.77 var(--display);
  letter-spacing: -.025em;
  text-transform: uppercase;
}
.game-masthead h1 span { color: var(--orange); }
.game-masthead h1 small {
  display: block;
  margin-top: .7rem;
  color: var(--pitch);
  font: 700 clamp(.72rem, 1.4vw, 1rem)/1.2 var(--mono);
  letter-spacing: .16em;
}
.masthead-copy > p:last-child { max-width: 690px; margin: 0; color: var(--muted); font-size: clamp(.95rem, 1.4vw, 1.12rem); line-height: 1.6; }
.masthead-mark {
  position: relative;
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--acid);
  background: var(--pitch);
  isolation: isolate;
}
.masthead-mark::before, .masthead-mark::after {
  position: absolute;
  z-index: -1;
  content: "";
  border: 2px solid rgba(216, 255, 67, .4);
}
.masthead-mark::before { inset: 24px; }
.masthead-mark::after { width: 125px; height: 125px; border-radius: 50%; }
.masthead-mark strong { font: 400 7rem/.8 var(--display); }
.masthead-mark small { position: absolute; right: 2.4rem; bottom: 2rem; font: 700 .62rem var(--mono); text-transform: uppercase; }

.league-rail {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  margin: clamp(2rem, 5vw, 4rem) 0 1rem;
  border: 1px solid var(--pitch);
  background: var(--pitch);
}
.league-rail button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .8rem;
  align-items: center;
  min-height: 64px;
  padding: .75rem 1rem;
  border: 0;
  color: var(--ink);
  background: var(--paper-bright);
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.league-rail button > .game-mark { width: 2.4rem; }
.league-rail button strong { font-size: .78rem; line-height: 1.15; }
.league-rail button:hover { background: #e5e0cd; }
.league-rail button[aria-pressed="true"] { color: var(--acid); background: var(--pitch); }
.league-rail button[aria-pressed="true"] > .game-mark { box-shadow: 0 0 0 2px var(--acid); }

.game-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  margin-bottom: 4rem;
}
.game-sidebar { display: grid; gap: 1rem; }
.rule-card, .status-card { border: 1px solid var(--pitch); background: var(--paper-bright); }
.rule-card { padding: 1rem; }
.rule-card ol { display: grid; gap: .75rem; margin: 1rem 0 0; padding: 0; list-style: none; counter-reset: rule; }
.rule-card li { display: grid; grid-template-columns: 26px 1fr; gap: .55rem; color: var(--muted); font-size: .78rem; line-height: 1.42; counter-increment: rule; }
.rule-card li::before { display: grid; width: 24px; height: 24px; place-items: center; content: counter(rule); color: var(--acid); background: var(--pitch); font: 700 .58rem var(--mono); }
.status-card { color: white; background: var(--pitch); }
.status-row { display: flex; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, .15); }
.status-row:last-child { border-bottom: 0; }
.status-row span { color: #9eb9af; font: 600 .58rem var(--mono); text-transform: uppercase; }
.status-row strong { font: 700 .7rem var(--mono); text-transform: uppercase; }
.mistake-marks { display: flex; gap: .34rem; }
.mistake-marks i { width: 11px; height: 15px; background: var(--acid); clip-path: polygon(20% 0, 40% 0, 50% 20%, 60% 0, 80% 0, 100% 22%, 84% 45%, 84% 100%, 16% 100%, 16% 45%, 0 22%); }
.mistake-marks i[data-spent="true"] { background: var(--orange); opacity: .5; }

.game-panel {
  min-width: 0;
  border: 2px solid var(--pitch);
  background: var(--paper-bright);
  box-shadow: 10px 10px 0 rgba(9, 36, 27, .13);
}
.game-panel-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.3rem; border-bottom: 1px solid var(--line); }
.game-panel-header h2 { margin: .25rem 0 0; font: 400 clamp(2.6rem, 5vw, 4.7rem)/.88 var(--display); text-transform: uppercase; }
.board-number { color: var(--orange); font: 700 1rem var(--mono); }
.board-navigation { display: grid; gap: .55rem; justify-items: end; }
.board-picker { display: flex; gap: .35rem; }
.board-picker button {
  display: grid;
  width: 34px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--pitch);
  color: var(--pitch);
  background: transparent;
  font: 700 .58rem var(--mono);
  cursor: pointer;
}
.board-picker button:hover { background: #e5e0cd; }
.board-picker button[aria-pressed="true"] { color: var(--acid); background: var(--pitch); }
.game-stage { padding: clamp(.75rem, 2.5vw, 1.5rem); }

.solved-groups { display: grid; gap: .55rem; }
.solved-group { padding: 1rem 1.1rem; border: 1px solid var(--pitch); animation: group-lock .28s ease both; }
.solved-group span { color: rgba(9, 36, 27, .65); }
.solved-group h3 { margin: .18rem 0 .35rem; font: 400 clamp(1.8rem, 3.6vw, 3.2rem)/.95 var(--display); text-transform: uppercase; }
.solved-group p { margin: 0; color: rgba(9, 36, 27, .72); font-size: .76rem; line-height: 1.4; }
.solved-group[data-revealed="true"] { border-style: dashed; }
.group-color-0 { background: var(--acid); }
.group-color-1 { background: var(--orange); }
.group-color-2 { background: var(--cyan); }
.group-color-3 { background: var(--rose); }

.player-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-top: .6rem; }
.player-tile {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-height: 78px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
  animation: tile-in .32s cubic-bezier(.2, .75, .25, 1) both;
  animation-delay: calc(var(--tile-index) * 18ms);
  transition: transform .14s, border-color .14s, background .14s, color .14s;
}
.player-tile:hover { z-index: 1; border-color: var(--pitch); transform: translateY(-3px) rotate(-.35deg); }
.player-tile:focus-visible, .league-rail button:focus-visible, .board-picker button:focus-visible, .game-actions button:focus-visible { z-index: 2; outline: 3px solid var(--orange); outline-offset: 3px; }
.player-tile-marker { display: grid; align-self: stretch; place-items: center; border-right: 1px solid var(--line); color: #6d7d75; font: 700 .52rem var(--mono); writing-mode: vertical-rl; }
.player-tile strong { min-width: 0; padding: .75rem .65rem; font-size: clamp(.72rem, 1.2vw, .86rem); line-height: 1.15; overflow-wrap: anywhere; }
.player-tile.is-selected { color: var(--acid); border-color: var(--pitch); background: var(--pitch); transform: translateY(-3px); }
.player-tile.is-selected .player-tile-marker { color: var(--orange); border-color: rgba(255, 255, 255, .2); }

.feedback-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  margin: 1rem 0 0;
  padding: .7rem .8rem;
  color: #4f665d;
  background: #e9e5d7;
  font-size: .78rem;
}
.feedback-line:focus { outline: none; }
.feedback-line[data-feedback-type="incorrect"], .feedback-line[data-feedback-type="lost"] { color: #8f2f20; background: #ffe0d7; }
.feedback-line[data-feedback-type="correct"], .feedback-line[data-feedback-type="won"] { color: #173f31; background: #e4f7a0; }
.selection-count { flex: 0 0 auto; font: 700 .58rem var(--mono); text-transform: uppercase; }

.game-actions {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: .55rem;
  margin-top: .7rem;
}
.game-actions button {
  min-height: 48px;
  padding: .75rem 1rem;
  border: 2px solid var(--pitch);
  color: var(--pitch);
  background: transparent;
  font: 700 .62rem var(--mono);
  text-transform: uppercase;
  cursor: pointer;
}
.game-actions button:hover:not(:disabled) { background: #e2dece; }
.game-actions button:disabled { cursor: not-allowed; opacity: .36; }
.game-actions .submit-action { color: var(--acid); background: var(--pitch); }
.game-actions .submit-action:hover:not(:disabled) { color: var(--pitch); background: var(--acid); }
.next-board { grid-column: 1 / -1; color: var(--pitch) !important; background: var(--acid) !important; }

.prototype-note { max-width: 840px; margin: 1rem auto 3rem; color: var(--muted); font-size: .76rem; line-height: 1.55; text-align: center; }

.connections-guide {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(0, 1.8fr);
  gap: 0 2.5rem;
  margin: 5rem 0 2rem;
  border-top: 2px solid var(--pitch);
}
.connections-guide > header { grid-column: 1 / -1; display: grid; grid-template-columns: .7fr 1.8fr; gap: 2.5rem; padding: 2rem 0 2.5rem; border-bottom: 1px solid var(--line); }
.connections-guide > header .eyebrow { grid-column: 1; }
.connections-guide > header h2 { grid-column: 2; margin: 0; font: 400 clamp(3.4rem, 7vw, 6.4rem)/.88 var(--display); text-transform: uppercase; }
.connections-guide > header > p:last-child { grid-column: 2; max-width: 840px; margin: 0; color: var(--muted); font-size: 1.02rem; line-height: 1.7; }
.connections-guide > section { grid-column: 2; padding: 2rem 0; border-bottom: 1px solid var(--line); }
.connections-guide > section::before { display: block; margin: 0 0 .5rem; content: counter(section, decimal-leading-zero) " / FIELD NOTES"; color: var(--orange); font: 700 .62rem var(--mono); letter-spacing: .06em; }
.connections-guide { counter-reset: section; }
.connections-guide > section { counter-increment: section; }
.connections-guide h3 { margin: 0 0 .8rem; font: 400 clamp(2.2rem, 4vw, 3.7rem)/.95 var(--display); text-transform: uppercase; }
.connections-guide section > p { margin: .75rem 0 0; color: #3f594f; font-size: .97rem; line-height: 1.75; }
.connections-guide a { color: #0a5a43; font-weight: 700; }
.connections-tip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.connections-tip-grid article { padding: 1rem; border: 1px solid var(--pitch); background: var(--paper-bright); }
.connections-tip-grid strong { display: block; font: 400 1.7rem var(--display); text-transform: uppercase; }
.connections-tip-grid p { margin: .35rem 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.connections-related { margin-bottom: 2rem; }

.manual-ad-slot { margin: 2.5rem 0 4rem; padding: .8rem; border: 1px solid var(--line); background: rgba(255, 253, 244, .75); }
.manual-ad-slot-label { display: block; margin-bottom: .4rem; color: var(--muted); font: 600 .56rem var(--mono); letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.connections-site-footer { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem 2rem; align-items: center; padding: 2rem clamp(1rem, 4vw, 3.5rem); color: #b8ccc4; background: var(--pitch); }
.connections-site-footer p { margin: 0; font-size: .78rem; }
.connections-site-footer nav { grid-column: 2; }
.connections-site-footer > span { font: 600 .6rem var(--mono); }

@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes group-lock { from { opacity: 0; transform: scale(.98); } }

@media (max-width: 860px) {
  .game-masthead { grid-template-columns: 1fr 190px; }
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar { grid-template-columns: 1fr 1fr; }
  .league-rail { grid-template-columns: repeat(3, 1fr); }
  .league-rail button:nth-child(n + 4) { grid-column: span 1; }
  .connections-guide, .connections-guide > header { grid-template-columns: 1fr; }
  .connections-guide > header .eyebrow, .connections-guide > header h2, .connections-guide > header > p:last-child, .connections-guide > section { grid-column: 1; }
  .connections-guide > header h2 { margin-top: .6rem; }
  .connections-site-footer { grid-template-columns: 1fr; }
  .connections-site-footer nav { grid-column: 1; }
}

@media (max-width: 620px) {
  .connections-site-header { min-height: 50px; padding: .45rem .7rem; }
  .connections-site-header nav a:not(:first-child) { display: none; }
  .connections-brand { font-size: 1.45rem; }
  .connections-brand img { width: 30px; height: 30px; }
  .connections-breadcrumbs { width: min(100% - 1.1rem, 1320px); margin-top: .65rem; font-size: .65rem; }
  .prototype-strip { min-height: 32px; padding-block: .42rem; }
  .prototype-strip span:last-child { display: none; }
  .app-shell { width: min(100% - .8rem, 1320px); }
  .game-masthead { grid-template-columns: 1fr; min-height: 0; margin-top: .65rem; box-shadow: 5px 5px 0 var(--orange); }
  .game-masthead::after { display: none; }
  .masthead-copy { padding: .75rem .9rem .85rem; }
  .eyebrow { font-size: .54rem; }
  .game-masthead h1 { margin: .32rem 0 0; font-size: clamp(3.35rem, 16.5vw, 4.1rem); line-height: .82; white-space: nowrap; }
  .masthead-copy > p:last-child { display: none; }
  .masthead-mark { display: none; }
  .league-rail {
    display: flex;
    margin: 1rem 0 .6rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .league-rail::-webkit-scrollbar { display: none; }
  .league-rail button { flex: 0 0 116px; min-height: 48px; padding: .55rem .6rem; scroll-snap-align: start; }
  .league-rail button:last-child { grid-column: auto; }
  .game-layout { gap: .6rem; margin-bottom: 2.5rem; }
  .game-sidebar { display: block; }
  .rule-card { display: none; }
  .status-card { display: grid; grid-template-columns: 1fr 1fr; }
  .status-row { align-items: center; padding: .62rem .7rem; border-bottom: 0; }
  .status-row:first-child { border-right: 1px solid rgba(255, 255, 255, .15); }
  .game-panel { box-shadow: 5px 5px 0 rgba(9, 36, 27, .15); }
  .game-panel-header { padding: .65rem .75rem; }
  .game-panel-header h2 { font-size: 2.35rem; }
  .board-number { font-size: .7rem; }
  .board-picker button { width: 30px; height: 28px; }
  .game-stage { padding: .55rem; }
  .player-grid { grid-template-columns: 1fr 1fr; gap: .42rem; }
  .player-tile { grid-template-columns: 22px minmax(0, 1fr); min-height: 66px; }
  .player-tile strong { padding: .55rem .45rem; font-size: .7rem; }
  .solved-group { padding: .78rem; }
  .solved-group h3 { font-size: 1.72rem; }
  .feedback-line { align-items: flex-start; min-height: 58px; margin-top: .7rem; font-size: .72rem; }
  .game-actions { position: sticky; z-index: 5; bottom: 0; grid-template-columns: 1fr 1fr; padding: .5rem 0 max(.5rem, env(safe-area-inset-bottom)); background: var(--paper-bright); }
  .game-actions button { min-height: 50px; padding: .6rem .45rem; font-size: .56rem; }
  .game-actions .submit-action { grid-column: 1 / -1; }
  .next-board { grid-column: 1 / -1; }
  .connections-guide { margin-top: 3rem; }
  .connections-guide > header { gap: 0; padding: 1.4rem 0 1.8rem; }
  .connections-guide > header h2 { font-size: 3.4rem; }
  .connections-guide > header > p:last-child { font-size: .92rem; }
  .connections-guide > section { padding: 1.5rem 0; }
  .connections-guide h3 { font-size: 2.45rem; }
  .connections-guide section > p { font-size: .9rem; line-height: 1.7; }
  .connections-tip-grid { grid-template-columns: 1fr; }
  .connections-site-footer { padding: 1.5rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
