@font-face {
  font-family: "DM Sans";
  src: url("./assets/dm-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #2b197e;
  --ink: #27196f;
  --cream: #fffaf0;
  --white: #fffdf7;
  --pale: #d9d0f8;
  --muted: #c9bceb;
  --line: #9586ce;
  --violet: #5c44e2;
  --violet-edge: #3d2aa3;
  --yellow: #ffdc25;
  --yellow-edge: #bf8c04;
  --spent-face: #57596b;
  --spent-edge: #404258;
  --spent-text: #e3e2e8;
  --pink: #ff8eaa;
  --play-width: 806px;
  --key-height: clamp(44px, 5.25vw, 70px);
  font: 100%/1.42 "DM Sans", "Avenir Next", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: var(--night); color: var(--white); }
h1, h2, h3, p { margin: 0; }
button, select { color: inherit; font: inherit; }
button:enabled, select { cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 4px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header { color: var(--ink); background: var(--white); color-scheme: light; }
.site-header-inner {
  width: min(calc(100% - 64px), 1440px);
  min-height: 104px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
}
.wordmark { width: clamp(148px, 18vw, 240px); height: auto; flex: none; }
.mode-nav { display: flex; align-items: center; gap: clamp(6px, 1.25vw, 18px); }
.mode-nav button {
  min-height: 44px;
  padding: 7px clamp(9px, 1.15vw, 18px);
  border: 0;
  border-radius: 9px;
  background: transparent;
  white-space: nowrap;
  font-size: clamp(.92rem, 1.5vw, 1.38rem);
  font-weight: 760;
}
.mode-nav button:hover { background: #ebe5ff; }
.mode-nav button[aria-pressed="true"] { color: var(--white); background: var(--ink); }
.mode-nav button:focus-visible { outline-color: var(--violet); }
.mode-nav .help-button { margin-inline-start: 6px; }

.page { width: min(calc(100% - 56px), 1280px); margin-inline: auto; padding: 32px 0 36px; }
.load-message { margin: 2rem auto; text-align: center; color: var(--pale); }
.game-layout { min-width: 0; }
.goal {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  grid-template-areas: "heading progress strikes";
  align-items: center;
  min-height: 61px;
  gap: 17px clamp(18px, 3.1vw, 44px);
}
.goal-heading-group { grid-area: heading; min-width: min(13vw, 144px); }
.goal h2 { font-size: clamp(1.4rem, 3vw, 2.25rem); font-weight: 850; line-height: 1; letter-spacing: -.04em; }
.puzzle-date { margin-block-start: 5px; color: var(--pale); font-size: .875rem; font-weight: 550; }
.puzzle-picker { margin-top: 7px; }
select {
  min-height: 37px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid #9280d7;
  border-radius: 7px;
  background: #3c2b90;
  font-size: .875rem;
  font-weight: 750;
}
.progress-group { grid-area: progress; padding-inline-start: clamp(18px, 3.1vw, 44px); border-inline-start: 1px solid var(--line); }
.progress-track { display: flex; align-items: center; gap: clamp(12px, 1.8vw, 24px); }
.move-total { flex: none; font-size: clamp(.95rem, 2vw, 1.55rem); font-weight: 820; letter-spacing: -.02em; }
.meter {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--meter-steps, 9), minmax(0, 1fr));
  gap: clamp(3px, .5vw, 7px);
  max-width: 380px;
}
.meter span { height: clamp(7px, 1vw, 13px); border-radius: 999px; background: #7665b5; }
.meter span.is-stretch { background: transparent; border: 1px solid #9b8ccf; }
.meter span.is-done { border-color: var(--yellow); background: var(--yellow); }
.goal-labels { display: flex; flex-wrap: wrap; gap: 3px 16px; margin-top: 3px; color: var(--pale); font-size: .85rem; font-weight: 620; }
.strike-status {
  grid-area: strikes;
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.7vw, 24px);
  padding-inline-start: clamp(18px, 3.1vw, 44px);
  border-inline-start: 1px solid var(--line);
  font-size: clamp(.95rem, 2vw, 1.45rem);
  font-weight: 820;
  white-space: nowrap;
}
.strike-marks { display: flex; gap: clamp(4px, .7vw, 9px); }
.strike-mark { display: grid; place-items: center; width: clamp(17px, 2.4vw, 28px); aspect-ratio: 1; border: 1px solid var(--pale); border-radius: 6px; }
.strike-mark img { visibility: hidden; width: 76%; height: 76%; }
.strike-mark.is-used { border-color: var(--pink); background: #442371; }
.strike-mark.is-used img { visibility: visible; }

.chain {
  --scroll-control: 43px;
  display: grid;
  grid-template-columns: var(--scroll-control) minmax(0, 1fr) var(--scroll-control);
  align-items: center;
  gap: 9px;
  width: min(100%, calc(var(--play-width) + 104px));
  margin: 41px auto 0;
}
.chain-scroll {
  grid-column: 2;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  border-block-end: 2px solid var(--line);
}
.chain-scroll::-webkit-scrollbar { display: none; }
.chain-scroll:focus-visible { outline-offset: 3px; border-radius: 4px; }
.chain-list {
  width: max-content;
  min-width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 3px 11px 8px;
  list-style: none;
}
.chain-row { display: flex; align-items: center; flex: none; color: var(--pale); }
.chain-row + .chain-row::before { content: ""; width: 5px; height: 5px; margin-inline: clamp(11px, 1.8vw, 27px); border-radius: 50%; background: var(--line); }
.chain-row[aria-current="step"] { color: var(--white); }
.chain-word { white-space: nowrap; font-size: clamp(1rem, 2.35vw, 2.13rem); font-weight: 870; letter-spacing: .08em; line-height: 1; }
.chain-change { color: var(--yellow); }
.chain-arrow {
  align-self: center;
  display: grid;
  place-items: center;
  width: var(--scroll-control);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #3c2b90;
}
#chain-earlier { grid-column: 1; grid-row: 1; }
#chain-later { grid-column: 3; grid-row: 1; }
.chain-arrow:enabled:hover { background: var(--violet); }
.chain-arrow:disabled { opacity: .46; }

.board { width: min(100%, var(--play-width)); margin: 37px auto 0; text-align: center; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(5px, .8vw, 12px); }
.tile {
  min-width: 0;
  aspect-ratio: 1 / 1.08;
  padding: 0;
  border: 1px solid #fffaf4;
  border-bottom: clamp(3px, .65vw, 8px) solid #d3c6b1;
  border-radius: clamp(9px, 1.7vw, 24px);
  background: var(--cream);
  color: var(--ink);
  font-size: clamp(1.75rem, 7.3vw, 6.15rem);
  font-weight: 880;
  line-height: 1;
  box-shadow: 0 4px 0 #170f51;
  transition: translate 120ms ease, box-shadow 120ms ease, background-color 100ms linear;
}
.tile:enabled:hover { background: #f7efdd; }
.tile[aria-pressed="true"]:enabled {
  z-index: 1;
  translate: 0 -3px;
  background: #fff0aa;
  border-color: #fff7d2;
  border-bottom-color: var(--yellow-edge);
  box-shadow: 0 0 0 3px var(--yellow), 0 7px 0 #170f51;
}
.tile[aria-pressed="true"]:focus-visible { outline-color: var(--white); outline-offset: 6px; }
.tile.is-draft:enabled { translate: 0 -5px; background: var(--yellow); border-color: #ffeb81; border-bottom-color: var(--yellow-edge); box-shadow: 0 8px 0 #170f51; }
.tile:enabled:active { translate: 0 2px; box-shadow: 0 2px 0 #170f51; }
.tile:disabled { opacity: .86; }
.board-instructions { margin-top: 24px; color: var(--white); font-size: clamp(.91rem, 2.15vw, 1.78rem); font-weight: 550; letter-spacing: -.025em; }
.move-count { display: inline-block; color: var(--muted); font-size: .85rem; font-weight: 650; }
.feedback { min-height: 24px; margin: 1px 0 9px; color: var(--yellow); font-size: clamp(.86rem, 1.5vw, 1rem); font-weight: 760; }
.feedback[data-tone="error"] { color: #ffaac2; }

.keyboard { display: grid; gap: clamp(5px, .9vw, 13px); margin-inline: auto; }
.key-row { display: flex; justify-content: center; gap: clamp(4px, .8vw, 10px); }
.key {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 1 calc((100% - 90px) / 10);
  min-width: 0;
  min-height: var(--key-height);
  padding: 0;
  border: 1px solid #826ef3;
  border-bottom: 4px solid var(--violet-edge);
  border-radius: clamp(6px, 1vw, 11px);
  background: var(--violet);
  color: var(--white);
  font-size: clamp(1rem, 3vw, 2.1rem);
  font-weight: 850;
  line-height: 1;
  transition: translate 100ms ease;
}
.key:enabled:hover { background: #644ce8; }
.key:enabled:active { translate: 0 2px; }
.key.is-spent, .key:disabled:not(.is-spent) {
  border-color: #737485;
  border-bottom-color: var(--spent-edge);
  background: var(--spent-face);
  color: var(--spent-text);
}
.key.is-spent::after {
  content: "";
  position: absolute;
  width: 76%;
  height: 2px;
  background: currentColor;
  transform: rotate(-44deg);
  border-radius: 2px;
  pointer-events: none;
}
.key-clear { flex-basis: calc((100% - 75px) / 9); }
.key-clear img { width: min(54%, 33px); height: auto; }
.key-clear:disabled img { opacity: .72; }

.actions { display: grid; gap: 8px; width: min(62%, 490px); margin: 36px auto 0; }
.actions.is-practice { width: 100%; grid-template-columns: .9fr 1.25fr 1.4fr; }
.secondary-button, .play-button {
  min-width: 0;
  min-height: 52px;
  padding: 8px 13px;
  border: 1px solid #977ee6;
  border-radius: 11px;
  color: var(--white);
  font-size: clamp(.94rem, 1.8vw, 1.28rem);
  font-weight: 820;
}
.secondary-button { background: #3d2d8d; }
.secondary-button:enabled:hover { background: var(--violet); }
.secondary-button:disabled { color: var(--muted); }
.play-button {
  min-height: clamp(48px, 6.25vw, 84px);
  border-color: #ffe86c;
  border-bottom: 5px solid var(--yellow-edge);
  background: var(--yellow);
  color: var(--ink);
  font-size: clamp(1.08rem, 2.55vw, 2rem);
  letter-spacing: -.04em;
  box-shadow: 0 4px 0 #170f51;
  transition: translate 100ms ease, box-shadow 100ms ease;
}
.play-button:enabled:hover { background: #ffe35e; }
.play-button:enabled:active { translate: 0 2px; box-shadow: 0 2px 0 #170f51; }
.play-button:disabled { border-color: #9182c7; border-bottom-color: #63509e; background: #7663ac; color: var(--white); box-shadow: none; }
.spent { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px 11px; margin: 14px auto 0; color: var(--pale); }
.spent h3 { font-size: .85rem; font-weight: 680; }
#spent-letters { display: flex; flex-wrap: wrap; gap: 5px; }
.spent-letter { font-size: .875rem; font-weight: 780; }

dialog { width: min(calc(100% - 32px), 480px); max-height: calc(100% - 32px); padding: 26px; border: 0; border-radius: 14px; background: var(--white); color: var(--ink); color-scheme: light; }
dialog::backdrop { background: #120b46c4; }
dialog h2 { margin-bottom: 12px; font-size: 1.9rem; font-weight: 850; letter-spacing: -.04em; }
dialog ul { padding-left: 20px; }
dialog li + li { margin-top: 8px; }
dialog form { margin-top: 16px; }
.example { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; padding: 10px; border-radius: 8px; background: #ece6ff; font-weight: 850; }
.example b { background: var(--yellow); }
dialog .play-button { width: 100%; min-height: 50px; box-shadow: none; font-size: 1rem; }

@media (max-height: 865px) and (min-width: 761px) {
  :root { --play-width: 650px; --key-height: 48px; }
  .site-header-inner { min-height: 79px; }
  .wordmark { width: min(21vw, 212px); }
  .page { padding-top: 19px; }
  .chain { margin-top: 12px; }
  .board { margin-top: 20px; }
  .tile { font-size: clamp(2.5rem, 6.25vw, 5.3rem); }
  .board-instructions { margin-top: 15px; font-size: 1.19rem; }
  .actions { margin-top: 17px; }
  .play-button { min-height: 58px; }
}

@media (max-width: 900px) {
  :root { --play-width: 650px; }
  .goal { column-gap: 16px; }
  .goal-heading-group { min-width: 0; }
  .progress-group, .strike-status { padding-inline-start: 15px; }
  .strike-status { gap: 10px; }
}

@media (max-width: 760px) {
  .site-header-inner { width: calc(100% - 32px); min-height: 74px; }
  .page { width: calc(100% - 32px); padding-block: 19px 34px; }
  .chain { --scroll-control: 36px; width: 100%; gap: 5px; margin-top: 17px; }
  .chain-list { min-height: 40px; }
  .chain-arrow { min-height: 36px; }
  .board { margin-top: 17px; }
  .board-instructions { margin-top: 12px; }
  .strike-mark { border-radius: 4px; }
  .actions { margin-top: 16px; }
}

@media (max-width: 580px) {
  .site-header-inner { flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding-block: 6px; }
  .wordmark { width: 148px; }
  .mode-nav { width: 100%; justify-content: center; gap: 3px; }
  .mode-nav button { min-height: 40px; padding-inline: 8px; font-size: .86rem; }
  .mode-nav .help-button { margin-inline-start: 2px; }
  .goal {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-areas: "heading strikes" "progress progress";
    gap: 9px 7px;
  }
  .goal h2 { font-size: 1.4rem; }
  .puzzle-date { margin-top: 3px; font-size: .8rem; }
  .progress-group, .strike-status { border: 0; padding: 0; }
  .strike-status { font-size: .875rem; }
  .goal-labels { font-size: .8rem; }
  .board { margin-top: 14px; }
  .tile { font-size: clamp(1.8rem, 9.6vw, 3.25rem); }
  .feedback { margin-bottom: 7px; }
  .key { flex-basis: calc((100% - 36px) / 10); border-bottom-width: 3px; }
  .key-clear { flex-basis: 10%; }
  .actions { width: 100%; }
  .actions.is-practice button { padding-inline: 4px; font-size: .82rem; }
}

@media (max-width: 350px) {
  .site-header-inner, .page { width: calc(100% - 20px); }
  .mode-nav button { padding-inline: 6px; font-size: .8rem; }
  .strike-status { gap: 5px; }
  .strike-marks { gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
