:root {
  color-scheme: light;
  --ink: #25244d;
  --deep: #272238;
  --cream: #fff1dc;
  --card: #fffaf0;
  --lime: #ffcf83;
  --lilac: #c8caff;
  --coral: #ff795e;
  --line: #d9d1e3;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 16px/1.5 "DM Sans", system-ui, sans-serif; }
.masthead {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #262854;
  border-bottom: 4px solid #ffd18d;
  color: #fff8f0;
}
.skyline {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 70% 58%;
}
.masthead::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, #191b48 0%, #1b1c47de 28%, #25234b54 57%, transparent 74%);
}
.hero, main { width: min(calc(100% - 42px), 1040px); margin-inline: auto; }
.hero { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 299px; padding: 32px 0; }
.brand { display: flex; align-items: center; gap: 9px; font: 750 .69rem/1.3 "IBM Plex Mono", monospace; letter-spacing: .12em; color: #ffe1ad; }
.brand span { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #ffe1ad9e; border-radius: 50%; font-size: 1.05rem; }
h1 { max-width: 100%; margin: 12px 0 6px; font: 900 clamp(3.05rem, 8vw, 6.4rem)/.95 "Archivo Black", system-ui, sans-serif; letter-spacing: -.09em; text-shadow: 0 3px 20px #15173b7a; }
h1 span { color: #ffb687; }
.hero p { margin: 10px 0 0; color: #fff1dc; font-size: clamp(.94rem, 2.2vw, 1.14rem); font-weight: 650; }
main { padding: 24px 0 40px; }
.toolbar, .cardhead, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.toolbar, .cardhead { justify-content: space-between; }
.toolbar { margin-bottom: 15px; font-size: .85rem; font-weight: 800; }
.puzzle-tabs { display: flex; gap: 5px; padding: 4px; background: #e9dff1; border-radius: 11px; }
.puzzle-tabs button { padding: 7px 12px; min-height: 38px; border: 1px solid transparent; background: transparent; }
.puzzle-tabs button:hover { background: #f4ebff; }
.puzzle-tabs button[aria-selected="true"] { background: var(--ink); color: white; }
.practice-picker, .archive-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 13px; font-size: .9rem; font-weight: 800; }
[hidden] { display: none !important; }
#streak:not(:empty) { background: var(--lilac); padding: 7px 11px; border-radius: 999px; }
.board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(185px, .29fr); gap: 24px; }
.steps { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 11px; }
.steps::before { content: ""; position: absolute; z-index: -1; border-top: 2px dashed #8d7bb4; left: 9%; right: 9%; top: 50%; }
.steps span { width: 44px; min-height: 42px; border: 1px solid var(--line); border-radius: 50%; padding: 10px 0 8px; text-align: center; justify-self: center; background: #f4e9f4; color: #514665; font: 750 .85rem/1.4 "IBM Plex Mono", monospace; }
.steps .active { background: var(--lilac); border-color: var(--ink); color: var(--ink); box-shadow: inset 0 -3px #9b80ef; }
.steps .solved { background: var(--lime); color: var(--ink); border-color: #7b8b2c; }
.card { position: relative; padding: clamp(18px, 4vw, 32px); border: 2px solid var(--ink); border-radius: 17px; background: var(--card); box-shadow: 4px 5px 0 #cfbad5; }
.cardhead { font: 800 .74rem/1.3 "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .09em; }
.cardhead span:last-child { background: #e5dafd; padding: 5px 9px; border-radius: 6px; }
h2 { margin: .62em 0 .74em; font: 820 clamp(1.65rem, 3.9vw, 2.58rem)/1.11 "Bricolage Grotesque", system-ui, sans-serif; letter-spacing: -.045em; }
button, select, input { color: var(--ink); font: inherit; min-height: 44px; border: 1px solid #625474; border-radius: 8px; padding: 8px 12px; background: var(--card); }
button, select, summary { cursor: pointer; }
button { font-weight: 800; }
button:hover, select:hover { background: #e5dafd; }
button.primary { color: white; background: var(--ink); border-color: var(--ink); }
button.primary:hover { background: #4b366e; }
button.early { background: var(--lime); border-color: var(--ink); }
button.early:hover { background: #ffdfaa; }
form { display: flex; gap: 8px; }
input { flex: 1; min-width: 0; width: 100%; }
.actions { margin-top: 12px; }
.actions:empty { display: none; }
#recap { margin: 0 0 13px; color: #514665; font-size: .88rem; }
#feedback { margin: 16px 0 0; color: #852e30; font-weight: 700; }
#feedback:empty { display: none; }
.trail { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #eee8f6; }
.trail h2 { margin: 0 0 4px; font-size: 1.1rem; letter-spacing: -.02em; }
.trail p { margin: 0; font-size: .86rem; color: #514665; }
.trail ol { margin: 7px 0 0; padding: 0; list-style: none; }
.trail ol:empty { display: none; }
.trail li { margin: 5px 0 0; padding: 5px 8px; background: var(--card); border-radius: 5px; font-size: .86rem; font-weight: 700; }
details { margin-top: 14px; font-size: .9rem; }
summary { font-weight: 800; }
details ol { padding-left: 20px; }
li { margin-bottom: 6px; }
.card[data-stage="decision"] { background: #fff0d1; }
.card[data-stage="guess"] { background: #ece3ff; }
.card[data-stage="win"] { background: var(--lime); }
.card[data-stage="miss"] { background: #ffe5dd; }
.card[data-stage="win"] h2, .card[data-stage="miss"] h2 { font-size: clamp(2rem, 5vw, 3.2rem); }
.scoreline { display: flex; gap: 6px; margin: -7px 0 15px; }
.scoreline i { width: 23px; height: 8px; border-radius: 3px; border: 1px solid #5f5469; background: #fff9ee; }
.scoreline .filled { background: var(--ink); }
.card[data-stage="miss"] .scoreline .filled { background: var(--coral); }
:focus-visible { outline: 3px solid #7441c8; outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (prefers-reduced-motion: no-preference) {
  .steps .solved { animation: stamp .24s ease-out both; }
  @keyframes stamp { from { transform: scale(.9); } to { transform: scale(1); } }
}
@media (max-width: 680px) {
  .hero, main { width: calc(100% - 30px); }
  .hero { min-height: 205px; justify-content: flex-start; padding: 16px 0 80px; }
  .skyline { object-position: 75% 61%; }
  .masthead::after { background: linear-gradient(180deg, #191b48eb, #1b1c4796 48%, transparent 86%), linear-gradient(90deg, #22234b82, transparent 87%); }
  h1 { font-size: clamp(2.8rem, 10vw, 4.6rem); margin-top: 7px; }
  .hero p { margin-top: 6px; }
  .board { grid-template-columns: 1fr; gap: 21px; }
  main { padding-top: 13px; }
  .toolbar { margin-bottom: 10px; }
}
@media (max-width: 380px) {
  .actions button { flex: 1 1 100%; }
}
