/* ================================================================
   デッキ作成ページ（PC 優先。狭い画面では 1 列に畳む）
   ================================================================ */
.deck-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.deck-bar__name { flex: 1 1 260px; min-width: 200px; }
.deck-bar__name input { width: 100%; padding: 9px 12px; font-size: 17px; font-weight: 700; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; }
.deck-bar__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.deck-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 70; background: #1c2430; color: #fff; padding: 10px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.deck-toast.is-warn { background: #8a4b00; }
.deck-toast.is-error { background: var(--danger); }

.deck-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 24px; align-items: start; padding-top: 16px; }

/* ---- 左: カードを探す ---- */
.pool { min-width: 0; }
.pool__filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--text-sub); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.is-on { background: var(--accent); color: #fff; }
#pool-q { flex: 1 1 220px; min-width: 180px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; font-size: 14px; background: #fff; }
.pool__filters .chip--color { width: 32px; height: 32px; font-size: 13px; }
.pool__filters select:disabled { opacity: 0.5; }
.pool__count { font-size: 13px; color: var(--text-sub); margin: 12px 0 10px; }
.pool__count b { color: var(--text); font-size: 16px; }
.pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 14px 10px; min-height: 240px; align-content: start; transition: opacity 0.12s; }
.pool-grid.is-loading { opacity: 0.45; pointer-events: none; }
.pool-message { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: var(--text-sub); background: var(--bg-soft); border: 1px dashed var(--line-strong); border-radius: var(--radius); line-height: 2.2; }
.pool-tile { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pool-tile__add { position: relative; display: block; width: 100%; padding: 0; border: none; background: none; border-radius: 6px; }
.pool-tile__add:hover .card-image { box-shadow: 0 0 0 3px var(--accent); }
.pool-tile.has-count .card-image, .pool-tile.is-selected .card-image { box-shadow: 0 0 0 3px var(--accent); }
.pool-tile.is-full .card-image img { filter: grayscale(0.7); opacity: 0.6; }
.pool-tile__count { position: absolute; top: 6px; right: 6px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.pool-tile__minus { position: absolute; top: 6px; left: 6px; z-index: 1; width: 26px; height: 26px; border-radius: 50%; border: none; background: #fff; color: var(--text); font-weight: 700; line-height: 1; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.pool-tile__minus:hover { background: var(--danger); color: #fff; }
.pool-tile__name { font-size: 12px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-tile__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; font-size: 11px; }
.pool-tile__meta a { margin-left: auto; }

/* ---- 右: 作成中のデッキ ---- */
.deck-panel { position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: #fff; scroll-margin-top: calc(var(--header-h) + 12px); }
.deck-panel__head { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.deck-panel__head h2 { font-size: 15px; }
.deck-total { font-size: 13px; color: var(--text-sub); }
.deck-total b { font-size: 22px; color: var(--text); margin-right: 2px; }
.deck-total.is-ok b { color: #1b8a4a; }
.deck-total.is-over b { color: var(--danger); }
.deck-panel__body { overflow-y: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.deck-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deck-slot { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; background: #fff; text-align: left; }
.deck-slot.is-empty { justify-content: center; min-height: 72px; border-style: dashed; border-color: var(--line-strong); color: var(--accent); font-weight: 600; font-size: 13px; }
.deck-slot.is-empty:hover { background: var(--accent-soft); }
.deck-slot .card-image { width: 42px; flex-shrink: 0; box-shadow: none; }
.deck-slot__info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.deck-slot__label { font-size: 10px; color: var(--text-mute); }
.deck-slot__name { font-size: 13px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-slot__sub { font-size: 11px; color: var(--text-sub); display: flex; align-items: center; gap: 4px; }
.deck-slot__btns { display: flex; flex-direction: column; gap: 2px; }
.deck-slot__btns button { border: none; background: none; font-size: 11px; color: var(--accent); padding: 2px 4px; white-space: nowrap; }
.deck-slot__btns button:hover { text-decoration: underline; }
.deck-slot__sub .color-dot, .deck-row__colors .color-dot, .stat-chips .color-dot { width: 16px; height: 16px; font-size: 9px; }
.check-box { border-radius: 8px; padding: 8px 12px; font-size: 13px; line-height: 1.6; }
.check-box + .check-box { margin-top: 6px; }
.check-box ul { list-style: disc; padding-left: 18px; }
.check-box--ok { background: #e9f7ef; color: #17663a; font-weight: 600; }
.check-box--error { background: var(--danger-soft); color: #8f1d1d; }
.check-box--warn { background: var(--warn-soft); color: #7a4500; }
.deck-list { display: flex; flex-direction: column; }
.deck-list__title { font-size: 11px; color: var(--text-mute); padding: 6px 0 2px; }
.deck-row { display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.deck-row__thumb { display: block; cursor: zoom-in; }
.deck-row__thumb .card-image { width: 34px; border-radius: 3px; box-shadow: 0 0 0 1px var(--line); }
.deck-slot__img { flex-shrink: 0; cursor: zoom-in; }
.deck-row__level { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-mute); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.deck-row__name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-row.is-warn .deck-row__name::before { content: "\f071"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: #c77700; margin-right: 4px; font-size: 11px; }
.deck-row__qty { display: inline-flex; align-items: center; gap: 4px; }
.deck-row__qty b { min-width: 16px; text-align: center; font-size: 15px; }
.deck-row__qty button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line-strong); background: #fff; line-height: 1; font-weight: 700; }
.deck-row__qty button:hover { border-color: var(--accent); color: var(--accent); }
.deck-empty { color: var(--text-mute); font-size: 13px; text-align: center; padding: 18px 0; }
.deck-stats h3 { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.curve { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; align-items: end; }
.curve li { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-height: 90px; }
.curve__n { font-size: 11px; color: var(--text-sub); min-height: 16px; }
.curve__bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; }
.curve__l { font-size: 11px; color: var(--text-mute); border-top: 1px solid var(--line-strong); width: 100%; text-align: center; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12px; }
.stat-chips > span { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; display: inline-flex; align-items: center; gap: 4px; }
.deck-jump { display: none; }

/* ---- 一覧で見る ---- */
.deck-overview { padding-top: 16px; }
.deck-overview__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.deck-overview__head h1 { font-size: 22px; }
.ov-top { display: grid; grid-template-columns: 200px 200px minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 24px; }
.ov-side { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.ov-card { display: flex; flex-direction: column; gap: 4px; color: var(--text); font-size: 12px; font-weight: 600; min-width: 0; }
.ov-card:hover { text-decoration: none; }
a.ov-card:hover .card-image { box-shadow: 0 0 0 3px var(--accent); }
.ov-card__label { font-size: 11px; color: var(--text-mute); font-weight: 500; }
.ov-card__img { position: relative; display: block; }
.ov-card__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-count { position: absolute; right: 5px; bottom: 5px; background: #1c2430; color: #fff; border-radius: 6px; padding: 0 8px; font-size: 15px; font-weight: 700; line-height: 1.6; }
.ov-empty.is-missing::after { content: "未選択"; }
.ov-section-title { font-size: 15px; margin-bottom: 12px; padding-left: 10px; border-left: 4px solid var(--accent); }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 12px; }

/* ---- カードにマウスを重ねたときの詳細 ---- */
.hover-card { position: fixed; z-index: 80; width: 520px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: hidden; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; padding: 12px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 36px rgba(10, 20, 40, 0.28); pointer-events: none; font-size: 13px; line-height: 1.6; }
.hover-card__info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hover-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.hover-card__meta .color-dot { width: 18px; height: 18px; font-size: 10px; }
.hover-card__name { font-size: 17px; font-weight: 700; line-height: 1.35; }
.hover-card__stats { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-sub); font-size: 12px; }
.hover-card__stats b { font-size: 15px; color: var(--text); }
.hover-card__cats { display: flex; flex-wrap: wrap; gap: 4px; }
.hover-card__cats span { border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 8px; font-size: 11px; }
.hover-card__text { border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 4px; padding: 5px 9px; }
.hover-card__text--hirameki { border-left-color: #e0a800; background: #fffdf3; }
.hover-card__text--cutin { border-left-color: #d6455a; background: #fff7f8; }
.hover-card__text--henso { border-left-color: #7a55c7; background: #faf7ff; }
.hover-card__text--none { border-left-color: var(--line-strong); color: var(--text-mute); }

/* ---- ダイアログ ---- */
.dialog--wide { width: min(1000px, calc(100vw - 32px)); }
.deck-image-preview { width: 100%; max-height: 62vh; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-soft); }
.dialog { border: none; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(10, 20, 40, 0.35); color: var(--text); }
.dialog::backdrop { background: rgba(18, 26, 40, 0.55); }
.dialog__inner { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.dialog__inner h2 { font-size: 18px; }
.dialog__inner p { font-size: 14px; color: var(--text-sub); }
.dialog__inner input[type="text"] { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 16px; }
.dialog__inner p.dialog__error { color: var(--danger); }
.dialog__notes { list-style: disc; font-size: 13px; color: #7a4500; background: var(--warn-soft); border-radius: 8px; padding: 10px 12px 10px 30px; display: flex; flex-direction: column; gap: 4px; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.saved-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.saved-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.saved-item__info { flex: 1; min-width: 0; }
.saved-item__name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item__sub { font-size: 12px; color: var(--text-mute); }

/* ---- プロキシ印刷（A4 に 63×88mm を 3×3） ---- */
#print-area { display: none; }
@media print {
  @page { size: A4 portrait; margin: 0; }
  body.has-print-area { display: block; min-height: 0; background: #fff; }
  body.has-print-area > *:not(#print-area) { display: none !important; }
  body.has-print-area #print-area { display: block; }
  .print-page { width: 210mm; height: 296mm; padding: 14mm 0 0 10.5mm; box-sizing: border-box; overflow: hidden; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-grid { display: grid; grid-template-columns: repeat(3, 63mm); grid-auto-rows: 88mm; }
  .print-grid img, .print-missing { width: 63mm; height: 88mm; display: block; object-fit: fill; outline: 0.2mm solid #bbb; outline-offset: -0.1mm; }
  .print-missing { display: grid; place-items: center; font-size: 10pt; text-align: center; }
  .print-note { width: 189mm; text-align: center; font-size: 7.5pt; color: #555; margin-top: 3mm; }
}

/* ---- 狭い画面 ---- */
@media (max-width: 1200px) {
  .deck-layout { grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; }
  .ov-top { grid-template-columns: 160px 160px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .page--deck { padding-bottom: 76px; }
  .deck-layout { display: block; }
  .deck-panel { position: static; max-height: none; margin-top: 20px; }
  .deck-jump { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 45; justify-content: center; padding: 11px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); }
  .deck-jump:hover { text-decoration: none; }
  .deck-toast { bottom: 68px; }
  .deck-bar__actions .btn { padding: 7px 10px; font-size: 13px; }
  .pool-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .ov-top { grid-template-columns: 1fr 1fr; }
  .ov-side { grid-column: 1 / -1; max-width: none; }
  .ov-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .seg { max-width: 100%; overflow-x: auto; }
}

/* ---- タッチ操作（長押しでカード詳細） ---- */
[data-hover] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
[data-hover] img { -webkit-touch-callout: none; pointer-events: none; -webkit-user-drag: none; }
.hover-card--touch { pointer-events: auto; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 560px) {
  .hover-card { grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 10px; font-size: 12px; }
  .hover-card__name { font-size: 15px; }
}
