:root {
  --bg: #f4f1ea; --surface: #fff; --ink: #1a1a1a; --muted: #6b6b6b;
  --line: #e2dccf; --accent: #2f6df6; --seam: #d98a00; --good: #2e8b57; --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#111318; --surface:#1b1e24; --ink:#eef1f6; --muted:#9aa1ac; --line:#2a2e36;
          --accent:#6f9bff; --seam:#e6b24a; --good:#5cc98a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
.app {
  max-width: 480px; margin: 0 auto; min-height: 100svh;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.header { text-align: center; }
.logo { font-size: clamp(28px, 8vw, 40px); font-weight: 800; letter-spacing: -.02em; margin: 0; }
.logo .q { color: var(--accent); }
.clue { color: var(--muted); margin: 8px 0 0; font-size: .98rem; }
.clue b { color: var(--ink); }

/* Fused word on its "sheet" */
.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 16px; box-shadow: 0 1px 0 var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.fused { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.tile {
  width: clamp(26px, 8.5vw, 38px); height: clamp(34px, 11vw, 48px);
  display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(1.1rem, 5.2vw, 1.55rem); font-weight: 700; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
  transition: background .25s, color .25s, border-color .25s;
}
.tile.seam { border-color: var(--seam); color: var(--seam); background: rgba(217,138,0,.12); }
.tile.p1 { color: var(--accent); }
.tile.p2 { color: var(--good); }
.seaminfo { margin: 0; color: var(--seam); font-size: .88rem; font-weight: 600; }

/* Entry */
.entry { display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.entry-row { display: flex; flex-direction: column; gap: 5px; }
.entry-tag { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.wordinput {
  width: 100%; padding: 12px 14px; font-size: 1.1rem; letter-spacing: .06em;
  font-family: ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink); text-transform: lowercase;
}
.wordinput:focus { outline: 2px solid var(--accent); border-color: transparent; }
.wordinput.bad { animation: shake .3s; border-color: var(--accent); }
.wordinput:disabled { opacity: .7; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

.btnrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.submit {
  padding: 12px 18px; font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap;
  background: var(--accent); border: none; border-radius: 10px; cursor: pointer;
}
.submit:disabled { opacity: .4; cursor: not-allowed; }
.linkbtn { background: none; border: none; color: var(--muted);
  font-size: .85rem; text-decoration: underline; cursor: pointer; padding: 0; }
.linkbtn:disabled { opacity: .5; cursor: default; text-decoration: none; }

.note { margin: 0; text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.2em; }

.result { display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.split-line { margin: 0; font-size: 1.2rem; font-weight: 700; text-align: center; }
.split-line .s1 { color: var(--accent); }
.split-line .s2 { color: var(--good); }
.split-line .seamtext { color: var(--seam); }
.score-line { margin: 0; font-size: 1.1rem; }
.wobble { margin: 0; text-align: center; color: var(--muted); font-size: .95rem; font-style: italic; }
.copied { color: var(--accent); font-size: .85rem; margin: 0; }
.foot { margin-top: auto; text-align: center; color: var(--muted); font-size: .78rem; }
