/* 初回表示より後に効くスタイル（モーダル・本文・フッターなど）。
   初回表示ぶんは src/pages3d/critical.css にあり、シェルへインライン注入される。 */

/* ---- モーダル共通 ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(4, 7, 14, .74);
    backdrop-filter: blur(3px);
    animation: fade-in .16s ease;
}
.modal[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }

.modal-card {
    width: 100%;
    max-width: 460px;
    max-height: calc(100dvh - 36px);
    display: flex;
    flex-direction: column;
    padding: 24px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: linear-gradient(180deg, #18213a 0%, #10182b 100%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.modal-card--wide { max-width: 620px; }
.modal-card--tight { max-width: 520px; text-align: center; }
.modal-card h2 { font-size: 1.3rem; margin-bottom: 6px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.modal-head .icon-button { font-size: 1.7rem; }
.modal-body { overflow-y: auto; min-height: 0; }
.modal-body h3 { font-size: 1rem; margin: 20px 0 8px; color: var(--ink); }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { margin: 0 0 12px; font-size: .9rem; color: var(--ink-2); }
.modal-body ul { margin: 0 0 12px; padding-left: 1.25em; font-size: .9rem; color: var(--ink-2); }
.modal-body li { margin-bottom: 6px; }
.modal-body b { color: var(--ink); }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }
.muted { color: var(--ink-3); font-size: .82rem; }

/* ---- 設定 ---- */
/* 設定はモードごとに持つ。項目の中に「AI対戦」「2人で対戦」の行を並べ、それぞれ個別に切り替える。 */
.setting { border: none; margin: 0 0 18px; padding: 0; }
.setting legend { padding: 0 0 8px; font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.both-tag { margin-left: 8px; font-size: .62rem; letter-spacing: .08em; text-transform: none; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--ink-3); }
.modal-lede { margin: 0 0 14px; padding-bottom: 13px; border-bottom: 1px solid var(--line); font-size: .82rem; color: var(--ink-3); }
.modal-lede b { color: var(--ink-2); }
.item-note { margin: 0 0 9px; font-size: .78rem; color: var(--ink-3); line-height: 1.65; }
.item-note b { color: var(--ink-2); }
.mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    flex-wrap: wrap;
    padding: 9px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(12, 18, 34, .5);
}
.mode-name { flex: 0 0 auto; font-size: .86rem; font-weight: 600; }
/* 選択肢が長い項目（ポーンの昇格）でも詰まらないよう、切替は行の余白まで広がる。
   ただし広がりすぎても間延びするので上限を置く。幅が足りないときは名前の下へ全幅で折り返す。 */
.seg-sm {
    display: inline-flex;
    flex: 1 1 180px;
    max-width: 260px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(8, 12, 24, .6);
}
.seg-sm button { flex: 1 1 auto; padding: 7px 12px; border: none; background: transparent; color: var(--ink-3); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.seg-sm button + button { border-left: 1px solid var(--line); }
.seg-sm button[aria-pressed="true"] { background: var(--accent-dim); color: var(--accent); }

/* ---- 昇格 ---- */
.promotion-choices { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.promo-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 84px;
    padding: 13px 6px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(12, 18, 34, .6);
    color: var(--ink);
}
.promo-btn:hover { border-color: var(--accent); background: var(--accent-dim); }
.promo-btn svg { width: 38px; height: 38px; color: #f2e8d2; }
.promo-btn span { font-size: .75rem; color: var(--ink-2); }

/* ---- 終局 ---- */
#gameend-modal .modal-card { text-align: center; align-items: center; }
.gameend-crest {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: rgba(12, 18, 34, .7);
}
.gameend-crest svg { width: 34px; height: 34px; }
.gameend-crest.win { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 26px rgba(224, 180, 94, .3); }
.gameend-crest.lose { border-color: var(--danger); color: var(--danger); }
.gameend-crest.draw { color: var(--ink-2); }
#gameend-title { font-size: 1.5rem; }
#gameend-reason { margin: 4px 0 0; color: var(--gold); font-size: .85rem; font-weight: 700; letter-spacing: .05em; }
.gameend-detail { margin: 10px 0 0; color: var(--ink-2); font-size: .9rem; }

/* ---- 重なり解消のポップアップ ---- */
.pick-popup {
    position: absolute;
    z-index: 20;
    display: flex;
    gap: 5px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: rgba(10, 15, 28, .96);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
    transform: translate(-50%, -120%);
}
.pick-popup[hidden] { display: none; }
.pick-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 46px;
    padding: 6px 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(20, 28, 48, .8);
    color: var(--ink);
    font-family: var(--mono);
    font-size: .72rem;
}
.pick-option:hover { border-color: var(--accent); background: var(--accent-dim); }
.pick-option svg { width: 19px; height: 19px; }
.pick-option .pick-name { color: var(--ink-2); }

/* ---- 押した駒の名前 ---- */
.piece-label {
    position: absolute;
    z-index: 16;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(10, 15, 28, .93);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
    color: var(--ink);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -100%);
    animation: label-in .14s ease-out;
}
.piece-label[hidden] { display: none; }
/* どちらの駒かは、駒の色と同じ点で示す（文字は増やさない） */
.piece-label::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f6eeda;
}
/* 黒い点は暗い台紙に埋もれるので、色見本と同じように細い縁だけ添える */
.piece-label[data-color="black"]::before { background: #15181f; box-shadow: 0 0 0 1px rgba(159,176,212,.5); }
@keyframes label-in { from { opacity: 0; transform: translate(-50%, -88%); } }

/* 名前の横の「?」。押すと、その駒の動き方の説明が開く */
.pl-help {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    margin: 0 -4px 0 1px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: rgba(98, 214, 255, .12);
    color: var(--accent);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: auto;   /* ラベル全体は素通しなので、このボタンだけ押せるようにする */
}
.pl-help[hidden] { display: none; }
/* 指でも押せるよう、見た目より広く取る（盤にかぶるのは駒の頭上だけ） */
.pl-help::after { content: ""; position: absolute; inset: -9px; }
.pl-help:hover { background: var(--accent); border-color: var(--accent); color: #08121c; }


/* ---- 遊び方パネル ---- */
/* 見出し・囲みはどれも <p> なので、.modal-body p より詳細度を上げて上書きする */
.modal-body .blk-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 22px 0 10px;
    font-family: var(--display);
    font-size: .96rem;
    font-weight: 700;
    color: var(--ink);
}
.modal-body .blk-title:first-child { margin-top: 0; }
.modal-body .blk-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.diffs { display: flex; flex-direction: column; gap: 8px; }
.diff {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(12, 18, 34, .55);
}
.diff-fig { display: inline-flex; width: 42px; height: 42px; flex: none; color: var(--accent); }
.diff-fig svg { width: 100%; height: 100%; }
.diff-txt b { display: block; font-size: .88rem; color: var(--ink); line-height: 1.5; }
.diff-txt small { display: block; margin-top: 2px; font-size: .79rem; color: var(--ink-2); line-height: 1.65; }
/* 見出しの中で目立たせたい語。斜体にはしない（日本語で読みにくくなるため） */
.diff-txt em { font-style: normal; font-weight: 700; color: var(--gold); }

.modal-body .win-box {
    margin: 0;
    padding: 11px 14px;
    border: 1px solid rgba(224, 180, 94, .28);
    border-radius: 11px;
    background: rgba(224, 180, 94, .09);
    font-size: .85rem;
    line-height: 1.7;
}
.win-box > b:first-child { display: block; color: var(--gold); }

.ops { display: flex; flex-direction: column; gap: 7px; }
.op { display: flex; align-items: center; gap: 11px; font-size: .85rem; color: var(--ink-2); }
.op-key {
    flex: none;
    min-width: 108px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(12, 18, 34, .6);
    color: var(--ink);
    font-family: var(--mono);
    font-size: .74rem;
    text-align: center;
}
.modal-body .hint-line { margin: 8px 0 0; font-size: .8rem; color: var(--ink-3); }

/* ---- ヘルプの駒一覧 ---- */
.help-pieces { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.help-piece {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 72px;
    padding: 9px 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(12, 18, 34, .55);
    color: var(--ink);
}
.help-piece[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-dim); }
.help-piece svg { width: 30px; height: 30px; color: #f2e8d2; }
.help-piece span { font-size: .7rem; color: var(--ink-2); }

/* ---- 本文ブロック（ルール解説など） ---- */
.prose-block {
    max-width: 780px;
    margin: 34px auto;
    padding: 28px 30px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(16, 23, 41, .6);
}
.prose-block h1 { font-size: 1.6rem; margin-bottom: 12px; }
.prose-block h2 { font-size: 1.35rem; margin-bottom: 14px; }
.prose-block h3 { font-size: 1.05rem; margin: 30px 0 10px; color: var(--gold); }
.prose-block p { margin: 0 0 14px; color: var(--ink-2); }
.prose-block ul { margin: 0 0 14px; padding-left: 1.3em; color: var(--ink-2); }
.prose-block li { margin-bottom: 7px; }
.prose-block b { color: var(--ink); }

.table-scroll { overflow-x: auto; margin: 0 0 16px; }
.piece-table { width: 100%; border-collapse: collapse; min-width: 340px; font-size: .9rem; }
.piece-table th, .piece-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.piece-table thead th { font-size: .75rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.piece-table tbody tr:last-child td { border-bottom: none; }
.piece-table .piece-cell { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.piece-table svg { width: 26px; height: 26px; flex: none; color: #f2e8d2; }
.piece-table td:last-child { color: var(--ink-2); }

/* ---- 他ゲーム・フッター ---- */
#other-games .game-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
#other-games .game-link {
    flex: 1 1 200px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(12, 18, 34, .55);
    text-decoration: none;
    color: var(--ink);
}
#other-games .game-link:hover { border-color: var(--accent); background: var(--accent-dim); }
#other-games .game-name { font-weight: 700; font-size: .92rem; }

.site-footer { max-width: 780px; margin: 0 auto; padding: 8px 30px 56px; color: var(--ink-3); font-size: .82rem; text-align: center; }
.footer-back { margin: 0 0 20px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(16, 23, 41, .5); color: var(--ink-2); font-size: .86rem; line-height: 1.8; }
.footer-back b { color: var(--ink); }
.site-copyright { margin: 0 0 10px; }
.third-party-notice summary { cursor: pointer; }
.third-party-notice-body { margin-top: 8px; }

@media (max-width: 560px) {
    .prose-block { margin: 22px 10px; padding: 20px 18px; border-radius: 12px; }
    .site-footer { padding: 8px 18px 44px; }
    .piece-table th:first-child, .piece-table td:first-child { padding-left: 0; }
    .piece-table { font-size: .84rem; }
}

/* ---- 駒の動き（小さな立体盤のポップアップ） ---- */
/* 対局中の盤には触らない。ここだけで完結させる */
.modal-card--move { max-width: 500px; gap: 12px; }
.modal-card--move .modal-head { margin-bottom: 0; align-items: flex-start; }
.move-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.move-glyph { display: inline-flex; width: 30px; height: 30px; flex: none; color: #f2e8d2; }
.move-glyph svg { width: 100%; height: 100%; }
.move-title-text { display: flex; flex-direction: column; min-width: 0; }
.move-title-text h2 { font-size: 1.05rem; }
.move-title-text small { color: var(--ink-2); font-size: .78rem; line-height: 1.6; }
.move-stage {
    position: relative;
    width: 100%;
    height: min(54vh, 350px);
    border: 1px solid var(--line);
    border-radius: 11px;
    background: radial-gradient(120% 90% at 50% 8%, #5f6f95 0%, #3f4d72 26%, #212e4c 56%, #0e1526 84%, #080d18 100%);
    overflow: hidden;
    touch-action: none;
}
#board3d-mini { display: block; width: 100%; height: 100%; }
/* 7種を必ず1行に収める。折り返すと「あと1個だけ下の段」になって押しにくい */
.move-switch {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    max-width: 330px;
    margin: 0 auto;
    width: 100%;
}
.move-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(12, 18, 34, .6);
    color: #dfe7f8;
}
.move-switch button svg { width: 24px; height: 24px; }
.move-switch button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.modal-card--move .hint-line { margin: 0; font-size: .78rem; color: var(--ink-3); text-align: center; }

/* 帯を閉じたとき、収納先の ? ボタンを一度だけ光らせる */
#btn-help { position: relative; }
#btn-help.pulse-once::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    animation: hint-ring .9s ease-out 1;
}
@keyframes hint-ring { from { opacity: .9; transform: scale(.7); } to { opacity: 0; transform: scale(1.5); } }

/* ---- 結果のシェア ---- */
.share-row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(12, 18, 34, .6);
    color: var(--ink-2);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
}
.share-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.share-btn svg { width: 16px; height: 16px; }
