/* Layout: 1カラムのゲーム盤。上に入力、下に推理履歴（新しい順）。表は横スクロール可 */
:root {
    --bg: #eef3f6;
    --panel: #ffffff;
    --panel-2: #f6f9fb;
    --line: #d3dee4;
    --fg: #17262c;
    --muted: #5b6f77;
    --accent: #e3b448;
    --accent-ink: #2a1f05;
    --icon-fg: #8a6412;
    --ok: #2f9e5f;
    --part: #e5901f;
    --ng: #d9534f;
    --cell-fg: #ffffff;
    --font-display: "Dela Gothic One", "Hiragino Kaku Gothic StdN", "Yu Gothic", sans-serif;
    --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
    --font-num: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
    color-scheme: light;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--fg); }
body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-block: 20px 40px;
}
.wrap { max-width: 1080px; margin: 0 auto; display: grid; gap: 20px; }
header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(28px, 6vw, 40px); margin: 0; letter-spacing: 0.04em; line-height: 1.1; }
h1 small { display: block; font-family: var(--font-body); font-size: 13px; color: var(--muted); letter-spacing: 0.08em; margin-top: 6px; font-weight: 500; }
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 4px; }
.tabs button { font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 8px 18px; border-radius: 999px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tabs button:focus-visible, .btn:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
details.howto summary { cursor: pointer; font-weight: 700; }
.howto-body { display: grid; gap: 10px; margin-top: 10px; color: var(--muted); }
.howto-body p { margin: 0; max-width: 65ch; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); font-size: 14px; }
.sw { width: 18px; height: 18px; border-radius: 4px; display: inline-block; }
.sw.ok { background: var(--ok); } .sw.part { background: var(--part); } .sw.ng { background: var(--ng); }

.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.status .info { color: var(--muted); }
.status .info b { color: var(--fg); font-family: var(--font-num); }
.btn { font: inherit; font-weight: 700; border-radius: 8px; padding: 9px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

.search { position: relative; }
.search input {
    width: 100%; font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--fg);
}
.search input::placeholder { color: var(--muted); }
.suggest {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 10; list-style: none; margin: 0; padding: 6px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow-y: auto;
    box-shadow: 0 12px 30px rgba(23,38,44,0.15);
}
.suggest li { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--line); }
.suggest .en { color: var(--muted); font-size: 12px; }

.icon {
    width: 44px; height: 44px; border-radius: 6px; flex: none; object-fit: cover; background: var(--line);
    display: inline-grid; place-items: center; font-family: var(--font-display); font-size: 18px; color: var(--icon-fg);
}
.suggest .icon { width: 36px; height: 36px; font-size: 15px; }

.board { overflow-x: auto; }
table { border-collapse: separate; border-spacing: 6px; min-width: 820px; width: 100%; }
th { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 0.08em; text-align: center; padding: 0 4px 2px; border-bottom: 2px solid var(--line); }
td { text-align: center; vertical-align: middle; height: 64px; border-radius: 6px; padding: 4px 6px; font-weight: 700; font-size: 13px; line-height: 1.35; }
td.champ { background: var(--panel-2); text-align: left; min-width: 160px; }
td.champ .c { display: flex; align-items: center; gap: 10px; }
td.ok { background: var(--ok); } td.part { background: var(--part); } td.ng { background: var(--ng); }
td.ok, td.part, td.ng { color: var(--cell-fg); text-shadow: 0 1px 1px rgba(0,0,0,0.18); }
td.year { font-family: var(--font-num); font-size: 15px; }
.arrow { display: block; font-size: 16px; line-height: 1; margin-top: 2px; }
tr.new td:not(.champ) { animation: flip 0.45s ease both; }
tr.new td:nth-child(3) { animation-delay: 0.08s; } tr.new td:nth-child(4) { animation-delay: 0.16s; }
tr.new td:nth-child(5) { animation-delay: 0.24s; } tr.new td:nth-child(6) { animation-delay: 0.32s; }
tr.new td:nth-child(7) { animation-delay: 0.40s; } tr.new td:nth-child(8) { animation-delay: 0.48s; }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
@media (prefers-reduced-motion: reduce) { tr.new td { animation: none !important; } }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }

.result { display: grid; gap: 12px; border-color: var(--accent); }
.result h2 { font-family: var(--font-display); font-weight: 400; margin: 0; font-size: 22px; }
.result .answer { display: flex; align-items: center; gap: 14px; }
.result .answer .icon { width: 64px; height: 64px; font-size: 26px; }
.result .answer b { font-size: 20px; }
.result p { margin: 0; color: var(--muted); }
.toast { color: var(--icon-fg); font-weight: 700; min-height: 1.6em; }

.ad-slot { border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; padding: 18px; font-size: 12px; }
footer { color: var(--muted); font-size: 12px; display: grid; gap: 6px; }
footer p { margin: 0; max-width: 90ch; }
