/* Games section — shares the site's palette + monospace feel. */

/* Square cards in a responsive grid. Each card is just a black icon + the game
   name; the description shows on the game's own page (and as a hover tooltip). */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  aspect-ratio: 1 / 1;
  padding: 12px 10px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--box-bg);
  color: var(--fg);
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.game-card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
.game-card:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.game-icon {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  color: var(--fg);   /* black / white — follows the theme, never the link color */
}
.game-icon svg { color: var(--fg); }
.game-card-name { font-size: 13px; line-height: 1.3; }
.game-card-cat {
  font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
}
.game-card[hidden] { display: none; }

/* Type filter bar — same feel as the jokes / blog filters. */
.game-filter {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 14px;
}
.game-filter-btn {
  font: inherit; font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--box-bg);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--shadow);
}
.game-filter-btn:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--shadow); }
.game-filter-btn.active { background: var(--fg); color: var(--box-bg); }
.game-empty { margin-top: 16px; }

@media (max-width: 480px) {
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .game-card-name { font-size: 12px; }
}

/* Per-game customization controls */
.game-options {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px;
  justify-content: center;
  border: 1px dashed var(--border-soft); padding: 8px 12px; margin: 4px 0 12px;
  font-size: 13px;
}
.game-options label { display: inline-flex; align-items: center; gap: 5px; }
.game-options select { font-family: inherit; font-size: 13px; padding: 2px 4px; }

.sh-conn { font-size: 11px; padding: 0 4px; opacity: 0.85; }
.sh-conn.live { color: #2e7d32; }
.sh-conn.manual { color: var(--muted); }
.sh-refresh { margin-left: 6px; }
.sh-manual-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

.game-topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft);
}
.game-back { color: var(--link); text-decoration: none; font-size: 13px; }
.game-back:hover { text-decoration: underline; }

.game-stage { text-align: center; margin-top: 10px; }
.game-status { font-size: 14px; margin: 10px 0; min-height: 20px; }
canvas { border: 1px solid var(--border); background: var(--box-bg); max-width: 100%; image-rendering: pixelated; }

/* Tic-tac-toe */
.ttt-board { display: inline-grid; grid-template-columns: repeat(3, 64px); gap: 4px; }
.ttt-cell {
  width: 64px; height: 64px; font-size: 32px; font-family: inherit;
  border: 1px solid var(--border); background: var(--box-bg); color: var(--fg);
  cursor: pointer; box-shadow: 2px 2px 0 var(--shadow);
}
.ttt-cell:hover { background: var(--accent-bg); color: var(--accent-fg); }
.ttt-cell:disabled { cursor: default; }

/* Memory */
.mem-board { display: inline-grid; grid-template-columns: repeat(4, 60px); gap: 6px; }
.mem-card {
  width: 60px; height: 60px; font-size: 26px; font-family: inherit;
  border: 1px solid var(--border); background: var(--accent-bg); color: var(--accent-bg);
  cursor: pointer; box-shadow: 2px 2px 0 var(--shadow);
}
.mem-card.flipped { background: var(--box-bg); color: var(--fg); }
.mem-card.matched { background: var(--ok-bg); color: var(--fg); cursor: default; }

/* Minesweeper */
.ms-board { display: inline-grid; gap: 2px; }
.ms-cell {
  width: 28px; height: 28px; border: 1px solid var(--border-soft);
  background: var(--accent-bg); color: var(--fg); font-family: inherit; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.ms-cell.open { background: var(--box-bg); cursor: default; }
.ms-cell.mine { background: #b04a2f; color: #fff; }
.ms-cell.flag { color: #c94f3d; }
.ms-n1 { color: #2f6f9f; } .ms-n2 { color: #2e7d32; } .ms-n3 { color: #b04a2f; }
.ms-n4 { color: #5a3fb0; } .ms-n5 { color: #8a5a2f; } .ms-n6 { color: #2f8a8a; }

/* Simon */
.simon { display: inline-grid; grid-template-columns: repeat(2, 96px); gap: 8px; padding: 8px; }
.simon-pad { width: 96px; height: 96px; border: 2px solid var(--border); cursor: pointer; opacity: 0.5; transition: opacity 0.08s ease; }
.simon-pad.lit { opacity: 1; }
.simon-pad.p0 { background: #2e8b57; border-top-left-radius: 60px; }
.simon-pad.p1 { background: #b04a2f; border-top-right-radius: 60px; }
.simon-pad.p2 { background: #2f6f9f; border-bottom-left-radius: 60px; }
.simon-pad.p3 { background: #d1a72e; border-bottom-right-radius: 60px; }

/* Lights Out */
.lo-board { display: inline-grid; gap: 4px; }
.lo-cell { width: 46px; height: 46px; border: 1px solid var(--border); background: var(--accent-bg); cursor: pointer; padding: 0; }
.lo-cell.on { background: var(--fg); }

/* Sliding puzzle */
.sp-board { display: inline-grid; gap: 5px; }
.sp-tile {
  width: 64px; height: 64px; font-size: 22px; font-family: inherit;
  border: 1px solid var(--border); background: var(--box-bg); color: var(--fg);
  cursor: pointer; box-shadow: 2px 2px 0 var(--shadow); padding: 0;
}
.sp-tile.blank { background: transparent; border-style: dashed; box-shadow: none; cursor: default; }

/* Shared little widgets used by several of the quick games */
.choice-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.big-btn { font-size: 20px; padding: 10px 20px; font-family: inherit; }
.game-input { font-family: inherit; font-size: 16px; padding: 6px 8px; }
.game-big { font-size: 40px; font-weight: bold; margin: 10px 0; }

/* Whack-a-mole */
.wam-grid { display: inline-grid; grid-template-columns: repeat(3, 84px); gap: 12px; }
.wam-hole { width: 84px; height: 84px; border: 1px solid var(--border); background: var(--accent-bg); border-radius: 50%; cursor: pointer; font-size: 34px; padding: 0; }
.wam-hole.up { background: var(--fg); color: var(--box-bg); }

/* Aim trainer */
.aim-area { position: relative; width: 100%; max-width: 440px; height: 300px; margin: 12px auto; border: 1px solid var(--border); background: var(--box-bg); overflow: hidden; box-shadow: 2px 2px 0 var(--shadow); }
.aim-target { position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--fg); cursor: pointer; }

/* Reaction test */
.reaction-box { width: 100%; max-width: 440px; height: 220px; margin: 12px auto; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 18px; text-align: center; cursor: pointer; user-select: none; }
.reaction-box.wait { background: #b04a2f; color: #fff; }
.reaction-box.go { background: #2e8b57; color: #fff; }

/* Playing card face */
.card-face { display: inline-flex; align-items: center; justify-content: center; width: 84px; height: 116px; border: 2px solid var(--border); background: var(--box-bg); font-size: 30px; box-shadow: 2px 2px 0 var(--shadow); margin: 6px; }
.card-face.red { color: #c94f3d; }

/* Tower of Hanoi */
.hanoi-pegs { display: flex; justify-content: space-around; align-items: flex-end; height: 190px; max-width: 480px; margin: 14px auto; }
.hanoi-peg { position: relative; width: 30%; height: 100%; display: flex; flex-direction: column-reverse; align-items: center; cursor: pointer; }
.hanoi-peg::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: var(--fg); }
.hanoi-peg.sel { background: var(--accent-bg); }
.hanoi-disc { height: 18px; background: var(--fg); margin-bottom: 2px; border: 1px solid var(--box-bg); z-index: 1; }

/* Stroop / hangman letters */
.stroop-word { font-size: 46px; font-weight: bold; margin: 16px 0; }
.letter-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 460px; margin: 12px auto; }
.letter-btn { width: 34px; height: 34px; font-family: inherit; font-size: 15px; border: 1px solid var(--border); background: var(--box-bg); cursor: pointer; padding: 0; }
.letter-btn:disabled { opacity: 0.4; cursor: default; }
.word-slots { font-size: 26px; letter-spacing: 6px; margin: 12px 0; }

/* Secret Hitler */
.sh-wrap { max-width: 760px; margin: 0 auto; }
.sh-tracks { display: grid; gap: 8px; margin: 12px 0; }
.sh-track { border: 1px solid var(--border); padding: 6px 8px; background: var(--box-bg); }
.sh-track .slots { display: flex; gap: 4px; margin-top: 4px; }
.sh-slot { width: 26px; height: 34px; border: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: center; font-size: 11px; }
.sh-slot.lib.on { background: #2f6f9f; color: #fff; }
.sh-slot.fas.on { background: #b04a2f; color: #fff; }
.sh-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.sh-player { border: 1px solid var(--border-soft); padding: 6px 8px; font-size: 13px; }
.sh-player.dead { opacity: 0.45; text-decoration: line-through; }
.sh-player .role-tag { font-size: 11px; }
.sh-badges { font-size: 10px; color: var(--muted); }
.sh-role-box { border: 2px solid var(--border); padding: 10px 12px; margin: 12px 0; background: var(--box-bg); box-shadow: 3px 3px 0 var(--shadow); }
.sh-role-lib { border-color: #2f6f9f; }
.sh-role-fas { border-color: #b04a2f; }
.sh-action-box { border: 1px dashed var(--border); padding: 12px; margin: 12px 0; }
.sh-log { font-size: 11px; color: var(--muted-2); max-height: 160px; overflow-y: auto; border: 1px solid var(--border-soft); padding: 6px 8px; margin-top: 12px; }
.sh-log div { margin-bottom: 2px; }
.sh-vote-btns button { font-size: 18px; padding: 6px 18px; margin: 0 6px; }
.sh-cards { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.sh-policy { width: 70px; height: 96px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: bold; cursor: pointer; box-shadow: 2px 2px 0 var(--shadow); }
.sh-policy.L { background: #2f6f9f; color: #fff; }
.sh-policy.F { background: #b04a2f; color: #fff; }
.sh-code { font-size: 22px; letter-spacing: 3px; border: 1px solid var(--border); padding: 4px 10px; background: var(--box-bg); }
