@font-face {
  font-family: "Barlow Condensed";
  src: url("./fonts/barlow-condensed-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #0f1724;
  --paper: #182332;
  --panel: #222f43;
  --ink: #edf3fa;
  --muted: #aebcd0;
  --line: #34455c;
  --accent: #d6f28a;
  --accent-hover: #e4f9ac;
  --accent-surface: #2a3b32;
  --good: #a8e4c8;
  --error: #fac0c8;
  --tray: #e0e7ee;
  --tray-line: #bfcada;
  --tray-ink: #172639;
  --tray-muted: #465a72;
  --display-font: "Barlow Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, .option:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.panel-heading h2:focus-visible, .feedback h3:focus-visible, .hint:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
svg { display: block; }
.site-header { background: #131e2e; border-bottom: 1px solid var(--line); }
.header-inner, .shell { width: min(100% - 3rem, 1040px); margin-inline: auto; }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: .66rem;
  color: var(--ink);
  text-decoration: none;
  font: 700 1.62rem/1 var(--display-font);
  letter-spacing: .055em;
  text-transform: uppercase;
}
.brand img { width: 34px; height: 34px; }

.header-actions { display: flex; align-items: center; gap: .4rem; }
.header-actions svg, .icon svg, .next-day svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button, .games-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: .36rem;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.games-button { gap: .5rem; padding: 0 .75rem; border-color: var(--line); font-size: .88rem; font-weight: 700; }
.icon-button:hover, .games-button:hover { background: var(--panel); color: var(--accent); }

.shell { padding: 1.65rem 0 1.15rem; }
.play-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .75rem; margin-bottom: 1.1rem; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .4rem; font: 700 clamp(2.1rem, 5vw, 3.1rem)/1.06 var(--display-font); text-transform: uppercase; letter-spacing: .02em; }
.play-header h1 { margin: 0; font-size: clamp(1.73rem, 4.1vw, 2.75rem); }
.challenge-date { display: block; margin-top: .36rem; color: var(--muted); font-size: .86rem; }
.panel-description { color: var(--muted); margin: .3rem 0 0; line-height: 1.45; }

.progress { width: clamp(6.25rem, 19vw, 10.75rem); }
.progress-text { margin-bottom: .4rem; font-size: .875rem; font-weight: 750; }
.progress-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.segment { height: .28rem; border-radius: 1px; background: var(--line); }
.segment--current { background: var(--accent); }
.segment--solved { background: #73c6df; }
.segment--revealed { background: #bb9b7c; }

.notice {
  margin-bottom: .8rem;
  padding: .7rem .9rem;
  gap: .5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: .42rem;
  background: var(--panel);
  color: var(--ink);
}

.playtest-calendar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .65rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.playtest-calendar label { color: var(--muted); }
.playtest-calendar select {
  min-height: 44px;
  max-inline-size: 100%;
  padding: .35rem .55rem;
  border: 1px solid var(--line);
  border-radius: .36rem;
  background: var(--paper);
  color: var(--ink);
}

.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, .94fr) minmax(0, 1.16fr);
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: var(--paper);
  overflow: clip;
}
.panel {
  padding: 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .6rem;
}
.puzzle-layout .panel { border: 0; border-radius: 0; }
.puzzle-layout .examples-panel { border-inline-end: 1px solid var(--line); background: #141f2f; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
h2 { margin: 0; font: 700 1.75rem/1.1 var(--display-font); letter-spacing: .025em; }
.puzzle-layout h2 { text-transform: uppercase; }
h3 { font-size: 1.05rem; }
.difficulty { font-size: .8rem; font-weight: 700; color: var(--accent); background: var(--accent-surface); padding: .27rem .52rem; border-radius: .24rem; }

.example-labels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr);
  text-align: center;
  padding: .75rem .5rem .34rem;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .065em;
}
.example-labels span:last-child { grid-column: 3; }

.examples-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .53rem; }
.pair, .challenge-preview {
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  padding: .38rem .5rem;
  background: var(--tray);
  border: 1px solid var(--tray-line);
  border-radius: .36rem;
}
.pair > .icon, .challenge-preview > .icon { color: var(--tray-muted); }
.challenge-preview { margin: .75rem 0 .95rem; padding-inline: 12%; background: #d5e3ef; border-color: #b1c5da; }
.scene-box, .scene { display: grid; place-items: center; width: 100%; min-width: 0; }
.scene svg { width: 56px; max-width: 100%; height: 53px; }
.scene--count svg { width: 65px; }
.scene--grid svg { width: 58px; height: 58px; }
.scene--row svg { width: 118px; height: 38px; }
.scene--badge svg { width: 82px; height: auto; }
.scene--letters svg { width: 128px; height: auto; }
.scene--blocks svg { width: 78px; }
.scene--towers svg, .scene--beads svg { width: 112px; height: auto; }
.scene--splice svg, .scene--strip svg { width: 162px; height: auto; }
.scene--overlay svg { width: 142px; height: auto; overflow: visible; }
.scene--mosaic svg { width: 56px; height: auto; }
.scene--path svg { width: 174px; height: auto; }
.scene--exit svg { width: 52px; height: auto; }

.example-labels--wide { grid-template-columns: minmax(0, 1fr) 1.25rem 4rem; }
.pair--wide, .challenge-preview--wide { grid-template-columns: minmax(0, 1fr) 1.25rem 4rem; }
.challenge-preview--wide { padding-inline: .5rem; }
.pair--towers, .challenge-preview--towers { background: #e7e8de; border-color: #c6ccbd; }
.pair--splice, .challenge-preview--splice { background: #dce9e5; border-color: #bdd2ca; }
.pair--overlay, .challenge-preview--overlay { padding-block-start: 1.45rem; background: #e3e5ee; border-color: #c6cadd; }
.pair--path, .challenge-preview--path { background: #e1ebf3; border-color: #c2d3e2; }
.pair--beads, .challenge-preview--beads { background: #f0eadf; border-color: #dbd0bb; }

.example-labels--equation, .pair--equation, .challenge-preview--equation {
  grid-template-columns: minmax(0, 1fr) 1.5rem 3.25rem;
}
.pair--equation { min-height: 65px; }
.challenge-preview--equation { padding-inline: .55rem; }
.equation-expression, .coin-group { display: flex; justify-content: center; align-items: center; gap: .2rem; }
.equation-expression { flex-wrap: wrap; gap: .24rem; }
.coin {
  display: grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
}
.coin--blue { background: #2352ad; }
.coin--red { background: #ae354d; }
.coin--gold { background: #865507; }
.equation-plus, .equation-equals { color: #48546d; font-weight: 750; }
.equation-number { color: #203252; font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.question {
  width: 50px;
  height: 50px;
  border: 1px dashed #6c859c;
  border-radius: .32rem;
  color: var(--tray-ink);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 750;
}

.choices-label { margin-bottom: .48rem; padding: 0; font-size: .9rem; font-weight: 750; }
.options { min-inline-size: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; padding: 0; margin: 0; border: 0; }
.options--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.option {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 74px;
  padding: .52rem 1.26rem .45rem;
  border: 1px solid var(--tray-line);
  border-radius: .36rem;
  background: var(--tray);
  color: var(--tray-ink);
  cursor: pointer;
  transition: background .13s ease, border-color .13s ease;
}

.option:hover:has(input:not(:disabled)) { border-color: #8ea7c6; background: #eff4f8; }
.option:has(input:checked:not(:disabled)) {
  border-color: #14365c;
  background: #c4dbf7;
  box-shadow: inset 0 0 0 3px #14365c;
}
.option:has(input:checked:not(:disabled)) .letter { background: #14365c; color: #fff; border-radius: .2rem; }
.option:has(input:checked:not(:disabled))::after {
  content: '';
  position: absolute;
  top: .42rem;
  right: .42rem;
  width: .8rem;
  height: .8rem;
  border: 2px solid #fff;
  outline: 2px solid #14365c;
  border-radius: 50%;
  background: #14365c;
}
.option:has(input:disabled) { cursor: default; }
.letter, .choice-mark { position: absolute; top: .32rem; display: grid; place-items: center; min-width: 1.1rem; height: 1.15rem; }
.letter { left: .36rem; color: var(--tray-muted); font-size: .76rem; font-weight: 800; }
.choice-mark { right: .3rem; color: var(--tray-ink); font-weight: 800; }
.choice-mark svg { width: 17px; height: 17px; stroke-width: 2; }
.option--wrong { border-color: #c76478; background: #f1d8df; }
.option--wrong .choice-mark { color: #8c3045; }
.option--correct { border-color: #56977c; background: #d4eee1; }
.option--correct .choice-mark { color: #215d45; }

.puzzle-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: .9rem; gap: .5rem; }
.puzzle-actions > .primary:only-child { margin-left: auto; }
.secondary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.primary, .hint-button, .text-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .36rem;
  gap: .35rem;
  font-size: .9rem;
  font-weight: 740;
  padding: .58rem .75rem;
}

.primary { border: 1px solid transparent; color: var(--tray-ink); background: var(--accent); padding-inline: 1rem; }
.primary:hover:enabled { background: var(--accent-hover); }
.primary:disabled { background: var(--panel); border-color: var(--line); color: var(--muted); }
.hint-button { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.hint-button:hover { background: var(--panel); }
.text-button { border: 0; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--ink); text-decoration: underline; }
.hint-button .icon svg { width: 17px; height: 17px; }

.hint, .retry, .feedback {
  background: var(--panel);
  color: var(--ink);
  padding: .7rem .8rem;
  border-radius: .38rem;
  margin: .8rem 0 0;
  font-size: .94rem;
  line-height: 1.48;
}
.retry { background: #3e2939; color: var(--error); }
.hint { margin: 0 0 .8rem; }
.feedback--solved { background: #203b37; color: var(--good); }
.feedback h3 { margin-bottom: .16rem; }
.feedback p { margin-bottom: 0; }

.challenge-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  margin-top: .45rem;
  padding: .35rem 0;
  color: var(--muted);
  font-size: .85rem;
}
.challenge-footer a { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: .15em; }

.next-day { display: inline-flex; align-items: center; gap: .45rem; }
.next-day svg { width: 17px; height: 17px; }
.next-day time { color: var(--ink); font-weight: 760; font-variant-numeric: tabular-nums; }

dialog { width: min(35rem, 100% - 2rem); padding: 1.25rem; border: 1px solid var(--line); border-radius: .6rem; color: var(--ink); background: var(--paper); box-shadow: 0 16px 48px #080e18b0; }
dialog::backdrop { background: #0a101bc8; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.close { font-size: 1.7rem; }
#help p { margin-bottom: .75rem; line-height: 1.5; }
.help-demo { margin: .8rem 0; padding: .45rem .75rem .68rem; border: 1px solid var(--tray-line); border-radius: .38rem; background: var(--tray); color: var(--tray-ink); }
.help-example-row { display: grid; grid-template-columns: 1fr 24px 1fr; align-items: center; justify-items: center; }
.help-example-row .scene svg { width: 45px; height: 44px; }
.help-example-row .icon { color: var(--tray-muted); }
.help-demo figcaption { margin-top: .28rem; text-align: center; font-size: .9rem; font-weight: 700; }
.help-details { font-size: .9rem; color: var(--muted); }
.help-details summary { width: fit-content; min-height: 44px; padding-block: .7rem; font-weight: 650; cursor: pointer; }
.help-details summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.help-actions { display: flex; justify-content: flex-end; margin-top: .42rem; }
.help-actions .primary { min-width: 104px; }
dialog p:last-child { margin-bottom: 0; color: var(--muted); }
.games-grid, .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); gap: .5rem; }
.metrics { margin-bottom: 0; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: .38rem; padding: .65rem .8rem; }
.metric dt { font-size: .83rem; color: var(--muted); }
.metric dd { font-size: 1.35rem; font-weight: 800; margin: .2rem 0 0; }
.achievements-heading { margin: 1.1rem 0 .45rem; }
.achievements { list-style: none; padding: 0; margin: 0; display: grid; gap: .42rem; }
.achievement { padding: .58rem .7rem; border: 1px solid var(--line); border-radius: .38rem; background: var(--panel); }
.achievement--earned { border-color: #477966; background: #203b37; }
.achievement-title { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.achievement-state { font-size: .8rem; font-weight: 750; color: var(--muted); }
.achievement--earned .achievement-state { color: var(--good); }
.achievement-description { font-size: .84rem; color: var(--muted); }
.legal { max-width: 42rem; }
.legal p { line-height: 1.55; }
dialog { max-height: calc(100dvh - 2rem); overflow-y: auto; }

.game-link { display: flex; align-items: center; gap: .7rem; min-height: 62px; border: 1px solid var(--line); border-radius: .38rem; padding: .55rem; text-decoration: none; }
.game-link:hover { background: var(--panel); border-color: #6582a2; }
.game-mark { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border-radius: .34rem; background: #263b54; color: #a5ccf1; }
.game-copy { display: grid; gap: .15rem; }
.game-copy span { color: var(--muted); font-size: .85rem; }

.results { max-width: 670px; margin-inline: auto; }
.result-score { font-size: 1.06rem; color: var(--muted); margin: .5rem 0 1rem; }
.result-tiles { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: .5rem; margin: 0 0 1rem; }
.result-tile { display: grid; gap: .2rem; padding: .65rem .5rem; border-radius: .38rem; background: var(--panel); font-size: .83rem; }
.result-tile--2 { background: var(--accent-surface); color: var(--accent); }
.result-tile--1 { background: #3c332b; color: #f4d4a6; }
.next-game { margin-top: 1.25rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.share-text { display: block; width: 100%; margin-top: .7rem; min-height: 6rem; border: 1px solid var(--line); border-radius: .38rem; padding: .5rem; color: var(--ink); background: var(--background); }
.share-status { margin: .5rem 0 0; color: var(--good); }

.screen-reader {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .header-inner, .shell { width: min(100% - 2rem, 600px); }
  .shell { padding-top: 1.05rem; }
  .play-header { gap: .55rem; margin-bottom: .85rem; }
  .puzzle-layout { grid-template-columns: minmax(0, 1fr); }
  .puzzle-layout .examples-panel { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .panel { padding: 1rem; }
  .pair { min-height: 65px; }
}

@media (max-width: 420px) {
  .header-inner { min-height: 56px; }
  .header-actions { gap: .1rem; }
  .brand { gap: .38rem; font-size: 1.4rem; }
  .brand img { width: 32px; height: 32px; }
  .games-button { gap: .3rem; padding-inline: .48rem; }
  .panel { padding: .85rem; }
  .option { min-height: 68px; padding-inline: .75rem; }
  .options--row, .options--letters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options--towers, .options--beads, .options--splice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options--badge .option { padding: 1.3rem .55rem .35rem; }
  .options--overlay, .options--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options--overlay .option, .options--grid .option { padding: 1.3rem .55rem .45rem; }
  .options--overlay .scene--mosaic svg, .options--grid .scene--grid svg { width: 76px; height: auto; }
  .panel-heading { gap: .3rem; }
  .examples-list { gap: .35rem; }
  .puzzle-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .puzzle-actions .primary { width: 100%; }
  .help-actions .primary { width: 100%; }
}

@media (max-width: 360px) {
  .header-inner { gap: .3rem; }
  .brand { font-size: 1.26rem; }
  .games-button { padding-inline: .5rem; }
  .games-label { display: none; }
}

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

@media (forced-colors: active) {
  .option:has(input:checked:not(:disabled)), .option--correct { border: 2px solid Highlight; }
  .option:has(input:checked:not(:disabled))::after { background: Highlight; border-color: HighlightText; outline-color: Highlight; forced-color-adjust: none; }
  .segment--current, .segment--solved { background: Highlight; forced-color-adjust: none; }
}
