:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  line-height: 1.55;
  color: #edf0f8;
  background: #0e1420;
  --muted: #aab5ca;
  --surface: #151e2e;
  --panel: #101827;
  --line: #29364a;
  --accent: #ffb282;
  --blue: #a4c8fa;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select, textarea, input { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--blue); text-underline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.frame { width: min(calc(100% - 3rem), 70rem); margin-inline: auto; }

.top {
  background: #101826;
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  min-height: 4.1rem;
}

.views { display: flex; gap: .2rem; }
.view {
  min-height: 2.75rem;
  padding: .42rem .72rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
}
.view[aria-pressed="true"], .view-current { color: #f4d4be; background: #28242c; border-color: #53413f; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: inherit;
  text-decoration: none;
  font-size: 1.18rem;
  font-weight: 750;
  letter-spacing: -.03em;
  white-space: nowrap;
}

.signal {
  width: .75rem;
  height: .75rem;
  border-radius: 3px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 14px #ffb28255;
  transform: rotate(45deg);
}

.mode { display: flex; gap: .65rem; align-items: center; min-width: 0; }
.mode label { font-size: .9rem; color: var(--muted); }

select, button, textarea, input {
  border: 1px solid var(--line);
  border-radius: .55rem;
  color: inherit;
  background: #1a2639;
}

select { padding: .45rem .7rem; min-width: 7rem; max-width: 100%; }
button { padding: .63rem .95rem; font-weight: 640; }
button:hover:not(:disabled) { border-color: #7890b1; }

.intro {
  position: relative;
  isolation: isolate;
  margin-block: 1.55rem .55rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.05rem;
  background: #141f32;
}

.intro-copy { position: relative; padding: clamp(1.4rem, 3.7vw, 2.4rem); }
.intro-copy p:last-child { max-width: 39ch; color: #c3ccdf; }
.shift, .label { font: .76rem/1.45 var(--mono); text-transform: uppercase; letter-spacing: .085em; }
.shift { color: var(--accent); }
.label { color: var(--blue); }

h1 {
  font-size: clamp(2.4rem, 5.1vw, 4.18rem);
  line-height: .98;
  letter-spacing: -.062em;
  margin-block: .48rem .75rem;
  text-wrap: balance;
}

h1 span { color: var(--accent); }

.hero-image {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, #141f32 0, #101b2dee 30%, #101b2d10 68%, #101b2d00 100%),
    url("./assets/circuit-board.jpg") right 59% / 91% auto no-repeat,
    #141f32;
}

.hero-image::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 39%, #a4c8fa18 50%, transparent 61%);
  background-size: 210% 100%;
  animation: sweep 1.8s ease-out both;
}

@keyframes sweep {
  from { background-position: 100% 0; opacity: .1; }
  45% { opacity: .8; }
  to { background-position: 0 0; opacity: 0; }
}

.game-tools {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  min-height: 2.7rem;
  gap: .35rem .85rem;
  margin-bottom: .5rem;
}

#daily-status { margin-right: auto; color: #d3d9e8; font-size: .85rem; }
#daily-status:empty, #puzzle-status:empty { display: none; }
.text-button { color: var(--blue); border-color: transparent; background: transparent; }
#copy-puzzle { font-size: .85rem; }
.clipboard-notice { color: var(--muted); font-size: .86rem; }
.clipboard-notice:not(:has(p:empty)) { margin-bottom: .65rem; }
.clipboard-notice input { display: block; width: 100%; margin-top: .3rem; padding: .54rem .65rem; }

.workbench { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); gap: 1rem; }

.brief, .inputs, .results {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  padding: clamp(1.1rem, 2.8vw, 1.65rem);
}

h2 { font-size: clamp(1.22rem, 2vw, 1.55rem); line-height: 1.23; letter-spacing: -.035em; }
.brief h2 { margin-top: .4rem; }
code { font-family: var(--mono); }

#signature {
  display: block;
  margin-top: .8rem;
  padding: .65rem .7rem;
  border-radius: .5rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #c2dbff;
  font-size: .85rem;
  overflow-wrap: anywhere;
}

#rules { color: #c3ccdf; padding-left: 1.15rem; margin: 1rem 0 0; }
#rules li + li { margin-top: .55rem; }
#rules li::marker { color: #7fa6dd; }

.input-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem; margin-bottom: .8rem; }
#budget-marks { display: flex; gap: .24rem; }
#budget-marks i { width: .62rem; height: .31rem; border: 1px solid #546685; border-radius: 1px; transition: background-color .18s; }
#budget-marks i.filled { background: var(--accent); border-color: var(--accent); }
.budget-stack { display: flex; align-items: center; gap: .45rem; }
#budget { color: var(--muted); font: .77rem/1.45 var(--mono); font-variant-numeric: tabular-nums; }
.case-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .44rem; }

.case {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .5rem;
  place-items: center start;
  padding: .59rem .58rem;
  min-height: 2.85rem;
  background: var(--panel);
  text-align: left;
  transition: background-color .18s, border-color .18s;
}

.case code { overflow-wrap: anywhere; font-size: .77rem; font-weight: 480; line-height: 1.45; }
.case-index { color: var(--muted); font: .7rem var(--mono); }
.case-indicator { font: 1rem/1 var(--mono); color: var(--blue); }
.case[aria-pressed="true"] { border-color: #d69d79; background: #302629; }
.case[aria-pressed="true"] .case-indicator { color: var(--accent); transform: rotate(45deg); }
.case[aria-pressed="false"]:disabled { opacity: .67; }
.actions { display: flex; gap: .65rem; margin-top: 1rem; }
.primary { background: var(--accent); color: #251911; border-color: transparent; }
.primary:hover:not(:disabled) { background: #ffd0b3; border-color: transparent; }
.primary:disabled { opacity: .62; }

.results { margin-top: 1rem; animation: arrive .3s ease-out; }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.result-head button { white-space: nowrap; }
#record, #share-status { color: var(--muted); margin-top: .35rem; }
#share-status:empty { display: none; }
#share-copy { width: 100%; min-height: 5.5rem; margin-top: .65rem; padding: .7rem; }
.coverage { margin: 1.1rem 0 1rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--panel); padding: .75rem; }
.coverage-table { width: 100%; border-collapse: collapse; }
.coverage-table caption { text-align: left; font-weight: 640; margin: 0 .4rem .45rem; }
.coverage-table th, .coverage-table td { padding: .38rem .48rem; border-top: 1px solid var(--line); }
.coverage-table thead { color: var(--muted); font: .76rem var(--mono); }
.coverage-table thead th:first-child, .coverage-table tbody th { text-align: left; }
.coverage-table td { text-align: center; width: 17%; }
.matrix-link { text-align: left; color: var(--blue); background: transparent; border: none; padding: .24rem 0; font-size: .87rem; text-decoration: underline; text-underline-offset: 3px; }
.matrix-hit, .matrix-pass { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: .32rem; font: .83rem var(--mono); }
.matrix-hit { color: #b7f0d3; background: #1a3b36; border: 1px solid #395d54; }
.matrix-hit { animation: mark-in .28s ease-out both; }
.coverage-table td:nth-child(3) .matrix-hit { animation-delay: .06s; }
.coverage-table td:nth-child(4) .matrix-hit { animation-delay: .12s; }
.matrix-pass { color: #9aabc5; background: #243044; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.findings { padding: 0; margin: 1rem 0 0; list-style: none; }
.finding { border-bottom: 1px solid var(--line); }
.finding summary { position: relative; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .72rem .3rem .72rem 1.35rem; cursor: pointer; font-weight: 620; }
.finding summary::before { content: "+"; position: absolute; left: .3rem; color: var(--blue); font: 1rem var(--mono); }
.finding details[open] summary::before { content: "−"; }
.finding summary::-webkit-details-marker { display: none; }
.finding p { color: #c3ccdf; font-size: .91rem; padding: 0 .75rem .7rem 1.35rem; }
.outcome { color: #f7bd9b; font: .72rem var(--mono); }
.caught .outcome { color: #b0ead0; }
.witness { display: flex; flex-wrap: wrap; align-items: baseline; gap: .28rem .65rem; margin: 0 .7rem .6rem 1.35rem; font-size: .8rem; color: var(--muted); }
.witness code { overflow-wrap: anywhere; color: var(--blue); }
.solution { margin-top: .9rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--panel); }
.solution summary { cursor: pointer; color: var(--blue); }
.solution p { margin-top: .55rem; }
.solution ul { margin: .4rem 0 0; padding-left: 1.25rem; }
.solution code { overflow-wrap: anywhere; color: var(--blue); }

#archive {
  width: min(calc(100% - 1.5rem), 35rem);
  max-height: calc(100dvh - 1.5rem);
  padding: clamp(.9rem, 3.2vw, 1.45rem);
  border: 1px solid #435473;
  border-radius: .85rem;
  background: var(--surface);
  color: inherit;
}
#archive[open] { animation: arrive .2s ease-out; }
#archive::backdrop { background: #0b101bd4; }
.archive-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; }
.archive-head p { margin-top: .35rem; color: var(--muted); font-size: .87rem; }
.archive-list { display: grid; gap: .35rem; padding: .15rem; margin: .85rem 0 .45rem; max-height: min(53dvh, 23.5rem); overflow: auto; list-style: none; }
.archive-choice {
  display: grid;
  grid-template-columns: minmax(5rem, .8fr) minmax(0, 1.25fr) auto;
  align-items: baseline;
  gap: .45rem;
  width: 100%;
  background: var(--panel);
  text-align: left;
}
.archive-choice:focus-visible { outline-offset: -3px; }
.archive-date { color: var(--muted); font-size: .8rem; font-weight: 450; }
.archive-puzzle { font-size: .91rem; overflow-wrap: anywhere; }
.archive-score { color: var(--accent); font: .77rem var(--mono); }

footer { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-block: 1.3rem 1.8rem; color: var(--muted); font-size: .84rem; }
footer a { margin-left: auto; }

@keyframes arrive { from { opacity: .55; transform: translateY(.4rem); } to { opacity: 1; transform: none; } }
@keyframes mark-in { from { opacity: .4; transform: scale(.8); } to { opacity: 1; transform: none; } }

@media (max-width: 49rem) {
  .workbench { grid-template-columns: 1fr; }
  .hero-image { background-size: auto, cover; }
}

@media (max-width: 35rem) {
  .frame { width: calc(100% - 1.5rem); }
  .nav { min-height: 3.5rem; gap: .45rem; }
  .views { gap: .05rem; }
  .view { padding: .35rem .44rem; font-size: .82rem; }
  .mode label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  select { max-width: min(12rem, 49vw); }
  .intro { margin-top: .85rem; }
  .intro-copy { padding: 1.08rem 1.16rem; }
  .intro h1 { font-size: clamp(1.85rem, 8vw, 2.65rem); }
  .intro h1 br { display: none; }
  .intro-copy p:last-child { max-width: 31ch; font-size: .93rem; }
  .hero-image {
    background-image: linear-gradient(90deg, #101b2df5, #101b2dc4 53%, #101b2d7d), url("./assets/circuit-board.jpg");
    background-position: center, 63% center;
  }
  .case-grid { grid-template-columns: 1fr; }
  .workbench { gap: .72rem; }
  .brief, .inputs { padding: .88rem 1rem; }
  #rules { font-size: .92rem; line-height: 1.42; margin-top: .7rem; }
  #rules li + li { margin-top: .38rem; }
  #signature { margin-top: .59rem; }
  .result-head { flex-wrap: wrap; }
  .coverage { padding: .35rem; }
  .coverage-table th, .coverage-table td { padding: .32rem .2rem; }
  footer a { margin-left: 0; }
}

@media (max-width: 24rem) {
  .view { padding: .35rem .36rem; }
  .brand { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
