body:has(.binary-game-page) {
  background: var(--bg-base);
  overflow: hidden;
}

html:has(.binary-game-page),
body:has(.binary-game-page),
body:has(.binary-game-page) main,
.binary-game-page,
.binary-game-page * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html:has(.binary-game-page)::-webkit-scrollbar,
body:has(.binary-game-page)::-webkit-scrollbar,
body:has(.binary-game-page) main::-webkit-scrollbar,
.binary-game-page::-webkit-scrollbar,
.binary-game-page *::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body:has(.binary-game-page) main {
  width: 100%;
  max-width: none;
  height: calc(100dvh - 7rem);
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(0.7rem, 2vw, 1.35rem) !important;
}

.binary-game-page {
  --game-text: var(--text-body);
  --game-muted: var(--text-muted);
  --game-line: color-mix(in srgb, var(--accent-primary) 72%, var(--text-muted));
  --game-line-soft: color-mix(in srgb, var(--accent-primary) 34%, transparent);
  --game-border: color-mix(in srgb, var(--text-muted) 58%, transparent);
  --game-border-soft: color-mix(in srgb, var(--text-muted) 24%, transparent);
  --game-action: var(--accent-action);
  --game-ok: var(--accent-primary);
  --game-danger: color-mix(in srgb, var(--accent-action) 78%, var(--text-body));

  width: min(100%, 980px);
  height: min(760px, 100%);
  min-height: 0;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.9rem;
  margin: 0 auto;
  padding: clamp(0.8rem, 2vw, 1.25rem);
  border: 2px solid var(--game-border);
  outline: 1px solid var(--game-border-soft);
  outline-offset: 5px;
  background: transparent;
  color: var(--game-text);
  font-family: var(--font-stack-mono, "Fira Code", "Courier New", monospace);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: auto;
}

.binary-game-page *,
.binary-game-page *::before,
.binary-game-page *::after {
  box-sizing: border-box;
}

.binary-game-page [hidden] {
  display: none !important;
}

.binary-game-page a {
  color: var(--game-action);
  border-bottom-color: var(--game-line-soft);
}

.binary-game-page a:hover {
  background: transparent;
  color: var(--game-line);
  border-bottom-color: var(--game-line);
}

.game-topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--game-border-soft);
  color: var(--game-muted);
  font-size: 0.72rem;
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.back-link,
.ghost-command {
  font-family: inherit;
}

.game-screen {
  min-height: 0;
  display: none;
}

.game-screen.is-active {
  display: grid;
}

#screen-menu.is-active {
  gap: 1rem;
  align-content: center;
}

#screen-game.is-active {
  width: min(100%, 920px);
  grid-template-columns: 1fr;
  gap: 1rem;
  align-content: start;
  justify-items: center;
}

#screen-about.is-active,
#screen-credits.is-active {
  width: min(100%, 820px);
  gap: 1rem;
  align-content: start;
  justify-items: center;
}

.boot-panel,
.terminal-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.boot-panel {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 0;
  padding: clamp(0.5rem, 4vh, 1.7rem) 0;
  text-align: center;
}

.boot-panel::before {
  content: "01000010 01010101 01010011 01000011 01000001";
  display: block;
  margin-bottom: 0.55rem;
  color: var(--game-muted);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
}

.boot-label {
  display: inline-block;
  margin: 0 0 0.45rem;
  color: var(--game-muted);
  font-size: 0.66rem;
  line-height: 1.1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ascii-title,
.mini-ascii-title {
  overflow-wrap: break-word; 
  word-break: break-word;
  margin: 0;
  color: var(--game-line);
  font-family: inherit;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 0.88;
  text-transform: uppercase;
  white-space: pre;
  text-shadow: 2px 0 0 color-mix(in srgb, var(--game-action) 72%, transparent);
}

.ascii-title {
  font-size: clamp(2.6rem, 11vw, 6rem);
}

.mini-ascii-title {
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  font-size: clamp(1rem, 3.1vw, 1.65rem);
}

.boot-panel h1,
.compact-game-header p {
  margin: 0.65rem 0 0;
  color: var(--game-action);
  font-size: clamp(0.78rem, 1.8vw, 1rem);
  line-height: 1.25;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.boot-panel p {
  max-width: 54ch;
  margin: 0.9rem 0 0;
  color: var(--game-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.game-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.game-menu button,
.ghost-command,
.guess-row button,
.victory-panel button {
  min-height: 44px;
  appearance: none;
  border: 1px solid var(--game-border);
  border-radius: 0;
  background: transparent;
  color: var(--game-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.game-menu button {
  position: relative;
  padding: 0.85rem 0.95rem;
  text-align: left;
}

.game-menu button::before {
  content: ">";
  display: inline-block;
  margin-right: 0.55rem;
  color: var(--game-action);
}

.game-menu button::after {
  position: absolute;
  right: 0.8rem;
  color: var(--game-muted);
  font-family: "Symbols Nerd Font", "Symbols Nerd Font Mono", var(--font-stack-mono, monospace);
  font-size: 0.92rem;
  line-height: 1;
}

.game-menu button:nth-child(1)::after {
  content: "\f04b";
}

.game-menu button:nth-child(2)::after {
  content: "\f129";
}

.game-menu button:nth-child(3)::after {
  content: "\f2c2";
}

.game-menu button:hover,
.ghost-command:hover,
.guess-row button:hover,
.victory-panel button:hover {
  border-color: var(--game-border);
  color: var(--game-action);
}

.compact-game-header {
  width: min(100%, 760px);
  display: flex;
  flex-wrap: nowrap;
  gap: 0.9rem;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid var(--game-border);
}

.text-screen-header {
  width: min(100%, 760px);
  display: flex;
  flex-wrap: nowrap;
  gap: 0.9rem;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid var(--game-border);
}

.text-screen-header h2 {
  margin: 0;
}

.mini-title-block {
  flex: 0 1 auto;
  min-width: 0;
  display: grid;
  justify-items: start;
  text-align: left;
}

.compact-game-header p {
  margin-top: 0.35rem;
  color: var(--game-muted);
  font-size: 0.72rem;
}

.ghost-command {
  width: fit-content;
  min-height: 38px;
  padding: 0.55rem 0.7rem;
}

.compact-game-header .ghost-command {
  flex: 0 0 auto;
  width: fit-content;
}

.text-screen-header .ghost-command {
  flex: 0 0 auto;
  width: fit-content;
}

.header-spacer {
  flex: 0 0 auto;
  width: 4.6rem;
}

.play-panel {
  width: min(100%, 760px);
  min-height: 0;
  display: grid;
  justify-items: center;
}

.history-section {
  width: min(100%, 920px);
  min-height: 0;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--game-border-soft);
}

.game-hud {
  width: 100%;
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  text-align: center;
  margin-bottom: 1rem;
}

.game-instruction {
  display: block;
  color: var(--game-line);
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.match-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 1rem;
  margin: 0;
}

.match-stats div {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.match-stats dt,
.match-stats dd {
  margin: 0;
}

.match-stats dt {
  color: var(--game-muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.match-stats dd {
  color: var(--game-action);
  font-size: clamp(0.96rem, 2.2vw, 1.18rem);
}

.match-bounds {
  border-top: 1px dashed var(--game-border-soft);
  padding-top: 0.35rem;
}

.guess-form {
  width: min(100%, 24rem);
  margin: 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--game-border-soft);
}

.guess-form label,
.section-heading h2,
.text-screen h2 {
  display: block;
  margin: 0;
  color: var(--game-line);
  font-size: 0.78rem;
  line-height: 1.2;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.guess-form label {
  margin-bottom: 0.4rem;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.guess-row input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--game-border);
  border-radius: 0;
  background: transparent;
  color: var(--game-text);
  caret-color: var(--game-action);
  font: inherit;
  font-size: 1rem;
}

.guess-row input::placeholder {
  color: var(--game-muted);
}

.guess-row input:focus {
  border-color: var(--game-border);
  outline: 1px solid var(--game-border);
  outline-offset: 2px;
}

.guess-row button,
.victory-panel button {
  padding: 0.65rem 0.9rem;
}

.guess-row button {
  min-width: 3rem;
  font-size: 1.2rem;
  line-height: 1;
}

.guess-row button:disabled,
.guess-row input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.game-message {
  width: min(100%, 32rem);
  min-height: 3.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.9rem;
  padding: 0.65rem 0.8rem;
  border: 1px dashed var(--game-border);
  background: transparent;
  color: var(--game-text);
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  box-shadow: 3px 3px 0 var(--game-border-soft);
}

.game-message.is-error {
  border-color: var(--game-border);
  color: var(--game-danger);
}

.game-message.is-success {
  border-color: var(--game-border);
  color: var(--game-ok);
}

.victory-panel {
  width: min(100%, 34rem);
  display: grid;
  justify-items: center;
  justify-self: center;
  position: relative;
  margin-top: 0.9rem;
  padding: 1rem 1.1rem;
  border: 2px solid var(--game-border);
  border-radius: 0;
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--bg-surface) 92%, var(--game-ok)),
      var(--bg-surface) 62%
    );
  box-shadow:
    7px 7px 0 color-mix(in srgb, var(--bg-base) 74%, transparent),
    10px 10px 0 var(--game-border-soft);
  text-align: center;
  transform: translateY(-0.15rem) rotate(-0.2deg);
}

.victory-panel::before,
.victory-panel::after {
  content: "";
  position: absolute;
  width: 0.62rem;
  height: 0.62rem;
  background: var(--game-border);
}

.victory-panel::before {
  top: 0.35rem;
  left: 0.35rem;
}

.victory-panel::after {
  right: 0.35rem;
  bottom: 0.35rem;
}

.victory-panel h2 {
  margin: 0;
  color: var(--game-ok);
  font-family: inherit;
  font-size: clamp(1.9rem, 6vw, 3.35rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 color-mix(in srgb, var(--game-action) 48%, transparent);
}

.victory-panel.is-optimal {
  border-color: var(--game-ok);
}

.victory-panel.is-over-limit {
  border-color: var(--game-action);
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--bg-surface) 88%, var(--game-action)),
      var(--bg-surface) 64%
    );
}

.victory-panel.is-over-limit h2 {
  color: var(--game-action);
}

.victory-panel p {
  max-width: none;
  margin: 0.65rem 0 0.85rem;
  color: var(--game-text);
  font-size: 0.88rem;
  line-height: 1.45;
}

.victory-panel button {
  background: color-mix(in srgb, var(--bg-base) 72%, transparent);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.section-heading .boot-label {
  margin: 0;
}

.guess-history {
  display: block;
  column-width: 13rem;
  column-gap: 1rem;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.history-scroll {
  max-height: clamp(180px, 30dvh, 320px);
  overflow-y: auto;
  padding-right: 0.35rem;
  scrollbar-gutter: auto;
}

.guess-history li {
  max-width: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
  align-items: baseline;
  break-inside: avoid;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--game-border-soft);
  color: var(--game-text);
  font-size: 0.84rem;
  line-height: 1.25;
}

.guess-history .empty-history {
  display: block;
  color: var(--game-muted);
}

.history-guess {
  color: var(--game-text);
}

.history-result {
  color: var(--game-action);
}

.history-hit .history-result {
  color: var(--game-ok);
}

.text-screen .terminal-panel {
  max-width: 820px;
}

.text-screen p {
  max-width: 76ch;
  color: var(--game-text);
  font-size: 0.92rem;
  line-height: 1.65;
}

.credits-panel {
  width: min(100%, 36rem);
  display: grid;
  gap: 0.85rem;
}

.credits-note {
  margin: 0;
  color: var(--game-muted);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: center;
}

.credits-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.credit-item {
  display: grid;
  grid-template-columns: 1.4rem minmax(5.5rem, auto) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--game-border-soft);
  color: var(--game-text);
  font-size: 0.88rem;
  line-height: 1.35;
}

.credit-item::before {
  color: var(--game-action);
  font-family: "Symbols Nerd Font", "Symbols Nerd Font Mono", var(--font-stack-mono, monospace);
  font-size: 1rem;
  line-height: 1;
}

.credit-author::before {
  content: "\f2bd";
}

.credit-site::before {
  content: "\f0ac";
}

.credit-github::before {
  content: "\f09b";
}

.credit-github {
  cursor: pointer;
}

.credit-item span {
  color: var(--game-muted);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.credit-item strong,
.credit-item a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.credit-item a:hover {
  color: var(--game-line);
}

.credits-easter {
  justify-self: center;
  max-width: min(100%, 32rem);
  margin: 0.15rem 0 0;
  padding: 0.65rem 0.8rem;
  border: 1px dashed var(--game-border);
  color: var(--game-ok);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
  box-shadow: 3px 3px 0 var(--game-border-soft);
}

.credits-easter.is-visible {
  animation: terminal-reveal 0.28s steps(3, end);
}

.binary-game-page.is-credit-glitch .text-screen-header h2 {
  animation: credit-glitch 0.58s steps(2, end);
}

@keyframes terminal-reveal {
  0% {
    opacity: 0;
    transform: translateY(0.25rem);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes credit-glitch {
  0%,
  100% {
    transform: translate(0, 0);
    text-shadow: none;
  }

  24% {
    transform: translate(-1px, 1px);
    text-shadow: 2px 0 0 var(--game-action);
  }

  52% {
    transform: translate(1px, -1px);
    text-shadow: -2px 0 0 var(--game-ok);
  }

  78% {
    transform: translate(-1px, 0);
    text-shadow: 1px 1px 0 var(--game-action);
  }
}

@media (max-width: 860px) {
  body:has(.binary-game-page) main {
    align-items: start;
    height: calc(100dvh - 6.5rem);
    min-height: 0;
  }

  .binary-game-page {
    height: 100%;
    min-height: 0;
  }

  .history-section {
    padding-top: 0.9rem;
  }

  .history-scroll {
    max-height: 34dvh;
  }
}

@media (max-width: 620px) {
  body:has(.binary-game-page) main {
    padding: 0.65rem !important;
  }

  .binary-game-page {
    gap: 0.75rem;
    padding: 0.75rem;
    outline-offset: 3px;
  }

  .game-topbar {
    display: grid;
    gap: 0.25rem;
  }

  .ascii-title {
    font-size: clamp(2.15rem, 16vw, 3.7rem);
  }

  .game-menu {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .compact-game-header {
    gap: 0.55rem;
    text-align: left;
  }

  .mini-title-block {
    justify-items: start;
    text-align: left;
  }

  .ghost-command,
  .game-menu button {
    width: 100%;
  }

  .compact-game-header .ghost-command,
  .text-screen-header .ghost-command {
    width: fit-content;
  }

  .header-spacer {
    display: none;
  }

  .guess-row {
    grid-template-columns: minmax(0, 1fr) minmax(3.25rem, auto);
    gap: 0.45rem;
  }

  .guess-row button {
    width: auto;
    min-width: 3.25rem;
    padding-inline: 0.7rem;
  }

  .guess-form,
  .game-hud,
  .game-message,
  .victory-panel {
    width: 100%;
  }

  .history-scroll {
    max-height: 38dvh;
  }

  .guess-history {
    column-count: 1;
    column-width: auto;
  }

  .guess-history li {
    grid-template-columns: 1fr;
    gap: 0.18rem;
  }
}
