body[data-crossword-desk] {
  --cw-ink: #211d1a;
  --cw-pine: #59663b;
  --cw-rust: #a83923;
  --cw-paper: #f8efdf;
  --cw-texture: url("/assets/riddle-desk-paper.webp");
  background: linear-gradient(#fffaf046,#fffaf046), var(--cw-texture) center top / 704px auto repeat, var(--cw-paper);
}
[data-crossword-desk] .game-shell { background: transparent; padding-top: clamp(12px, 3vw, 44px); }
[data-crossword-desk] .game-layout { display: block; }
[data-crossword-desk] .game-panel {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(0, 2.35fr);
  grid-template-areas: "title tools" "title board" "title status" "title tools-after";
  align-items: start;
  overflow: visible;
  padding: clamp(10px, 2vw, 28px);
  color: var(--cw-ink);
  background: transparent;
  border: 0;
  box-shadow: none;
}
[data-crossword-desk] .game-panel::before { display: none; }
.crossword-heading {
  grid-area: title;
  position: relative;
  align-self: stretch;
  container-type: inline-size;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(14px, 2.3vw, 38px) 0 0;
}
.crossword-heading h1 {
  font: 700 clamp(2.55rem, 18.1cqw, 5.1rem)/.98 var(--font-editorial);
  overflow-wrap: anywhere;
  letter-spacing: -.05em;
  margin: 0;
  color: #171e24;
}
.crossword-heading h1::after,
.crossword-clue-nav h2::after {
  content: "";
  display: block;
  width: 70%;
  height: 7px;
  margin: .2em 0 0;
  background: #bc3d29;
  clip-path: polygon(0 74%, 15% 32%, 31% 14%, 52% 0, 76% 14%, 100% 73%, 91% 63%, 65% 52%, 34% 66%, 12% 100%);
}
.crossword-heading picture { align-self: center; }
.crossword-heading img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 16px;
  max-width: 350px;
}
.crossword-settings,
.crossword-paper,
.crossword-play-controls {
  background: var(--cw-texture) center / 720px auto, var(--cw-paper);
  border: 1px solid #beab85;
  border-radius: 16px 10px 18px 8px / 8px 18px 11px 17px;
  box-shadow: 3px 5px 0 #b5996952, 0 6px 16px #6d48251e;
}
.crossword-settings {
  grid-area: tools;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 12px;
}
.crossword-settings .tool-btn,
.crossword-clue-nav .tool-btn,
.crossword-keyboard button,
.crossword-actions .btn-secondary {
  min-height: 44px;
  color: var(--cw-ink);
  background: #fff8ebc9;
  border: 1px solid #76674d;
  border-radius: 7px;
  box-shadow: 0 2px 0 #6f5b382e;
}
.crossword-settings .tool-btn {
  width: auto;
  gap: .4em;
  padding: 7px 10px;
  text-wrap: nowrap;
}
.crossword-settings svg { width: 19px; height: 19px; }
.crossword-settings .tool-btn[aria-pressed="true"] { background: #e5e7bc; }
[data-crossword-desk] .game-board-wrap {
  grid-area: board;
  min-width: 0;
  padding: 10px 0 0;
  margin: 0;
  background: transparent;
  overflow: visible;
}
.crossword-desk { width: 100%; min-width: 0; }
.crossword-paper {
  display: grid;
  grid-template-columns: minmax(0,1.35fr) minmax(0,1fr);
  gap: clamp(10px, 2vw, 21px);
  align-items: start;
  padding: clamp(10px, 2vw, 24px);
}
.crossword-viewport {
  min-width: 0;
  overflow: auto;
  max-height: min(62vh, 520px);
  padding: 2px;
  scrollbar-color: #93855e #efe0bf;
}
.crossword-grid {
  width: min(100%, calc(28px * var(--cw-cols)));
  min-width: var(--cw-min-width);
  margin-inline: auto;
  border: 0;
  background: transparent;
  gap: 0;
}
.crossword-grid .cw-cell {
  min-width: 0;
  min-height: 0;
  background: #fff9eb;
  box-shadow: inset 0 0 0 .6px #3d382e;
}
.crossword-grid .cw-blank { background: transparent; box-shadow: none; }
.crossword-grid .cw-block { background: #332c26; }
.crossword-grid .is-solved { background: #e3e9bd; }
.crossword-grid .is-active { background: #f1e4ad; }
.crossword-grid .is-selected { background: #dcc068; box-shadow: inset 0 0 0 2px #63562d; }
.crossword-grid .is-incorrect { background: #f5b7a2; }
.crossword-grid .cw-number { top: 1px; left: 2px; color: #42362d; font: 700 9px/1 var(--font-ui); }
.crossword-grid input {
  position: absolute;
  inset: 0;
  min-width: 0;
  padding: 4px 0 0;
  color: #241c14;
  font: 700 clamp(.76rem, 1.5vw, 1.22rem)/1 var(--font-ui);
  border-radius: 0;
  cursor: text;
}
.crossword-grid input:focus { outline: 0; }
.crossword-grid .is-solved input { animation: crossword-ink .22s ease-out; }
@keyframes crossword-ink { from { opacity: .45; transform: scale(.8); } to { opacity: 1; transform: none; } }
.crossword-clue-paper {
  padding: 10px 12px;
  color: var(--cw-ink);
  background: #fff6e4d9;
  border: 1px solid #b9a781;
  border-radius: 12px 6px 13px 5px;
  box-shadow: 2px 3px 0 #b5996942;
}
.crossword-clue-nav {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) 42px;
  gap: 6px;
  align-items: center;
  text-align: center;
}
.crossword-clue-nav h2 {
  color: var(--cw-ink);
  margin: 0;
  font: italic 700 clamp(1.1rem, 2vw, 1.75rem)/1.1 var(--font-editorial);
}
.crossword-clue-nav h2::after { margin-inline: auto; height: 4px; }
.crossword-clue-nav .tool-btn { padding: 0; justify-content: center; font-size: 1.4rem; }
.crossword-current-clue {
  min-height: 2em;
  margin: 8px 0;
  text-align: center;
  font: 600 clamp(1.08rem, 1.9vw, 1.55rem)/1.2 var(--font-editorial);
}
.crossword-clue-preview { display: none; }
@media (min-width: 621px) {
  .crossword-clue-preview { display: grid; margin: 0 0 4px; }
  .crossword-clue-preview button {
    background: transparent;
    border: 0;
    border-top: 1px solid #c9b89b;
    color: var(--cw-ink);
    padding: 6px 0;
    text-align: left;
    min-height: 40px;
    line-height: 1.3;
    cursor: pointer;
  }
  .crossword-clue-preview button:hover { color: var(--cw-rust); }
}
.crossword-clue-index summary { cursor: pointer; padding: 8px 0; }
.crossword-clue-index .crossword-clues { grid-template-columns: 1fr; gap: 12px; max-height: 17rem; overflow-y: auto; }
.crossword-clue-index .cw-clue { min-height: 44px; font-size: .9rem; line-height: 1.3; }
.crossword-clue-index .cw-clue.is-active { background: #ead88f; }
.crossword-clue-index .cw-clue.is-solved { color: #435421; }
.crossword-play-controls {
  display: flex;
  gap: 12px;
  padding: 12px;
  align-items: stretch;
  margin-top: 10px;
}
.crossword-keyboard { flex: 1; display: grid; gap: 6px; min-width: 0; }
.crossword-keyboard > div { display: flex; justify-content: center; gap: clamp(2px,.5vw,7px); }
.crossword-keyboard button {
  flex: 0 1 10%;
  min-width: 0;
  padding: 0 2px;
  font: 700 1rem/1 var(--font-ui);
  cursor: pointer;
}
.crossword-keyboard button:active,
.crossword-actions button:active { transform: translateY(1px); box-shadow: none; }
[data-crossword-actions]:empty { display: none; }
.crossword-actions { display: flex; flex-direction: column; gap: 7px; justify-content: center; }
.crossword-actions .btn { min-height: 44px; padding-inline: 11px; }
.crossword-actions .btn-primary { background: var(--cw-rust); border-color: #8f2d1b; color: white; font: 700 1.2rem/1 var(--font-editorial); }
[data-crossword-desk] .game-status-line { grid-area: status; border: 0; background: transparent; color: var(--cw-ink); padding: 10px 2px; }
.crossword-after {
  grid-area: tools-after;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.crossword-after .tool-btn { width: auto; }
[data-crossword-desk] .game-aside { margin-top: 16px; }
.crossword-keyboard button:focus-visible,
.crossword-settings button:focus-visible,
.crossword-clue-paper :is(button, summary):focus-visible { outline: 2px solid #42331d; outline-offset: 2px; }
@media (max-width: 900px) {
  [data-crossword-desk] .game-panel {
    grid-template-columns: minmax(0,1fr);
    grid-template-areas: "title" "tools" "board" "status" "tools-after";
  }
  .crossword-heading { padding: 0 28% 14px 0; }
  .crossword-heading img { position: absolute; top: -8px; right: 0; width: min(25%,112px); margin: 0; }
  .crossword-heading h1 { font-size: clamp(2rem,7vw,4rem); }
  .crossword-heading h1::after { width: 55%; background: var(--cw-pine); }
}
@media (max-width: 620px) {
  [data-crossword-desk] #game > .container { width: calc(100% - 14px); }
  [data-crossword-desk] .game-panel { padding: 3px; }
  .crossword-paper { grid-template-columns: minmax(0,1fr); padding: 7px; }
  .crossword-viewport { max-height: min(43vh, 365px); }
  .crossword-grid { width: min(100%, calc(22px * var(--cw-cols))); }
  .crossword-settings .tool-btn { width: 100%; }
  .crossword-settings { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 7px; }
  .crossword-play-controls { flex-direction: column; padding: 8px; }
  .crossword-actions { flex-direction: row; }
  .crossword-actions .btn { flex: 1; }
  .crossword-current-clue { min-height: 0; }
  .crossword-grid input { font-size: clamp(.85rem,4vw,1.1rem); }
}
@media (min-width: 621px) and (max-width: 1200px) {
  [data-crossword-desk] .game-shell { padding-top: 12px; }
  [data-crossword-desk] .game-panel { padding: 10px; }
  .crossword-paper { padding: 12px; }
  .crossword-grid {
    width: min(100%,calc(clamp(28px,(100svh - 334px) / var(--cw-rows),34px) * var(--cw-cols)));
  }
  .crossword-viewport { max-height: clamp(240px,calc(100svh - 330px),460px); }
  .crossword-grid input { font-size: 1rem; }
  .crossword-clue-paper { max-height: clamp(240px,calc(100svh - 330px),460px); overflow-y: auto; }
  .crossword-clue-preview button { min-height: 44px; }
}
@media (min-width: 621px) and (max-width: 900px) {
  .crossword-heading { padding: 0 16% 8px 0; }
  .crossword-heading h1 { font-size: clamp(2rem,5.9vw,3rem); }
  .crossword-heading img { top: -2px; right: 0; width: 12%; }
  .crossword-settings { padding: 6px; }
}
@media (min-width: 901px) and (max-width: 1200px) {
  [data-crossword-desk] .game-panel {
    grid-template-columns: minmax(180px, .72fr) minmax(0,2.45fr);
    grid-template-areas: "title board" "tools board" "tools status" "tools tools-after";
    column-gap: 14px;
  }
  .crossword-heading { align-self: start; justify-content: start; padding: 0 0 12px; }
  .crossword-heading h1 { font-size: clamp(2.3rem,16cqw,3.25rem); }
  .crossword-settings { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 7px; }
  .crossword-settings .tool-btn { padding-inline: 5px; justify-content: center; white-space: normal; }
  [data-crossword-desk] .game-board-wrap { padding-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .crossword-grid input { animation: none !important; }
}
.force-reduced-motion .crossword-grid input { animation: none !important; }
