* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo UI', sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 1.5rem;
    /* 2.5rem * 0.6 = 1.5rem */
    color: #2c3e50;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.title-icon {
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
}

/* タブスタイル */
.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    background: white;
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    color: #666;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background-color: #e8f4f8;
    color: #2c3e50;
}

.tab-button.active {
    background-color: #3498db;
    color: white;
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

/* コンテンツエリア */
.content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.category-content {
    display: none;
}

.category-content.active {
    display: block;
}

/* 選択コントロール */
.selection-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 20px 0;
    border-top: 2px solid #f0f0f0;
    border-bottom: 2px solid #f0f0f0;
}

.global-select-btn {
    padding: 12px 24px;
    border: 2px solid #FD7E14;
    background: #FFFFFF;
    color: #CC5500;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.global-select-btn:hover {
    background: linear-gradient(135deg, #FFD1A3, #FFB366);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(253, 126, 20, 0.3);
}

.global-select-btn.clear-mode {
    background: linear-gradient(135deg, #FF8C00, #FF7F00);
    border-color: #FF4500;
    color: #FFFFFF;
}

.global-select-btn.clear-mode:hover {
    background: linear-gradient(135deg, #FF7F00, #FF4500);
    box-shadow: 0 2px 8px rgba(255, 69, 0, 0.3);
}

.category-select-btn {
    padding: 12px 24px;
    border: 2px solid #FFC107;
    background: #FFFFFF;
    color: #856404;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.category-select-btn:hover {
    background: linear-gradient(135deg, #FFEAA7, #FFD93D);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.category-select-btn.clear-mode {
    background: linear-gradient(135deg, #FFD700, #FFC107);
    border-color: #FF8C00;
    color: #FFFFFF;
}

.category-select-btn.clear-mode:hover {
    background: linear-gradient(135deg, #FFC107, #FF8C00);
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.3);
}

/* 単語グリッド */
.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.word-button {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #E6F3FF, #D1E7FF);
    color: #2c3e50;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo UI', sans-serif;
    text-align: center;
    transition: all 0.3s ease;
    user-select: none;
}

.word-button:hover {
    background: linear-gradient(135deg, #D1E7FF, #B8D4FF);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.word-button.selected {
    background: linear-gradient(135deg, #87CEEB, #98D8E8);
    color: #2c3e50;
    border: 1.5px solid #000000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* コントロールパネル */
.controls {
    padding-top: 25px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 20px;
}

/* 絵の種類・絵の大きさの行を表示カード枚数の行に近づける */
.control-row:nth-child(2) {
    margin-top: -15px;
    margin-bottom: 5px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-group label {
    font-weight: normal;
    color: #2c3e50;
    font-size: 1.1rem;
    min-width: 120px;
    flex-shrink: 0;
}

.card-count-buttons,
.image-type-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.count-btn,
.type-btn {
    padding: 10px 16px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.count-btn {
    background: linear-gradient(135deg, #FFE5F1, #FFD1E3);
    color: #C2185B;
}

.count-btn:hover {
    background: linear-gradient(135deg, #FFD1E3, #FFB8D1);
    transform: translateY(-1px);
}

.count-btn.active {
    background: linear-gradient(135deg, #E91E63, #C2185B);
    color: white;
    border-color: #E91E63;
}

.type-btn {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    color: #D97706;
}

.type-btn:hover {
    background: linear-gradient(135deg, #FDE68A, #FCD34D);
    transform: translateY(-1px);
}

.type-btn.active {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    border-color: #F59E0B;
}

/* サイズボタンスタイル */
.size-btn {
    padding: 10px 16px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 50px;
    text-align: center;
}

.size-btn:hover {
    transform: translateY(-1px);
}

/* 小サイズボタン */
.size-btn[data-size="small"] {
    background: linear-gradient(135deg, #E8F5E8, #C8E6C9);
    color: #388E3C;
    border-color: #C8E6C9;
}

.size-btn[data-size="small"]:hover {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
}

.size-btn[data-size="small"].active {
    background: linear-gradient(135deg, #66BB6A, #4CAF50);
    color: white;
    border-color: #66BB6A;
}

/* 中サイズボタン */
.size-btn[data-size="medium"] {
    background: linear-gradient(135deg, #E8F5E8, #C8E6C9);
    color: #388E3C;
    border-color: #C8E6C9;
}

.size-btn[data-size="medium"]:hover {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
}

.size-btn[data-size="medium"].active {
    background: linear-gradient(135deg, #66BB6A, #4CAF50);
    color: white;
    border-color: #66BB6A;
}

/* 大サイズボタン */
.size-btn[data-size="large"] {
    background: linear-gradient(135deg, #E8F5E8, #C8E6C9);
    color: #388E3C;
    border-color: #C8E6C9;
}

.size-btn[data-size="large"]:hover {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
}

.size-btn[data-size="large"].active {
    background: linear-gradient(135deg, #66BB6A, #4CAF50);
    color: white;
    border-color: #66BB6A;
}

.selected-count {
    font-size: 1.1rem;
    font-weight: normal;
    color: #2c3e50;
    text-align: center;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selected-count #selected-count {
    color: #e74c3c;
    font-weight: bold;
}

.selected-count #selected-count::after {
    content: " 語";
    color: #e74c3c;
    font-weight: bold;
}

.display-cards-btn {
    padding: 15px 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    aspect-ratio: 1;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
}

.display-cards-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1f5f8b);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.display-cards-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.2rem;
        /* 2rem * 0.6 = 1.2rem */
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1 1 50%;
        font-size: 0.9rem;
        padding: 12px 8px;
    }

    .word-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .word-button {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .control-row {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .control-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .control-group label {
        min-width: auto;
    }

    .selected-count,
    .display-cards-btn {
        width: 100px;
        height: 100px;
        aspect-ratio: 1;
        justify-content: center;
    }

    .display-cards-btn {
        font-size: 0.8rem;
    }

    .card-count-buttons,
    .image-type-buttons {
        justify-content: center;
    }

    .count-btn,
    .type-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .size-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

}

@media (max-width: 480px) {
    .word-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .word-button {
        padding: 8px 10px;
        font-size: 0.7rem;
    }

    .tab-button {
        flex: 1 1 100%;
    }
}