#app:has(> .puzzle-header) { padding-block-start: clamp(14px, 2vw, 24px); }
.puzzle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-block-end: 10px;
}
.puzzle-header h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.85rem); letter-spacing: -.025em; }
.puzzle-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  inline-size: clamp(128px, 30%, 310px);
  max-inline-size: 100%;
  min-width: 0;
}
.puzzle-count { font-size: .85rem; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.puzzle-progress {
  display: block;
  appearance: none;
  min-width: 0;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 5px;
  overflow: hidden;
  color: #d6a93f;
  background: #e4dbcd;
}
.puzzle-progress::-webkit-progress-bar { background: #e4dbcd; }
.puzzle-progress::-webkit-progress-value { background: linear-gradient(90deg, #a06c16, #db9d2f); border-radius: 5px; }
.puzzle-progress::-moz-progress-bar { background: linear-gradient(90deg, #a06c16, #db9d2f); border-radius: 5px; }

.puzzle-frame { padding: 5px; border: 1px solid #a08765; border-radius: 13px; background: #806d55; box-shadow: 0 5px 17px #55452c31; }
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-auto-rows: minmax(57px, auto);
  overflow: hidden;
  border-radius: 7px;
  background: #e8dcc1 url('./puzzle-map.webp') center / 100% 100% no-repeat;
}
.puzzle-piece {
  --tile: #1a2024ad;
  --seam: #141b21bf;
  --tile-text: #fff7e6;
  --topic-bg: #181f24d9;
  --tile-ring: #b2c5cc;
  --tile-glow: transparent;
  --tile-focus: #a6dcff;
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 55px;
  padding: 3px 2px;
  border: 0;
  border-top: 1px solid var(--seam);
  border-left: 1px solid var(--seam);
  border-radius: 0;
  background: var(--tile);
  color: var(--tile-text);
}
.puzzle-piece::before {
  content: '';
  position: absolute;
  z-index: 1;
  top: calc(50% - 5px);
  right: -5px;
  width: 7px;
  height: 11px;
  border: 1px solid var(--seam);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: var(--tile);
  pointer-events: none;
}
.puzzle-piece:nth-child(even)::before {
  top: auto;
  right: auto;
  bottom: -5px;
  left: calc(50% - 5px);
  width: 11px;
  height: 7px;
  border: 1px solid var(--seam);
  border-top: 0;
  border-radius: 0 0 7px 7px;
}
.puzzle-piece:hover { --tile: #1a202493; --seam: #586773; }
.puzzle-piece[data-complete='true'] {
  --tile: #ffdf8ccb;
  --seam: #bf8730;
  --tile-text: #33270f;
  --topic-bg: #fff6d5;
  --tile-ring: #93601c;
  --tile-glow: #fff4bd;
  --tile-focus: #204f77;
  box-shadow: inset 0 0 0 1px #ca9037, inset 0 0 12px 1px var(--tile-glow);
}
.puzzle-piece[data-complete='true']:hover { --tile: #ffebaddf; }
.puzzle-piece[aria-current='true'] { box-shadow: inset 0 0 0 2px var(--tile-ring), inset 0 0 12px 1px var(--tile-glow); }
.puzzle-piece:focus-visible { outline: 2px solid var(--tile-focus); outline-offset: -4px; }
.puzzle-number, .puzzle-topic { position: relative; z-index: 2; max-width: 100%; }
.puzzle-number { font-size: .78rem; font-weight: 780; line-height: 1.13; font-variant-numeric: tabular-nums; }
.puzzle-topic { padding: 1px 2px; border-radius: 3px; background: var(--topic-bg); font-size: .7rem; line-height: 1.1; text-wrap: balance; hyphens: auto; overflow-wrap: anywhere; }
.puzzle-mark {
  position: absolute;
  z-index: 3;
  top: 2px;
  right: 2px;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border-radius: 50%;
  background: #765521;
  color: white;
  font-size: .74rem;
  font-weight: 800;
  line-height: 1;
}
.puzzle-mark.correct { background: #176343; }
.puzzle-mark.incorrect { background: #a23840; }

.puzzle-rail { display: grid; gap: 12px; position: sticky; top: 16px; }
.puzzle-rail-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 6px; }
.puzzle-rail-links .text-button { padding: 5px 4px; }
.puzzle-rail-links .puzzle-account { color: var(--muted); font-size: .83rem; }
.puzzle-rail-meter { display: grid; gap: 6px; min-width: 0; }
.puzzle-rail-meter p { grid-column: 1; margin: 0; font-size: .86rem; }
.puzzle-rail-meter .puzzle-progress { height: 6px; }
.puzzle-skip { margin: 0; padding: 5px 8px; min-height: 36px; font-size: .86rem; }
.puzzle-question-topic { font-size: .86rem; font-weight: 700; color: #355873; }

@media (max-width: 980px) {
  .puzzle-grid { grid-template-columns: repeat(15, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .puzzle-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
}
@media (max-width: 750px) {
  .puzzle-rail { position: static; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .puzzle-rail-meter { grid-column: 1 / -1; grid-row: 2; }
  .puzzle-skip { grid-column: 2; grid-row: 1; }
}
@media (max-width: 620px) {
  .puzzle-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  .puzzle-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
@media (max-width: 390px) {
  .puzzle-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
