/* レイアウト：1画面。上に説明と間違い回数、中央に4×4、下にボタン。結果は同じ場所に差し替わる。試作 docs/prototype/tsunagari.html から。 */
:root {
  --bg: #f6f4ee; --surface: #ffffff; --fg: #17191d; --fg-2: #5b5f67; --fg-3: #8d919a;
  --tile: #ebe8df; --tile-on: #4a4d55; --tile-on-fg: #ffffff; --line: #dedbd1;
  --y: #f3d35a; --g: #9ccb5d; --b: #86b4e8; --p: #b98fe0; --on-color-fg: #17191d;
  --accent: #17191d; --accent-fg: #ffffff; --danger: #c43d3d;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #141518; --surface: #1d1f24; --fg: #f2f1ec; --fg-2: #b8bbc3; --fg-3: #7f838c; --tile: #2a2d34; --tile-on: #e6e4dc; --tile-on-fg: #17191d; --line: #30333b; --y: #d9b93e; --g: #86b84a; --b: #6b9edb; --p: #a67bd3; --accent: #f2f1ec; --accent-fg: #17191d; --danger: #e06666; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #141518; --surface: #1d1f24; --fg: #f2f1ec; --fg-2: #b8bbc3; --fg-3: #7f838c; --tile: #2a2d34; --tile-on: #e6e4dc; --tile-on-fg: #17191d; --line: #30333b; --y: #d9b93e; --g: #86b84a; --b: #6b9edb; --p: #a67bd3; --accent: #f2f1ec; --accent-fg: #17191d; --danger: #e06666; color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-weight: 500; -webkit-tap-highlight-color: transparent; }
.wrap { max-width: 520px; margin: 0 auto; padding-block: 18px 32px; padding-inline: 16px; display: grid; gap: 14px; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
h1 { font-size: 24px; font-weight: 900; margin: 0; letter-spacing: .04em; }
.meta { font-size: 13px; color: var(--fg-3); white-space: nowrap; }
.lead { text-wrap: balance; margin: 0; font-size: 14px; color: var(--fg-2); text-align: center; }
.board { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { aspect-ratio: 1 / .78; border: 0; border-radius: 8px; background: var(--tile); color: var(--fg); font: inherit; font-weight: 700; font-size: clamp(12px, 3.6vw, 17px); line-height: 1.2; padding: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; text-align: center; word-break: keep-all; overflow-wrap: anywhere; transition: transform .08s, background .12s; user-select: none; min-width: 0; }
.tile:active { transform: scale(.96); }
.tile[aria-pressed="true"] { background: var(--tile-on); color: var(--tile-on-fg); }
.tile.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.solved { border-radius: 8px; padding: 12px 10px; text-align: center; color: var(--on-color-fg); display: grid; gap: 2px; animation: pop .25s; }
@keyframes pop { from { transform: scale(.96); opacity: .6; } }
.solved .t { font-weight: 900; font-size: 15px; letter-spacing: .04em; }
.solved .w { font-size: 14px; }
.solved.y { background: var(--y); } .solved.g { background: var(--g); } .solved.b { background: var(--b); } .solved.p { background: var(--p); }
.mist { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 14px; color: var(--fg-2); min-height: 22px; }
.mist i { width: 11px; height: 11px; border-radius: 50%; background: var(--fg); display: inline-block; }
.mist i.off { background: var(--line); }
.btns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
button.b { font: inherit; font-weight: 700; font-size: 15px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--fg); background: transparent; color: var(--fg); cursor: pointer; min-width: 0; }
button.b.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.b:disabled { opacity: .35; cursor: default; }
button:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 14px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 5; white-space: nowrap; }
.toast.show { opacity: 1; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px; text-align: center; display: grid; gap: 10px; }
.result h2 { margin: 0; font-size: 20px; font-weight: 900; }
.grid { font-size: 22px; line-height: 1.15; letter-spacing: 2px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.result .s { font-size: 13px; color: var(--fg-2); }
details { font-size: 13px; color: var(--fg-2); }
summary { cursor: pointer; font-weight: 700; color: var(--fg); }
details p { margin: 6px 0 0; }
@media (prefers-reduced-motion: reduce) { .tile, .solved { animation: none; transition: none; } }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--fg-2); text-align: center; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
.stats div { display: grid; gap: 2px; }
.stats dt { font-size: 11px; color: var(--fg-3); }
.stats dd { margin: 0; font-size: 20px; font-weight: 900; }
.app { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.app p { margin: 0; font-size: 13px; color: var(--fg-2); }
a.b { font: inherit; font-weight: 700; font-size: 15px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--fg); color: var(--fg); text-decoration: none; }
footer { font-size: 12px; color: var(--fg-3); text-align: center; }
footer a { color: inherit; }
.tile.mid { font-size: clamp(10px, 3.1vw, 16px); }
.tile.long { font-size: clamp(11px, 3.2vw, 15px); }
@media (max-width: 360px) { button.b { padding: 9px 13px; font-size: 14px; } }
