/* デッキビルダー専用スタイル（既存 style.css の雰囲気に合わせた配色） */

:root {
    --c-red: #ef4444;
    --c-purple: #a855f7;
    --c-green: #22c55e;
    --c-white: #e5e7eb;
    --c-yellow: #eab308;
    --c-blue: #3b82f6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    background: #1a1d2b;
    color: #e8e8f0;
}

.hidden {
    display: none !important;
}

button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: #4a6cd4;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}

button:hover {
    background: #5d7de0;
}

button.danger {
    background: #d44a4a;
}

button.danger:hover {
    background: #e05d5d;
}

input[type="text"] {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1d2b;
    color: #e8e8f0;
    font-size: 13px;
}

/* ---- ヘッダー ---- */

#topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: #242838;
}

#topbar h1 {
    margin: 0;
    font-size: 18px;
}

#topbar-note {
    font-size: 12px;
    color: #b8bdd4;
}

#lobby-link {
    margin-left: auto;
    color: #7fd4ff;
    font-size: 13px;
    text-decoration: none;
}

#lobby-link:hover {
    text-decoration: underline;
}

/* ---- 2ペインレイアウト ---- */

#builder {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    height: calc(100vh - 46px);
}

#pool-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 8px;
}

#deck-pane {
    width: 400px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    background: #20243266;
    border-radius: 10px;
    padding: 10px;
}

@media (max-width: 960px) {
    #builder {
        flex-direction: column;
        height: auto;
    }

    #pool-pane {
        min-height: 60vh;
    }

    #deck-pane {
        width: auto;
    }
}

/* ---- フィルタ ---- */

#filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: #242838;
    border-radius: 10px;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 12px;
    color: #b8bdd4;
}

.family-select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1d2b;
    color: #e8e8f0;
    font-size: 13px;
    outline: none;
}

.family-select:focus {
    border-color: #4a6cd4;
}

.chip-group {
    display: flex;
    gap: 4px;
}

.chip {
    background: #2c3044;
    color: #cdd2e8;
    border: 1px solid #555;
    padding: 4px 10px;
    font-size: 12px;
}

.chip:hover {
    background: #3a4059;
}

.chip.active {
    background: #4a6cd4;
    border-color: #7fa0ff;
    color: #fff;
}

.chip-red.active {
    background: #a43a32;
    border-color: #d4564a;
}

.chip-purple.active {
    background: #6e34a0;
    border-color: #9a4ad4;
}

.chip-green.active {
    background: #2f7a3a;
    border-color: #4ad45e;
}

.chip-white.active {
    background: #8a8fa8;
    border-color: #d8dcef;
    color: #1a1d2b;
}

.chip-yellow.active {
    background: #b09a2a;
    border-color: #e8cf4a;
    color: #1a1d2b;
}

.chip-blue.active {
    background: #2f4aa0;
    border-color: #4a6cd4;
}

#search-input {
    width: 180px;
}

#filter-reset {
    background: #3a4059;
}

#filter-reset:hover {
    background: #4a5170;
}

#pool-count {
    margin-left: auto;
    font-size: 12px;
    color: #b8bdd4;
}

/* ---- カードプール ---- */

#pool-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    align-content: start;
    padding: 6px;
}

.pool-card {
    position: relative;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.2) 100%);
    padding: 12px 8px 8px 14px;
    cursor: pointer;
    user-select: none;
    overflow: visible;
    transition: transform 0.1s;
}

/* カラー枠（多色カードは斜めに2色分割） */
.pool-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--c-main, #555) 50%, var(--c-sub, #555) 50%);
    z-index: -1;
}

.pool-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(30, 32, 44, 0.95) 0%, #14161f 100%);
    z-index: -1;
}

.pool-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.pool-card .name {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 4px;
    padding-right: 40px;
    padding-left: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pool-card .info {
    font-size: 11px;
    color: #cdd2e8;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.reduction-icons {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 2px;
}

.reduction-label {
    font-size: 10px;
    color: #8a90ac;
}

.reduction-icons .sym-icon {
    width: 12px;
    height: 12px;
}

.pool-card.limited {
    opacity: 0.55;
    cursor: not-allowed;
}

.limited-mark {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: #d44a4a;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 4px;
}

.count-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ffd968;
    color: #1a1d2b;
    font-size: 11px;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 10px;
    z-index: 10;
}

.add-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    padding: 0;
    line-height: 1;
    font-size: 16px;
    border-radius: 50%;
}

.sym-icon {
    position: relative;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
    border: none;
    vertical-align: middle;
}
.sym-icon.bg-red { background-image: url('/imgs/symbols/red_symbol.png'); }
.sym-icon.bg-purple { background-image: url('/imgs/symbols/violet_symbol.png'); }
.sym-icon.bg-green { background-image: url('/imgs/symbols/green_symbol.png'); }
.sym-icon.bg-white { background-image: url('/imgs/symbols/white_symbol.png'); }
.sym-icon.bg-yellow { background-image: url('/imgs/symbols/yellow_symbol.png'); }
.sym-icon.bg-blue { background-image: url('/imgs/symbols/blue_symbol.png'); }

.cost-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1e293b;
    border: 2px solid #475569;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    z-index: 10;
}

/* ---- カード種別コストアイコン（バトスピ物理カード準拠） ---- */
/* スピリット: 丸（デフォルト） — 変更なし */

/* ネクサス: 六角形 */
.cost-badge.cost-nexus,
.row-cost.cost-nexus {
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: #475569;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.cost-badge.cost-nexus::before,
.row-cost.cost-nexus::before {
    content: '';
    position: absolute;
    inset: 2px;
    background: #1e293b;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: -1;
}

.cost-badge.cost-nexus {
    width: 28px;
    height: 28px;
    top: -6px;
    left: -6px;
}

.row-cost.cost-nexus {
    width: 24px;
    height: 24px;
    line-height: 24px;
}

/* ブレイヴ: 菱形の角を削った八角形（縦横は同じ長さ。スピリットの丸と見分けが付くように） */
.cost-badge.cost-brave,
.row-cost.cost-brave {
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: #475569;
    clip-path: polygon(38% 3%, 62% 3%, 97% 38%, 97% 62%, 62% 97%, 38% 97%, 3% 62%, 3% 38%);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* 内側を暗くして「縁取り」に見せる（ネクサスの六角形と同じ作り） */
.cost-badge.cost-brave::before,
.row-cost.cost-brave::before {
    content: '';
    position: absolute;
    inset: 2px;
    background: #1e293b;
    clip-path: polygon(38% 3%, 62% 3%, 97% 38%, 97% 62%, 62% 97%, 38% 97%, 3% 62%, 3% 38%);
    z-index: -1;
}

/* 丸より一回り大きく取る（八角形は角が落ちるぶん小さく見えるため） */
.cost-badge.cost-brave {
    width: 30px;
    height: 30px;
    top: -7px;
    left: -7px;
}

.row-cost.cost-brave {
    width: 26px;
    height: 26px;
    line-height: 26px;
}

/* マジック: 二重菱形（角と辺をずらして重ねた2枚のひし形） */
.cost-badge.cost-magic,
.row-cost.cost-magic {
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.cost-badge.cost-magic {
    width: 28px;
    height: 28px;
    top: -6px;
    left: -6px;
}

.row-cost.cost-magic {
    width: 24px;
    height: 24px;
    line-height: 24px;
}

.cost-badge.cost-magic::before,
.cost-badge.cost-magic::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    background: #1e293b;
    border: 1.5px solid #475569;
    z-index: -1;
}

.cost-badge.cost-magic::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cost-badge.cost-magic::after {
    transform: translate(-50%, -50%) rotate(0deg);
}

.row-cost.cost-magic::before,
.row-cost.cost-magic::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    background: #1e293b;
    border: 1.5px solid #475569;
    z-index: -1;
}

.row-cost.cost-magic::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.row-cost.cost-magic::after {
    transform: translate(-50%, -50%) rotate(0deg);
}

/* モバイル（ホバー不可端末）ではさらにタップ領域を拡大 */
@media (hover: none) {
    .add-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* ---- カード詳細 ---- */

#detail-panel {
    position: fixed;
    z-index: 200;
    width: 340px;
    max-height: 70vh;
    overflow-y: auto;
    background: #14161fF0;
    border: 1px solid #3a4059;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    transition: opacity 0.12s ease;
}

#detail-panel.hidden {
    opacity: 0;
    visibility: hidden;
}

.detail-placeholder {
    margin: 0;
    color: #6a7090;
}

.detail-title {
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 4px;
}

.detail-meta {
    color: #b8bdd4;
    margin-bottom: 6px;
}

.detail-effect {
    white-space: pre-wrap;
    line-height: 1.6;
    color: #cdd2e8;
}

/* ---- デッキ面 ---- */

#deck-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

#deck-name-input {
    flex: 1;
}

#deck-count {
    font-size: 16px;
    font-weight: bold;
}

#deck-count.valid {
    color: #6ee06e;
}

#deck-count.invalid {
    color: #ffd968;
}

#deck-validation {
    font-size: 12px;
}

.validation-ok {
    color: #6ee06e;
}

.validation-error {
    color: #ff8888;
}

.validation-warning {
    color: #ffd968;
}

#deck-list {
    background: #14161f;
    border-radius: 8px;
    padding: 6px;
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
}

.deck-empty,
.saved-empty {
    margin: 8px;
    font-size: 12px;
    color: #6a7090;
}

.deck-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-left: 4px solid #555;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 12px;
    background: #20243266;
    cursor: pointer;
}

.deck-row:hover {
    background: #2c3044;
}

.deck-row {
    border-left-color: transparent;
    border-image: linear-gradient(to bottom, var(--c-main, #333), var(--c-sub, #333)) 1 0 0 1;
}

.row-cost {
    position: relative;
    width: 22px;
    height: 22px;
    line-height: 18px; /* adjusting for 2px border */
    text-align: center;
    background: #1e293b;
    border: 2px solid #475569;
    border-radius: 50%;
    font-weight: bold;
    flex-shrink: 0;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    font-size: 11px;
}

.row-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-type {
    color: #8a90ac;
    font-size: 11px;
}

.row-count {
    font-weight: bold;
    color: #ffd968;
}

.row-minus {
    width: 36px;
    height: 36px;
    padding: 0;
    line-height: 1;
    font-size: 16px;
    background: #d44a4a;
    border-radius: 50%;
    flex-shrink: 0;
}

.row-minus:hover {
    background: #e05d5d;
}

/* モバイル（ホバー不可端末）ではさらにタップ領域を拡大 */
@media (hover: none) {
    .row-minus {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* ---- 統計 ---- */

#deck-stats h2,
#deck-io h2 {
    margin: 4px 0;
    font-size: 14px;
    color: #ffd968;
}

.stats-block h3 {
    margin: 4px 0;
    font-size: 12px;
    color: #b8bdd4;
}

.stats-columns {
    display: flex;
    gap: 16px;
}

.stats-columns .stats-block {
    flex: 1;
}

.curve-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin-bottom: 2px;
}

.curve-label {
    width: 22px;
    text-align: right;
    color: #b8bdd4;
}

.curve-track {
    flex: 1;
    height: 10px;
    background: #14161f;
    border-radius: 5px;
    overflow: hidden;
}

.curve-bar {
    height: 100%;
    background: #4a6cd4;
    border-radius: 5px;
    transition: width 0.15s;
}

.curve-value {
    width: 20px;
    color: #cdd2e8;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    margin-bottom: 2px;
}

.stat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-red {
    background: #d4564a;
}

.dot-purple {
    background: #9a4ad4;
}

.dot-green {
    background: #4ad45e;
}

.dot-white {
    background: #d8dcef;
}

/* ---- 保存・書き出し ---- */

.io-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.io-label {
    font-size: 12px;
    color: #b8bdd4;
}

#saved-decks {
    background: #14161f;
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 6px;
    max-height: 140px;
    overflow-y: auto;
}

.saved-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    font-size: 12px;
}

.saved-info {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-badge {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    margin: 0 4px;
}

.saved-badge.valid {
    background: #2f7a3a;
    color: #fff;
}

.saved-badge.invalid {
    background: #ffd968;
    color: #1a1d2b;
}

.saved-row button {
    padding: 3px 8px;
    font-size: 11px;
}

#import-file {
    display: none;
}

#import-label {
    padding: 6px 12px;
    border-radius: 6px;
    background: #4a6cd4;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}

#import-label:hover {
    background: #5d7de0;
}

#import-result {
    font-size: 12px;
    background: #14161f;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 6px;
}

.import-error-head {
    color: #ff8888;
    font-weight: bold;
    margin-bottom: 4px;
}

.preset-btn {
    border: 1px solid #555;
    background: #2c3044;
}

.preset-btn.chip-red {
    background: #a43a32;
}

.preset-btn.chip-purple {
    background: #6e34a0;
}

.preset-btn.chip-green {
    background: #2f7a3a;
}

.preset-btn.chip-white {
    background: #8a8fa8;
    color: #1a1d2b;
}

.preset-btn.chip-yellow {
    background: #b09a2a;
    color: #1a1d2b;
}

.preset-btn.chip-blue {
    background: #2f4aa0;
}

/* ---- トースト ---- */

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #242838;
    border: 1px solid #4a6cd4;
    color: #e8e8f0;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* ---- アクセシビリティ: モーション低減設定を尊重 ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Note Badge ---- */
.note-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: bold;
    color: #fff;
    pointer-events: none;
    z-index: 10;
}
.note-badge.unimplemented { background: #d44a4a; }
.note-badge.partial { background: #d48a4a; }
.note-badge.simplified { background: #d4c44a; color: #333; }

.detail-note {
    margin-top: 8px;
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
}
.detail-note.unimplemented { background: rgba(212, 74, 74, 0.2); border: 1px solid #d44a4a; }
.detail-note.partial { background: rgba(212, 138, 74, 0.2); border: 1px solid #d48a4a; }
.detail-note.simplified { background: rgba(212, 196, 74, 0.2); border: 1px solid #d4c44a; }

.row-note {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: bold;
    color: #fff;
    margin-left: 4px;
}
.row-note.unimplemented { background: #d44a4a; }
.row-note.partial { background: #d48a4a; }
.row-note.simplified { background: #d4c44a; color: #333; }
