:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --text: #1d1b19;
  --muted: #6b6560;
  --border: #d9d4cc;
  --accent: #6d4aff;
  --accent-text: #ffffff;
  --line: #ffb020;
  --line-text: #1d1b19;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --surface: #222129;
    --text: #ecebf0;
    --muted: #9c99a6;
    --border: #3a3843;
    --accent: #8b6dff;
    --line: #ffbf47;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

header { text-align: center; margin-bottom: 12px; }
h1 { margin: 0; font-size: 2rem; letter-spacing: 0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); }

.board {
  --size: 5;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 6px;
  width: 100%;
  aspect-ratio: 1;
  max-height: 80vh;
  margin: 0 auto;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  overflow-wrap: anywhere;
  hyphens: auto;
  transition: background 120ms, transform 80ms;
  -webkit-tap-highlight-color: transparent;
}
.cell:active { transform: scale(0.96); }
.cell span { display: block; max-height: 100%; }
.cell.len-s { font-size: clamp(0.7rem, 2.6vw, 1.05rem); }
.cell.len-m { font-size: clamp(0.62rem, 2.1vw, 0.92rem); }
.cell.len-l { font-size: clamp(0.55rem, 1.7vw, 0.8rem); }
.cell.len-xl { font-size: clamp(0.5rem, 1.4vw, 0.7rem); }
.cell.marked { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.cell.in-line { background: var(--line); color: var(--line-text); }
.cell.free { cursor: default; font-size: clamp(0.8rem, 2.6vw, 1.1rem); letter-spacing: 0.08em; }
.cell:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; }

.status {
  min-height: 1.6em;
  margin: 10px 0;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--line);
}
.status.pop { animation: pop 500ms ease-out; }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

.banner, .message {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: center;
}
.banner { background: var(--accent); color: var(--accent-text); border: none; }
.message { background: var(--surface); border: 1px solid var(--line); }
footer { text-align: center; margin-top: 8px; }
.debug-code { font-size: 0.75rem; color: var(--muted); opacity: 0.6; user-select: all; }

button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
