/* リセット */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html {
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    padding: 16px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ヘッダー */
.header {
    margin-bottom: 12px;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.header h1 {
    font-family: 'Segoe UI', 'Helvetica Neue', 'Noto Sans JP', sans-serif;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: #ffffff;
    margin: 0;
}

/* ティア選択 */
.tier-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    justify-content: center;
}

.tier-selector label {
    font-size: 16px;
    color: #b0b0b0;
}

.tier-selector select {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tier-selector select:hover {
    border-color: #4a4a4a;
    background-color: #2f2f2f;
}

.features-btn {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    touch-action: manipulation;
}

.features-btn:hover {
    border-color: #22c55e;
    background-color: #2f3a2a;
    color: #22c55e;
}

.last-updated {
    font-size: 12px;
    color: #f59e0b;
    white-space: nowrap;
    font-weight: 500;
}

.clear-btn {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.clear-btn:hover {
    border-color: #ef4444;
    background-color: #3a2a2a;
    color: #ef4444;
}


/* タブ（SP版のみ） */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid #3a3a3a;
}

.tabs-container.hidden {
    display: none;
}

.tab-button {
    padding: 12px 16px;
    background-color: transparent;
    color: #b0b0b0;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.tab-button.active {
    color: #e0e0e0;
    border-bottom-color: #22c55e;
}

.tab-button:hover {
    color: #e0e0e0;
}

/* グリッドレイアウト */
.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 24px;
}

.character-card {
    background-color: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.character-card.hidden {
    display: none;
}

/* キャラクター名ヘッダー */
.character-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #3a3a3a;
    margin-bottom: 16px;
}

.character-name {
    font-size: 14px;
    color: #b0b0b0;
    white-space: nowrap;
    flex-shrink: 0;
}

.character-name-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.character-name-input-container {
    flex: 1;
    position: relative;
    min-width: 0;
}

.character-name-input {
    width: 100%;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 8px;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    -webkit-user-select: text;
    user-select: text;
}

.character-name-input:focus {
    outline: none;
    border-color: #4a4a4a;
    background-color: #2f2f2f;
}

.character-name-input::placeholder {
    color: #666;
}

.character-name-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-top: -1px;
}

.character-name-dropdown.hidden {
    display: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #3a3a3a;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #323232;
}

.dropdown-item-text {
    flex: 1;
    color: #e0e0e0;
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: transparent;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    flex-shrink: 0;
    margin-left: 8px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.dropdown-item-delete:hover {
    color: #ef4444;
    background-color: #3a3a3a;
    border-radius: 2px;
}

.character-name-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: transparent;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
    touch-action: manipulation;
}

.character-name-clear-btn:hover {
    color: #e0e0e0;
    background-color: #3a3a3a;
}

.character-name-clear-btn svg {
    display: block;
}

/* カード入力エリア */
.card-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    flex: 1;
}

.card-input-row {
    display: grid;
    grid-template-columns: 1fr 120px 60px;
    align-items: center;
    gap: 12px;
}

.card-label {
    font-size: 12px;
    color: #b0b0b0;
}

.card-input-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    overflow: hidden;
    width: 120px;
}

.card-input-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: transparent;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.card-input-btn:hover:not(:disabled) {
    background-color: #3a3a3a;
}

.card-input-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.card-input-value {
    width: 48px;
    background-color: transparent;
    color: #e0e0e0;
    text-align: center;
    border: none;
    font-size: 14px;
    padding: 4px;
    -webkit-user-select: text;
    user-select: text;
}

.card-input-value:focus {
    outline: none;
}

.card-multiplier {
    font-size: 12px;
    color: #b0b0b0;
    width: 60px;
    text-align: right;
}

.removal-value {
    width: 48px;
    text-align: center;
    color: #e0e0e0;
    font-size: 14px;
}

.next-value {
    font-size: 12px;
    color: #b0b0b0;
    white-space: nowrap;
    width: 60px;
    text-align: right;
    font-weight: 500;
}

/* カード削除関連 */
.card-removal-btn {
    padding: 8px 16px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.card-removal-btn:hover {
    background-color: #2f2f2f;
    border-color: #4a4a4a;
}

.card-removal-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.next-removal-text {
    font-size: 12px;
    color: #e0e0e0;
}

.next-removal-max {
    color: #b0b0b0;
    font-size: 12px;
}

/* 合計セクション */
.total-section {
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #3a3a3a;
}

.total-row:last-child {
    border-bottom: none;
}

.total-label {
    color: #e0e0e0;
    font-weight: 500;
    font-size: 14px;
}

.total-value {
    color: #22c55e;
    font-weight: 600;
    font-size: 16px;
}

.total-value.exceeded {
    color: #ef4444;
}

.limit-label {
    color: #b0b0b0;
    font-size: 12px;
}

.limit-value {
    color: #e0e0e0;
    font-weight: 500;
}

/* リセットボタン */
.reset-button {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: transparent;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.reset-btn:hover {
    color: #e0e0e0;
    background-color: #3a3a3a;
}

/* その他のツール */
.other-tools {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #3a3a3a;
}

.other-tools h3 {
    font-size: 14px;
    color: #b0b0b0;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.other-tools ul {
    list-style: none;
}

.other-tools li {
    margin-bottom: 8px;
}

.other-tools a {
    color: #22c55e;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
    padding: 4px 0;
    display: inline-block;
    font-weight: 600;
}

.other-tools a:hover {
    color: #4ade80;
    text-decoration: underline;
}

.reference-note {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #3a3a3a;
    font-size: 12px;
    color: #b0b0b0;
    line-height: 1.6;
}

.reference-note a {
    color: #b0b0b0;
    text-decoration: underline;
}

.reference-note a:hover {
    color: #d0d0d0;
}

/* レスポンシブ：SP版 */
@media (max-width: 768px) {
    .characters-grid {
        display: block;
    }

    .character-card {
        display: none;
    }

    .character-card.active {
        display: flex;
    }

    .tabs-container {
        display: flex;
    }

    .header-content {
        justify-content: center;
        gap: 8px;
    }

    .header h1 {
        font-size: 18px;
        flex: 0 1 auto;
    }

    .features-btn {
        font-size: 12px;
        padding: 6px 12px;
        flex-shrink: 0;
    }

    .last-updated {
        font-size: 10px;
    }

    .card-multiplier {
        width: auto;
    }
}

/* PC版：複数カラムを並べる */
@media (min-width: 769px) {
    .tabs-container {
        display: none !important;
    }

    .character-card {
        display: flex !important;
    }

    .characters-grid {
        grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    }
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-in-out;
}

.modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-in-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #3a3a3a;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #e0e0e0;
    font-weight: 500;
}

.modal-close {
    background-color: transparent;
    border: none;
    color: #b0b0b0;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #e0e0e0;
}

.modal-body {
    padding: 20px;
}

.features-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.feature-item {
    margin-bottom: 16px;
}

.feature-text {
    width: 100%;
}

.feature-text h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #e0e0e0;
    font-weight: 600;
}

.feature-text p {
    margin: 0;
    font-size: 14px;
    color: #b0b0b0;
    line-height: 1.5;
}

/* レスポンシブ：SP版モーダル */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .feature-text h3 {
        font-size: 14px;
    }

    .feature-text p {
        font-size: 12px;
    }
}
