* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f4e4c1 0%, #e8d5b7 50%, #d4b896 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    background-image: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(139, 69, 19, 0.06) 40px,
            rgba(139, 69, 19, 0.06) 80px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 10px,
            rgba(193, 120, 23, 0.03) 10px,
            rgba(193, 120, 23, 0.03) 20px
        );
}

body > * {
    position: relative;
    z-index: 2;
}

.container {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(101, 67, 33, 0.2),
        0 0 0 1px rgba(139, 69, 19, 0.1);
    padding: 50px;
    max-width: 900px;
    width: 100%;
    backdrop-filter: blur(10px);
    border: 3px solid #d4a574;
}

h1 {
    text-align: center;
    color: #654321;
    margin-bottom: 15px;
    font-size: 36px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(139, 69, 19, 0.1);
}

.description {
    text-align: center;
    color: #8b6f47;
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.6;
}

.info-message {
    text-align: center;
    color: #c17817;
    margin-bottom: 30px;
    font-size: 14px;
    padding: 12px;
    background: #fff9f0;
    border-radius: 8px;
    border: 2px solid #d4a574;
}

.input-section {
    margin-bottom: 30px;
}

label {
    display: block;
    margin-bottom: 12px;
    color: #654321;
    font-weight: 600;
    font-size: 14px;
}

input[type="text"],
input[type="file"] {
    width: 100%;
    padding: 14px;
    border: 2px solid #d4a574;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    background: #fffef9;
}

input[type="text"]:focus,
input[type="file"]:focus {
    outline: none;
    border-color: #c17817;
    box-shadow: 0 0 0 3px rgba(193, 120, 23, 0.1);
}

input[type="file"] {
    cursor: pointer;
}

.upload-area {
    border: 3px dashed #d4a574;
    border-radius: 12px;
    padding: 50px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    background: linear-gradient(135deg, #fff9f0 0%, #fef5e7 100%);
    margin-bottom: 15px;
}

.upload-area:hover {
    border-color: #c17817;
    background: #ffffff;
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(193, 120, 23, 0.15);
}

.upload-area.dragover {
    border-color: #c17817;
    background: #fff5e6;
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(193, 120, 23, 0.2);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.upload-text {
    color: #654321;
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: 500;
}

.upload-hint {
    color: #8b6f47;
    font-size: 14px;
}

.camera-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #d4a574 0%, #c17817 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(193, 120, 23, 0.2);
}

.camera-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(193, 120, 23, 0.3);
    background: linear-gradient(135deg, #c17817 0%, #a0610f 100%);
}

#fileInput {
    display: none;
}

.preview-section {
    margin-bottom: 20px;
    text-align: center;
}

#preview {
    max-width: 100%;
    max-height: 300px;
    display: none;
    margin: 20px auto 0 auto;
    border-radius: 12px;
    border: 3px solid #d4a574;
    box-shadow: 0 4px 12px rgba(101, 67, 33, 0.15);
}

.preview-section .error {
    display: none;
    background: #ffe5e5;
    color: #a0522d;
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 15px;
    margin-bottom: 10px;
    border: 2px solid #d2691e;
    font-weight: 500;
    font-size: 14px;
}

.change-image-btn {
    margin-top: 15px;
    width: auto;
    padding: 12px 24px;
    background: linear-gradient(135deg, #a0886f 0%, #8b7355 100%);
    font-size: 13px;
    border: none;
}

.reset-btn {
    width: auto;
    padding: 16px 32px;
    background: linear-gradient(135deg, #d2691e 0%, #a0522d 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(210, 105, 30, 0.3);
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(210, 105, 30, 0.4);
}

button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #d4a574 0%, #c17817 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(193, 120, 23, 0.3);
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(193, 120, 23, 0.4);
    background: linear-gradient(135deg, #c17817 0%, #a0610f 100%);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #cccccc;
    transform: none;
}

.loading {
    display: none;
    text-align: center;
    margin-top: 30px;
    color: #c17817;
    font-size: 18px;
    font-weight: 600;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.result-section {
    margin-top: 60px;
    display: none;
    text-align: center;
    position: relative;
    padding-top: 40px;
    border-top: 2px solid #d4a574;
}

.result-section h2 {
    color: #654321;
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: 700;
}

.result-container {
    display: inline-block;
    position: relative;
    max-width: 100%;
}

#resultImage {
    max-width: 100%;
    max-height: 600px;
    display: block;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(101, 67, 33, 0.2);
    border: 3px solid #d4a574;
}

.download-btn {
    margin-top: 20px;
    width: auto;
    padding: 14px 32px;
    background: linear-gradient(135deg, #87a96b 0%, #6b8e4e 100%);
    box-shadow: 0 4px 12px rgba(107, 142, 78, 0.3);
}

.download-btn:hover {
    box-shadow: 0 6px 20px rgba(107, 142, 78, 0.4);
    background: linear-gradient(135deg, #6b8e4e 0%, #5a7c3e 100%);
}

/* カメラモーダル */
.camera-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.camera-modal.active {
    display: flex;
}

.camera-modal-content {
    background: white;
    border-radius: 16px;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.camera-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.close-btn {
    background: #d2691e;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s;
}

.close-btn:hover {
    background: #a0522d;
    transform: rotate(90deg);
}

#cameraVideo {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.camera-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.capture-btn,
.switch-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    width: auto;
}

.capture-btn {
    background: linear-gradient(135deg, #d4a574 0%, #c17817 100%);
    color: white;
}

.switch-btn {
    background: linear-gradient(135deg, #a0886f 0%, #8b7355 100%);
    color: white;
}

.capture-btn:hover,
.switch-btn:hover {
    transform: translateY(-2px);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .container {
        padding: 30px 20px;
    }

    h1 {
        font-size: 28px;
    }

    .upload-area {
        padding: 30px 20px;
    }

    .camera-modal-content {
        padding: 15px;
    }
}
