/* Connect 4 — two-player multiplayer. Mobile-first.
   Shares the look-and-feel family with Bobble (same surface palette,
   same component vocabulary) but the brand accent is red rather than
   blue, and the board is a Connect-4-blue grid with circular slots. */

:root {
  --bg:        #0e1118;
  --surface-1: #161a23;
  --surface-2: #1d2230;
  --text:      #e6e9f2;
  --text-dim:  #8d93a8;
  --border:    #2a3142;
  --accent:    #ff6b6b;          /* red — main brand colour + seat 1 */
  --accent-2:  #ff8b8b;
  --good:      #5ad07e;
  --warn:      #ffb347;
  --bad:       #ff6b6b;
  --p1:        #ff5a5a;           /* seat 1 disc */
  --p1-hi:     #ff9a9a;
  --p2:        #ffd166;           /* seat 2 disc */
  --p2-hi:     #ffe48a;
  --board:     #2b6cff;           /* the classic blue frame */
  --slot:      #0a0d14;           /* empty hole — slightly darker than bg */
  --radius-md: 12px;
  --radius-sm: 8px;
  --on-accent: #0e1118;
  --bg-accent: #2a1b22;
}

:root[data-theme="light"] {
  --bg:        #f5f7fb;
  --surface-1: #ffffff;
  --surface-2: #eef1f9;
  --text:      #1a1f2e;
  --text-dim:  #5a6378;
  --border:    #d3d9e6;
  --accent:    #e53e3e;
  --accent-2:  #ff6b6b;
  --good:      #2a9d4f;
  --warn:      #b97a16;
  --bad:       #d83c3c;
  --p1:        #e53e3e;
  --p1-hi:     #ff8585;
  --p2:        #e0a500;
  --p2-hi:     #ffd166;
  --board:     #2954c9;
  --slot:      #d3d9e6;
  --on-accent: #ffffff;
  --bg-accent: #f8d8da;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(ellipse at 30% 0%, var(--bg-accent) 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Two drifting background blobs — kept lighter than Bobble's because the
   blue board is already a strong focal point. */
.c4-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.c4-blob {
  position: absolute;
  width: 60vmin; height: 60vmin;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.18;
  will-change: transform;
}
.c4-blob-1 { background: var(--accent); top: -15vmin; left: -10vmin;  animation: blob-1 26s ease-in-out infinite; }
.c4-blob-2 { background: var(--p2);    bottom: -15vmin; right: -10vmin; animation: blob-2 32s ease-in-out infinite; }
@keyframes blob-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(14vw, 16vh) scale(1.15); }
}
@keyframes blob-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-10vw, -18vh) scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .c4-blob { animation: none; }
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px 40px;
}

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--board);
  box-shadow: 0 2px 0 #0a0d14, 0 4px 10px rgba(43, 108, 255, 0.4);
  gap: 3px; padding: 0 5px;
}
.brand-disc {
  width: 11px; height: 11px; border-radius: 50%;
}
.brand-disc.red    { background: var(--p1); }
.brand-disc.yellow { background: var(--p2); }
h1 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.4px;
     text-shadow: 0 2px 0 rgba(0,0,0,0.35); }
h2 { margin: 12px 0 6px; font-size: 18px; }
h3 { margin: 8px 0 4px; font-size: 16px; }
p  { margin: 6px 0; }
a  { color: var(--accent); }
a:hover { color: var(--accent-2); }
.muted { color: var(--text-dim); }
.warn  { color: var(--warn); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; min-height: 42px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
  border: 1px solid var(--accent);
  font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  box-shadow: 0 3px 0 rgba(0,0,0,0.4), 0 4px 12px rgba(255, 107, 107, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.4), 0 2px 4px rgba(255, 107, 107, 0.2);
}
.btn.secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
.btn.secondary:hover { background: var(--surface-2); }
.btn.secondary:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,0.3); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

/* Forms */
.input {
  width: 100%;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 42px;
  font: inherit;
}
.input.large {
  font-size: 24px; letter-spacing: 6px; text-transform: uppercase;
  text-align: center; font-weight: 800;
}
.label {
  font-size: 12px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 4px;
}

/* Generic checkbox-row toggle (used by "join as spectator"). */
.c4-toggle {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
}
.c4-toggle input[type=checkbox] {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  margin-top: 2px; accent-color: var(--accent);
  cursor: pointer;
}
.c4-toggle > span { flex: 1; }

/* Mode picker (Classic / Relaxed / Vs Bot) — styled radio buttons that
   look like clickable cards. The native input is hidden but kept in the
   tab order; checked state lifts the surrounding label. */
.mode-grid {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 6px;
}
.mode-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
}
.mode-option input[type=radio] {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  margin-top: 2px; accent-color: var(--accent);
  cursor: pointer;
}
.mode-option > span { flex: 1; }
.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.mode-detail { /* container for the bot-level picker, etc. */ }

/* Bot level picker — five compact radio cells in a row. */
.level-picker {
  display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.level-option {
  flex: 1 1 auto; min-width: 48px; cursor: pointer;
}
.level-option input[type=radio] {
  position: absolute; opacity: 0; pointer-events: none;
}
.level-option > span {
  display: block; text-align: center;
  padding: 10px 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.level-option input:checked + span {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  border-color: var(--accent);
  color: var(--text);
}
.level-option input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* Active-games list shown on the index page. */
.game-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.game-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.game-entry.your-turn {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}
.game-entry-main { flex: 1; min-width: 0; }
.game-entry-top {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.game-entry-top .game-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700; letter-spacing: 0.05em;
}
.game-entry-top .game-mode {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 6px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.game-entry-sub { font-size: 13px; margin-top: 2px; }
.game-entry .btn { flex: 0 0 auto; padding: 6px 12px; }

/* Cards */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px; margin: 12px 0;
}
.card + .card { margin-top: 14px; }

/* Game code badge — shown big on host.php */
.code-badge {
  display: inline-block;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 36px; font-weight: 800; letter-spacing: 8px;
  background: linear-gradient(135deg, var(--surface-2) 0%, #2d3450 100%);
  color: var(--accent-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 18px; margin: 8px 0;
  user-select: all;
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
}
.code-inline {
  display: inline-block;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 18px; letter-spacing: 4px; font-weight: 700;
  color: var(--accent-2);
}

/* Seat badges (Red / Yellow chips next to player names) */
.seat-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase;
  margin-right: 6px;
  vertical-align: middle;
}
.seat-badge.red    { background: rgba(255, 90, 90, 0.18);  color: var(--p1); border: 1px solid var(--p1); }
.seat-badge.yellow { background: rgba(255, 209, 102, 0.18); color: var(--p2); border: 1px solid var(--p2); }

/* Player lists (lobby + results) */
.player-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.player-list li {
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.player-list li.empty { opacity: 0.6; }
.player-list li.me    { border-color: var(--accent); }
.player-list li.winner { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.player-list li.stale { opacity: 0.55; }
.player-list.spec li { font-size: 13px; padding: 6px 10px; }

/* Turn indicator (top of play.php) */
.turn-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px 4px 4px;
  font-size: 14px;
}
.turn-disc {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.3);
}
.turn-disc.p1 { background: radial-gradient(circle at 30% 30%, var(--p1-hi), var(--p1)); }
.turn-disc.p2 { background: radial-gradient(circle at 30% 30%, var(--p2-hi), var(--p2)); }

/* Move clock */
.clock {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 800; font-size: 22px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  color: var(--text);
  transition: color .2s, border-color .2s, text-shadow .2s;
}
.clock.warn {
  color: var(--warn); border-color: var(--warn);
  text-shadow: 0 0 12px rgba(255, 179, 71, 0.6);
}
.clock.bad {
  color: var(--bad); border-color: var(--bad);
  text-shadow: 0 0 16px rgba(255, 107, 107, 0.8);
  animation: clock-pulse 1s ease-in-out infinite;
}
@keyframes clock-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .clock.bad { animation: none; }
}

/* ===================== The board ====================================
   A 7×6 grid of holes punched into a blue frame. The holes are circular
   "slots" (dark background) and a "disc" element sits inside each slot.
   The disc is transparent until filled. Drop animation slides the disc
   from above into its final position. */

.board-wrap {
  position: relative;
  max-width: 560px;
  margin: 14px auto;
  /* aspect-ratio handled by .board itself */
}

.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 10px;
  background: linear-gradient(160deg, var(--board) 0%, #1f5ad9 100%);
  border-radius: var(--radius-md);
  aspect-ratio: 7 / 6;
  box-shadow: 0 6px 0 rgba(0,0,0,0.5), 0 10px 24px rgba(0,0,0,0.4),
              inset 0 2px 4px rgba(255,255,255,0.18);
}

.cell {
  aspect-ratio: 1;
  background: var(--slot);
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 3px 5px rgba(0,0,0,0.55), inset 0 -1px 2px rgba(255,255,255,0.05);
  overflow: hidden;
}

.cell .disc {
  display: block;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: transparent;
  position: relative;
}

/* Player discs — radial gradient for a 3D-ish "real plastic" look. */
.cell.p1 .disc {
  background: radial-gradient(circle at 32% 30%, var(--p1-hi) 0%, var(--p1) 55%, #c43434 100%);
  box-shadow: inset 0 -4px 6px rgba(0,0,0,0.35), inset 0 3px 4px rgba(255,255,255,0.3);
}
.cell.p2 .disc {
  background: radial-gradient(circle at 32% 30%, var(--p2-hi) 0%, var(--p2) 55%, #c9a020 100%);
  box-shadow: inset 0 -4px 6px rgba(0,0,0,0.35), inset 0 3px 4px rgba(255,255,255,0.3);
}

/* Drop animation. The disc enters from above and bounces slightly into
   its slot. We translate the disc (not the cell) so the slot frame
   stays in place. */
.cell.drop .disc {
  animation: disc-drop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes disc-drop {
  0%   { transform: translateY(-650%); }
  60%  { transform: translateY(0); }
  72%  { transform: translateY(-12%); }
  85%  { transform: translateY(0); }
  92%  { transform: translateY(-4%); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .cell.drop .disc { animation: none; }
}

/* Winning cells glow green and pulse softly. */
.cell.winning {
  box-shadow: inset 0 3px 5px rgba(0,0,0,0.55), 0 0 0 3px var(--good), 0 0 22px var(--good);
  animation: win-pulse 1.4s ease-in-out infinite alternate;
}
@keyframes win-pulse {
  from { box-shadow: inset 0 3px 5px rgba(0,0,0,0.55), 0 0 0 3px var(--good), 0 0 16px var(--good); }
  to   { box-shadow: inset 0 3px 5px rgba(0,0,0,0.55), 0 0 0 3px var(--good), 0 0 30px var(--good); }
}
@media (prefers-reduced-motion: reduce) {
  .cell.winning { animation: none; }
}

/* Column overlay — invisible click targets above the board. When it's the
   caller's turn we colour them faintly and show a preview disc at the top
   of the column on hover. */
.board-cols {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 10px;
  z-index: 2;
  pointer-events: none;
}
.col-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  border-radius: 6px;
  position: relative;
  transition: background 0.12s ease;
}
.col-btn:disabled { cursor: not-allowed; pointer-events: none; }

.board-wrap.my-turn .col-btn:hover {
  background: rgba(255,255,255,0.06);
}

/* Hover preview disc, floating at the top of the column. Uses the
   `--turn-bg` var driven by the turn-1/turn-2 modifier on .board-wrap. */
.board-wrap.turn-1 { --turn-bg: radial-gradient(circle at 32% 30%, var(--p1-hi), var(--p1) 55%, #c43434); }
.board-wrap.turn-2 { --turn-bg: radial-gradient(circle at 32% 30%, var(--p2-hi), var(--p2) 55%, #c9a020); }

.board-wrap.my-turn .col-btn:not(:disabled):hover::before {
  content: '';
  position: absolute;
  top: -10%;
  left: 14%;
  right: 14%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--turn-bg);
  opacity: 0.75;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  /* Don't bounce in on hover — just appear cleanly. */
  animation: preview-fade 0.18s ease;
}
@keyframes preview-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 0.75; transform: translateY(0); }
}

/* Final-board layout on results.php — same as play but no click overlay. */
.board-wrap.results { max-width: 480px; }

/* Leaderboard table. Wrapped in .table-wrap for horizontal scroll on
   narrow screens — better than collapsing columns. */
.table-wrap { overflow-x: auto; }
.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.leaderboard th, .leaderboard td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.leaderboard th {
  font-size: 11px; font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky; top: 0;
}
.leaderboard th.num, .leaderboard td.num   { text-align: right; }
.leaderboard th.rank, .leaderboard td.rank { width: 36px; text-align: center; color: var(--text-dim); font-weight: 700; }
.leaderboard td.name { font-weight: 700; }
.leaderboard td.win  { color: var(--good); }
.leaderboard td.loss { color: var(--bad); }
.leaderboard td.draw { color: var(--warn); }
.leaderboard td.last { color: var(--text-dim); font-size: 12px; }
/* Top three get tinted rank chips. Reads as a podium without hijacking
   the table layout. */
.leaderboard tbody tr:nth-child(1) td.rank { color: #ffd166; font-size: 16px; }
.leaderboard tbody tr:nth-child(2) td.rank { color: #cfd6e4; font-size: 16px; }
.leaderboard tbody tr:nth-child(3) td.rank { color: #d4884a; font-size: 16px; }
.leaderboard tbody tr:hover { background: var(--surface-2); }

/* Footer */
.foot {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 24px; color: var(--text-dim); font-size: 12px;
}

/* Toast — Bobble-style with a slight pop. */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--surface-1); color: var(--text);
  border: 2px solid var(--border); border-radius: 999px;
  padding: 10px 18px; font-size: 15px; font-weight: 700;
  z-index: 50; pointer-events: none;
  opacity: 0; transition: opacity .15s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; }
.toast.good { background: rgba(90, 208, 126, 0.18); color: var(--good); border-color: var(--good); }
.toast.bad  { background: rgba(255, 107, 107, 0.18); color: var(--bad);  border-color: var(--bad); }

/* Winner line on results.php */
.winner-line {
  text-align: center; font-size: 28px; font-weight: 800;
  margin: 6px 0 8px;
  color: var(--text);
}
.winner-line.me {
  color: var(--good);
  text-shadow: 0 0 20px rgba(90, 208, 126, 0.6);
  animation: winner-glow 2s ease-in-out infinite alternate;
}
.winner-line.draw  { color: var(--warn); }
.winner-line.other { color: var(--text-dim); }
@keyframes winner-glow {
  from { text-shadow: 0 0 10px rgba(90, 208, 126, 0.4); }
  to   { text-shadow: 0 0 24px rgba(90, 208, 126, 0.8); }
}
@media (prefers-reduced-motion: reduce) {
  .winner-line.me { animation: none; }
}

/* Header icon buttons (theme + mute). */
.c4-iconbtn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); border-radius: 999px;
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; line-height: 1;
  transition: transform .08s, background .15s, border-color .15s;
}
.c4-iconbtn:hover  { background: var(--surface-2); border-color: var(--accent); }
.c4-iconbtn:active { transform: scale(0.92); }
.c4-iconbtn .c4-mute-off { display: none; }
.c4-iconbtn.is-muted .c4-mute-on  { display: none; }
.c4-iconbtn.is-muted .c4-mute-off { display: inline; color: var(--text-dim); }
.c4-iconbtn .c4-theme-sun  { display: none; }
.c4-iconbtn.is-light .c4-theme-moon { display: none; }
.c4-iconbtn.is-light .c4-theme-sun  { display: inline; }

/* PWA update modal — same shape as Bobble's so users on both sites see
   the same UI for a service-worker update. */
.c4-update-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: all;
}
.c4-update-modal[hidden] { display: none !important; }
.c4-update-modal-box {
  width: 100%; max-width: 400px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 22px 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  text-align: center;
}
.c4-update-modal-box h2 { margin: 0 0 8px; font-size: 18px; color: var(--accent); }
.c4-update-modal-box p  { margin: 0 0 16px; font-size: 14px; color: var(--text-dim); }
.c4-update-modal-buttons { display: flex; gap: 10px; }
.c4-update-modal-buttons .btn { flex: 1; }

/* Shake (used for rejected moves) */
.c4-shake { animation: c4-shake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes c4-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* Confetti */
.c4-confetti-wrap {
  position: fixed; inset: 0; pointer-events: none; z-index: 70;
  overflow: hidden;
}
.c4-confetti {
  position: absolute; width: 10px; height: 14px;
  border-radius: 2px; opacity: 0.95;
  animation: confetti-fall 1.6s ease-in forwards;
  transform-origin: center;
  will-change: transform, opacity;
}
@keyframes confetti-fall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--drift), var(--fall)) rotate(var(--rot)); opacity: 0; }
}

/* Small-screen tweaks. The board is the only thing that really needs
   special handling — bigger touch targets via the column buttons (which
   stretch to fill the column anyway, so this mostly just sizes the
   surrounding padding). */
@media (max-width: 520px) {
  .container { padding: 10px 10px 32px; }
  .code-badge { font-size: 28px; letter-spacing: 6px; padding: 8px 14px; }
  .board { gap: 5px; padding: 7px; }
  .board-cols { gap: 5px; padding: 7px; }
}
