@font-face {
    font-family: 'Reggae One';
    src: url('ReggaeOne-Regular.ttf') format('truetype');
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: #f4f4f9;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

h1 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin: 10px 0;
    text-align: center;
    flex-shrink: 0;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    gap: 10px;
    padding: 0 15px; 
}

.flex-spacer { 
    flex-grow: 1; 
    min-width: 10px;
}

#generator-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    gap: 0;
    margin: 0;
}

#canvas-area {
    flex-shrink: 0;
    width: 100%;
    background-color: #e0e0e0;
    padding: 10px;
    box-sizing: border-box;
    text-align: center;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#canvas-area h2 { display: none; }

#statusCanvas {
    max-width: 100%;
    max-height: 30vh;
    width: auto;
    height: auto;
    display: inline-block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.canvas-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#saveLocalBtn, #downloadBtn {
    flex: 1;
    margin: 0;
    padding: 10px 5px;
    font-size: 0.9rem;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#saveLocalBtn { background-color: #27ae60; }
#saveLocalBtn:hover { background-color: #219150; }

#downloadBtn { background-color: #e74c3c; }
#downloadBtn:hover { background-color: #c0392b; }

#input-controls {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    padding-bottom: 80px;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

#input-controls h2 { margin-top: 20px; font-size: 1.1rem; border-bottom: 2px solid #eee; padding-bottom: 5px; }
#input-controls h3 { font-size: 1rem; margin-top: 15px; margin-bottom: 5px; }

#input-controls label {
    display: block;
    margin-bottom: 5px;
    width: 100%;
    box-sizing: border-box;
    font-weight: bold;
    color: #555;
    margin-top: 10px;
}

#input-controls input[type="text"],
#input-controls input[type="number"],
#input-controls select {
    display: block;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 10px;
    font-size: 16px; 
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
}

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: inner-spin-button !important;
    opacity: 1 !important;
    display: block !important;
    height: auto;
    margin-left: 5px;
}

#input-controls input[type="file"] {
    margin-bottom: 15px;
    padding: 10px 0;
}

.select-group {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    margin-top: 5px;
    margin-bottom: 15px;
    padding: 5px 2px 10px 2px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.select-group::-webkit-scrollbar { height: 4px; }
.select-group::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }
.select-group input[type="radio"] { display: none; }

#input-controls .select-group label {
    display: flex;
    flex-shrink: 0;
    border: 2px solid transparent;
    background-color: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 2px;
    box-sizing: border-box;
    box-shadow: none;  
    margin-top: 0;
    font-weight: normal;
}

.select-group label img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.select-group input[type="radio"]:checked + label {
    background-color: #eaf4fd !important;
    border-color: #3498db !important;   
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.6) !important;
    transform: scale(1.1);
}

.select-group input[type="radio"]:checked + label img {
    opacity: 1.0;
    filter: none;
}

.text-btn-group {
    justify-content: flex-start;
    gap: 15px;
    padding: 10px;
}

#input-controls .text-btn-group label {
    width: auto;
    min-width: 80px;
    height: auto;
    border: 2px solid #ddd;
    background-color: #fff;
    border-radius: 8px;
    padding: 10px 0;
    font-size: 15px;
    color: #555;
    text-align: center;
    opacity: 0.8;
    transition: all 0.2s ease;
    margin-top: 0;
    cursor: pointer;
}

.text-btn-group input[type="radio"]:checked + label {
    background-color: #eaf4fd !important;
    color: #1f618d !important;
    border: 2px solid #3498db !important;
    opacity: 1 !important;
    transform: scale(1.05);
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5) !important;
    font-weight: bold;
}

#attributeSelect,
#luckSkillSelect {
    justify-content: space-between;
    padding-left: 25px;   
    padding-right: 25px;  
}

#numberSelect {
    justify-content: center;
    gap: 30px;
    padding-left: 0;
}

#mainComboAttributeSelect,
#subComboAttributeSelect {
    justify-content: space-between;
    gap: 0;
    padding-left: 2px;
    padding-right: 2px;
}

.pos-size-group {
    margin-bottom: 15px;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 4px;
    background-color: #fafafa;
}
.pos-size-group .pos-row,
.pos-size-group .size-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.pos-size-group span { font-size: 0.9rem; white-space: nowrap; font-weight: bold;}
.pos-size-group input[type="number"] { width: 100%; text-align: center; margin-bottom: 0; }

.color-setting-group { display: flex; align-items: center; margin-bottom: 10px; gap: 10px; background: #eee; padding: 5px; border-radius: 4px;}
.color-setting-group label { width: auto; margin: 0; font-size: 0.9rem; }
.color-setting-group input[type="color"] { width: 40px; height: 30px; border: none; padding: 0; margin-bottom: 0;}

#tribeBtn { background-color: #f39c12; color: white; padding: 12px; width: auto; border: none; border-radius: 6px; margin-top: 5px; cursor: pointer; font-size: 14px;}
#tribeInput { display: inline-block; width: calc(100% - 110px) !important; margin-right: 5px; background-color: #f9f9f9; }

.ss-input-group { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.ss-input-group input { width: 80px !important; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); padding-top: 60px; }
.modal-content { background-color: #fefefe; margin: 5% auto; padding: 20px; width: 90%; max-width: 400px; border-radius: 8px; }
.close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.tribe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 15px; }
.tribe-grid button { padding: 12px; background-color: #3498db; color: white; border: none; border-radius: 4px; font-size: 0.9rem;}

#ability-controls { border: 1px solid #ddd; padding: 10px; border-radius: 4px; margin-bottom: 10px; }
.ability-item { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; }

#input-controls .ability-item label {
    width: auto;
    font-size: 0.9rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    border: none;
    background: none;
    height: 46px;
    padding: 0;
    color: #333;
}

.ability-item input[type="checkbox"] {
    transform: scale(1.6);
    margin: 0 6px 0 2px;
    cursor: pointer;
}

.ability-item input[type="text"] {
    flex-grow: 1;
    margin: 0;
    height: 46px;
    padding: 0 10px;
    box-sizing: border-box;
}

.ability-item button {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
    height: 46px;
    font-size: 1.2rem;
    margin: 0;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.add-btn { background-color: #2ecc71; color: white; border: none; padding: 12px; width: 100%; border-radius: 4px; margin-top: 5px; font-size: 1rem; cursor: pointer;}

.reset-btn { 
    background-color: #95a5a6; 
    color: white; 
    padding: 10px; 
    width: 100%; 
    border: none; 
    border-radius: 4px; 
    margin-top: 10px; 
    font-size: 0.9rem; 
    cursor: pointer;
    transition: background-color 0.2s;
}
.reset-btn:hover { background-color: #7f8c8d; }

#helpBtn {
    padding: 5px 10px;
    font-size: 0.8rem;
    background-color: #5abdff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

#helpModal ul { padding-left: 20px; }
#helpModal li { margin-bottom: 8px; font-size: 0.95rem; }
#helpModal h4 { margin-top: 15px; font-size: 1.05rem; color: #2c3e50; }

/* 保存・読込用スタイル */
#ioTextarea:focus { outline: 2px solid #3498db; }
#openSaveLoadBtn:hover { background-color: #2980b9; }

/* 過去データリストのコンテナ */
#historyListContainer {
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px;
    margin-top: 10px;
}

details summary {
    padding: 5px 0;
    user-select: none;
    transition: color 0.2s;
}
details summary:hover {
    color: #3498db !important;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    background: #fff;
    transition: background 0.2s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background-color: #f9f9f9; }

.history-name {
    flex-grow: 1;
    cursor: pointer;
    font-weight: bold;
    color: #2c3e50;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.history-name:hover { color: #3498db; text-decoration: underline; }

.history-delete {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 5px;
    margin-left: 10px;
}
.history-delete:hover { color: #c0392b; transform: scale(1.1); }

@media (min-width: 1024px) {
    body { overflow: auto; display: block; }
    #generator-area {
        flex-direction: row; align-items: flex-start; overflow: visible; gap: 30px; padding: 20px; max-width: 1200px; margin: 0 auto;
    }
    #canvas-area {
        position: sticky; top: 20px; width: 50%; max-width: 600px; background: none; padding: 0; box-shadow: none;
    }
    #statusCanvas { max-height: none; width: 100%; }
    #input-controls {
        width: 50%; max-height: 90vh; padding-bottom: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    h1 { 
        padding: 20px 20px 0; 
        margin: 20px auto; 
        max-width: 1200px;
    }
    
    .canvas-buttons { display: flex; width: 100%; margin: 10px 0; }
    #saveLocalBtn, #downloadBtn { width: auto; display: block; }
}

/* ゲージトグルボタン */
.gauge-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #ccc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0 6px 0 2px;
    background-color: white;
    flex-shrink: 0;
    box-sizing: border-box;
    transition: all 0.2s;
}
.gauge-toggle.active {
    border: none;
    background-image: url('ability_gauge.png');
    background-size: cover;
    background-position: center;
    background-color: transparent;
}

/* 並び替え用の◻︎ボタン */
.sort-box {
    width: 30px;
    height: 30px;
    border: 2px solid #999;
    background-color: white;
    color: #333;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 5px;
    border-radius: 4px;
    user-select: none;
    flex-shrink: 0;
    box-sizing: border-box;
}
.sort-box.selected {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
}
.sort-box.disabled {
    background-color: #eee;
    cursor: not-allowed;
    border-color: #ccc;
    color: #aaa;
}
/* アビリティ用カスタムドロップダウンのスタイル */
.ability-input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    height: 46px;
}
.ability-input-wrapper input[type="text"] {
    width: 100%;
    margin: 0;
    height: 100%;
    box-sizing: border-box;
}
.suggest-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    z-index: 999;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    display: none;
    padding: 0;
    margin: 0;
    list-style: none;
    border-radius: 0 0 4px 4px;
}
.suggest-list li {
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}
.suggest-list li:last-child {
    border-bottom: none;
}
.suggest-list li:hover {
    background-color: #eaf4fd;
}