:root {
  --paper: #e8f3ef;
  --ink: #14241f;
  --muted: #4d635b;
  --line: #b7cdc4;
  --tile: #f7fbf9;
  --correct: #0f6e6b;
  --present: #c8962e;
  --absent: #5c564c;
  --lost: #a33b32;
  --key: #d7ebe3;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.screen {
  max-width: 520px; margin: 0 auto; padding: 8px 10px 12px;
  min-height: 100%; display: flex; flex-direction: column; gap: 8px;
}
.center { justify-content: center; }
.top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.mark {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 700; font-size: 26px; letter-spacing: 0.01em; margin: 0; line-height: 1;
}
.mark span { color: var(--correct); }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tools button, .back {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 10px; font-size: 12px; font-weight: 700; min-height: 36px;
}
.tools button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.primary, .tools button.primary {
  background: var(--ink); color: var(--paper); border: 0; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; min-height: 40px;
}
.screen > .primary { align-self: center; }
.legal {
  margin: 0; font-size: 11px; line-height: 1.35;
  background: #f3faf7; border-left: 3px solid var(--correct); padding: 5px 8px;
}
.stats { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 12px; }
.stats b { color: var(--ink); }
.msg { min-height: 1.3em; margin: 0; text-align: center; font-size: 14px; }
.msg.bad { color: var(--lost); font-weight: 700; }
.msg.good { color: var(--correct); font-weight: 700; }
.place { margin: 0; text-align: center; font-size: 13px; font-weight: 700; }
.grid3 {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  width: min(100%, 300px); margin: 0 auto;
}
.cell {
  aspect-ratio: 1; border-radius: 14px; border: 2px solid var(--line); background: var(--tile);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 4px; min-width: 0; touch-action: manipulation;
}
.cell.open { color: var(--muted); }
.cell.active { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.grid3.lock .cell.open:not(.active) { opacity: 0.55; }
.cell.claimed { background: var(--correct); border-color: var(--correct); color: #fff; }
.cell.lost { background: #f8ebe8; border-color: #e3b2ac; color: var(--lost); }
.cell.hot { outline: 3px solid var(--ink); outline-offset: 2px; }
.ratio { font-size: 14px; font-weight: 800; color: var(--ink); }
.word {
  font-family: Georgia, Palatino, serif; font-weight: 700; letter-spacing: 0.08em;
  font-size: 12px; text-transform: uppercase;
}
.disc { width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.cross { width: 26px; height: 26px; position: relative; }
.cross::before, .cross::after {
  content: ""; position: absolute; left: 11px; top: 0; width: 3px; height: 26px; background: var(--lost); border-radius: 2px;
}
.cross::before { transform: rotate(45deg); }
.cross::after { transform: rotate(-45deg); }
.tiles { width: min(100%, 250px); margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tile {
  aspect-ratio: 1; border-radius: 8px; border: 2px solid var(--line); background: var(--tile);
  display: grid; place-items: center; font-family: Georgia, Palatino, serif;
  font-size: clamp(16px, 5vw, 24px); font-weight: 700; text-transform: uppercase;
  user-select: none;
}
.tile.filled { border-color: #7f978e; animation: pop .12s ease; }
.tile.correct { background: var(--correct); color: #fff; border-color: var(--correct); }
.tile.present { background: var(--present); color: var(--ink); border-color: var(--present); }
.tile.absent { background: var(--absent); color: #f4fbf8; border-color: var(--absent); }
#app.cb .tile.correct, #app.cb .key.correct { box-shadow: inset 0 0 0 3px #fff; }
#app.cb .tile.present, #app.cb .key.present {
  background: repeating-linear-gradient(180deg, #c8962e, #c8962e 5px, #8a6414 5px, #8a6414 10px);
  color: var(--ink); border-color: #8a6414;
}
#app.cb .tile.absent, #app.cb .key.absent {
  background-color: #3f3b36;
  color: #f4fbf8;
  background-image: linear-gradient(to top right, transparent calc(50% - 1px), #f4fbf8 calc(50% - 1px), #f4fbf8 calc(50% + 1px), transparent calc(50% + 1px));
}
.row.shake { animation: shake .35s linear; }
@keyframes pop { 50% { transform: scale(1.06); } }
@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.legend, .note { margin: 0; font-size: 11px; line-height: 1.35; color: var(--muted); text-align: center; }
.back { align-self: center; }
.keys { display: flex; flex-direction: column; gap: 5px; margin-top: auto; width: 100%; }
.krow { display: flex; gap: 3px; justify-content: center; }
.key {
  flex: 1; min-width: 0; height: 42px; border: 0; border-radius: 7px; background: var(--key);
  font-weight: 700; text-transform: uppercase; font-size: 13px; padding: 0; touch-action: manipulation;
}
.key.wide { flex: 1.45; font-size: 11px; text-transform: none; }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: var(--ink); }
.key.absent { background: var(--absent); color: #f4fbf8; }
.actions { display: flex; justify-content: center; }
@media (max-width: 420px) {
  .top { flex-direction: column; align-items: stretch; }
  .tools { justify-content: flex-start; }
  .mark { font-size: 22px; }
  .screen { padding: 8px; gap: 6px; }
  .grid3 { width: min(100%, 280px); }
  .word { font-size: 11px; letter-spacing: 0.04em; }
}
@media (max-height: 620px) {
  .screen { gap: 4px; }
  .key { height: 38px; }
  .legal { padding: 3px 8px; }
  .tiles { width: min(100%, 228px); }
}
@media (min-height: 700px) {
  .grid3 { width: min(100%, 400px); }
  .tiles { width: min(100%, 300px); }
  .key { height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile.filled, .row.shake { animation: none; }
}
