@charset "UTF-8";

/* =========================================================
   Number Place Life — シミュレーター スタイル
   配色は CSS 変数にまとめ、OS のダークモードにも追随する
   ========================================================= */

:root {
    --bg: #f5f6f8;
    --panel-bg: #ffffff;
    --board-bg: #ffffff;
    --text: #1d2129;
    --text-weak: #6b7280;
    --line: #c7cbd3;
    --line-strong: #3b4252;
    --accent: #2f6fd0;
    --accent-weak: #dceafd;
    --given: #1d2129;
    --entry: #2f6fd0;
    --wrong-bg: #fde2e2;
    --wrong-text: #c92a2a;
    --ruler-bg: #eef2f8;
    --review-bg: #fdf0d0;
    --same-bg: #d9e7fb;
    --select-bg: #bcd7fa;
    --ok: #2f9e44;
    --action-bg: #bf4904;
    --action-bg-hover: #a63d02;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 6px 20px rgba(0, 0, 0, .06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --panel-bg: #1c2027;
        --board-bg: #1a1e24;
        --text: #e6e8ec;
        --text-weak: #9aa2af;
        --line: #3a414c;
        --line-strong: #8b93a1;
        --accent: #6ea8fe;
        --accent-weak: #24344d;
        --given: #e6e8ec;
        --entry: #6ea8fe;
        --wrong-bg: #4a2226;
        --wrong-text: #ff8787;
        --ruler-bg: #232935;
    --review-bg: #45391c;
        --same-bg: #2b3a52;
        --select-bg: #35507a;
        --ok: #51cf66;
        --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 0 40px;
    background: var(--bg);
    color: var(--text);
    font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo,
                 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.7;
    -webkit-text-size-adjust: 100%;
}

.app-header {
    padding: 24px 16px 8px;
    text-align: center;
}

.app-header h1 {
    margin: 0;
    font-size: 1.6rem;
    letter-spacing: .02em;
}

.app-header .accent { color: var(--accent); }

/* 版の表示。Firebase 版（Pro）と区別するための小さなラベル */
.app-header .tier {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 10px;
    vertical-align: 4px;
    background: var(--accent-weak);
    border-radius: 999px;
    color: var(--accent);
    font-size: .48em;
    font-weight: 700;
    letter-spacing: .08em;
}

.tagline {
    margin: 4px 0 0;
    color: var(--text-weak);
    font-size: .85rem;
}

.app-footer {
    margin-top: 32px;
    text-align: center;
    color: var(--text-weak);
    font-size: .78rem;
}

/* ---------- レイアウト ---------- */

.layout {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

@media (min-width: 900px) {
    .layout { grid-template-columns: minmax(0, 540px) minmax(0, 1fr); }
}

.board-area { display: grid; justify-items: center; gap: 12px; }

/* ---------- ステータスバー ---------- */

.statusbar {
    width: min(92vw, 520px);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: baseline;
    padding: 10px 14px;
    background: var(--panel-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.status-item { display: inline-flex; align-items: baseline; gap: 6px; }
.status-label { color: var(--text-weak); font-size: .72rem; }
.status-item b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.status-mode { margin-left: auto; color: var(--accent); font-size: .78rem; font-weight: 700; }

/* ---------- 盤面 ---------- */

.board-wrap { position: relative; width: min(92vw, 520px); }

.board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    aspect-ratio: 1 / 1;
    background: var(--board-bg);
    border: 3px solid var(--line-strong);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
    touch-action: manipulation;
}

.board:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    user-select: none;
    background: transparent;
    transition: background-color .08s linear;
}

/* 3x3 ブロックの区切りを太線にする */
.cell.edge-right  { border-right: 2px solid var(--line-strong); }
.cell.edge-bottom { border-bottom: 2px solid var(--line-strong); }
.cell.last-col    { border-right: none; }
.cell.last-row    { border-bottom: none; }

.cell-value {
    font-size: clamp(1.1rem, 5.2vw, 1.8rem);
    font-weight: 500;
    color: var(--entry);
    font-variant-numeric: tabular-nums;
}

.cell.is-given .cell-value { color: var(--given); font-weight: 700; }
.cell.is-wrong { background: var(--wrong-bg) !important; }
.cell.is-wrong .cell-value { color: var(--wrong-text); font-weight: 700; }
.cell.is-conflict { background: var(--wrong-bg) !important; }
.cell.is-conflict .cell-value { color: var(--wrong-text); }

.cell.is-ruler  { background: var(--ruler-bg); }
.cell.is-same   { background: var(--same-bg); }
.cell.is-review { background: var(--review-bg); }   /* 誤読の可能性があるマス */
.cell.is-cursor { background: var(--select-bg); }

.cell.is-cursor::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent);
    pointer-events: none;
}

/* メモ（候補数字） */
.cell-memos {
    position: absolute;
    inset: 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    pointer-events: none;
}

.cell-memos i {
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
    font-size: clamp(.42rem, 1.7vw, .62rem);
    line-height: 1;
    color: var(--text-weak);
    visibility: hidden;
}

.cell-memos i.on { visibility: visible; }

/* ---------- オーバーレイ（一時停止・クリア） ---------- */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(3px);
    border-radius: 6px;
    z-index: 5;
}

.overlay[hidden] { display: none; }

.overlay-inner {
    background: var(--panel-bg);
    padding: 24px 28px;
    border-radius: 12px;
    text-align: center;
    max-width: 84%;
    box-shadow: var(--shadow);
}

.overlay-title { margin: 0 0 6px; font-size: 1.25rem; font-weight: 700; }
.overlay-body { margin: 0 0 14px; color: var(--text-weak); font-size: .9rem; white-space: pre-line; }

/* ---------- テンキー ---------- */

.pad {
    width: min(92vw, 520px);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.pad-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 10px 0 6px;
    background: var(--panel-bg);
    color: var(--accent);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    box-shadow: var(--shadow);
    font-family: inherit;
    transition: transform .06s ease, background-color .1s;
}

.pad-key:hover { background: var(--accent-weak); }
.pad-key:active { transform: translateY(1px); }
.pad-key:disabled { opacity: .4; cursor: not-allowed; }

.pad-num { font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.pad-left { font-size: .62rem; color: var(--text-weak); min-height: 1em; }
.pad-key.pad-erase { color: var(--text-weak); }
.pad-key.is-done { opacity: .35; }
.pad-key.is-memo { background: var(--accent-weak); }

/* テンキー直下の開始・一時停止・最初からやり直すボタン。
   幅と中央寄せをテンキー（.pad）にそろえる */
.pad-controls { width: min(92vw, 520px); justify-content: center; }

/* ---------- パネル ---------- */

.side { display: grid; gap: 16px; }

.panel {
    background: var(--panel-bg);
    padding: 16px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.panel[hidden] { display: none; }

/* オプション・キーボード操作は、どちらも「遊びながら参照する」補足情報
   なので横に並べる。ただし狭い画面では詰まりすぎるので1列に戻す。
   問題入力モード中はオプション側が非表示になり空きができるので、
   その間はキーボード操作を1列いっぱいに広げる */
.side-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.panel h2 {
    margin: 0 0 8px;
    font-size: .95rem;
    letter-spacing: .04em;
    border-left: 4px solid var(--accent);
    padding-left: 8px;
}

/* 画像の読み取り領域 */

.dropzone {
    padding: 16px 12px;
    text-align: center;
    border: 2px dashed var(--line);
    border-radius: 10px;
    transition: border-color .1s, background-color .1s;
}

.dropzone.is-over {
    border-color: var(--accent);
    background: var(--accent-weak);
}

.dropzone.is-busy { opacity: .6; }

.dropzone-title { margin: 0 0 4px; font-size: .85rem; font-weight: 700; }

.dropzone-body {
    margin: 0 0 10px;
    font-size: .75rem;
    line-height: 1.6;
    color: var(--text-weak);
}

.dropzone .btn { flex: 0 0 auto; }

kbd {
    display: inline-block;
    padding: 1px 5px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: .9em;
}

.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 10px;
    font-size: .72rem;
    color: var(--text-weak);
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.hint { margin: 0 0 10px; font-size: .8rem; color: var(--text-weak); }
.hint code {
    background: var(--ruler-bg);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: .9em;
}

textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .88rem;
    line-height: 1.5;
    resize: vertical;
}

textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.btn {
    flex: 1 1 auto;
    padding: 9px 14px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color .1s, transform .06s ease;
}

.btn:hover { background: var(--accent-weak); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { font-weight: 500; color: var(--text-weak); }
.btn.wide { flex-basis: 100%; }

/* 開始・一時停止・再開 — 遊びの中心となる操作なので、赤みのオレンジで目立たせる */
.btn.action { background: var(--action-bg); border-color: var(--action-bg); color: #fff; }
.btn.action:hover { background: var(--action-bg-hover); border-color: var(--action-bg-hover); }

.toggle-list { display: grid; gap: 6px; }
.toggle-row { margin: 10px 0; }

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    cursor: pointer;
}

.toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.message { margin: 10px 0 0; font-size: .8rem; min-height: 1.2em; }
.message.error { color: var(--wrong-text); }
.message.ok { color: var(--ok); }
.message.warn { color: #d9822b; }

.keys {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 14px;
    margin: 0;
    font-size: .8rem;
}

.keys dt { color: var(--text-weak); font-family: ui-monospace, Menlo, Consolas, monospace; }
.keys dd { margin: 0; }

/* ---------- 支援バナー ---------- */

/* kofi-banner 本体は Shadow DOM で隔離されている。
   置き場所はここで、色や角丸は CSS カスタムプロパティで指定する */
.app-footer aside {
    max-width: 1000px;
    margin: 24px auto 0;
    padding: 0 16px;
}

/* コンポーネントの既定は赤いグラデーション。
   コーヒーに合わせて焙煎した豆のような茶系へ差し替える。
   文字はクリーム色（既定）のままで、茶色地とのコントラストを保つ */
.app-footer kofi-banner {
    --kofi-bg: linear-gradient(135deg, #7b5230 0%, #5a3a21 60%, #3f2716 100%);
    --kofi-shadow: 0 12px 26px rgba(90, 58, 33, 0.45);
    /* 既定の金色の枠線は薄めなので、明るい背景でも輪郭が見えるよう少し強める */
    --kofi-border: rgba(252, 211, 77, 0.55);
    --kofi-border-hover: rgba(252, 211, 77, 0.85);
}

/* スクリプトを読み込めなかったときに表示される代替リンク。
   元のマークアップは Tailwind のクラスを持つが、このサイトは
   Tailwind を使っていないため、ここで見た目を与える */
.app-footer kofi-banner > a {
    display: block;
    padding: 12px;
    color: var(--accent);
    font-size: .82rem;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.app-footer kofi-banner > a:hover { filter: brightness(1.15); }

/* ---------- 広告ブロッカー検知バナー ---------- */

/* adblock-banner 本体にも margin-top はあるが、それは単体で貼られた
   ときの既定値。ここでは支援バナーと横幅・余白をそろえるため、
   .app-footer aside と同じ max-width・margin を明示的に指定する */
.app-footer adblock-banner {
    display: block;
    max-width: 1000px;
    margin: 24px auto 0;
    padding: 0 16px;
}

/* ---------- Pro への案内 ---------- */

.pro-promo {
    max-width: 1000px;
    margin: 24px auto 0;
    padding: 16px 18px;
    background: var(--panel-bg);
    border: 1px solid var(--accent-weak);
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: left;
}

.pro-promo-title {
    margin: 0 0 6px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
}

.pro-promo-body {
    margin: 0 0 10px;
    font-size: .78rem;
    line-height: 1.6;
    color: var(--text-weak);
}

.pro-promo-link {
    display: inline-block;
    padding: 8px 14px;
    color: var(--accent);
    background: var(--accent-weak);
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}

.pro-promo-link:hover { filter: brightness(1.05); }

/* ---------- BOOTH（冊子）への案内 ---------- */

.booth-promo {
    max-width: 1000px;
    margin: 24px auto 0;
    padding: 16px 18px;
    background: var(--panel-bg);
    border: 1px solid var(--accent-weak);
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.booth-promo-thumb {
    flex: 0 0 auto;
    width: 140px;
    max-width: 45%;
    height: auto;
    display: block;
}

.booth-promo-text {
    flex: 1 1 200px;
    min-width: 200px;
}

.booth-promo-title {
    margin: 0 0 6px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
}

.booth-promo-body {
    margin: 0 0 10px;
    font-size: .78rem;
    line-height: 1.6;
    color: var(--text-weak);
}

.booth-promo-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.booth-promo-link {
    display: inline-block;
    padding: 8px 14px;
    color: var(--accent);
    background: var(--accent-weak);
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}

.booth-promo-link:hover { filter: brightness(1.05); }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
