:root {
  color-scheme: light;
  --paper: #fdfdfa;
  --ink: #252922;
  --muted: #565d52;
  --line: #d9ddd4;
  --green: #285b36;
  --mono: "Courier New", monospace;
  background: var(--paper);
  color: var(--ink);
  font: 100%/1.55 system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; }
button:focus-visible { outline: 2px dashed var(--green); outline-offset: 4px; }

.page, .footer {
  width: min(45rem, calc(100% - 2 * clamp(1rem, 5vw, 2rem)));
  margin-inline: auto;
}

.intro {
  padding-top: clamp(3.25rem, 9vw, 6rem);
  text-align: center;
}

.intro img {
  display: block;
  width: min(100%, 25rem);
  height: auto;
  margin-inline: auto;
}

.status {
  width: fit-content;
  margin: 1rem auto 1.35rem;
  padding: .15rem .55rem;
  border: 1px solid currentColor;
  color: var(--green);
  font: 700 .875rem/1.45 var(--mono);
  letter-spacing: .14em;
}

.tagline { font-size: clamp(1.25rem, 3.7vw, 1.625rem); font-weight: 750; }
.description { max-width: 35rem; margin: .45rem auto 0; color: var(--muted); }
.page { position: relative; }
.menu-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--green);
  font: 700 .875rem var(--mono);
  text-underline-offset: .25em;
}
.menu-link:focus-visible { outline: 2px dashed var(--green); outline-offset: 3px; }
.catalogue { padding-top: clamp(1.25rem, 4vw, 3rem); }
.catalogue-header { margin: 1.6rem 0 1.2rem; }
.catalogue-header h1 { font: 700 clamp(1.75rem, 7vw, 2.5rem)/1.2 var(--mono); }
.catalogue-header p { margin-top: .5rem; color: var(--muted); }
.game-picker { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.game-picker li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-block: .85rem;
  border-bottom: 1px solid var(--line);
}
.game-picker h2 { font: 700 1.0625rem var(--mono); }
.game-picker p { margin-top: .2rem; color: var(--muted); }
.arcade-button {
  min-height: 44px;
  padding: .4rem .75rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: 700 .875rem var(--mono);
}
.arcade-button:hover { border-color: var(--green); color: var(--green); }
.arcade-button[aria-expanded="true"] { background: var(--green); border-color: var(--green); color: var(--paper); }
.game { margin-top: clamp(2.75rem, 7vw, 4rem); }
.catalogue-player .game { margin-top: 2rem; }

.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .35rem 1rem;
  font-family: var(--mono);
}

.game-header h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .14em; }
.scores { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .875rem; }
.scores strong { color: var(--ink); }
.arena { position: relative; margin-top: .5rem; }
#scene { display: block; width: 100%; height: 142px; image-rendering: pixelated; }
.game-over { position: absolute; inset: 40% 0 auto; text-align: center; font: 700 1rem var(--mono); letter-spacing: .2em; pointer-events: none; }
.play-area { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; touch-action: manipulation; }
.game-message { margin-top: .65rem; color: var(--muted); }

.game-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .65rem 1rem;
  margin-top: .65rem;
}

#game-controls { font-size: .875rem; color: var(--muted); }
kbd { padding: .12em .35em; border: 1px solid var(--line); color: var(--ink); font: 700 .875rem var(--mono); }
#play-button { min-height: 44px; padding: .35rem .8rem; border: 1px solid currentColor; background: transparent; color: var(--green); cursor: pointer; font: 700 .875rem var(--mono); }
#play-button:hover { background: var(--green); border-color: var(--green); color: var(--paper); }
#play-button:disabled { visibility: hidden; }

.pairs-board, .trail-board { display: grid; gap: .35rem; margin: 1rem auto; }
.pairs-board { max-width: 21rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.trail-board { max-width: 18rem; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pairs-board button, .trail-board button, .trail-board .water {
  aspect-ratio: 1;
  min-width: 0;
  min-height: 44px;
}
.pairs-board button, .trail-board button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 700 1.25rem var(--mono);
}
.pairs-board button:hover, .trail-board button:hover { border-color: var(--green); }
.pairs-board [data-face] { border-color: var(--green); }
.pairs-board [data-face="matched"] { background: #eaf1e5; cursor: default; }
.pixel-icon { display: block; width: 25px; height: 25px; image-rendering: pixelated; }
.trail-board .water { display: grid; place-items: center; color: var(--muted); }
.trail-board .water::after { content: ""; width: 12px; height: 8px; border-block: 1px solid var(--line); }
.trail-board button { background: #eaf1e5; border-color: #a9bca3; }
.trail-board button[data-tile="frog"] { background: var(--paper) url("../../favicon.svg") center / 72% no-repeat; image-rendering: pixelated; border-color: var(--green); }
.trail-board button[data-tile="fly"]::after { content: ""; width: 9px; height: 9px; background: var(--green); clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%); }
.trail-board button[data-tile="flag"]::after { content: ""; width: 16px; height: 17px; background: var(--ink); clip-path: polygon(0 0, 100% 0, 100% 52%, 20% 52%, 20% 100%, 0 100%); }
#trail-controls { margin-top: .5rem; }
#pairs-message, #trail-message, #trail-controls { color: var(--muted); font-size: .9375rem; }

.topics { margin-top: clamp(2rem, 6vw, 3rem); border-top: 1px solid var(--line); padding-top: 1.5rem; }
.topics h2 { font: 700 1.25rem/1.35 var(--mono); }
.topics ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1.75rem; padding: 0; margin: 1rem 0 0; list-style: none; }
.topics li { position: relative; padding-inline-start: 1rem; }
.topics li::before { content: ""; position: absolute; inset: .65em auto auto 0; width: 5px; height: 5px; background: var(--green); }
.footer { margin-top: clamp(2.75rem, 7vw, 4rem); border-top: 1px solid var(--line); padding: 1rem 0 1.5rem; text-align: center; color: var(--muted); font-family: var(--mono); }

@media (max-width: 37rem) {
  .topics ul { grid-template-columns: 1fr; }
}
