.kw { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 10px 10px; gap: 8px; }
.kw__area { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.kw__grid { --s: min((100cqw - 4px) / var(--w), (100cqh - 4px) / var(--h), 46px); display: grid;
  grid-template-columns: repeat(var(--w), var(--s)); grid-template-rows: repeat(var(--h), var(--s)); }
.kw__gap { display: block; }
.kw__cell { position: relative; display: grid; place-items: center; margin: -1px 0 0 -1px; background: #fffaf2; color: #3b2618;
  border: 2px solid var(--edge); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s; }
.kw__cell b { font-family: var(--display); font-weight: 600; font-size: calc(var(--s) * .56); line-height: 1; }
.kw__n { position: absolute; left: 2px; top: 1px; font-style: normal; font-weight: 800; font-size: max(8px, calc(var(--s) * .27)); line-height: 1; color: #8c735f; }
.kw__cell.sel { background: #ffe1c2; }
.kw__cell.cur { background: var(--orange); color: #fff; }
.kw__cell.cur .kw__n { color: #fff; }
.kw__cell.locked { background: #d9f6df; color: #1f4d2c; }
.kw__cell.locked.sel { background: #c6eecf; }
.kw__cell.shown { background: #fde3e0; color: #c03d3d; }
.kw__cell.pop { animation: kwPop .4s ease-out; }
.kw__cell.shake { animation: kwShake .4s; }
@keyframes kwPop { 50% { transform: scale(1.12); z-index: 2; } }
@keyframes kwShake { 25%, 75% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }

.kw__clue { flex: none; display: flex; align-items: stretch; gap: 6px; min-height: 58px; }
.kw__step { flex: none; width: 40px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font-family: var(--display); font-weight: 600; font-size: 26px; cursor: pointer; }
.kw__cluetext { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 12px;
  border-radius: 14px; background: var(--orange-soft); color: var(--ink); font-weight: 700; font-size: 16px; line-height: 1.25;
  white-space: pre-line; overflow-wrap: anywhere; }
.kw__cluetext small { font-size: 13px; color: var(--muted); }
.kw__cluetext b { font-family: var(--display); font-weight: 600; color: var(--orange-ink); }
.kw__cluetext em { font-style: normal; color: var(--muted); }

.kw__keys { flex: none; display: flex; flex-direction: column; gap: 6px; }
.kw__row { display: flex; justify-content: center; gap: 4px; }
.kw__key { flex: 1; max-width: 42px; height: 44px; padding: 0; border-radius: 10px; border: 2px solid var(--line); background: var(--card);
  color: var(--ink); box-shadow: 0 3px 0 var(--line); font-family: var(--display); font-weight: 600; font-size: 19px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.kw__key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); background: var(--orange-soft); }
.kw__back { flex: 1.6; max-width: 66px; }
.kw__done { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 800; font-size: 15px; padding: 6px 14px; border-radius: 12px; cursor: pointer; }
.kw__done.sure { color: var(--red-dark); background: var(--red-soft); }
.kw__done:disabled { visibility: hidden; }

@media (prefers-color-scheme: dark) {
  .kw__cell { border-color: #1d120a; }
  .kw__cluetext b { color: var(--orange); }
  .kw__done.sure { color: #ffb4b4; background: color-mix(in srgb, var(--red) 22%, transparent); }
}
.kw.calm .kw__cell { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .kw__cell { transition: none; }
  .kw__cell.pop, .kw__cell.shake { animation: none; }
}
