:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
  line-height: 1.5;
  color: #e8e8e8;
  background: #212121;

  --page: #212121;
  --header: #212121;
  --panel: #292929;
  --inset: #242424;
  --control: #343434;
  --control-hover: #404040;
  --line: #444;
  --tile-line: #707070;
  --text: #e8e8e8;
  --muted: #a6a6a6;
  --key: #5a5a5a;
  --key-hover: #686868;
  --green: #3f7a4c;
  --green-hover: #477f52;
  --success: #a3dbac;
  --amber: #f2a81e;
  --hint: #ffd18a;
  --error: #ffaf9f;
  --radius: 8px;
  --panel-radius: 12px;
  --page-width: 1152px;
  --gutter: 16px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
}

:where(h1, h2, h3, p, ul, ol, dl) {
  margin-block: 0;
}

:where(h1, h2, h3) {
  line-height: 1.2;
  text-wrap: balance;
}

:where(img, svg) {
  display: block;
  max-width: 100%;
}

:where(a) {
  color: var(--hint);
  text-underline-offset: 0.2em;
}

:where(button, input, select) {
  font: inherit;
  color: inherit;
}

:where(button, summary) {
  cursor: pointer;
}

:where(button, a, summary) {
  -webkit-tap-highlight-color: transparent;
}

:where(button:disabled) {
  cursor: default;
}

:where(button, a, summary, input, select):focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.container {
  width: min(var(--page-width), calc(100% - 2 * var(--gutter)));
  margin-inline: auto;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding-block: 20px 40px;
}

.page-layout > * {
  min-width: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 4;
  transform: translateY(-160%);
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--page);
  background: var(--hint);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid #373737;
  background: var(--header);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 24px;
  min-height: 63px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  flex: none;
  border: 1px solid #4e7354;
  border-radius: 7px;
  background: #2b382d;
}

.brand-mark::before {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: #6aab77;
  box-shadow: 6px -5px #8bc996, 12px -10px #b2dfb7;
}

.brand-mark > i {
  display: none;
}

.menu-toggle,
.language-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.menu-toggle svg,
.language-menu summary svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.menu-toggle:hover,
.language-menu summary:hover,
.language-menu[open] summary {
  background: var(--control);
}

.site-nav {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  gap: 4px;
  padding-block: 8px 16px;
}

.header-inner:has(.menu-toggle[aria-expanded="true"]) .site-nav,
.site-nav[data-open="true"],
.site-nav.is-open {
  display: flex;
}

.site-nav > a,
.language-options a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.site-nav > a:hover,
.language-options a:hover {
  background: var(--control);
  color: var(--text);
}

.site-nav > a[aria-current="page"],
.language-options a[aria-current] {
  background: #29382c;
  color: #b9dfbf;
}

.language-menu {
  position: relative;
}

.language-menu summary {
  list-style: none;
  font-size: 14px;
  white-space: nowrap;
}

.language-menu summary::-webkit-details-marker {
  display: none;
}

.language-menu summary::after {
  width: 6px;
  height: 6px;
  margin-inline: 4px 1px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: rotate(45deg) translateY(-2px);
}

.language-menu[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.language-code {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.language-options {
  display: grid;
  min-width: 9rem;
  margin: 6px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  list-style: none;
}

.main-column {
  display: grid;
  align-content: start;
  gap: 24px;
}

.ad-slot {
  display: none;
  width: 300px;
  height: 250px;
  border: 1px solid #333;
  border-radius: var(--panel-radius);
  background: #232323;
}

.ad-slot:empty {
  visibility: hidden;
}

.game-card,
.content-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--panel);
}

.game-header,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.game-header {
  align-items: center;
  min-height: 40px;
  margin-bottom: 8px;
}

.game-header h1,
.content-card h1 {
  font-size: clamp(1.45rem, 3.4vw, 2rem);
  letter-spacing: -0.035em;
}

.game-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  min-height: 44px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid #424242;
  border-radius: var(--radius);
  background: var(--inset);
}

.status-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 7px;
  min-width: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.status-item strong {
  color: var(--text);
  white-space: nowrap;
}

.status-label {
  color: var(--muted);
}

.ladder {
  --tile-size: clamp(40px, 13vw, 56px);
  --tile-gap: clamp(4px, 1.3vw, 8px);

  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  height: 196px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 8px;
  border: 1px solid #414141;
  border-radius: var(--radius);
  background: var(--inset);
  scrollbar-width: thin;
  scrollbar-color: #666 var(--inset);
}

.word-row {
  display: grid;
  grid-template-columns: minmax(1.25rem, 2.75rem) max-content minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.row-label,
.row-clue {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.word-tiles {
  display: grid;
  grid-template-columns: repeat(4, var(--tile-size));
  gap: var(--tile-gap);
}

.tile {
  display: grid;
  width: var(--tile-size);
  height: var(--tile-size);
  place-items: center;
  border: 2px solid var(--tile-line);
  border-radius: 5px;
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 750;
  line-height: 1;
}

.word-row.current .tile {
  border-color: #8f7b54;
  background: #2c2923;
}

.word-row.current .tile:empty {
  border-style: dashed;
}

.word-row.current .tile.hinted,
.tile.hinted {
  border-color: var(--amber);
  background: #403420;
}

.tile.changed {
  background: #353535;
}

.word-row.won .tile {
  border-color: #69a275;
  background: #2f4532;
  color: #d1f2d4;
}

.feedback {
  min-height: 24px;
  margin: 3px 0;
  color: var(--hint);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.feedback[data-kind="error"],
.feedback[data-type="error"],
.feedback.error {
  color: var(--error);
}

.feedback[data-kind="success"],
.feedback[data-type="success"],
.feedback.success {
  color: var(--success);
}

.game-actions,
.action-row,
.page-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #5a9063;
  border-radius: var(--radius);
  background: #376742;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
}

.button:hover {
  background: var(--green);
}

.button.secondary,
.button.ghost {
  background: var(--control);
  border-color: #535353;
  color: var(--text);
}

.button.ghost {
  background: transparent;
}

.button.secondary:hover,
.button.ghost:hover {
  background: var(--control-hover);
}

.button:disabled,
.button[aria-disabled="true"] {
  background: #2e2e2e;
  border-color: #474747;
  color: #aaa;
}

.game-header .button {
  flex: none;
}

.archive-back {
  display: inline-flex;
  margin-bottom: 12px;
}

.keyboard {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.key-row {
  display: grid;
  gap: clamp(3px, 1vw, 6px);
}

.key-row.keys-10 {
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

.key-row.keys-9 {
  width: 90%;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  justify-self: center;
}

.key-row.keys-control {
  grid-template-columns: minmax(0, 1.65fr) repeat(7, minmax(0, 1fr)) minmax(0, 1.35fr);
}

.key {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 1px 0;
  border: 1px solid #696969;
  border-radius: 6px;
  background: var(--key);
  color: #fff;
  font-size: clamp(0.82rem, 3vw, 1rem);
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
  transition: background 80ms ease, transform 80ms ease;
}

.key:hover {
  background: var(--key-hover);
}

.key:active,
.key.pressed {
  background: #737373;
  transform: translateY(1px);
}

.key-submit {
  border-color: #619a6a;
  background: var(--green);
  font-size: clamp(0.64rem, 2.65vw, 0.84rem);
  overflow-wrap: anywhere;
}

.key-submit:hover,
.key-submit:active,
.key-submit.pressed {
  background: var(--green-hover);
}

.key-delete {
  font-size: 1.16rem;
}

.key svg {
  width: 18px;
  height: 18px;
}

.key:disabled {
  background: #353535;
  border-color: #515151;
  color: #aaa;
  transform: none;
}

.game-result {
  margin: 4px 0 12px;
  padding: 12px;
  border: 1px solid #5d8d63;
  border-radius: var(--radius);
  background: #2b3e2d;
}

.game-result h2 {
  width: fit-content;
  margin-bottom: 4px;
  color: #d1f2d4;
  font-size: 1.25rem;
}

.game-result h2:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 2px;
}

.game-result .action-row {
  margin-top: 12px;
}

.play-body:has(.game-result:not([hidden])) > .feedback:empty {
  min-height: 0;
  margin: 0;
}

[data-share-fallback] {
  margin-top: 12px;
}

[data-share-fallback] input {
  margin-top: 4px;
}

.mode-choices {
  display: grid;
  align-content: start;
  gap: 12px;
  padding-block: 16px 8px;
}

.mode-choices > h2 {
  grid-column: 1 / -1;
  font-size: 1.2rem;
}

.mode-choice {
  min-height: 56px;
  padding: 12px;
  border: 1px solid #595959;
  border-radius: var(--radius);
  background: var(--control);
  color: var(--text);
  text-align: left;
}

.mode-choice:hover {
  border-color: #68996e;
  background: #304233;
}

.mode-choice > span {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

.prose {
  color: #d7d7d7;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.prose > * + * {
  margin-block-start: 0.9em;
}

.prose :is(h1, h2, h3) {
  color: var(--text);
}

.prose h2 {
  margin-block-start: 1.25em;
  font-size: 1.3rem;
}

.prose h3 {
  margin-block-start: 1.15em;
  font-size: 1.05rem;
}

.prose :is(ul, ol) {
  padding-inline-start: 1.35em;
}

.prose li + li {
  margin-top: 0.3em;
}

.prose details {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--inset);
}

.prose details > summary {
  min-height: 32px;
  color: var(--text);
  font-weight: 700;
}

.prose details[open] > summary {
  margin-bottom: 4px;
}

.link-list,
.word-grid,
.archive-list {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.link-list a,
.archive-list > li > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--inset);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.link-list a:hover,
.archive-list > li > a:hover {
  border-color: #688c6d;
  background: #2d382e;
}

.link-list a.primary {
  border-color: #5a9063;
  background: #376742;
  color: #fff;
}

.link-list a.primary:hover {
  background: var(--green);
}

.example-ladder {
  padding: 12px;
  border: 1px solid var(--tile-line);
  border-radius: var(--radius);
  background: var(--inset);
  color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
}

.example-ladder span {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--tile-line);
  border-radius: 4px;
}

.word-grid {
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
}

.word-grid > * {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--inset);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 600;
  text-align: center;
}

.page-controls {
  margin-top: 16px;
}

.tool-form {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.tool-form label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.tool-form > label {
  margin-bottom: 0;
}

:is(.tool-form, [data-share-fallback]) input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--tile-line);
  border-radius: var(--radius);
  background: var(--inset);
  color: var(--text);
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.tool-form .action-row {
  width: 100%;
}

.tool-form .action-row input {
  flex: 1 1 7rem;
  min-width: 0;
  width: auto;
}

.form-fields {
  display: grid;
  width: 100%;
  gap: 8px 12px;
}

.form-fields > * {
  min-width: 0;
}

.form-fields .feedback:empty {
  min-height: 0;
  margin: 0;
}

.tool-result {
  padding: 12px;
  border: 1px solid #5b7b60;
  border-radius: var(--radius);
  background: #2a382c;
  overflow-wrap: anywhere;
}

.tool-result:empty {
  margin: 0;
  padding: 0;
  border: 0;
}

.tool-result ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin-top: 8px;
  padding-left: 24px;
}

.site-footer {
  border-top: 1px solid #3a3a3a;
  color: var(--muted);
}

.footer-inner,
.consent-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-block: 16px;
  font-size: 0.875rem;
}

.site-footer :is(a, button) {
  color: var(--text);
}

.footer-inner :is(nav, .footer-links) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.footer-inner a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.consent-bar {
  margin-block: 0 16px;
  padding-inline: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.modal {
  width: min(29rem, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
  border: 1px solid #585858;
  border-radius: var(--panel-radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 16px 48px #0007;
}

.modal::backdrop {
  background: #0009;
}

.modal-header {
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h2 {
  font-size: 1.3rem;
}

.modal .action-row {
  margin-top: 16px;
}

@media (max-width: 479px) {
  .word-row:has(.row-clue:not(:empty)) {
    grid-template-columns: minmax(1.25rem, 2.75rem) max-content;
    justify-content: start;
  }

  .row-clue:not(:empty) {
    grid-column: 2;
  }
}

@media (max-width: 359px) {
  .game-actions .button {
    padding-inline: 9px;
  }
}

@media (min-width: 540px) {
  .mode-choices {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .word-row {
    grid-template-columns: minmax(2rem, 3.5rem) max-content minmax(0, 1fr);
    gap: 10px;
  }

  .row-label,
  .row-clue {
    font-size: 0.8125rem;
  }

  .game-card,
  .content-card,
  .modal {
    padding: 24px;
  }

  .ladder {
    height: 208px;
    padding-inline: 12px;
  }
}

@media (min-width: 800px) {
  .header-inner {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .menu-toggle {
    display: none;
  }

  .header-inner .site-nav {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: center;
    padding-block: 0;
  }

  .site-nav > .language-menu {
    margin-inline-start: auto;
  }

  .language-options {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 3;
    box-shadow: 0 10px 24px #0004;
  }

  .game-card:has(.play-body:not([hidden])) {
    min-height: 568px;
  }

  .game-header {
    margin-bottom: 0;
  }

  .play-body {
    display: grid;
    grid-template-areas:
      "status status"
      "rollover rollover"
      "ladder ladder"
      "result result"
      "actions feedback"
      "keyboard keyboard";
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
  }

  .game-status {
    grid-area: status;
    column-gap: 28px;
  }

  .play-body > [data-new-day] {
    grid-area: rollover;
    justify-self: start;
    margin-bottom: 8px;
  }

  .ladder {
    grid-area: ladder;
    height: 220px;
  }

  .game-result {
    grid-area: result;
  }

  .play-body > .feedback {
    grid-area: feedback;
    margin-block: 10px 0;
  }

  .game-actions {
    grid-area: actions;
    margin-top: 10px;
  }

  .game-header .button,
  .game-actions .button {
    min-height: 36px;
  }

  .keyboard {
    grid-area: keyboard;
    margin-top: 16px;
  }

  .key {
    min-height: 42px;
  }
}

@media (min-width: 960px) {
  .page-layout {
    padding-block: 32px 56px;
  }
}

@media (min-width: 1024px) {
  .page-layout {
    grid-template-columns: minmax(600px, 1fr) 300px;
  }

  .ad-slot {
    display: block;
  }
}

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