.game-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.crossword-card {
  background: #e6f2e9;
}

.cw-mini-board {
  display: grid;
  grid-template: repeat(3, 26px) / repeat(3, 26px);
  gap: 3px;
  margin-inline: 10px;
  transform: rotate(-7deg);
}

.cw-mini-board span {
  display: grid;
  place-items: center;
  border: 1px solid #a8c6b6;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 2px 0 #bfd9c9;
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
}

.cw-mini-board span:nth-child(1) { grid-area: 1 / 2; }
.cw-mini-board span:nth-child(2) { grid-area: 2 / 1; }
.cw-mini-board span:nth-child(3) { grid-area: 2 / 2; background: #ffebba; }
.cw-mini-board span:nth-child(4) { grid-area: 2 / 3; }
.cw-mini-board span:nth-child(5) { grid-area: 3 / 2; }

.cw-shell {
  max-width: 1000px;
  margin: 0 auto;
}

.cw-menu {
  max-width: 800px;
  margin: 0 auto;
}

.cw-menu h1,
.cw-heading h1 {
  font-size: clamp(29px, 5vw, 44px);
  line-height: 1.1;
}

.cw-menu > p {
  margin-top: 9px;
  color: var(--muted);
}

.cw-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.cw-option {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 13px;
  border: 1px solid #cbded1;
  border-radius: 15px;
  background: #eef6ee;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
}

.cw-option:hover {
  border-color: #b28e47;
  background: #fff1d5;
}

.cw-option-number {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 10px;
  background: #fffdf5;
  color: var(--green);
}

.cw-option small {
  display: block;
  margin-top: 3px;
  color: var(--green);
  font-size: 13px;
}

.cw-option .icon {
  width: 20px;
  height: 20px;
}

.cw-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 16px;
  margin-bottom: 20px;
}

.cw-heading > p {
  color: var(--muted);
  font-size: 14px;
}

.cw-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  align-items: start;
  gap: 25px;
}

.cw-current {
  padding: 12px 15px;
  border: 1px solid #d4e5d8;
  border-radius: 14px;
  background: #edf6ee;
}

#cw-current-number {
  margin-bottom: 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

#cw-current-clue {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.28;
}

.cw-board {
  display: grid;
  grid-template-columns: repeat(var(--cw-width), minmax(0, 1fr));
  grid-template-rows: repeat(var(--cw-height), minmax(0, 1fr));
  gap: 3px;
  width: min(100%, calc(var(--cw-width) * 41px));
  aspect-ratio: var(--cw-width) / var(--cw-height);
  margin: 18px auto;
}

.cw-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 4px 0 0;
  border: 1px solid #a9bfb2;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 900 clamp(16px, 4.5vw, 23px) / 1 var(--font);
  cursor: text;
}

.cw-cell.cw-in-word {
  border-color: #7dab91;
  background: #e4f1e7;
}

.cw-cell[data-check="correct"] {
  border-color: #579873;
  background: #dbf0df;
}

.cw-cell[data-check="wrong"] {
  border-color: #b84a3c;
  background: #ffe7e1;
  color: #9c3129;
}

.cw-cell[data-check="wrong"]::after {
  content: '×';
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.cw-cell.cw-selected {
  border-color: var(--green);
  outline: 2px solid var(--green);
  z-index: 1;
}

.cw-cell.cw-selected:not([data-check]) {
  background: #ffe8ac;
}

.cw-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.cw-input {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  outline-offset: -2px;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  scroll-margin-block: 12px;
  cursor: text;
}

.cw-input::selection {
  background: transparent;
  color: transparent;
}

.cw-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.cw-controls .button {
  min-height: 44px;
  padding-inline: 17px;
  font-size: 15px;
}

.cw-controls [hidden] {
  display: none;
}

.cw-feedback {
  margin-top: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 15px;
  font-weight: 800;
}

.cw-feedback:empty {
  margin: 0;
}

.cw-feedback[data-state="wrong"] { color: #9c3129; }
.cw-feedback[data-state="correct"] { color: var(--green); }

.cw-clues h2 {
  font-size: 18px;
}

.cw-clues ol {
  display: grid;
  gap: 6px;
  margin: 7px 0 14px;
  padding: 0;
  list-style: none;
}

.cw-clues ol:last-child {
  margin-bottom: 0;
}

.cw-clue {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f4f7f1;
  color: var(--ink);
  text-align: left;
  font: 750 15px / 1.3 var(--font);
}

.cw-clue:hover,
.cw-clue[aria-pressed="true"] {
  border-color: #92b9a2;
  background: #e4f1e7;
}

.cw-clue-number {
  display: grid;
  place-items: center;
  min-height: 24px;
  border-radius: 7px;
  background: var(--paper);
  color: var(--green);
  font-weight: 900;
}

@media (max-width: 780px) {
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .cw-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .game-grid { grid-template-columns: 1fr; }
  .cw-game { padding-inline: 12px; }
  .cw-picker { grid-template-columns: minmax(0, 1fr); }
}
