:root {
  color-scheme: light;
  --bg: #fbfbf8;
  --input: #f0f1ed;
  --ink: #111827;
  --muted: #687184;
  --line: #d9ddd3;
  --green: #397a46;
  --gold: #a47b16;
  --blue: #2f6d9f;
  --red: #af4747;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111312;
    --input: #202421;
    --ink: #f3f5f1;
    --muted: #a6afa7;
    --line: #343a35;
    --green: #87bd7b;
    --gold: #d6b757;
    --blue: #8ab5e4;
    --red: #db7777;
  }
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 35%, transparent);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.35rem, 7vw, 3.55rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.site-header,
.shell {
  width: min(820px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  margin-top: 48px;
  margin-bottom: 34px;
}

.brand-row {
  min-width: 0;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.control-strip {
  margin-top: 22px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
}

.difficulty {
  display: flex;
  gap: 10px;
}

.segmented,
.chip,
.quiet-button,
.icon-button {
  padding: 0;
  color: var(--muted);
  text-align: left;
}

.segmented.active,
.chip.active,
.quiet-button.active {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.quiet-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.segmented:hover,
.chip:hover {
  color: var(--ink);
}

.date-controls {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-controls[hidden],
#newRandom[hidden],
.solution-section[hidden],
.result-panel[hidden],
.share-row[hidden] {
  display: none;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
}

input[type="date"],
#guessInput,
#shareText {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--input);
}

input[type="date"] {
  min-height: 44px;
  max-width: 176px;
  padding: 0 12px;
  font-weight: 750;
}

.game-board {
  margin-top: 40px;
}

.word-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

.word-tile {
  display: grid;
  gap: 10px;
}

.word-tile.target {
  text-align: right;
}

.word-tile span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.word-tile strong {
  overflow-wrap: anywhere;
  font-size: clamp(2.2rem, 7vw, 3.1rem);
  line-height: 1;
}

.context-line {
  margin: 34px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 750;
  line-height: 1.5;
}

.meter-block {
  margin-top: 26px;
}

.meter-label,
.rule-line,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.meter-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 850;
}

.meter-label strong {
  color: var(--ink);
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease, background-color 180ms ease;
}

.meter span.warning {
  background: var(--gold);
}

.meter span.blocked {
  background: var(--red);
}

.guess-form {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 12px;
}

#guessInput {
  min-width: 0;
  min-height: 58px;
  padding: 0 16px;
  font-size: 1.05rem;
  font-weight: 750;
}

#submitGuess {
  min-height: 58px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
}

.message {
  min-height: 28px;
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.message.error {
  color: var(--red);
}

.message.success {
  color: var(--green);
}

.rule-line {
  flex-wrap: wrap;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 850;
}

.result-panel {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.result-panel p {
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.path-section,
.solution-section,
.stats-section,
.rules {
  margin-top: 44px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.share-row {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
}

#shareText {
  min-width: 0;
  min-height: 48px;
  padding: 0 12px;
  font-weight: 750;
}

.guess-table {
  width: 100%;
  margin-top: 24px;
  border-collapse: collapse;
  table-layout: fixed;
}

.guess-table th,
.guess-table td {
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.guess-table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.guess-table th:first-child,
.guess-table td:first-child {
  width: 42px;
}

.guess-table th:nth-child(3),
.guess-table th:nth-child(4),
.guess-table td:nth-child(3),
.guess-table td:nth-child(4) {
  width: 104px;
}

.guess-table th:last-child,
.guess-table td:last-child {
  width: 92px;
}

.path-word {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.read-badge {
  display: inline;
  color: var(--muted);
  font-weight: 750;
}

.read-badge.closer {
  color: var(--blue);
}

.read-badge.warm {
  color: var(--gold);
}

.read-badge.hot,
.read-badge.target {
  color: var(--green);
}

.solution-status {
  color: var(--muted);
  font-weight: 850;
}

.stats-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  text-align: left;
}

.stats-section div {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stats-section strong {
  font-size: 1.55rem;
}

.rules summary {
  cursor: pointer;
  font-weight: 900;
}

.rules p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

#copyShare,
#shareResult {
  padding: 0 16px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
}

.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;
}

@media (max-width: 680px) {
  .site-header,
  .shell {
    width: min(100% - 32px, 820px);
  }

  .site-header {
    margin-top: 26px;
    margin-bottom: 28px;
  }

  .control-strip,
  .difficulty {
    grid-template-columns: 1fr;
  }

  .mode-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .difficulty {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .control-strip {
    margin-top: 18px;
    padding-bottom: 24px;
  }

  .date-controls {
    justify-self: stretch;
    display: grid;
    grid-template-columns: 36px 1fr 36px;
  }

  input[type="date"] {
    width: 100%;
    max-width: none;
  }

  .game-board {
    margin-top: 36px;
  }

  .word-grid,
  .guess-form,
  .share-row {
    grid-template-columns: 1fr;
  }

  .word-tile.target {
    text-align: left;
  }

  .stats-section {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .guess-table {
    font-size: 0.88rem;
  }

  .guess-table th,
  .guess-table td {
    padding: 12px 5px;
  }

  .guess-table th:first-child,
  .guess-table td:first-child {
    width: 30px;
  }

  .guess-table th:nth-child(3),
  .guess-table th:nth-child(4),
  .guess-table td:nth-child(3),
  .guess-table td:nth-child(4) {
    width: 68px;
  }

  .guess-table th:last-child,
  .guess-table td:last-child {
    width: 66px;
  }

  .read-badge {
    font-size: 0.82rem;
  }
}
