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

body {
    font-family: 'Zen Maru Gothic', sans-serif;
    background: white;
    min-height: 100vh;
    padding: 20px;
}

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

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

header h1 {
    color: #333;
    font-size: 1.8rem;
    font-weight: 400;
    text-shadow: none;
}

/* トグルボタン */
.toggle-buttons {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 30px;
    background: #e8e8e8;
    border-radius: 25px;
    padding: 4px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.toggle-btn {
    padding: 10px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    background: transparent;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.toggle-btn:hover {
    color: #333;
}

.toggle-btn.active {
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 作成エリア */
.creator-section {
    background: white;
    margin-bottom: 40px;
}

.canvas-wrapper {
    position: relative;
    width: 400px;
    height: 400px;
    margin: 0 auto 30px;
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

#baseImage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

#drawingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

.drawing-hint {
    text-align: center;
    color: #666;
    font-size: 1rem;
    margin: 15px 0 10px;
}

/* 葉っぱ選択パネル */
.leaf-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.leaf-option {
    width: 50px;
    height: 50px;
    object-fit: contain;
    cursor: pointer;
    border-radius: 8px;
    border: 3px solid transparent;
    background: #f5f5f5;
    padding: 5px;
    transition: all 0.2s ease;
}

.leaf-option:hover {
    border-color: #ccc;
    transform: scale(1.1);
}

.leaf-option.selected {
    border-color: #606258;
    background: #e8e8e8;
}

/* コントロール */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: #333;
}

.control-group label {
    font-weight: 600;
}

#penSize {
    width: 200px;
}

#penSizeValue {
    font-weight: bold;
    color: #666;
    min-width: 30px;
    text-align: right;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 100px;
}

.btn {
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: white;
    color: black;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: #f5f5f5;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

#clearBtn {
    font-size: 1.8rem;
}

/* アップロードボタン */
.upload-group {
    margin-top: 20px;
    text-align: center;
}

.btn-upload {
    background: transparent;
    color: #888;
    border: 2px dashed #ccc;
    box-shadow: none;
    font-size: 0.9rem;
    padding: 10px 20px;
}

.btn-upload:hover {
    background: #f9f9f9;
    border-color: #999;
    color: #666;
    box-shadow: none;
}

/* ギャラリー */
.gallery-section {
    background: white;
    margin-bottom: 40px;
}

.gallery-section h2 {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 20px;
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    min-height: 100px;
}

.gallery-item {
    position: relative;
    border-radius: 10px;
    overflow: visible;
    background: white;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
}

.gallery-item .delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.gallery-item:hover .delete-btn {
    display: flex;
}

.gallery-item .delete-btn:hover {
    background: rgba(255, 0, 0, 1);
}

.character-tooltip {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: black;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.gallery-item:hover .character-tooltip {
    opacity: 1;
}

.gallery-empty {
    text-align: center;
    color: #999;
    font-size: 1.2rem;
    padding: 40px;
    grid-column: 1 / -1;
}

/* わらわらアニメーション */
.animation-section {
    background: white;
    margin-top: 300px;
    margin-bottom: 40px;
    width: 100%;
}

.animation-section h2 {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 20px;
    text-align: center;
}

#animationCanvas {
    width: 100%;
    height: 400px;
    background: white;
    cursor: pointer;
    display: block;
}

/* 落下アニメーション用 */
.falling-character {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    transition: none;
}

@keyframes fallAndShrink {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--fall-x), var(--fall-y)) scale(0.2);
        opacity: 1;
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .canvas-wrapper {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    #drawingCanvas {
        width: 100%;
        height: 100%;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}
