:root {
  --panel: #ffffff;
  --text: #111111;
  --muted: #666666;
  --tile-empty: #d9d9d9;
  --tile-white: #ffffff;
  --tile-filled: #6aaa64;
  --tile-text: #ffffff;
  --tile-white-text: #111111;
  --tile-border: #111111;
  --tile-shadow: rgba(0, 0, 0, 0.08);
  --key: #d1d1d1;
  --key-yellow: #c9b458;
  --key-text: #111111;
  --key-shadow: rgba(0, 0, 0, 0.12);
  --tile-max: 58px;
  --tile-gap: 10px;
  --tile-min: 18px;
  --unavailable: #8a8a8a;
  --unavailable-text: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  background: var(--bg);
}

.app {
  width: min(1000px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.hero { display: grid; gap: 12px; margin-bottom: 24px; }

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4.5rem); line-height: 0.95; letter-spacing: -0.05em; }

.subtitle { max-width: 62ch; margin: 0; font-size: 1rem; line-height: 1.6; color: var(--muted); }

.layout { display: grid; grid-template-columns: 1fr; gap: 18px; }

.capture-area { display: grid; gap: 18px; }

.panel { background: var(--panel); border: 1px solid #111111; border-radius: 0; box-shadow: none; backdrop-filter: none; padding: 18px; }

.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-bottom: 18px; }

.control { display: grid; gap: 8px; }
.control label { font-size: 0.82rem; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.control input[type="number"] { width: 110px; padding: 12px 14px; border: 1px solid #111111; border-radius: 0; font: inherit; background: white; color: var(--text); }

.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-left: auto; width: min(100%, 780px); }
.mode-toggle { background: #f0f0f0; color: var(--text); border: 1px solid #111111; border-radius: 0; box-shadow: none; }
.mode-toggle.is-testing { background: #111111; color: #ffffff; }
button { font: inherit; }
.action-button { border: 0; border-radius: 0; padding: 12px 16px; background: #f0f0f0; color: var(--text); cursor: pointer; box-shadow: none; width: 100%; white-space: nowrap; }
.action-button.secondary { background: #f0f0f0; color: var(--text); }
.action-button.is-busy { background: #111111; color: #ffffff; cursor: progress; }

.board-wrap { display: grid; gap: 16px; justify-items: center; padding: 14px 6px 6px; }
.board { display: flex; flex-wrap: wrap; gap: var(--tile-gap); width: 100%; justify-content: center; max-width: 100%; margin: 0 auto; }

.tile { aspect-ratio: 1; border: 2px solid var(--tile-border); border-radius: 0; background: var(--tile-empty); width: 100%; max-width: var(--tile-max); display: grid; place-items: center; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tile-text); box-shadow: 0 8px 18px var(--tile-shadow); transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; flex: 0 1 clamp(var(--tile-min), calc((100% - ((var(--word-length) - 1) * var(--tile-gap))) / var(--word-length)), var(--tile-max)); }
.tile.is-green { background: var(--tile-filled); color: var(--tile-text); }
.tile.is-white { background: var(--tile-white); color: var(--tile-white-text); }
.tile.is-green input { color: var(--tile-text); }
.tile.is-white input { color: var(--tile-white-text); }

.tile input { width: 100%; height: 100%; border: 0; outline: 0; text-align: center; background: transparent; display: block; margin: 0; line-height: 1; font: inherit; color: inherit; -webkit-appearance: none; appearance: none; text-transform: uppercase; caret-color: #111111; padding: 0; box-sizing: border-box; }
.tile:focus-within { transform: translateY(-1px); border-color: #111111; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18); }
.board-empty .tile input::placeholder { color: #777777; opacity: 1; }

.summary { display: grid; gap: 8px; width: min(760px, 100%); color: var(--muted); font-size: 0.95rem; }
.summary strong { color: var(--text); }

.keyboard { display: grid; gap: 8px; width: fit-content; max-width: 100%; margin-inline: auto; justify-items: center; }
.keyboard-row { display: grid; gap: 8px; justify-content: center; }

.key { border: 0; border-radius: 6px; min-height: 52px; padding: 0; background: var(--key); color: var(--key-text); font-weight: 700; letter-spacing: 0.02em; cursor: pointer; box-shadow: 0 10px 18px var(--key-shadow); transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease, opacity 0.14s ease; }
.key:hover { transform: translateY(-1px); }
.key.unavailable { background: var(--unavailable); color: var(--unavailable-text); box-shadow: none; }
.key.yellow { background: var(--key-yellow); color: #ffffff; box-shadow: none; }

.legend { margin: 0; font-size: 0.9rem; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .app { width: min(100vw - 20px, 1000px); padding-top: 20px; }
  .panel { padding: 14px; border-radius: 0; }
  .controls { align-items: stretch; }
  .actions { margin-left: 0; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-button { white-space: normal; }
  .board { gap: 8px; grid-template-columns: repeat(var(--word-length), minmax(34px, 1fr)); }
  .keyboard-row { gap: 6px; }
  .key { min-height: 46px; }
}
