@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-latin.woff2") format("woff2");
}

@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/dm-mono-400-latin.woff2") format("woff2");
}

@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/dm-mono-500-latin.woff2") format("woff2");
}

:root {
  --ink: #19221d;
  --muted: #69726b;
  --paper: #f3f0e8;
  --panel: rgba(255, 255, 255, 0.72);
  --line: #d8d8cd;
  --green: #2e6b4c;
  --lime: #d7f45b;
  --coral: #ef775f;
  --shadow: 0 24px 70px rgba(42, 56, 47, 0.1);
  --grid: rgba(25, 34, 29, 0.035);
  --glass: rgba(255, 255, 255, 0.55);
  --field: rgba(255, 255, 255, 0.88);
  --past-field: rgba(243, 240, 232, 0.7);
  --result: #e8e8df;
  --dialog: #fbfaf6;
  --button-bg: #19221d;
  --button-text: #fff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf2eb;
  --muted: #a7b0a9;
  --paper: #101511;
  --panel: rgba(24, 31, 26, 0.86);
  --line: #39443c;
  --green: #8fcaa4;
  --lime: #d7f45b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --grid: rgba(237, 242, 235, 0.035);
  --glass: rgba(38, 48, 41, 0.72);
  --field: rgba(29, 38, 32, 0.94);
  --past-field: rgba(22, 29, 24, 0.8);
  --result: #29332c;
  --dialog: #182019;
  --button-bg: #d7f45b;
  --button-text: #172019;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Manrope", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.32;
  pointer-events: none;
}

.page-glow--one {
  top: -10rem;
  right: -7rem;
  background: var(--lime);
}

.page-glow--two {
  bottom: -14rem;
  left: -8rem;
  background: #f3a99b;
}

.game-shell {
  width: min(960px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 72px;
}

.site-footer {
  display: flex;
  padding: 30px 4px 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.site-footer a,
.text-link {
  color: inherit;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.site-footer a:hover,
.text-link:hover {
  color: var(--green);
  text-decoration-color: currentColor;
}

.site-footer p {
  margin: 0;
}

.info-shell {
  width: min(760px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0 50px;
}

.info-main {
  padding: 76px 0 36px;
}

.info-main h1 {
  max-width: 680px;
  margin-bottom: 26px;
  font-size: clamp(2.7rem, 8vw, 5rem);
}

.info-card {
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid rgba(25, 34, 29, 0.09);
  border-radius: 24px;
  color: var(--muted);
  line-height: 1.75;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.info-card h2 {
  margin: 34px 0 8px;
  color: var(--ink);
  font-size: 1.2rem;
  letter-spacing: -0.025em;
}

.info-card h2:first-child {
  margin-top: 0;
}

.info-card p,
.info-card ul {
  margin: 0 0 16px;
}

.info-card li + li {
  margin-top: 6px;
}

.info-card strong {
  color: var(--ink);
}

.info-card a {
  color: var(--green);
}

.info-card code {
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--ink);
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
  background: var(--result);
}

.info-note {
  padding: 16px 18px;
  border-left: 3px solid var(--lime);
  border-radius: 0 10px 10px 0;
  background: rgba(215, 244, 91, 0.14);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: var(--paper);
  font-family: Georgia, serif;
  font-size: 1.55rem;
  font-style: italic;
  background: var(--ink);
  transform: rotate(-3deg);
}

.topbar-actions {
  display: flex;
  gap: 9px;
}

.help-button,
.theme-button,
.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.help-button:hover,
.theme-button:hover,
.dialog-close:hover {
  background: var(--field);
  transform: rotate(4deg);
}

.theme-button span {
  display: block;
  font-size: 1.05rem;
  line-height: 1;
  transition: transform 240ms ease;
}

.theme-button:hover span {
  transform: rotate(18deg);
}

.intro {
  display: grid;
  justify-items: center;
  padding: 70px 20px 48px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.19em;
}

h1 {
  max-width: 750px;
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.96;
}

.intro-copy {
  max-width: 570px;
  margin: 24px 0 30px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.target-card {
  display: inline-flex;
  min-width: 170px;
  padding: 13px 19px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1px solid rgba(46, 107, 76, 0.2);
  border-radius: 999px;
  background: rgba(215, 244, 91, 0.42);
  box-shadow: 0 7px 20px rgba(80, 97, 37, 0.08);
}

.target-label {
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.target-value {
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 1.32rem;
}

.board {
  padding: 26px;
  border: 1px solid rgba(25, 34, 29, 0.09);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.board-heading {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px 142px;
  gap: 14px;
  padding: 0 6px 10px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.board-heading span:nth-child(2) {
  text-align: center;
}

.history {
  display: grid;
  gap: 9px;
  margin-bottom: 9px;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px 142px;
  gap: 14px;
  align-items: stretch;
}

.guess-row--past {
  animation: row-in 300ms ease both;
}

.digit-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.digit-inputs,
.past-digits {
  display: grid;
  height: 64px;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.digit-input,
.past-digit {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  text-align: center;
  background: var(--field);
  transition: border 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.digit-input:focus {
  z-index: 1;
  border-color: var(--green);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(46, 107, 76, 0.13);
  transform: translateY(-2px);
}

.past-digit {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--past-field);
}

.past-digit--empty {
  color: #c6c8c1;
}

.result-cell {
  display: grid;
  min-width: 0;
  height: 64px;
  padding: 0 10px;
  place-items: center;
  overflow: hidden;
  border-radius: 13px;
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.1rem, 2.8vw, 1.55rem);
  text-overflow: ellipsis;
  background: var(--result);
}

.result-cell--pending {
  color: #979c96;
  border: 1px dashed #c9cbc4;
  background: transparent;
}

.result-cell--success {
  color: #f8fff8;
  background: var(--green);
  box-shadow: 0 7px 18px rgba(46, 107, 76, 0.22);
}

.submit-button {
  display: flex;
  height: 64px;
  padding: 0 22px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 13px;
  color: var(--button-text);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--button-bg);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--green);
  transform: translateY(-2px);
}

.submit-button:disabled,
.digit-input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.game-footer {
  display: flex;
  min-height: 42px;
  padding-top: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.game-footer p {
  margin: 0;
}

.hint-area {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
}

.hint-area[hidden],
.hint-button[hidden],
.hint-text[hidden] {
  display: none;
}

.hint-button {
  display: inline-flex;
  padding: 8px 13px;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.hint-button:hover:not(:disabled) {
  background: rgba(46, 107, 76, 0.08);
  transform: translateY(-1px);
}

.hint-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.hint-text {
  margin: 0;
  padding: 10px 15px;
  border-radius: 11px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  background: rgba(215, 244, 91, 0.22);
}

.attempt-dots {
  display: flex;
  gap: 6px;
}

.attempt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4d5ce;
}

.attempt-dot--used {
  background: var(--ink);
}

.message {
  display: none;
  margin-top: 5px;
  padding: 16px 18px;
  border-radius: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.message:not(:empty) {
  display: block;
}

.message--win {
  color: #fff;
  background: var(--green);
}

:root[data-theme="dark"] .result-cell--success,
:root[data-theme="dark"] .message--win {
  color: #f8fff8;
  background: #356b4a;
}

.message--loss,
.message--error {
  color: #7b3022;
  background: #fbe0da;
}

.solution {
  display: flex;
  margin-top: 12px;
  padding: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid rgba(25, 34, 29, 0.12);
  border-radius: 15px;
  background: var(--field);
  animation: row-in 300ms ease both;
}

.solution[hidden] {
  display: none;
}

.solution-label,
.solution-example span {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.solution-explanation {
  max-width: 580px;
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.55;
}

.solution-example {
  min-width: 120px;
  text-align: right;
}

.solution-example span {
  display: block;
  color: var(--muted);
}

.solution-example strong {
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 1.35rem;
}

.help-dialog {
  width: min(500px, calc(100% - 32px));
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  background: var(--dialog);
  box-shadow: 0 30px 100px rgba(25, 34, 29, 0.25);
}

.help-dialog::backdrop {
  background: rgba(25, 34, 29, 0.4);
  backdrop-filter: blur(5px);
}

.help-dialog h2 {
  max-width: 360px;
  margin: 0 0 20px;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.help-dialog ol,
.help-dialog > p:last-child {
  color: var(--muted);
  line-height: 1.7;
}

.help-dialog li + li {
  margin-top: 8px;
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 1.3rem;
}

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

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 700px) {
  .game-shell {
    width: min(100% - 24px, 600px);
    padding-top: 20px;
  }

  .intro {
    padding: 52px 10px 36px;
  }

  .board {
    padding: 14px;
    border-radius: 20px;
  }

  .board-heading {
    grid-template-columns: 1fr 88px;
  }

  .guess-row {
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 8px;
  }

  .submit-button {
    grid-column: 1 / -1;
    height: 52px;
    justify-content: center;
  }

  .guess-row--past {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .guess-row--past .submit-button {
    display: none;
  }

  .digit-inputs,
  .past-digits,
  .result-cell {
    height: 56px;
  }

  .digit-inputs,
  .past-digits {
    gap: 5px;
  }

  .digit-input,
  .past-digit,
  .result-cell {
    border-radius: 10px;
  }

  .solution {
    align-items: flex-start;
    flex-direction: column;
  }

  .solution-example {
    text-align: left;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .info-shell {
    width: min(100% - 24px, 600px);
    padding-top: 20px;
  }

  .info-main {
    padding-top: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
