/* リセットとベース */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --border-color: #dee2e6;
    --bg-light: #f8f9fa;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.header h2 {
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.subtitle a {
    color: white;
    text-decoration: underline;
    font-size: 18px;
    transition: opacity 0.3s ease;
}

.subtitle a:hover { text-decoration: none; }

/* ステップセクション */
.step {
    display: none;
    padding: 40px 20px;
    animation: fadeIn 0.3s ease-in;
}

.step.active {
    display: block;
}

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

.step h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: #333;
    text-align: center;
}

/* フレームグリッド */
.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.frame-item {
    position: relative;
    border: 3px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    background: var(--bg-light);
}

.frame-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.frame-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.frame-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.frame-item .checkmark {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.frame-item.selected .checkmark {
    display: flex;
}

/* アップロードエリア */
.upload-area {
    margin-bottom: 24px;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 40px 20px;
    background: var(--bg-light);
}

.upload-label:hover {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
}

.upload-label.drag-over {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.1);
}

.upload-label svg {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.upload-label p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 0.9rem !important;
    color: #999 !important;
}

/* エディター */
.editor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.canvas-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--bg-light);
}

#canvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: move;
}

.controls {
    width: 100%;
    max-width: 500px;
}

.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #555;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-controls input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.zoom-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.zoom-controls input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.zoom-controls input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.zoom-controls input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.hint {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin-top: 8px;
}

/* 結果表示 */
.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

#resultImage {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.result-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ボタン */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--bg-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--border-color);
}

.btn-icon svg {
    color: var(--primary-color);
}

.button-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* フッター */
.footer {
    text-align: center;
    padding: 24px;
    background: var(--bg-light);
    color: #666;
    font-size: 0.9rem;
}

/* レスポンシブ */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 12px;
    }

    .header {
        padding: 24px 16px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .step {
        padding: 24px 16px;
    }

    .frames-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }

    .btn {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .result-actions {
        flex-direction: column;
        width: 100%;
    }

    .result-actions .btn {
        width: 100%;
    }
}



