/* 牌譜のページ (/paifu・/paifu/import・/paifu/view)。dukilab.com の css/paifu.css から移したもの。style.css のトークンとパーツを使う */

.pf-section { padding: var(--space-7) 0 0; scroll-margin-top: 72px; }
#pfViewer { scroll-margin-top: 72px; }
.pf-section:last-child { padding-bottom: var(--space-8); }
.pf-lead { margin-top: var(--space-3); color: var(--ink-muted); }
.pf-lead code, .pf-note code { font-family: var(--font-mono); color: var(--ink); }
.pf-note { margin-top: var(--space-2); font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.pf-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.pf-minus { color: var(--ink-muted); }

/* 読み込み */
.pf-label { display: block; margin-top: var(--space-5); font-size: 14px; font-weight: 700; }
.pf-input {
    display: block; width: 100%; margin-top: var(--space-2); padding: var(--space-3);
    font-family: var(--font-mono); font-size: 13px; line-height: 20px; word-break: break-all;
    background: var(--surface-raised); color: var(--ink);
    border: var(--border-hair) solid var(--line-strong); border-radius: var(--radius-none); resize: vertical;
}
.pf-actions { margin-top: var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-3); }
.pf-file { cursor: pointer; }
.pf-file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pf-file:focus-within { outline: var(--border-strong) solid var(--focus-ring); outline-offset: 2px; }
.pf-error { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border: var(--border-strong) solid var(--ink); font-weight: 700; }
.pf-privacy { margin-top: var(--space-5); }
.pf-privacy p { margin-top: var(--space-1); font-size: 14px; line-height: 22px; }
.pf-copied { margin-top: var(--space-3); font-weight: 700; }

/* 対局 */
.pf-meta { margin-top: var(--space-4); display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-3); }
.pf-meta__item { padding: var(--space-2) var(--space-3); border: var(--border-hair) solid var(--line); background: var(--surface-raised); }
.pf-meta__value { font-weight: 700; }
.pf-scroll { margin-top: var(--space-4); overflow-x: auto; }
.pf-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 22px; }
.pf-table th { text-align: left; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .06em; color: var(--ink-muted); padding: var(--space-1) var(--space-2); background: var(--surface-sunken); border-bottom: var(--border-hair) solid var(--line); white-space: nowrap; }
.pf-table td { padding: var(--space-2); border-bottom: var(--border-hair) solid var(--line); vertical-align: top; }
.pf-table .pf-num { text-align: right; white-space: nowrap; }
.pf-row--self td { font-weight: 700; }
.pf-rules { margin-top: var(--space-4); font-size: 14px; }
.pf-rules summary { cursor: pointer; font-weight: 700; }
.pf-rulelist { margin: var(--space-2) 0 0 var(--space-5); }

.pf-round { cursor: pointer; }
.pf-round:hover td, .pf-round:focus-visible td { background: var(--surface-sunken); }
.pf-round:focus-visible { outline: var(--border-strong) solid var(--focus-ring); outline-offset: -2px; }
.pf-round.is-current td { background: var(--surface-sunken); }
.pf-round.is-current .pf-round__title { box-shadow: inset 4px 0 0 var(--ink); }
.pf-round__title { white-space: nowrap; font-weight: 700; }
.pf-round__title small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-muted); }

/* 再生 (ワールドの観戦モニターと同じ並べ方: 上の帯・真ん中の卓・四隅の席の枠) */
.pf-board { margin-top: var(--space-4); }
.is-hidden { visibility: hidden; }

/* 上の帯 (反転): 卓・ルール・ドラ・局と供託 */
.pf-band {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-6);
    padding: var(--space-2) var(--space-4); min-height: 56px;
    background: var(--inverse-surface); color: var(--inverse-ink);
}
.pf-band__table { font-size: 22px; line-height: 30px; font-weight: 800; }
.pf-band__rule { font-weight: 700; }
.pf-band__dora { display: inline-flex; align-items: center; gap: var(--space-3); margin-left: auto; margin-right: auto; font-weight: 700; }
.pf-band__kyoku { font-weight: 700; }
.pf-band__kyotaku { font-weight: 700; }

/* 卓と四隅の席の枠 */
.pf-stage {
    margin-top: var(--space-3);
    display: grid; gap: var(--space-3);
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    grid-template-areas: "tl felt tr" "bl felt br";
}
.pf-corner--tl { grid-area: tl; }
.pf-corner--bl { grid-area: bl; }
.pf-corner--br { grid-area: br; }
.pf-corner--tr { grid-area: tr; }
.pf-corner { min-width: 0; display: flex; }
.pf-stage > .pf-felt { grid-area: felt; }

.pf-seat {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1);
    padding: var(--space-4) var(--space-3) var(--space-3);
    background: var(--surface-raised); border: var(--border-hair) solid var(--line);
    --dl-cut: 16px;
}
.pf-seat--turn { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pf-seat__wind { color: var(--ink-muted); }
.pf-seat__riichi { align-self: flex-start; padding: 0 var(--space-3); line-height: 26px; font-weight: 700; background: var(--ink); color: var(--surface); }
.pf-seat__name { font-weight: 700; font-size: 18px; line-height: 26px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-seat__points { font-weight: 700; font-size: 22px; line-height: 28px; }

/* 席の枠の手牌の欄 (収まらないときは牌を小さくする) */
.pf-hand {
    display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-2);
    padding: 3px; border: var(--border-hair) solid var(--line-strong); background: var(--surface-sunken);
}
.pf-hand__tiles, .pf-hand__melds { display: flex; align-items: flex-end; min-width: 0; }
.pf-hand__tiles { flex: 14 1 0; }
.pf-hand__melds { flex: 0 1 auto; gap: 3px; }
.pf-hand__meld { display: flex; align-items: flex-end; min-width: 0; }
.pf-hand .pf-tile { --w: auto; --h: auto; flex: 0 1 22px; min-width: 0; aspect-ratio: 3 / 4; height: auto; }
.pf-hand .pf-tile--drawn { margin-left: 4px; }
.pf-hand .pf-tile--side { flex-basis: 29px; aspect-ratio: 4 / 3; }
.pf-hand .pf-tile--side .pf-tile__img { position: absolute; left: 50%; top: 50%; width: 75%; height: 133.3%; transform: translate(-50%, -50%) rotate(90deg); }
.pf-hand .pf-tile--side.pf-tile--back { aspect-ratio: 4 / 3; }

/* 牌 (絵は役一覧と同じ /media/tiles の CC0 の牌) */
.pf-tiles { display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-end; }
.pf-tile {
    --w: 26px; --h: 35px;
    position: relative; display: inline-block; flex: none;
    width: var(--w); height: var(--h);
    user-select: none;
}
.pf-tile__img { display: block; width: 100%; height: 100%; border-radius: 3px; outline: 1px solid rgba(0, 0, 0, .3); outline-offset: -1px; }
.pf-tile--back { background: #c98a2e; border-radius: 3px; outline: 1px solid rgba(0, 0, 0, .3); outline-offset: -1px; }
.pf-tile--tsumogiri .pf-tile__img { filter: brightness(.78); }
.pf-tile--called { opacity: .35; }

/* 卓を上から見た図 (座標は 728 × 728。下の場所を 90° ずつ回して4席) */
.pf-felt { position: relative; width: 100%; aspect-ratio: 1; background: #1f4d3e; overflow: hidden; container-type: inline-size; }
.pf-felt__center {
    position: absolute; left: 34.9%; top: 34.9%; width: 30.2%; height: 30.2%;
    background: #0d1013; color: #eef2f5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2%;
    font-weight: 800; font-size: max(8px, 2.3cqw); line-height: 1.3; text-align: center;
}
.pf-felt__kyotaku { font-weight: 400; font-size: .85em; }
.pf-place { position: absolute; inset: 0; pointer-events: none; }
.pf-place .pf-tile--abs { position: absolute; --w: auto; --h: auto; }
.pf-place .pf-tile--sideways .pf-tile__img { position: absolute; left: 50%; top: 50%; width: 74.4%; height: 134.4%; transform: translate(-50%, -50%) rotate(90deg); }
.pf-place .pf-tile--back.pf-tile--sideways { background: #c98a2e; }
.pf-place__points { position: absolute; left: 36.3%; top: 57.4%; width: 27.5%; text-align: center; color: #eef2f5; font-size: max(7px, 2cqw); line-height: 1.6; white-space: nowrap; }
.pf-place--turn .pf-place__points { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.pf-place__stick { position: absolute; left: 41.8%; top: 62.4%; width: 16.5%; height: 1.1%; background: #eef2f5; }

/* 局の結果の板 (卓の図の真ん中に重ねる) */
.pf-felt__result {
    position: absolute; left: 11.6%; top: 32.2%; width: 76.8%; height: 35.6%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%;
    padding: 0 4%; background: #0d1013; color: #eef2f5; text-align: center;
    font-size: max(10px, 3.6cqw); line-height: 1.4;
}
.pf-felt__result-line { white-space: pre-wrap; }
.pf-felt__result-moves { margin-top: 4%; display: flex; flex-wrap: wrap; justify-content: center; gap: .2em 1.4em; white-space: nowrap; }

/* 待ちの欄 (赤くしない。残り0枚は暗く) */
.pf-wait { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--space-2); min-height: 52px; overflow-x: auto; overflow-y: hidden; }
.pf-wait__label { flex: none; color: var(--ink-muted); }
.pf-wait__none { color: var(--ink-muted); }
.pf-wait__item { flex: none; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.pf-wait__left { font-size: 12px; font-weight: 700; }
.pf-wait__item.is-empty .pf-tile__img { filter: brightness(.35); }
.pf-wait__item.is-empty .pf-wait__left { color: rgb(89, 89, 89); }
/* 卓の上で、聴牌している人の待ちと同じ河・鳴き・抜きの牌 */
.pf-tile--wait .pf-tile__img { outline: 2px solid #e5484d; outline-offset: -1px; }
.pf-tile--wait::after { content: ""; position: absolute; inset: 0; background: rgba(229, 72, 77, .25); border-radius: 3px; pointer-events: none; }
.pf-tile--wait.pf-tile--tsumogiri::after { opacity: .8; }
/* 小牌マイティの和了で、マイティがなった牌 (卓と同じく赤くする。待ちの枠線は付けない) */
.pf-tile--mighty::after { content: ""; position: absolute; inset: 0; background: rgba(229, 72, 77, .45); border-radius: 3px; pointer-events: none; }

/* 切り替え (名前だけのボタン。オンは反転) */
.pf-toggle { min-height: 44px; transition: border-color 120ms ease-out, background-color 150ms ease-out, color 150ms ease-out; }
.pf-toggle[aria-pressed="true"] { background: var(--inverse-surface); color: var(--inverse-ink); border-color: var(--inverse-surface); --dl-cut-color: var(--surface); }
@media (prefers-reduced-motion: reduce) {
    .pf-toggle { transition: none; }
}

/* 卓の下の和了の内訳 */
.pf-result { margin-top: var(--space-4); padding: var(--space-4); background: var(--inverse-surface); color: var(--inverse-ink); }
.pf-result .dl-tag { color: var(--inverse-ink); }
.pf-win + .pf-win { margin-top: var(--space-3); }
.pf-win__head { font-weight: 700; }
.pf-yaku { list-style: none; margin-top: var(--space-1); display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 var(--space-5); }
.pf-yaku li { display: flex; justify-content: space-between; border-bottom: var(--border-hair) solid var(--line-strong); font-size: 14px; }
.pf-result__ura { margin-top: var(--space-3); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* 操作 */
.pf-controls { margin-top: var(--space-3); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pf-controls .dl-btn { min-width: 52px; justify-content: center; }
.pf-controls__move { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.pf-controls__move .dl-btn, .pf-board .pf-toggle { min-width: 0; padding-left: var(--space-2); padding-right: var(--space-2); }
.pf-count { display: flex; flex-direction: column; align-items: center; padding: 0 var(--space-2); line-height: 20px; color: var(--ink-muted); }
.pf-controls--sub { margin-top: var(--space-4); gap: var(--space-5); }
.pf-step { display: flex; align-items: center; gap: var(--space-2); flex: 1 1 260px; }
.pf-step input { flex: 1; accent-color: var(--ink); }
.pf-select { display: flex; align-items: center; gap: var(--space-2); }
.pf-select select { font: inherit; font-size: 14px; padding: var(--space-1) var(--space-2); background: var(--surface-raised); color: var(--ink); border: var(--border-hair) solid var(--line-strong); border-radius: var(--radius-none); }

@media (max-width: 960px) {
    .pf-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "felt felt" "tl tr" "bl br"; }
}
@media (max-width: 760px) {
    .pf-seat { padding: var(--space-3) var(--space-2) var(--space-2); }
    .pf-seat__name { font-size: 15px; line-height: 22px; }
    .pf-seat__points { font-size: 17px; line-height: 24px; }
    .pf-tile { --w: 20px; --h: 27px; }
    .pf-controls__move { margin-left: 0; }
    .pf-controls .dl-btn { flex: 1 1 auto; min-width: 44px; padding-left: var(--space-2); padding-right: var(--space-2); }
}
@media (max-width: 520px) {
    .pf-stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "felt" "tl" "bl" "br" "tr"; }
}

/* ---- dmj-site で足したもの ---- */
.pf-error--top { margin-top: var(--space-7); }
.pf-subhead { margin-top: var(--space-6); font-size: 18px; line-height: 26px; font-weight: 700; }

/* 一覧 */
.pf-empty { margin-top: var(--space-4); }
.pf-filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3) var(--space-5); }
.pf-filters input[type="date"] {
    font: inherit; font-size: 14px; padding: var(--space-1) var(--space-2);
    background: var(--surface-raised); color: var(--ink); border: var(--border-hair) solid var(--line-strong); border-radius: var(--radius-none);
}
.pf-list td:first-child, .pf-list th:first-child { width: 1%; }
.pf-list input[type="checkbox"], #pfSelectAll { width: 18px; height: 18px; accent-color: var(--ink); }
.pf-members { min-width: 240px; }
.pf-members strong { font-weight: 800; }
.pf-row--muted td { color: var(--ink-muted); }

/* 読み込み */
.pf-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
    margin-top: var(--space-5); min-height: 160px; padding: var(--space-5);
    border: var(--border-strong) dashed var(--line-strong); background: var(--surface-raised); cursor: pointer; text-align: center;
}
.pf-drop.is-over { border-color: var(--ink); background: var(--surface-sunken); }
.pf-drop:focus-within { outline: var(--border-strong) solid var(--focus-ring); outline-offset: 2px; }
.pf-drop__title { font-size: 18px; font-weight: 700; }
.pf-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pf-done { font-weight: 700; }

/* 共有 */
.pf-choice { margin-top: var(--space-3); border: 0; padding: 0; display: grid; gap: var(--space-2); }
.pf-choice label { display: flex; gap: var(--space-2); align-items: center; cursor: pointer; }
.pf-choice input { width: 18px; height: 18px; accent-color: var(--ink); }
.pf-names { margin-top: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; }
.pf-names li { padding: var(--space-1) var(--space-3); border: var(--border-hair) solid var(--line); }
.pf-field { margin-top: var(--space-3); width: 100%; max-width: 640px; padding: var(--space-2) var(--space-3); font-family: var(--font-mono); font-size: 14px; border: var(--border-hair) solid var(--ink); background: var(--surface-raised); color: var(--ink); }
.pf-shareinfo { margin-top: var(--space-6); }
.pf-shareinfo .pf-actions { margin-top: var(--space-3); }
