/* Fluently Silent — calm, low-contrast, unhurried.
   Nothing saturated, nothing that flashes, nothing that counts down. */

:root {
  --bg: #f4f3ef;
  --surface: #fbfaf7;
  --surface-2: #efeee8;
  --ink: #333e39;
  --ink-soft: #77837d;
  --line: #e3e1d9;
  --accent: #5d8a73;
  --accent-soft: #e7efe9;
  --radius: 14px;
  --max: 900px;

  /* Muted game palette — desaturated so long play is easy on the eyes. */
  --c1: #7f9e8b;
  --c2: #a8937c;
  --c3: #8395ad;
  --c4: #b09795;
  --c5: #9a8fa6;
  --c6: #b0a67e;
  --c7: #7e9d9a;
  --c8: #9d8f87;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 22px; width: 100%; }

a { color: var(--accent); }

/* ---------- chrome ---------- */

.topbar { border-bottom: 1px solid var(--line); }

.topbar-inner {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

.back { color: var(--ink-soft); text-decoration: none; font-size: 0.95rem; }
.back:hover { color: var(--ink); }

main { flex: 1; }

.foot {
  border-top: 1px solid var(--line);
  padding: 22px 0 30px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.foot-inner { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between; }

/* ---------- landing ---------- */

.hero { padding: 72px 0 44px; }

h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 600;
  max-width: 18ch;
}

.lede { margin: 0; color: var(--ink-soft); max-width: 52ch; }

.band { padding: 30px 0; }

.band-head { margin-bottom: 20px; }
.band-head h2 { margin: 0 0 2px; font-size: 1.15rem; font-weight: 600; letter-spacing: -0.015em; }
.band-head p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 14px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -20px rgba(51, 62, 57, 0.28);
}

.game-art { display: block; height: 62px; margin-bottom: 8px; }
.game-art svg { display: block; width: 100%; height: 100%; overflow: visible; }

.game-name { font-weight: 600; letter-spacing: -0.01em; }
.game-blurb { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.45; }

/* ---------- play page ---------- */

.play { padding: 40px 0 56px; }
.play-head { margin-bottom: 22px; }
.play-head h1 { margin: 0 0 4px; font-size: 1.6rem; max-width: none; }
.rule { margin: 0; color: var(--ink-soft); font-size: 0.97rem; }

.stage-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(51, 62, 57, 0.04), 0 12px 32px -18px rgba(51, 62, 57, 0.18);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  min-height: 1px;
}

.controls:empty { display: none; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 18px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  min-height: 44px;
  line-height: 24px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { border-color: var(--accent); background: #fff; }
.btn[aria-pressed="true"], .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }

.seg { display: inline-flex; gap: 6px; }
.spacer { flex: 1; }

.stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 340px;
  touch-action: manipulation;
}

.stage svg, .stage canvas { max-width: 100%; height: auto; display: block; }

/* Boards float very slightly off the shell. */
.stage > svg, .stage > canvas, .stage > .board {
  filter: drop-shadow(0 1px 1px rgba(51, 62, 57, 0.05)) drop-shadow(0 10px 22px rgba(51, 62, 57, 0.07));
}

/* A small settle when a puzzle resolves — no confetti, just a breath. */
.stage.solved > * { animation: settle 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes settle {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.015); }
  100% { transform: scale(1); }
}

/* Any element that should ease its transform (rotating pipes, lifting tubes). */
.ease-t { transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1); }

.status {
  margin: 14px 0 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
  min-height: 1.6em;
}

.status.done { color: var(--accent); font-weight: 500; }

.more { margin-top: 26px; }
.more summary { cursor: pointer; color: var(--ink-soft); font-size: 0.93rem; }
.more-grid { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 14px 2px 0; }
.more-grid a { text-decoration: none; font-size: 0.93rem; }
.more-grid a:hover { text-decoration: underline; }

@media (max-width: 620px) {
  .hero { padding: 48px 0 32px; }
  .stage-shell { padding: 12px; }
  .stage { min-height: 300px; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

/* ---------- memory pairs (DOM cards with a real flip) ---------- */

.mc-grid { display: grid; gap: 12px; perspective: 900px; }

.mc-card {
  position: relative;
  width: 92px; height: 108px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
  border-radius: 14px;
}

.mc-card.up { transform: rotateY(180deg); }
.mc-card.done { cursor: default; }

.mc-face {
  position: absolute; inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
}

.mc-back {
  background: linear-gradient(160deg, #f3f2ec, #e9e8e1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.mc-back::after {
  content: "";
  width: 14px; height: 14px; border-radius: 50%;
  background: #d9d7cf;
}

.mc-front {
  background: #fff;
  transform: rotateY(180deg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 6px 14px -10px rgba(51, 62, 57, 0.3);
}

.mc-card.done .mc-front { background: var(--accent-soft); border-color: #cfdfd5; }
.mc-card.done { transform: rotateY(180deg) scale(0.96); }

.mc-front svg { width: 46px; height: 46px; display: block; }

@media (max-width: 480px) {
  .mc-card { width: 70px; height: 84px; }
  .mc-front svg { width: 36px; height: 36px; }
  .mc-grid { gap: 9px; }
  .mc-grid[data-cols="5"] .mc-card { width: 56px; height: 68px; }
  .mc-grid[data-cols="5"] .mc-front svg { width: 30px; height: 30px; }
  .mc-grid[data-cols="5"] { gap: 7px; }
}

/* ---------- sliding tiles (DOM tiles that actually slide) ---------- */

.sl-board {
  position: relative;
  background: #ebeae4;
  border-radius: 18px;
  padding: 8px;
  box-shadow: inset 0 2px 6px rgba(51, 62, 57, 0.08);
}

.sl-tile {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 4px 10px -6px rgba(51, 62, 57, 0.35);
  transition: transform 190ms cubic-bezier(0.2, 0.7, 0.2, 1), background 300ms ease, color 300ms ease;
}

.sl-tile:hover { background: #fbfaf7; }
.sl-board.solved .sl-tile { background: var(--accent-soft); color: var(--accent); border-color: #cfdfd5; cursor: default; }
