body.theme-crossword {
  --accent: #2f6b52;
  --accent-soft: #e7f1eb;
  --accent-strong: #214b3a;
  --accent-line: #bfd2c7;
  --accent-wash: rgba(47, 107, 82, 0.14);
}

:root[data-color-scheme="dark"] body.theme-crossword {
  --accent: #67b48c;
  --accent-soft: #17231e;
  --accent-strong: #d7eee1;
  --accent-line: #325040;
  --accent-wash: rgba(103, 180, 140, 0.2);
}

:root[data-color-palette="rose"] body.theme-crossword {
  --accent: #ff4ea5;
  --accent-soft: #ffd7ea;
  --accent-strong: #c81f75;
  --accent-line: #ff9bca;
  --accent-wash: rgba(255, 78, 165, 0.24);
}

:root[data-color-scheme="dark"][data-color-palette="rose"] body.theme-crossword {
  --accent: #ff7fc1;
  --accent-soft: #3c1125;
  --accent-strong: #ffdeef;
  --accent-line: #ff72bb;
  --accent-wash: rgba(255, 127, 193, 0.28);
}

:root[data-color-palette="ocean"] body.theme-crossword {
  --accent: #287b8d;
  --accent-soft: #e1f2f2;
  --accent-strong: #1d5860;
  --accent-line: #bcdcdf;
  --accent-wash: rgba(40, 123, 141, 0.16);
}

:root[data-color-scheme="dark"][data-color-palette="ocean"] body.theme-crossword {
  --accent: #65c0cb;
  --accent-soft: #152325;
  --accent-strong: #dcf7f8;
  --accent-line: #34565a;
  --accent-wash: rgba(101, 192, 203, 0.18);
}

.crossword-app {
  width: 95vw;
  margin-left: 50%;
  padding: 10px 0 52px;
  display: flex;
  flex-direction: column;
  transform: translateX(-50%);
}

.crossword-play-area {
  display: flex;
  flex-direction: column;
}

.crossword-board-stack:fullscreen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px;
  background: var(--paper);
}

.crossword-board-stack:fullscreen .crossword-board-panel,
.crossword-board-stack:fullscreen .crossword-controls-panel {
  width: fit-content;
  max-width: min(80vw, 100%);
}

.crossword-board-stack:fullscreen .crossword-grid-wrap {
  max-width: min(80vw, 100%);
  max-height: 80vh;
  overflow: auto;
}

.crossword-board-stack:fullscreen .play-crossword-grid {
  --cell-size: clamp(
    26px,
    min(
      calc((80vw - 72px) / var(--crossword-width)),
      calc((80vh - 220px) / var(--crossword-height))
    ),
    72px
  );
}

.crossword-board-stack:fullscreen .play-cell input {
  padding-top: calc(var(--cell-size) * 0.26);
  font-size: calc(var(--cell-size) * 0.44);
}

.crossword-board-stack:fullscreen .play-cell-number {
  top: calc(var(--cell-size) * 0.08);
  left: calc(var(--cell-size) * 0.1);
  min-width: calc(var(--cell-size) * 0.34);
  min-height: calc(var(--cell-size) * 0.34);
  font-size: calc(var(--cell-size) * 0.21);
}

.crossword-topbar {
  order: 2;
  width: fit-content;
  max-width: min(100%, 58rem);
  margin: 22px auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.crossword-topbar h1 {
  font-size: clamp(2.2rem, 7vw, 4.9rem);
}

.crossword-topbar p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
}

.crossword-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.crossword-meta span {
  padding: 8px 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.crossword-layout {
  display: contents;
}

.crossword-board-panel,
.crossword-controls-panel,
.crossword-clues {
  background: var(--crossword-panel);
  border: 1px solid var(--crossword-panel-line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crossword-board-stack {
  order: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.crossword-board-panel {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

.crossword-controls-panel {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 20px;
}

.crossword-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

.crossword-toolbar button,
.crossword-frame-button,
.crossword-clues button {
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.crossword-toolbar button {
  min-height: 40px;
  padding: 8px 11px;
  color: var(--white);
  background: var(--ink);
  border: 1px solid var(--ink);
  font-weight: 800;
}

.crossword-toolbar button:nth-child(2) {
  color: var(--ink);
  background: var(--gold);
  border-color: #b78c17;
}

.crossword-toolbar button:nth-child(3),
.crossword-toolbar button:nth-child(4) {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.crossword-toolbar button:hover,
.crossword-toolbar button:focus-visible,
.crossword-frame-button:hover,
.crossword-frame-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.crossword-status {
  min-height: 30px;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.crossword-status[data-type="success"] {
  color: var(--leaf-dark);
}

.crossword-status[data-type="error"] {
  color: var(--critical);
}

.crossword-grid-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  padding: 0;
  position: relative;
}

.crossword-frame-button {
  min-height: 40px;
  padding: 8px 11px;
  color: var(--white);
  background: var(--blue);
  border: 1px solid var(--blue);
  font-weight: 800;
}

.crossword-frame-button:hover,
.crossword-frame-button:focus-visible {
  background: #2953d6;
  border-color: #2953d6;
}

.play-cell {
  width: var(--cell-size);
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  background: var(--crossword-cell);
}

.play-cell.block {
  background: var(--crossword-grid-bg);
}

.play-cell input {
  width: 100%;
  height: 100%;
  padding: 8px 1px 1px;
  color: var(--crossword-ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: none;
  text-align: center;
  text-transform: uppercase;
  font: 800 calc(var(--cell-size) * 0.42) Arial, Helvetica, sans-serif;
}

.play-cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  z-index: 1;
  min-width: 14px;
  min-height: 14px;
  display: grid;
  place-items: center;
  color: var(--crossword-muted);
  background: var(--crossword-cell-number);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.5rem;
  font-weight: 850;
  line-height: 1;
}

.play-cell-number:hover,
.play-cell-number:focus-visible {
  color: var(--white);
  background: var(--blue);
  outline: none;
}

.play-cell.active {
  background: var(--crossword-active);
}

.play-cell.selected {
  box-shadow: inset 0 0 0 3px var(--crossword-selected);
}

.play-cell.correct {
  background: var(--crossword-correct);
}

.play-cell.wrong {
  background: var(--crossword-wrong);
}

.crossword-clue-popup {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 8;
  padding: 11px 12px;
  color: var(--white);
  background: var(--ink);
  border: 1px solid var(--popup-line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(23, 33, 33, 0.26);
  font-weight: 800;
}

.crossword-clue-popup[hidden] {
  display: none;
}

.crossword-clues {
  order: 3;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(18rem, 28rem));
  justify-content: center;
  gap: 18px;
}

.crossword-clues ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.crossword-clues button {
  width: 100%;
  padding: 10px;
  color: var(--crossword-ink);
  background: var(--crossword-cell);
  border: 1px solid var(--crossword-panel-line);
  text-align: left;
  line-height: 1.35;
}

.crossword-clues button span {
  color: var(--crossword-muted);
  font-weight: 800;
}

.crossword-clues button:hover,
.crossword-clues button:focus-visible,
.crossword-clues button.active {
  border-color: var(--crossword-selected);
  background: var(--crossword-active);
  outline: none;
}

.crossword-stats {
  order: 4;
  width: min(100%, 58rem);
  margin-top: 22px;
  margin-left: auto;
  margin-right: auto;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crossword-stats h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.crossword-seo {
  order: 5;
  width: min(100%, 58rem);
  margin-top: 22px;
  margin-left: auto;
  margin-right: auto;
  padding: 22px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crossword-seo[hidden] {
  display: none;
}

.crossword-seo h2 {
  margin-bottom: 12px;
}

.crossword-seo-intro,
.crossword-seo-body p {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.02rem;
}

.crossword-seo-intro {
  margin: 0 0 12px;
}

.crossword-seo-body {
  display: grid;
  gap: 12px;
}

.crossword-seo-body p {
  margin: 0;
}

.crossword-related-links {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.crossword-related-label {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.crossword-related-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.crossword-related-link-list a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.crossword-related-link-list a:hover,
.crossword-related-link-list a:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  transform: translateY(-1px);
}

.crossword-layout {
    grid-template-columns: 1fr;
  }

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

.crossword-meta {
    justify-content: flex-start;
  }

.crossword-clues {
    width: min(100%, 28rem);
    grid-template-columns: 1fr;
  }

.crossword-app {
    display: flex;
    flex-direction: column;
    padding-top: 8px;
  }

.crossword-board-stack:fullscreen {
    padding: 12px;
    justify-content: flex-start;
  }

.crossword-layout {
    display: contents;
  }

.crossword-board-panel {
    padding: 8px;
  }

.crossword-board-stack {
    order: 1;
    gap: 10px;
  }

.crossword-controls-panel {
    padding: 12px;
  }

.crossword-toolbar {
    margin: 0;
  }

.crossword-status {
    margin: 8px 0 0;
  }

.crossword-topbar {
    order: 2;
    width: 100%;
    max-width: none;
    margin: 18px 0 16px;
  }

.crossword-topbar h1 {
    font-size: clamp(1.9rem, 14vw, 3.2rem);
  }

.crossword-clues {
    order: 3;
  }

.crossword-stats {
    order: 4;
  }