.games-main {
  max-width: 1180px;
  margin: auto;
  padding: 42px 24px 72px;
  color: var(--ink);
}
.game-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.game-heading h1 {
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 550;
  letter-spacing: -0.045em;
  margin: 6px 0 12px;
  line-height: 1.1;
}
.game-heading p {
  max-width: 660px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
}
.game-heading .eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.game-heading a {
  color: var(--accent);
  font-size: 12px;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 740px) minmax(245px, 1fr);
  gap: 24px;
  align-items: start;
}
.game-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}
.game-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hairline);
}
.game-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg);
}
.game-btn,
.game-tabs button,
.game-select,
.game-date {
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
}
.game-btn:hover,
.game-tabs button:hover {
  background: var(--soft);
}
.game-btn.primary {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
  border-color: var(--accent);
}
.game-tabs button {
  border-color: transparent;
  background: transparent;
}
.game-tabs button.active {
  background: var(--surface);
  box-shadow: 0 1px 4px #142c3610;
  color: var(--accent);
}
.game-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.game-date {
  max-width: 140px;
  padding: 8px;
}
.game-select {
  max-width: 145px;
  padding: 9px;
}
.game-timer {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.game-stage {
  padding: 28px 32px;
  min-height: 300px;
  position: relative;
}
.game-status {
  font-size: 12px;
  min-height: 22px;
  margin: 0 0 16px;
  color: var(--muted);
}
.game-status.error {
  color: #a7473c;
}
.game-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 2px;
}
.game-controls .active {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent);
}
.game-sync {
  padding: 12px 22px;
  background: var(--bg);
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--hairline);
}
.game-side {
  display: grid;
  gap: 18px;
}
.game-side section {
  padding: 22px;
}
.game-side h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}
.game-side p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
}
.game-side label {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 12px;
}
.room-input {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.room-input input {
  min-width: 0;
  width: 100%;
  padding: 9px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font: inherit;
  color: var(--ink);
  font-size: 12px;
}
.game-side .game-btn {
  padding: 9px 11px;
}
.game-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.game-ranks {
  padding: 0;
  list-style: none;
  margin: 0;
}
.game-ranks li {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  border-top: 1px solid var(--hairline);
  padding: 10px 0;
  font-size: 12px;
}
.game-ranks small {
  color: var(--muted);
}
.game-player {
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
}
.game-player progress {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
  display: block;
  margin-top: 7px;
}
.room-code {
  font:
    600 22px ui-monospace,
    monospace;
  letter-spacing: 0.14em;
  color: var(--ink);
}
.puzzle-grid {
  --n: 6;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: visible;
  touch-action: none;
  user-select: none;
}
.puzzle-grid.with-sums {
  max-width: 500px;
  border: 0;
  gap: 4px;
}
.puzzle-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font:
    500 clamp(16px, 2.4vw, 25px) ui-sans-serif,
    system-ui;
  cursor: pointer;
  padding: 0;
  touch-action: none;
}
.puzzle-cell:hover {
  filter: brightness(0.97);
}
.puzzle-cell.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  z-index: 2;
  background: var(--soft);
}
.puzzle-cell.given {
  font-weight: 750;
  background: var(--bg);
  cursor: default;
}
.puzzle-cell.error {
  color: #b64035;
  background: #fbe7df;
}
.puzzle-cell.block {
  background: var(--ink);
  color: var(--surface);
  cursor: default;
}
.puzzle-cell.shaded {
  background: #263b43;
  color: #fff;
}
.puzzle-cell.marked:after {
  content: "×";
  position: absolute;
  font-size: 34px;
  opacity: 0.35;
}
.puzzle-cell.keep {
  box-shadow: inset 0 0 0 3px #6a9980;
  border-radius: 50%;
}
.puzzle-cell .small-number {
  position: absolute;
  left: 4px;
  top: 3px;
  font-size: 9px;
  line-height: 1;
  font-weight: 600;
}
.puzzle-cell .notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 80%;
  font-size: 10px;
  font-weight: 400;
}
.puzzle-cell.region {
  background: var(--region);
  color: #21343a;
}
.puzzle-cell.region.selected {
  outline-color: #152f40;
}
.puzzle-cell .cage-sum {
  position: absolute;
  left: 3px;
  top: 2px;
  font-size: 9px;
  line-height: 1;
  z-index: 1;
}
.puzzle-cell .edge-clue {
  position: absolute;
  z-index: 4;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  border-radius: 50%;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
}
.edge-clue.right {
  right: -9px;
  top: calc(50% - 8px);
}
.edge-clue.bottom {
  bottom: -9px;
  left: calc(50% - 8px);
}
.puzzle-cell.sum-clue {
  background: var(--bg);
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 6px;
}
.puzzle-cell.sum-clue.met {
  background: #deeee5;
  color: #345f4c;
}
.puzzle-cell.blank {
  background: var(--bg);
  border: 0;
  cursor: default;
}
.kakuro-clue {
  background: linear-gradient(
    45deg,
    transparent 49%,
    #ffffff65 50%,
    transparent 51%
  );
}
.kakuro-clue .across {
  position: absolute;
  right: 4px;
  top: 4px;
  font-size: 12px;
}
.kakuro-clue .down {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 12px;
}
.cell-symbol {
  font-size: 30px;
}
.puzzle-cell.found {
  background: #d9e9df;
  color: #315443;
}
.puzzle-cell.trail {
  background: var(--soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.number-pad {
  display: flex;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  margin: 20px auto 0;
}
.number-pad button {
  min-width: 36px;
  min-height: 39px;
  font-size: 17px;
  padding: 6px 9px;
}
.crossword-clues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}
.crossword-clues h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.clue-button {
  display: block;
  text-align: left;
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 100%;
  border-radius: 4px;
}
.clue-button.active {
  background: var(--soft);
}
.clue-button b {
  margin-right: 5px;
}
.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  justify-content: center;
  margin-top: 20px;
  font-size: 12px;
  letter-spacing: 0.05em;
}
.word-list .found {
  text-decoration: line-through;
  color: var(--muted);
}
.guess-boards {
  display: grid;
  gap: 24px;
}
.guess-boards.multi {
  grid-template-columns: 1fr 1fr;
}
.guess-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 5px auto;
  max-width: 470px;
}
.letter-tile {
  display: inline-grid;
  place-items: center;
  width: clamp(27px, 5vw, 47px);
  height: clamp(35px, 5vw, 48px);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
  font-size: 21px;
  font-weight: 600;
}
.letter-tile.correct,
.puzzle-cell.correct {
  background: #6c907c;
  color: #fff;
  border-color: #ffffff40;
}
.letter-tile.present,
.puzzle-cell.present {
  background: #baa25c;
  color: #fff;
  border-color: #ffffff40;
}
.letter-tile.absent,
.puzzle-cell.absent {
  background: #718087;
  color: #fff;
  border-color: #ffffff40;
}
.letter-tile.joined {
  margin-left: -5px;
  border-left: 0;
  border-radius: 0 5px 5px 0;
}
.letter-tile.anchor-start {
  border-left: 3px solid var(--ink);
}
.letter-tile.anchor-end {
  border-right: 3px solid var(--ink);
}
.guess-form {
  display: flex;
  gap: 8px;
  max-width: 470px;
  margin: 20px auto;
}
.guess-input {
  width: 100%;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  padding: 12px;
  color: var(--ink);
  font:
    600 16px ui-monospace,
    monospace;
}
.game-keyboard {
  max-width: 540px;
  margin: 20px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}
.game-keyboard button {
  min-width: 28px;
  padding: 10px 9px;
  font-size: 12px;
}
.game-target {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
}
.game-target strong {
  font-size: 26px;
  color: var(--ink);
  margin-left: 8px;
}
.anagram-tiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 22px;
}
.anagram-tiles button {
  width: 52px;
  height: 56px;
  font-size: 24px;
  background: var(--soft);
}
.found-words {
  columns: 3;
  font-size: 13px;
  line-height: 1.9;
  max-height: 230px;
  overflow: auto;
}
.shift-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.shift-letter {
  min-width: 28px;
  height: 39px;
  display: grid;
  place-items: center;
  font:
    600 18px ui-monospace,
    monospace;
  border: 0;
  background: var(--bg);
  color: var(--ink);
  border-radius: 4px;
}
.shift-gap {
  width: 14px;
  height: 39px;
  border: 0;
  background: #e0ece4;
  color: #38624b;
  border-radius: 3px;
  padding: 0;
  font-size: 14px;
}
.shift-gap.used {
  width: 28px;
  background: #c5ae72;
  color: #fff;
}
.shift-letter.removed {
  background: #c5ae72;
  color: #fff;
}
.shift-letter.fog {
  color: transparent;
  text-shadow: 0 0 7px var(--ink);
}
.shift-row.correct .shift-letter {
  box-shadow: inset 0 -2px #6c907c;
}
.shift-row small {
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  margin: 5px;
}
.shift-tiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 15px;
}
.shift-tiles button {
  background: #c5ae72;
  color: #fff;
  font-size: 18px;
  min-width: 35px;
}
.shift-tiles .selected {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.shift-answer {
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.1em;
  margin: 18px 0;
}
.game-result {
  margin: 24px auto 0;
  padding: 22px;
  background: var(--soft);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  text-align: center;
}
.game-result h2 {
  font-size: 23px;
  font-weight: 550;
  margin: 0 0 8px;
}
.game-result p {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0;
}
.game-result .game-btn {
  margin-top: 12px;
}
.wiki-route {
  padding: 15px;
  border-radius: 8px;
  background: var(--soft);
  font-size: 13px;
  line-height: 1.8;
  margin-bottom: 18px;
}
.wiki-article {
  font-size: 14px;
  line-height: 1.8;
  max-height: 620px;
  overflow: auto;
  padding: 6px 12px 18px;
  overflow-wrap: anywhere;
}
.wiki-article h2 {
  font-size: 20px;
  margin: 28px 0 12px;
}
.wiki-article h3 {
  font-size: 16px;
  margin-top: 24px;
}
.wiki-article table {
  font-size: 12px;
  max-width: 100%;
  display: block;
  overflow: auto;
  border-collapse: collapse;
}
.wiki-article th,
.wiki-article td {
  border: 1px solid var(--hairline);
  padding: 5px;
}
.wiki-article a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wiki-credit {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 16px;
}
.game-collection {
  margin-top: 48px;
}
.game-collection h2 {
  font-weight: 550;
  font-size: 23px;
}
.game-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.game-card {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
}
.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.game-card .game-icon {
  display: block;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
}
.game-heading h1 {
  display: flex;
  align-items: center;
  gap: 14px;
}
.game-heading .game-icon {
  flex: 0 0 auto;
  width: clamp(36px, 4vw, 48px);
  height: auto;
}
.game-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
}
.game-card p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}
.games-credits {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
  margin-top: 28px;
}
.game-loading {
  color: var(--muted);
  font-size: 14px;
  padding: 40px;
  text-align: center;
}
.race-wait {
  padding: 70px 20px;
  text-align: center;
  background: var(--bg);
  border-radius: 10px;
}
.race-wait strong {
  font-size: 24px;
  display: block;
  margin-bottom: 12px;
}
.race-wait p {
  color: var(--muted);
  font-size: 13px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
:root[data-theme="dark"] .puzzle-cell.region {
  filter: brightness(0.8);
  color: #172a30;
}
:root[data-theme="dark"] .puzzle-cell.sum-clue.met {
  background: #29453a;
  color: #bbdfc9;
}
:root[data-theme="dark"] .puzzle-cell.error {
  background: #522f2d;
  color: #ffc1b6;
}
:root[data-theme="dark"] .puzzle-cell.found {
  background: #29453a;
  color: #bbdfc9;
}
@media (max-width: 850px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .game-side {
    grid-template-columns: 1fr 1fr;
  }
  .game-cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .game-stage {
    padding: 24px;
  }
  .game-heading {
    gap: 10px;
  }
  .game-heading > a {
    white-space: nowrap;
  }
}
@media (max-width: 480px) {
  .games-main {
    padding: 28px 16px 48px;
  }
  .game-heading {
    display: block;
  }
  .game-heading > a {
    display: inline-block;
    margin-top: 16px;
  }
  .game-toolbar {
    padding: 13px;
    gap: 8px;
  }
  .game-stage {
    padding: 20px 12px;
  }
  .game-side {
    grid-template-columns: 1fr;
  }
  .game-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .game-card {
    padding: 16px;
  }
  .puzzle-cell {
    font-size: 21px;
  }
  .puzzle-grid[style*="--n:9"] .puzzle-cell,
  .puzzle-grid[style*="--n:15"] .puzzle-cell {
    font-size: 15px;
  }
  .puzzle-cell .cage-sum,
  .puzzle-cell .small-number {
    font-size: 8px;
    left: 3px;
    top: 2px;
  }
  .puzzle-cell .notes {
    font-size: 7px;
  }
  .cell-symbol {
    font-size: 23px;
  }
  .puzzle-cell .edge-clue {
    font-size: 10px;
    width: 13px;
    height: 13px;
  }
  .edge-clue.right {
    right: -7px;
    top: calc(50% - 6px);
  }
  .edge-clue.bottom {
    bottom: -7px;
    left: calc(50% - 6px);
  }
  .game-keyboard {
    gap: 3px;
  }
  .game-keyboard button {
    min-width: 25px;
    padding: 9px 6px;
    font-size: 11px;
  }
  .crossword-clues {
    gap: 10px;
  }
  .guess-row {
    gap: 3px;
  }
  .letter-tile {
    font-size: 17px;
  }
  .guess-boards.multi .letter-tile {
    height: 30px;
    font-size: 14px;
  }
  .anagram-tiles button {
    width: 36px;
    height: 44px;
    padding: 5px;
    font-size: 21px;
  }
  .shift-letter {
    min-width: 23px;
    font-size: 16px;
  }
  .shift-gap {
    width: 10px;
  }
  .found-words {
    columns: 2;
  }
  .game-timer {
    font-size: 11px;
  }
  .game-date {
    max-width: 130px;
  }
}

.cage-outline {
  position: absolute;
  inset: 3px;
  pointer-events: none;
}
.shift-row {
  flex-wrap: nowrap;
}
.shift-letter {
  min-width: 0;
  flex: 0 1 28px;
  padding: 0;
}
.shift-gap {
  flex: 0 1 14px;
}
.shift-gap.used {
  flex-basis: 28px;
}
.shift-row > .game-btn {
  flex: 0 0 30px;
  padding: 7px;
}
@media (max-width: 480px) {
  .shift-letter {
    flex-basis: 23px;
  }
  .shift-gap {
    flex-basis: 10px;
  }
}

.wiki-unavailable { padding: 20px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--soft); color: var(--ink); }
.wiki-unavailable h3 { margin: 0 0 10px; font-size: 18px; }
.wiki-unavailable p { font-size: 13px; line-height: 1.7; }
.wiki-unavailable .game-controls { flex-wrap: wrap; }
.wiki-route { overflow-wrap: anywhere; }
