      :root {
        --primary: #2c3e50;
        --accent: #f39c12;
        --bg: #f0f2f5;
        --white: #ffffff;
        --border: #dde1e7;
        --text-muted: #7f8c8d;
        --sidebar-w: 270px;
        --primary-bg: rgba(44, 62, 80, 0.08);
        --header-bg: #f5f6fa;
      }
      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
        touch-action: manipulation;
      }
      html {
        overscroll-behavior: none;
      }
      body {
        font-family:
          "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", Meiryo,
          sans-serif;
        background: var(--bg);
        color: var(--primary);
        height: 100vh;
        height: 100dvh; /* モバイルアドレスバー考慮 */
        display: flex;
        flex-direction: column;
        overscroll-behavior: none;
      }
      /* ── Layout ── */
      .layout {
        display: flex;
        flex: 1;
        overflow: hidden;
      }

      /* ── Sidebar ── */
      .sidebar {
        width: var(--sidebar-w);
        background: var(--white);
        border-right: 1px solid var(--border);
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
      .sidebar-inner {
        padding: 14px;
        flex: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .sidebar-footer {
        padding: 14px;
        border-top: 1px solid var(--border);
        flex-shrink: 0;
        background: var(--white);
      }

      .filter-section {
        margin-bottom: 14px;
      }
      .filter-label {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 10px;
        font-weight: bold;
        letter-spacing: 0.8px;
        text-transform: uppercase;
        color: var(--text-muted);
        margin-bottom: 6px;
      }
      /* ラベル + OR/AND トグル行 */
      .filter-label-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
      }
      .filter-label-row .filter-label {
        margin-bottom: 0;
      }
      .field-mode-toggle {
        display: flex;
        gap: 2px;
      }
      .field-mode-btn {
        padding: 2px 7px;
        font-size: 10px;
        font-weight: bold;
        border-radius: 3px;
        border: 1px solid var(--border);
        color: var(--text-muted);
        background: none;
        cursor: pointer;
        user-select: none;
        transition: all 0.12s;
      }
      .field-mode-btn.on {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
      }
      .btn-deselect-all {
        font-size: 10px;
        color: var(--text-muted);
        background: none;
        border: 1px solid var(--border);
        border-radius: 3px;
        padding: 1px 5px;
        cursor: pointer;
        font-weight: normal;
        letter-spacing: 0;
        text-transform: none;
        line-height: 1.4;
        flex-shrink: 0;
      }
      .btn-deselect-all:hover {
        background: var(--bg);
        color: var(--primary);
      }
      .filter-input {
        width: 100%;
        padding: 7px 10px;
        border: 1px solid var(--border);
        border-radius: 5px;
        font-size: 16px;
        color: var(--primary);
        outline: none;
        transition: border-color 0.15s;
      }
      .filter-input:focus {
        border-color: var(--accent);
      }
      .input-wrap {
        position: relative;
      }
      .input-wrap .filter-input {
        padding-right: 28px;
      }
      .input-clear {
        position: absolute;
        right: 7px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        cursor: pointer;
        color: #bbb;
        font-size: 15px;
        line-height: 1;
        padding: 0;
        display: none;
      }
      .input-clear:hover {
        color: #666;
      }

      /* Ink toggles */
      .ink-grid {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 5px;
      }
      /* 全色対象状態（未選択）: 薄めに全色表示 */
      .ink-grid.ink-all .ink-btn:not(.disabled) {
        opacity: 0.55;
        border-color: rgba(255,255,255,0.25);
      }
      .ink-btn {
        padding: 5px 4px;
        border-radius: 5px;
        font-size: 11px;
        font-weight: bold;
        cursor: pointer;
        text-align: center;
        color: white;
        opacity: 0.28;
        transition: opacity 0.15s, border-color 0.15s;
        user-select: none;
        border: 2px solid transparent;
      }
      .ink-btn.on {
        opacity: 1;
        border-color: rgba(255,255,255,0.5);
      }
      /* 全色対象ヒント */
      .ink-all-hint {
        font-size: 10px;
        color: var(--accent);
        text-align: center;
        margin-top: 4px;
        font-weight: bold;
        letter-spacing: 0.02em;
        opacity: 1;
        transition: opacity 0.2s;
      }
      .ink-all-hint.hidden {
        opacity: 0;
        pointer-events: none;
      }

      /* Pill checkboxes */
      .pill-group {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
      }
      .pill {
        padding: 3px 9px;
        border: 1.5px solid var(--border);
        border-radius: 20px;
        font-size: 11px;
        cursor: pointer;
        background: var(--white);
        color: var(--text-muted);
        transition: all 0.15s;
        user-select: none;
      }
      .pill.on {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
      }

      /* Range inputs */
      .range-row {
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .range-row .filter-input {
        width: 70px;
        text-align: center;
        padding: 7px 6px;
      }
      .range-sep {
        color: var(--text-muted);
        font-size: 12px;
        flex-shrink: 0;
      }

      /* Radio inkable */
      .radio-group {
        display: flex;
        gap: 5px;
      }
      .radio-btn {
        padding: 4px 10px;
        border: 1.5px solid var(--border);
        border-radius: 20px;
        font-size: 11px;
        cursor: pointer;
        background: var(--white);
        color: var(--text-muted);
        transition: all 0.15s;
        user-select: none;
      }
      .radio-btn.on {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
      }

      /* Dual range slider */
      .dual-range-wrap {
        position: relative;
        height: 28px;
        display: flex;
        align-items: center;
        margin: 4px 2px 0;
      }
      .range-track-bg {
        position: absolute;
        width: 100%;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
      }
      .range-track-fill {
        position: absolute;
        height: 4px;
        background: var(--primary);
        border-radius: 2px;
      }
      .dual-range-wrap input[type="range"] {
        position: absolute;
        width: 100%;
        height: 4px;
        -webkit-appearance: none;
        appearance: none;
        background: transparent;
        pointer-events: none;
        margin: 0;
        outline: none;
      }
      .dual-range-wrap input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: var(--primary);
        border: 2px solid #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
        pointer-events: all;
        cursor: pointer;
      }
      .dual-range-wrap input[type="range"]::-moz-range-thumb {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: var(--primary);
        border: 2px solid #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
        pointer-events: all;
        cursor: pointer;
      }
      .range-val {
        font-size: 12px;
        color: var(--primary);
        font-weight: bold;
        margin-left: auto;
      }

      /* Set dropdown */
      .set-dropdown {
        position: relative;
      }
      .set-dropdown-trigger {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 7px 10px;
        border: 1px solid var(--border);
        border-radius: 5px;
        background: var(--white);
        font-size: 13px;
        cursor: pointer;
        color: var(--primary);
        text-align: left;
      }
      .set-dropdown-trigger:hover {
        border-color: var(--accent);
      }
      .set-dropdown-arrow {
        font-size: 10px;
        color: var(--text-muted);
        transition: transform 0.15s;
      }
      .set-dropdown-panel.open + * {
      }
      .set-dropdown-panel {
        display: none;
        position: absolute;
        top: calc(100% + 2px);
        left: 0;
        right: 0;
        background: var(--white);
        border: 1px solid var(--border);
        border-radius: 5px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        z-index: 200;
        max-height: 220px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .set-dropdown-panel.open {
        display: block;
      }
      .set-checkbox-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 7px 10px;
        font-size: 12px;
        cursor: pointer;
        color: var(--primary);
        user-select: none;
      }
      .set-checkbox-item:hover {
        background: var(--bg);
      }
      .set-checkbox-item input[type="checkbox"] {
        cursor: pointer;
        accent-color: var(--primary);
      }

      /* Sort row */
      .sort-row {
        display: flex;
        gap: 6px;
        align-items: center;
      }
      .sort-row .filter-input {
        flex: 1;
        padding: 6px 8px;
      }
      .sort-dir {
        padding: 6px 10px;
        border: 1px solid var(--border);
        border-radius: 5px;
        background: var(--white);
        font-size: 12px;
        cursor: pointer;
        flex-shrink: 0;
        color: var(--primary);
      }
      .sort-dir:hover {
        background: var(--bg);
      }

      /* Sidebar buttons */
      .btn-search {
        width: 100%;
        padding: 10px;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 14px;
        font-weight: bold;
        cursor: pointer;
        margin-bottom: 6px;
        transition: background 0.15s;
      }
      .btn-search:hover {
        background: #d68910;
      }
      .btn-clear {
        width: 100%;
        padding: 8px;
        background: var(--white);
        color: var(--text-muted);
        border: 1px solid var(--border);
        border-radius: 6px;
        font-size: 13px;
        cursor: pointer;
      }
      .btn-clear:hover {
        background: var(--bg);
      }

      /* ── Scroll to top button ── */
      #btn-scroll-top {
        display: none;
        position: fixed;
        bottom: 24px;
        right: 16px;
        z-index: 900;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary);
        color: #fff;
        border: none;
        font-size: 20px;
        line-height: 44px;
        text-align: center;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        opacity: 0;
        transition: opacity 0.25s;
        padding: 0;
      }
      #btn-scroll-top.visible {
        display: block;
        opacity: 1;
      }

      /* ── Results area ── */
      .results-area {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .results-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 14px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border);
      }
      .result-count {
        font-size: 13px;
        color: var(--text-muted);
      }
      .result-limit-note {
        font-size: 11px;
        color: #e67e22;
        font-weight: bold;
      }
      /* ── コストジャンプバー ── */
      .cost-jump-bar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;        /* Firefox */
        -ms-overflow-style: none;     /* IE/Edge */
        gap: 4px;
        padding: 5px 0 6px;
        margin-bottom: 10px;
        position: sticky;
        top: 0;
        background: var(--bg);
        z-index: 20;
        border-bottom: 1px solid var(--border);
      }
      .cost-jump-bar::-webkit-scrollbar {
        display: none;                /* Chrome/Safari */
      }
      .cost-jump-btn {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        border: 1.5px solid var(--border);
        background: var(--white);
        font-size: 11px;
        font-weight: bold;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text);
        transition: background 0.12s, color 0.12s, border-color 0.12s;
        user-select: none;
        flex-shrink: 0;
        touch-action: manipulation;
      }
      .cost-jump-btn:hover {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
      }
      .cost-jump-bar-label {
        font-size: 10px;
        color: var(--text-muted);
        align-self: center;
        margin-right: 2px;
        white-space: nowrap;
        font-weight: bold;
        letter-spacing: 0.5px;
        flex-shrink: 0;
      }

      .card-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
        gap: 14px;
      }
      .card-item {
        background: var(--white);
        border-radius: 8px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
        padding: 8px;
        cursor: pointer;
        transition:
          transform 0.15s,
          box-shadow 0.15s;
        position: relative;
      }
      .card-item:hover {
        transform: translateY(-4px);
        box-shadow: 0 6px 14px rgba(0, 0, 0, 0.13);
      }
      /* カード画像ラッパー（プレースホルダー用にアスペクト比固定） */
      .card-img-wrap {
        position: relative;
        width: 100%;
        aspect-ratio: 63 / 88;  /* Lorcana カード縦横比 */
        border-radius: 5px;
        overflow: hidden;
        flex-shrink: 0;
      }
      .card-image {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        border-radius: 5px;
        display: block;
        object-fit: cover;
        opacity: 0;
        transition: opacity 0.35s ease;
      }
      .card-image.loaded {
        opacity: 1;
      }
      /* プレースホルダー */
      .card-placeholder {
        position: absolute;
        inset: 0;
        border-radius: 5px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 7px;
        overflow: hidden;
      }
      .card-ph-cost {
        align-self: flex-end;
        background: rgba(0,0,0,0.45);
        color: white;
        font-size: 13px;
        font-weight: bold;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }
      .card-ph-shimmer {
        flex: 1;
        margin: 4px 0;
        border-radius: 3px;
        background: linear-gradient(
          90deg,
          rgba(255,255,255,0) 0%,
          rgba(255,255,255,0.10) 40%,
          rgba(255,255,255,0.18) 50%,
          rgba(255,255,255,0.10) 60%,
          rgba(255,255,255,0) 100%
        );
        background-size: 250% 100%;
        animation: ph-shimmer 1.6s ease-in-out infinite;
      }
      @keyframes ph-shimmer {
        0%   { background-position:  150% 0; }
        100% { background-position: -150% 0; }
      }
      .card-ph-name {
        font-size: 9px;
        color: rgba(255,255,255,0.75);
        font-weight: bold;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      /* ── 軽量モード: Lorcanaカード風レイアウト ── */
      .card-placeholder-light {
        padding: 0;
        justify-content: flex-start;
      }
      /* ヘッダー: インクドット + コスト */
      .card-ph-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 5px 6px 2px;
        flex-shrink: 0;
      }
      .card-ph-ink-row {
        display: flex;
        align-items: center;
        gap: 3px;
      }
      .card-ph-ink-dot {
        width: 9px;
        height: 9px;
        border-radius: 50%;
        border: 1.5px solid rgba(255,255,255,0.5);
        flex-shrink: 0;
      }
      .card-ph-inkable-icon {
        font-size: 9px;
        line-height: 1;
        color: rgba(255,255,255,0.8);
        margin-left: 1px;
      }
      .card-ph-inkable-no {
        color: rgba(255,255,255,0.28);
      }
      /* アート中央エリア: タイプバッジ + クラス */
      .card-ph-art {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 2px 5px;
        min-height: 0;
      }
      .card-ph-type-badge {
        color: rgba(255,255,255,0.95);
        font-size: 9px;
        font-weight: bold;
        padding: 2px 8px;
        border-radius: 10px;
        white-space: nowrap;
        letter-spacing: 0.3px;
        border: 1px solid rgba(255,255,255,0.3);
      }
      .card-ph-cls {
        font-size: 8px;
        color: rgba(255,255,255,0.65);
        text-align: center;
        line-height: 1.3;
      }
      /* ネームバナー */
      .card-ph-namebanner {
        background: rgba(0,0,0,0.55);
        padding: 3px 5px;
        text-align: center;
        flex-shrink: 0;
        backdrop-filter: blur(2px);
      }
      .card-ph-light-name {
        font-size: 9px;
        color: white;
        font-weight: bold;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.3;
      }
      .card-ph-light-subname {
        font-size: 8px;
        color: rgba(255,220,120,0.9);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
      }
      /* スタットフッター */
      .card-ph-footer {
        background: rgba(0,0,0,0.65);
        padding: 4px 6px;
        flex-shrink: 0;
        border-top: 1px solid rgba(255,255,255,0.1);
      }
      .card-ph-stats {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .card-ph-stat {
        display: flex;
        align-items: center;
        gap: 2px;
        font-size: 12px;
        font-weight: bold;
        color: white;
        min-width: 22px;
        line-height: 1;
      }
      .card-ph-stat-icon {
        font-size: 9px;
        opacity: 0.8;
      }
      .card-ph-stat-lore {
        color: #f1c40f;
        justify-content: center;
      }
      .card-ph-stat-empty {
        min-width: 22px;
      }
      .card-cost {
        position: absolute;
        top: 14px;
        left: 14px;
        background: rgba(0, 0, 0, 0.65);
        color: white;
        font-size: 12px;
        font-weight: bold;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .card-name {
        font-size: 12px;
        font-weight: bold;
        margin: 7px 0 2px;
        line-height: 1.3;
        min-height: 2.6em;   /* 最大2行分を確保 */
      }
      .card-sub {
        font-size: 10px;
        color: var(--text-muted);
        margin-bottom: 5px;
        min-height: 1.3em;   /* サブネームなしでも1行分確保 */
      }
      .badge-row {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
      }
      .badge {
        display: inline-block;
        color: white;
        font-size: 10px;
        padding: 2px 8px;
        border-radius: 10px;
        font-weight: bold;
        white-space: nowrap;
      }

      .empty-state {
        text-align: center;
        padding: 80px 20px;
        color: #bbb;
      }
      .empty-state .icon {
        font-size: 48px;
        margin-bottom: 12px;
      }
      .empty-state p {
        font-size: 15px;
      }

      /* ── Modal ── */
      .modal {
        display: none;
        position: fixed;
        z-index: 1000;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .modal-content {
        background: var(--white);
        margin: 4% auto 20px;
        padding: 28px;
        border-radius: 12px;
        width: 90%;
        max-width: 780px;
        position: relative;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
      }
      .modal-close {
        position: absolute;
        top: 14px;
        right: 18px;
        font-size: 26px;
        cursor: pointer;
        color: #bbb;
        line-height: 1;
      }
      .modal-close:hover {
        color: var(--primary);
      }
      .modal-body {
        display: flex;
        gap: 24px;
        flex-wrap: wrap;
      }
      .modal-img {
        flex: 1;
        min-width: 200px;
        max-width: 280px;
      }
      .modal-img img {
        width: 100%;
        border-radius: 8px;
      }
      .modal-info {
        flex: 2;
        min-width: 260px;
      }
      .modal-info h2 {
        font-size: 20px;
        margin-bottom: 3px;
      }
      .modal-info h3 {
        font-size: 14px;
        color: var(--text-muted);
        font-weight: normal;
        margin-bottom: 14px;
      }
      .info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        background: var(--bg);
        padding: 12px;
        border-radius: 8px;
        margin-bottom: 14px;
      }
      .info-item span {
        font-size: 10px;
        color: var(--text-muted);
        display: block;
      }
      .info-item strong {
        font-size: 14px;
        display: inline-flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
      }
      .effects-title {
        font-size: 13px;
        font-weight: bold;
        margin-bottom: 8px;
        color: var(--text-muted);
      }
      .effect-box {
        border-left: 3px solid var(--accent);
        padding: 8px 12px;
        margin-bottom: 8px;
        background: #fffbf3;
        border-radius: 0 5px 5px 0;
        font-size: 13px;
      }
      .effect-name {
        font-weight: bold;
        display: block;
        margin-bottom: 3px;
      }
      .flavor-text {
        font-style: italic;
        color: var(--text-muted);
        font-size: 12px;
        margin-top: 14px;
        padding-top: 12px;
        border-top: 1px dashed var(--border);
      }
      .en-name-display {
        font-size: 11px;
        color: var(--text-muted);
        margin-top: 6px;
      }

      /* Ink AND mode */
      @keyframes shake {
        0%,
        100% {
          transform: translateX(0);
        }
        20%,
        60% {
          transform: translateX(-4px);
        }
        40%,
        80% {
          transform: translateX(4px);
        }
      }
      .ink-btn.shake {
        animation: shake 0.3s ease;
      }
      .ink-btn.disabled {
        cursor: not-allowed;
        opacity: 0.15 !important;
      }
      /* ink-mode-row は field-mode-toggle に統合済み */

      /* ── View tabs ── */
      .view-tabs {
        display: flex;
        background: var(--primary);
        flex-shrink: 0;
      }
      .view-tab {
        flex: 1;
        padding: 8px 12px;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        color: rgba(255, 255, 255, 0.55);
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
        transition: all 0.15s;
        white-space: nowrap;
      }
      .view-tab.active {
        color: white;
        border-bottom-color: var(--accent);
      }
      .deck-badge {
        display: inline-block;
        background: var(--accent);
        color: white;
        border-radius: 10px;
        padding: 1px 6px;
        font-size: 11px;
        margin-left: 4px;
        min-width: 18px;
        text-align: center;
      }

      /* ── View slider ── */
      .view-container {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
      }
      .view-slider {
        display: flex;
        width: 400%;
        flex: 1;
        min-height: 0;
        transition: transform 0.3s ease;
      }
      .view-slider.show-deck {
        transform: translateX(-25%);
      }
      .view-slider.show-list {
        transform: translateX(-50%);
      }
      .view-slider.show-game {
        transform: translateX(-75%);
      }
      .view-search {
        width: 25%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
      }
      .view-deck {
        width: 25%;
        overflow-y: auto;
        background: var(--bg);
        min-height: 0;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .view-list {
        width: 25%;
        overflow-y: auto;
        background: var(--bg);
        min-height: 0;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .view-game {
        width: 25%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        background: var(--bg);
        min-height: 0;
        user-select: none;
        -webkit-user-select: none;
      }
      .game-scroll-body {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }

      /* ── Deck panel ── */
      .deck-panel {
        padding: 14px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        max-width: 900px;
        margin: 0 auto;
        width: 100%;
      }
      .deck-stats-bar {
        background: var(--white);
        border-radius: 8px;
        padding: 6px 10px;
        display: flex;
        align-items: stretch;
        gap: 0;
        border: 1px solid var(--border);
        overflow-x: auto;
        white-space: nowrap;
      }
      .stat-group {
        display: flex;
        gap: 6px;
        align-items: center;
        padding: 0 8px;
      }
      .stat-group:not(:last-child) {
        border-right: 1px solid var(--border);
      }
      .stat-group:first-child {
        padding-left: 0;
      }
      .stat-item {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      .stat-label {
        font-size: 8px;
        color: var(--text-muted);
        font-weight: bold;
        white-space: nowrap;
      }
      .stat-value {
        font-size: 14px;
        font-weight: bold;
        color: var(--primary);
        line-height: 1.2;
      }
      .stat-sub {
        font-size: 8px;
        color: var(--text-muted);
        white-space: nowrap;
      }
      .stat-pct {
        font-size: 8px;
        color: var(--text-muted);
      }
      .ink-color-dot {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        margin-right: 3px;
        vertical-align: middle;
      }

      /* ── Cost chart ── */
      .deck-section-title {
        font-size: 11px;
        font-weight: bold;
        letter-spacing: 0.8px;
        text-transform: uppercase;
        color: var(--text-muted);
        margin-bottom: 4px;
      }
      .deck-chart-section {
        background: var(--white);
        border-radius: 8px;
        padding: 12px 16px;
        border: 1px solid var(--border);
      }
      .chart-bars {
        display: flex;
        align-items: flex-end;
        gap: 3px;
        height: 80px;
      }
      .chart-col {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        height: 100%;
      }
      .chart-count {
        font-size: 9px;
        color: var(--primary);
        font-weight: bold;
        height: 14px;
        line-height: 14px;
      }
      .chart-bar-wrap {
        flex: 1;
        width: 100%;
        display: flex;
        align-items: flex-end;
      }
      .chart-bar {
        width: 100%;
        background: var(--primary);
        border-radius: 2px 2px 0 0;
        transition: height 0.3s ease;
      }
      .chart-bar-stacked {
        width: 100%;
        display: flex;
        flex-direction: column-reverse;
        border-radius: 2px 2px 0 0;
        overflow: hidden;
        transition: height 0.3s ease;
      }
      .chart-bar-dual-seg {
        width: 100%;
        display: flex;
        flex-direction: row;
      }
      .chart-mode-toggle {
        display: flex;
        gap: 3px;
        flex-shrink: 0;
      }
      .chart-mode-btn {
        font-size: 9px;
        padding: 2px 6px;
        border: 1px solid var(--border);
        border-radius: 3px;
        background: var(--white);
        color: var(--text-muted);
        cursor: pointer;
        line-height: 1.5;
        white-space: nowrap;
      }
      .chart-mode-btn.active {
        background: var(--primary);
        color: var(--white);
        border-color: var(--primary);
      }
      .chart-label {
        font-size: 9px;
        color: var(--text-muted);
        margin-top: 2px;
      }

      /* ── Deck card list ── */
      .deck-card-list-wrap {
        background: var(--white);
        border-radius: 8px;
        border: 1px solid var(--border);
        overflow: hidden;
      }
      .deck-list-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
        border-bottom: 1px solid var(--border);
      }
      .deck-list-item:last-child {
        border-bottom: none;
      }
      .deck-list-thumb {
        width: 30px;
        height: 42px;
        object-fit: cover;
        border-radius: 3px;
        flex-shrink: 0;
      }
      .deck-list-info {
        flex: 1;
        min-width: 0;
      }
      .deck-list-name {
        font-size: 12px;
        font-weight: bold;
        color: var(--primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .deck-list-sub {
        font-size: 10px;
        color: var(--text-muted);
      }

      /* ── Deck view mode toggle ── */
      .deck-view-toggle {
        display: flex;
        gap: 4px;
      }
      .deck-view-btn {
        padding: 3px 9px;
        font-size: 11px;
        border-radius: 4px;
        border: 1px solid var(--border);
        background: var(--white);
        color: var(--text-muted);
        cursor: pointer;
        transition: all 0.12s;
      }
      .deck-view-btn.active {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
      }

      /* ── Deck grid (image-only) ── */
      .deck-card-list-wrap.grid-mode {
        background: none;
        border: none;
      }
      #deck-card-list.grid-mode {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
        padding: 4px;
      }
      .deck-grid-item {
        position: relative;
        border-radius: 6px;
        overflow: hidden;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
      }
      .deck-grid-item img {
        width: 100%;
        display: block;
        aspect-ratio: 63/88;
        object-fit: cover;
      }
      .deck-grid-count {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.65);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 4px 2px;
      }
      .deck-grid-count .deck-ctrl-btn {
        width: 20px;
        height: 20px;
        font-size: 13px;
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.4);
        color: white;
      }
      .deck-grid-count .deck-ctrl-btn:hover {
        background: var(--accent);
        border-color: var(--accent);
      }
      .deck-grid-count .deck-ctrl-count {
        font-size: 13px;
        color: white;
        min-width: 14px;
      }

      /* ── Deck +/- controls ── */
      .deck-ctrl {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
      }
      .deck-ctrl-btn {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        border: 1.5px solid var(--border);
        background: var(--white);
        color: var(--primary);
        font-size: 15px;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        transition: all 0.12s;
        flex-shrink: 0;
      }
      .deck-ctrl-btn:hover {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
      }
      .deck-ctrl-btn.minus:hover {
        background: #e74c3c;
        border-color: #e74c3c;
      }
      .deck-ctrl-count {
        font-size: 13px;
        font-weight: bold;
        color: var(--primary);
        min-width: 16px;
        text-align: center;
      }
      .card-item-deck-ctrl {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 4px 0 2px;
        margin-top: auto;    /* 常にカード下部に固定 */
      }
      .card-item-deck-ctrl .deck-ctrl-btn {
        width: 40px;
        height: 36px;
        border-radius: 8px;
        font-size: 18px;
        line-height: 1;
      }
      .card-item-deck-ctrl .deck-ctrl-count {
        font-size: 16px;
        min-width: 20px;
      }
      /* モーダル内デッキ操作バー */
      .modal-deck-ctrl {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        background: var(--bg);
        border: 1.5px solid var(--border);
        border-radius: 10px;
        padding: 10px 16px;
        margin-bottom: 14px;
      }
      .modal-deck-ctrl .deck-ctrl-btn {
        width: 44px;
        height: 40px;
        border-radius: 8px;
        font-size: 20px;
        line-height: 1;
      }
      .modal-deck-ctrl .deck-ctrl-count {
        font-size: 20px;
        font-weight: bold;
        min-width: 28px;
        text-align: center;
      }
      .modal-deck-ctrl-label {
        font-size: 11px;
        color: var(--text-muted);
        text-align: center;
        margin-bottom: 4px;
      }
      .card-item.card-in-deck {
        outline: 2.5px solid var(--accent);
      }

      /* ── Deck actions ── */
      .deck-actions {
        display: flex;
        gap: 8px;
        padding-bottom: 20px;
      }
      .btn-send-mulligan {
        flex: 1;
        padding: 12px;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.15s;
      }
      .btn-send-mulligan:disabled {
        background: #bdc3c7;
        cursor: not-allowed;
      }
      .btn-send-mulligan:not(:disabled):hover {
        background: #d68910;
      }
      .btn-clear-deck {
        padding: 12px 16px;
        background: var(--white);
        color: #e74c3c;
        border: 1px solid #e74c3c;
        border-radius: 6px;
        font-size: 13px;
        cursor: pointer;
        transition: all 0.15s;
      }
      .btn-clear-deck:hover {
        background: #fde8e8;
      }

      /* ── Toast ── */
      #toast-container {
        position: fixed;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        z-index: 9999;
        pointer-events: none;
      }
      .toast {
        background: rgba(44, 62, 80, 0.92);
        color: white;
        padding: 10px 22px;
        border-radius: 20px;
        font-size: 13px;
        opacity: 0;
        transition: opacity 0.3s;
        white-space: nowrap;
      }
      .toast.show {
        opacity: 1;
      }

      /* ── Sidebar overlay ── */
      .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 499;
      }
      .sidebar-overlay.show {
        display: block;
      }

      /* ── Deck list view ── */
      .list-panel {
        padding: 14px;
        max-width: 960px;
        margin: 0 auto;
      }
      .list-panel-header {
        background: var(--white);
        border-radius: 8px;
        padding: 12px 16px;
        border: 1px solid var(--border);
        margin-bottom: 14px;
        position: sticky;
        top: 0;
        z-index: 50;
      }
      .deck-grid-panel {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 14px;
      }
      .deck-card-item {
        background: var(--white);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 14px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
        transition: 0.2s;
        cursor: pointer;
        overflow: hidden; /* 長いデッキ名がカードを広げないよう封じ込め */
        min-width: 0;
      }

      /* ── Deck name marquee ── */
      .deck-name-marquee-wrap {
        display: flex;
        align-items: center;
        flex: 1;
        min-width: 0;
        cursor: pointer;
        gap: 4px;
      }
      .deck-name-marquee {
        overflow: hidden;
        flex: 1;
        min-width: 0;
      }
      .deck-name-inner {
        display: inline-block;
        white-space: nowrap;
      }
      .deck-name-inner.marquee-scrolling {
        will-change: transform;
        animation: deck-name-scroll var(--marquee-duration, 6s) linear infinite;
      }
      .deck-name-inner.marquee-paused {
        animation-play-state: paused;
      }
      .deck-name-pencil {
        flex-shrink: 0;
        font-style: normal;
      }
      /* デッキ名が短くて収まる場合: marquee を内容幅に縮めて鉛筆を直後に配置 */
      .deck-name-marquee-wrap.name-fits .deck-name-marquee {
        flex: 0 0 auto;
      }
      @keyframes deck-name-scroll {
        0%, 20%   { transform: translateX(0); }
        55%, 68%  { transform: translateX(var(--marquee-tx, -60px)); }
        68.01%    { transform: translateX(0); } /* 瞬間リセット */
        100%      { transform: translateX(0); }
      }
      .deck-card-item:hover {
        border-color: var(--accent);
        transform: translateY(-2px);
      }
      .deck-card-item-title {
        font-size: 13px;
        font-weight: bold;
        color: var(--primary);
        margin: 0 0 5px;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .deck-card-item-info {
        font-size: 12px;
        color: var(--text-muted);
        margin-bottom: 10px;
      }
      .deck-card-item-actions {
        display: flex;
        gap: 6px;
      }
      .deck-thumbnails {
        display: grid;
        grid-template-columns: repeat(8, 1fr);
        gap: 3px;
        margin-bottom: 10px;
        background: linear-gradient(135deg, #f0f4ff, #fdf6ff);
        border-radius: 4px;
        padding: 3px;
        position: relative;
      }
      .deck-thumb-detail-badge {
        position: absolute;
        bottom: 6px;
        right: 6px;
        background: rgba(0, 0, 0, 0.52);
        color: #fff;
        font-size: 11px;
        line-height: 1;
        padding: 3px 7px;
        border-radius: 20px;
        pointer-events: none;
        letter-spacing: 0.3px;
      }
      .deck-thumb-wrap {
        position: relative;
      }
      .deck-thumb-img {
        width: 100%;
        aspect-ratio: 63/88;
        border-radius: 3px;
        object-fit: cover;
        display: block;
      }
      .deck-thumb-text {
        width: 100%;
        aspect-ratio: 63/88;
        border-radius: 3px;
        font-size: 7px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative;
        font-weight: bold;
        border: 1px solid rgba(0, 0, 0, 0.1);
        overflow: hidden;
        padding: 1px;
        text-align: center;
      }
      .deck-thumb-cost {
        position: absolute;
        top: 1px;
        left: 2px;
        background: rgba(0, 0, 0, 0.6);
        color: #fff;
        border-radius: 50%;
        width: 11px;
        height: 11px;
        font-size: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .deck-thumb-cost.inkable-cost {
        border: 1px solid var(--accent);
        box-shadow: 0 0 3px rgba(243, 156, 18, 0.8);
      }
      .deck-thumb-count {
        position: absolute;
        bottom: 1px;
        left: 2px;
        background: rgba(0, 0, 0, 0.65);
        color: #fff;
        font-size: 8px;
        font-weight: bold;
        line-height: 1;
        padding: 2px 3px;
        border-radius: 3px;
        pointer-events: none;
      }
      /* ── Detail view ── */
      .detail-sticky-header {
        display: flex;
        flex-direction: column;
        background: var(--white);
        border-bottom: 1px solid var(--border);
        padding: 8px 14px;
        position: sticky;
        top: 0;
        z-index: 50;
        flex-shrink: 0;
        gap: 6px;
      }
      .detail-header-row1 {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
      }
      .detail-header-title {
        font-size: 13px;
        font-weight: bold;
        color: var(--primary);
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .detail-header-btns {
        display: flex;
        gap: 6px;
      }
      .detail-header-btns .btn-sm-outline,
      .detail-header-btns .btn-sm-primary {
        flex: 1;
        padding: 6px 10px;
        font-size: 11px;
        white-space: nowrap;
      }
      .detail-stats-wrap {
        padding: 12px 14px 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
      }
      .btn-overwrite {
        flex: 1;
        padding: 12px;
        background: #2980b9;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.15s;
      }
      .btn-overwrite:disabled {
        background: #bdc3c7;
        cursor: not-allowed;
      }
      .btn-overwrite:not(:disabled):hover {
        background: #2471a3;
      }
      .detail-cards-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
        padding: 0 14px 14px;
      }
      .detail-card-wrap {
        position: relative;
        cursor: pointer;
        transition: 0.15s;
      }
      .detail-card-wrap:hover {
        transform: translateY(-3px);
      }
      .detail-count-badge {
        position: absolute;
        top: -8px;
        right: -8px;
        background: var(--accent);
        color: white;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        font-size: 12px;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;
        pointer-events: none;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
      }
      /* ── Game view ── */
      .game-inner {
        padding: 12px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
      }
      .game-top-bar {
        background: var(--white);
        border-bottom: 1px solid var(--border);
        padding: 10px 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
        flex-wrap: wrap;
        gap: 8px;
        z-index: 100;
      }
      .game-ctrl-group {
        display: flex;
        gap: 6px;
        align-items: center;
      }
      .btn-game-back {
        padding: 6px 14px;
        background: var(--white);
        color: var(--primary);
        border: 1px solid var(--border);
        border-radius: 6px;
        font-size: 12px;
        cursor: pointer;
        font-weight: bold;
      }
      .btn-game-back:hover {
        background: var(--bg);
      }
      .btn-mulligan-confirm {
        padding: 8px 16px;
        background: #27ae60;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
      }
      .btn-mulligan-confirm:hover {
        background: #219a52;
      }
      .btn-draw {
        padding: 6px 14px;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 12px;
        cursor: pointer;
        font-weight: bold;
      }
      .btn-reset-game {
        padding: 6px 14px;
        background: #e74c3c;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 12px;
        cursor: pointer;
        font-weight: bold;
      }
      /* Game layout */
      .game-layout-wrap {
        display: grid;
        grid-template-columns: 260px 1fr;
        gap: 10px;
        align-items: start;
      }
      /* インラインアクションバー（スマホのみ・手札エリアと同幅） */
      #game-action-bar-inline {
        display: none;
      }
      /* インラインバー左右切替ボタン */
      .btn-align-toggle {
        padding: 5px 10px;
        background: var(--bg);
        color: var(--text-muted);
        border: 1px solid var(--border);
        border-radius: 6px;
        font-size: 13px;
        cursor: pointer;
        flex-shrink: 0;
      }
      .btn-align-toggle:hover {
        background: var(--border);
      }
      /* Stats panel */
      .game-stats-panel {
        background: var(--white);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 12px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      /* Eval box */
      .eval-box {
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px;
        margin-bottom: 10px;
      }
      .eval-btn-row {
        display: flex;
        gap: 5px;
        margin-bottom: 7px;
      }
      .eval-btn {
        flex: 1;
        padding: 8px;
        font-size: 16px;
        border-radius: 6px;
        border: none;
        cursor: pointer;
        font-weight: bold;
        color: white;
      }
      .eval-btn-good {
        background: #27ae60;
      }
      .eval-btn-okay {
        background: var(--text-muted);
      }
      .eval-btn-bad {
        background: #e74c3c;
      }
      .eval-result-row {
        display: flex;
        justify-content: space-between;
        font-size: 11px;
        font-weight: bold;
        background: var(--white);
        padding: 7px;
        border-radius: 6px;
      }
      /* Prob table */
      .prob-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 11px;
      }
      .prob-table th {
        text-align: right;
        padding: 3px;
        color: var(--text-muted);
        font-size: 10px;
        border-bottom: 1px solid var(--border);
      }
      .prob-table td {
        padding: 5px 3px;
        border-bottom: 1px solid var(--border);
      }
      .prob-val {
        background: var(--primary-bg);
        color: var(--primary);
        padding: 2px 5px;
        border-radius: 4px;
        font-weight: bold;
        display: inline-block;
        min-width: 38px;
        text-align: center;
      }

      /* Field area */
      .field-area-wrap {
        display: grid;
        grid-template-rows: 1fr 190px;
        gap: 8px;
        height: 480px;
      }
      .upper-zones {
        display: grid;
        grid-template-columns: 130px 130px 1fr;
        gap: 6px;
        height: 100%;
      }
      /* Zone */
      .zone {
        background: var(--white);
        border: 1px solid var(--border);
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
      .zone-header {
        background: var(--header-bg);
        padding: 5px 10px;
        font-size: 11px;
        font-weight: bold;
        border-bottom: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        flex-shrink: 0;
      }
      .zone-content {
        flex: 1;
        padding: 6px;
        overflow-y: auto;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        align-content: flex-start;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .hand-scroll {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        align-items: center;
        scrollbar-width: thin;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      /* Game cards */
      .card {
        position: relative;
        cursor: pointer;
        border: 2px solid var(--border);
        background: var(--white);
        flex-shrink: 0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        border-radius: 7px;
        transition:
          border 0.1s,
          box-shadow 0.1s,
          transform 0.1s,
          opacity 0.1s;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
      /* ゾーンの再描画範囲を封じ込める */
      .zone {
      }
      .card-size-normal {
        width: 88px;
        height: 122px;
      }
      .card-size-normal .card-cost {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: 4px;
        left: 4px;
      }
      .card-size-normal .card-body {
        padding: 24px 4px 4px;
      }
      .card-size-normal .card-name {
        font-size: 9px !important;
        margin: 0 !important;
        max-height: 2.8em;
        line-height: 1.2 !important;
      }
      .card-size-normal .card-type {
        font-size: 7px;
      }
      .card-size-normal .card-stats {
        font-size: 9px;
        bottom: 3px;
        left: 5px;
        right: 5px;
      }
      .card-size-detail {
        width: 100%;
        height: 100%;
        min-height: 90px;
      }
      .card-size-detail .card-cost {
        width: 22px;
        height: 22px;
        font-size: 11px;
        top: 5px;
        left: 5px;
      }
      .card-size-detail .card-body {
        padding: 28px 4px 4px;
      }
      .card-size-detail .card-name {
        font-size: 10px !important;
        margin: 0 !important;
        max-height: 2.8em;
        line-height: 1.2 !important;
      }
      .card-size-detail .card-type {
        font-size: 8px;
      }
      .card-size-detail .card-stats {
        font-size: 9px;
        bottom: 4px;
        left: 5px;
        right: 5px;
      }
      .card-size-modal {
        width: 180px;
        height: 252px;
        border-radius: 10px;
        border-width: 3px;
        flex-shrink: 0;
      }
      .card-size-modal .card-cost {
        width: 36px;
        height: 36px;
        font-size: 18px;
        top: 9px;
        left: 9px;
      }
      .card-size-modal .card-body {
        padding: 45px 8px 8px;
      }
      .card-size-modal .card-name {
        font-size: 17px !important;
        margin: 0 !important;
        max-height: 2.4em;
        line-height: 1.2 !important;
      }
      .card-size-modal .card-type {
        font-size: 12px;
        margin-bottom: 3px;
      }
      .card-size-modal .card-stats {
        font-size: 14px;
        bottom: 9px;
        left: 10px;
        right: 10px;
      }
      .card-cost {
        position: absolute;
        background: rgba(0, 0, 0, 0.75);
        color: #fff;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        border: 1px solid rgba(255, 255, 255, 0.5);
      }
      .inkable-cost {
        border-color: var(--accent) !important;
        border-width: 2px !important;
        box-shadow: 0 0 5px rgba(243, 156, 18, 0.7);
      }
      .card-body {
        text-align: center;
        width: 100%;
      }
      .card-name {
        font-weight: bold;
        line-height: 1.2;
        overflow: hidden;
      }
      .card-type {
        opacity: 0.75;
        font-weight: bold;
        text-transform: uppercase;
      }
      .card-stats {
        position: absolute;
        display: flex;
        justify-content: space-between;
        font-weight: bold;
      }
      .card-back {
        background: repeating-linear-gradient(
          45deg,
          #444,
          #444 10px,
          #333 10px,
          #333 20px
        ) !important;
        border-color: #222 !important;
      }
      .card-back * {
        display: none !important;
      }
      .card.img-mode {
        border: 2px solid transparent;
        background: transparent;
        padding: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
      }
      .card.img-mode img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
        border-radius: inherit;
      }
      .card.selected {
        border: 3px solid var(--accent) !important;
        box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.4) !important;
        transform: translateY(-6px);
        z-index: 10;
      }
      .card.moving {
        border: 3px solid var(--accent) !important;
        box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.4) !important;
        z-index: 15;
        opacity: 0.8;
      }
      /* Card color gradients */
      .color-purple {
        background: linear-gradient(135deg, #f3e8ff, #d8b4fe) !important;
        color: #1e293b !important;
      }
      .color-red {
        background: linear-gradient(135deg, #fee2e2, #fca5a5) !important;
        color: #1e293b !important;
      }
      .color-blue {
        background: linear-gradient(135deg, #e0f2fe, #7dd3fc) !important;
        color: #1e293b !important;
      }
      .color-yellow {
        background: linear-gradient(135deg, #fefce8, #fde047) !important;
        color: #1e293b !important;
      }
      .color-green {
        background: linear-gradient(135deg, #f0fdf4, #86efac) !important;
        color: #1e293b !important;
      }
      .color-steel {
        background: linear-gradient(135deg, #f8fafc, #cbd5e1) !important;
        color: #1e293b !important;
      }
      /* Game card modal */
      .game-modal-overlay {
        display: none;
        position: fixed;
        z-index: 2000;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(3px);
      }
      .game-modal-overlay.active {
        display: flex;
      }
      .game-modal-content {
        background: var(--white);
        border-radius: 12px;
        padding: 24px;
        max-width: 700px;
        width: 92%;
        position: relative;
        display: flex;
        gap: 20px;
        flex-wrap: wrap;
        box-shadow: 0 20px 30px rgba(0, 0, 0, 0.3);
        border: 1px solid var(--border);
        max-height: 92vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }
      .game-modal-close {
        position: absolute;
        top: 12px;
        right: 16px;
        font-size: 26px;
        cursor: pointer;
        color: #bbb;
        line-height: 1;
      }
      .game-modal-close:hover {
        color: var(--primary);
      }
      /* Btn helpers for game/list */
      .btn-sm-primary {
        padding: 7px 14px;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 12px;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.15s;
      }
      .btn-sm-primary:hover {
        background: #d68910;
      }
      .btn-sm-danger {
        padding: 7px 14px;
        background: #e74c3c;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 12px;
        font-weight: bold;
        cursor: pointer;
      }
      .btn-sm-danger:hover {
        background: #c0392b;
      }
      .btn-sm-outline {
        padding: 7px 14px;
        background: var(--white);
        color: var(--primary);
        border: 1px solid var(--border);
        border-radius: 6px;
        font-size: 12px;
        cursor: pointer;
      }
      .btn-sm-outline:hover {
        background: var(--bg);
      }
      .btn-sm-outline.deck-invalid-btn {
        opacity: 0.45;
        cursor: not-allowed;
      }
      .deck-invalid-badge {
        display: inline-block;
        background: #e74c3c;
        color: #fff;
        font-size: 10px;
        font-weight: bold;
        padding: 1px 5px;
        border-radius: 4px;
        margin-left: 6px;
        vertical-align: middle;
        line-height: 1.5;
      }
      /* ── Mobile ── */
      .mobile-toggle {
        display: none;
        width: 100%;
        padding: 10px;
        background: var(--accent);
        color: white;
        border: none;
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
        flex-shrink: 0;
      }
      @media (max-width: 760px) {
        .mobile-toggle {
          display: block;
        }
        .sidebar {
          position: fixed;
          top: 0;
          left: 0;
          height: 100%;
          z-index: 500;
          transform: translateX(-100%);
          transition: transform 0.25s;
          box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
        }
        .sidebar.open {
          transform: translateX(0);
        }
        .layout {
          display: block;
          overflow: visible;
        }
        .view-search {
          overflow-y: auto;
          overflow-x: hidden;
          overscroll-behavior: none;
        }
        .results-area {
          overflow: visible;
          flex: unset;
        }
        /* ── Game view mobile ── */
        .view-game {
        }
        .game-inner {
          padding: 8px;
          gap: 8px;
          width: 100%;
          overflow-x: hidden;
          box-sizing: border-box;
        }
        .game-top-bar {
          padding: 8px 10px;
          gap: 6px;
        }
        .btn-game-back {
          font-size: 11px;
          padding: 5px 10px;
        }
        .btn-mulligan-confirm {
          font-size: 12px;
          padding: 6px 12px;
        }
        .btn-draw,
        .btn-reset-game {
          font-size: 11px;
          padding: 5px 10px;
        }
        .game-layout-wrap {
          display: flex;
          flex-direction: column;
        }
        #field-area-container {
          order: 1;
          min-width: 0;
          width: 100%;
        }
        /* ヘッダーのゲームコントロールはスマホでは非表示（インラインバーに移動） */
        #header-game-ctrl {
          display: none;
        }
        /* インラインアクションバー: 3列グリッド（左スロット | 中央トグル | 右スロット） */
        #game-action-bar-inline {
          display: grid;
          grid-template-columns: 1fr auto 1fr;
          align-items: center;
          gap: 40px;
          background: var(--white);
          border: 1px solid var(--border);
          border-radius: 8px;
          padding: 8px 12px;
          margin-top: 6px;
        }
        /* 左スロット: 右寄せ、右スロット: 左寄せ */
        .inline-slot {
          display: flex;
          align-items: center;
          gap: 6px;
        }
        #inline-slot-left  { justify-content: flex-end; }
        #inline-slot-right { justify-content: flex-start; }
        /* インラインバー内のドロー・リセットボタンを同幅（リセット基準） */
        #inline-slot-left  .btn-draw,
        #inline-slot-left  .btn-reset-game,
        #inline-slot-right .btn-draw,
        #inline-slot-right .btn-reset-game {
          min-width: 5.5em;
          text-align: center;
        }
        #stats-panel-container {
          order: 3;
          margin-top: 8px;
          min-width: 0;
        }
        .field-area-wrap {
          height: 324px;
          grid-template-rows: 209px 107px;
          width: 100%;
          min-width: 0;
        }
        .upper-zones {
          display: grid;
          grid-template-columns: 63px 63px 1fr;
          height: 209px;
          min-width: 0;
          gap: 4px;
        }
        #discard-zone .zone-content,
        #cost-zone .zone-content {
          flex-wrap: wrap;
          overflow-y: auto;
          overflow-x: hidden;
        }
        #main-zone .zone-content {
          flex-wrap: wrap;
          overflow-x: hidden;
          overflow-y: auto;
          align-content: flex-start;
        }
        /* カードサイズ（53px×73px の 0.9倍） */
        .card-size-normal {
          width: 48px;
          height: 66px;
        }
        .card-size-normal .card-cost {
          width: 14px;
          height: 14px;
          font-size: 8px;
          top: 2px;
          left: 2px;
        }
        .card-size-normal .card-body {
          padding: 18px 2px 2px;
        }
        .card-size-normal .card-name {
          font-size: 7px !important;
        }
        .card-size-normal .card-type {
          font-size: 6px;
        }
        .card-size-normal .card-stats {
          font-size: 7px;
          bottom: 2px;
          left: 3px;
          right: 3px;
        }
        /* デッキ一覧モバイル */
        .list-panel {
          padding: 8px;
        }
        .list-panel-header {
          padding: 10px;
        }
        .deck-grid-panel {
          grid-template-columns: 1fr;
        }
        .detail-cards-grid {
          grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
          gap: 10px;
          padding: 0 8px 14px;
        }
      }