:root {
  --ink: #22483d;
  --green: #245c4c;
  --muted: #52685f;
  --paper: #faf8f1;
  --line: #d4dfd4;
  --gold: #edc871;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    20px/1.5 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
button,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 4px solid #ab6300;
  outline-offset: 5px;
}
button:disabled {
  cursor: default;
}
header {
  max-width: 1200px;
  margin: auto;
  padding: 25px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: Georgia, serif;
  font-size: 27px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand svg {
  width: 35px;
  height: 35px;
}
.tag {
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.help {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: transparent;
  padding: 10px 20px;
  color: var(--green);
  min-height: 48px;
}
main {
  max-width: 1120px;
  margin: auto;
  padding: 36px 40px 55px;
}
.intro {
  text-align: center;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 13px;
  font-weight: 750;
  color: #617569;
}
.intro h1 {
  font:
    normal clamp(36px, 5vw, 55px)/1.15 Georgia,
    serif;
  letter-spacing: -0.03em;
  margin: 10px 0 12px;
}
.intro p {
  margin: 0;
  color: var(--muted);
}
.settings {
  margin: 30px 0 24px;
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: end;
  flex-wrap: wrap;
}
.label {
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
}
.segments {
  display: flex;
  border: 1px solid #b8cbbb;
  border-radius: 12px;
  padding: 4px;
  background: #fff;
}
.segments button {
  border: 0;
  background: none;
  color: var(--ink);
  padding: 9px 17px;
  border-radius: 8px;
  font-size: 17px;
  min-height: 48px;
}
.segments button[aria-pressed="true"] {
  background: var(--green);
  color: white;
}
select {
  border: 1px solid #b8cbbb;
  background: #fff;
  border-radius: 12px;
  padding: 13px 34px 13px 15px;
  color: var(--ink);
  height: 66px;
  font-size: 17px;
}
.play-area {
  background: #eff2e8;
  border: 1px solid #dde4d6;
  border-radius: 24px;
  padding: 22px 30px 26px;
  box-shadow: 0 8px 30px #28483105;
}
.game-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 19px;
  gap: 12px;
  font-size: 17px;
}
.progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.track {
  width: 105px;
  height: 7px;
  background: #d6dfcf;
  border-radius: 8px;
  overflow: hidden;
}
.fill {
  height: 100%;
  background: var(--green);
  width: 0;
  transition: width 0.3s;
}
.quiet {
  border: 0;
  background: transparent;
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 5px;
  padding: 10px;
  min-height: 48px;
}
.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 760px;
  margin: auto;
}
.card {
  position: relative;
  aspect-ratio: 1.28;
  border-radius: 15px;
  border: 2px solid #fff;
  background: var(--green);
  box-shadow: 0 3px 0 #194434;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  color: white;
  transition:
    transform 0.15s,
    background 0.15s;
}
.card:hover:not(:disabled) {
  transform: translateY(-3px);
  background: #306f5b;
}
.card .back {
  font:
    normal 44px Georgia,
    serif;
  color: #e2cf8e;
  border: 1px solid #b3d0b055;
  border-radius: 50%;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
}
.card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid #a8c7a544;
  border-radius: 9px;
  pointer-events: none;
}
.card.open,
.card.matched {
  background: #fffdfa;
  color: var(--ink);
  border-color: #d0daca;
  box-shadow: 0 3px 0 #d4ddcc;
}
.card.matched {
  background: #e1ebd8;
  border-color: #9cb58d;
  box-shadow: none;
}
.picture {
  font-size: clamp(40px, 5vw, 64px);
  line-height: 1.1;
}
.name {
  font-size: 17px;
  margin-top: 6px;
}
.tick {
  position: absolute;
  right: 9px;
  top: 5px;
  font-size: 18px;
  color: var(--green);
}
.below {
  text-align: center;
  min-height: 100px;
  margin-top: 23px;
}
.status {
  margin: 0;
  font-size: 19px;
}
.substatus {
  color: var(--muted);
  font-size: 16px;
  margin: 5px 0;
}
.primary {
  background: var(--green);
  color: white;
  border: 2px solid var(--green);
  border-radius: 12px;
  min-height: 54px;
  padding: 10px 25px;
  margin-top: 12px;
  font-weight: 650;
}
.primary:hover {
  background: #164635;
}
.secondary {
  background: #fff;
  border: 1px solid #aec4b4;
  color: var(--green);
  border-radius: 12px;
  padding: 10px 21px;
  min-height: 54px;
  margin-top: 12px;
}
.footer-note {
  display: flex;
  justify-content: center;
  gap: 24px;
  color: var(--muted);
  font-size: 15px;
  margin-top: 25px;
}
.dot {
  color: #a17827;
  margin-right: 6px;
}
dialog {
  max-width: 530px;
  width: calc(100% - 32px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 30px;
  color: var(--ink);
  background: var(--paper);
}
dialog::backdrop {
  background: #123a2fd0;
}
dialog h2 {
  font:
    normal 32px Georgia,
    serif;
  margin-top: 0;
}
dialog li {
  margin: 14px 0;
}
dialog p {
  font-size: 18px;
}
.decor {
  color: #c29742;
  font-size: 27px;
  text-align: center;
  margin: 0 0 6px;
}
.hidden {
  display: none !important;
}
@media (min-width: 800px) {
  .board[data-size="8"] {
    max-width: 680px;
  }
  .board[data-size="16"] {
    max-width: 710px;
    gap: 12px;
  }
  .board[data-size="16"] .card {
    aspect-ratio: 1.5;
  }
  .board[data-size="16"] .picture {
    font-size: 48px;
  }
}
@media (max-width: 600px) {
  header {
    padding: 17px 20px;
  }
  .brand {
    font-size: 23px;
  }
  .tag {
    display: none;
  }
  main {
    padding: 26px 15px;
  }
  .intro p {
    font-size: 18px;
  }
  .settings {
    gap: 15px;
    margin: 25px 0 20px;
  }
  .segments button {
    padding: 8px 11px;
    font-size: 16px;
  }
  select {
    height: 64px;
  }
  .play-area {
    padding: 13px 12px 20px;
    border-radius: 18px;
  }
  .game-top {
    font-size: 15px;
    margin-bottom: 13px;
  }
  .track {
    width: 50px;
  }
  .progress {
    gap: 7px;
  }
  .board {
    gap: 10px;
  }
  .card {
    aspect-ratio: 0.83;
    border-radius: 11px;
  }
  .card .back {
    width: 40px;
    height: 40px;
    font-size: 30px;
  }
  .picture {
    font-size: 39px;
  }
  .name {
    font-size: 12px;
  }
  .tick {
    font-size: 13px;
    right: 4px;
    top: 2px;
  }
  .footer-note {
    gap: 12px;
    font-size: 13px;
  }
  .below {
    margin-top: 20px;
  }
  .status {
    font-size: 18px;
  }
}
@media (max-width: 600px) {
  .help {
    padding: 8px 12px;
    font-size: 15px;
    min-height: 44px;
  }
  .settings {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 10px;
    margin: 14px 0;
  }
  .settings > div {
    min-width: 0;
  }
  .label {
    font-size: 13px;
    margin-bottom: 4px;
  }
  .segments {
    padding: 3px;
  }
  .segments button {
    flex: 1;
    padding: 7px 2px;
    font-size: 14px;
    min-height: 44px;
    white-space: nowrap;
  }
  select {
    width: 100%;
    min-width: 0;
    height: 52px;
    padding: 8px 4px;
    font-size: 16px;
  }
  .play-area {
    padding: 10px 8px 14px;
  }
  .game-top {
    gap: 4px;
    margin-bottom: 8px;
    font-size: 14px;
  }
  .quiet {
    min-height: 44px;
    padding: 6px;
    font-size: 14px;
  }
  .track {
    width: 32px;
  }
  .board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  .card {
    aspect-ratio: 0.95;
    min-height: 62px;
    padding: 4px 2px;
  }
  .picture {
    font-size: clamp(28px, 8vw, 38px);
  }
  .name {
    max-width: 100%;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  .below {
    min-height: 0;
    margin-top: 14px;
  }
  .status {
    font-size: 16px;
  }
  .substatus {
    font-size: 14px;
  }
  .primary,
  .secondary {
    min-height: 48px;
    margin-top: 8px;
    padding: 9px 12px;
    font-size: 16px;
  }
  .footer-note {
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 14px;
    font-size: 12px;
  }
  dialog {
    max-height: calc(100svh - 24px);
    overflow-y: auto;
    padding: 20px;
    font-size: 16px;
  }
  dialog h2 {
    font-size: 26px;
  }
  dialog p {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
