* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to bottom, #d4c5b0 0%, #e8dcc8 50%, #d4c5b0 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.02) 2px,
            rgba(0,0,0,0.02) 4px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.02) 2px,
            rgba(0,0,0,0.02) 4px
        );
    pointer-events: none;
    z-index: 1;
}

body > * {
    position: relative;
    z-index: 2;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(139, 115, 85, 0.1);
    padding: 50px;
    max-width: 1000px;
    width: 100%;
    backdrop-filter: blur(10px);
}

h1 {
    text-align: center;
    color: #5a4a3a;
    margin-bottom: 40px;
    font-size: 32px;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    position: relative;
    padding-bottom: 20px;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 2px;
    background: linear-gradient(to right, transparent, #8b7355, transparent);
}

.input-section {
    margin-bottom: 30px;
}

label {
    display: block;
    margin-bottom: 12px;
    color: #5a4a3a;
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

input[type="text"],
input[type="file"] {
    width: 100%;
    padding: 14px;
    border: 1px solid #d4c5b0;
    border-radius: 2px;
    font-size: 14px;
    transition: all 0.3s;
    background: #fefefe;
}

input[type="text"]:focus,
input[type="file"]:focus {
    outline: none;
    border-color: #8b7355;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.1);
}

input[type="file"] {
    cursor: pointer;
}

.upload-area {
    border: 2px dashed #a0886f;
    border-radius: 2px;
    padding: 50px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    background: #f8f6f0;
    margin-bottom: 15px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.upload-area:hover {
    border-color: #8b7355;
    background: #ffffff;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.08);
}

.upload-area.dragover {
    border-color: #8b7355;
    background: #f5f1e8;
    transform: scale(1.01);
    box-shadow: inset 0 2px 16px rgba(139, 115, 85, 0.15);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.upload-text {
    color: #666;
    font-size: 16px;
    margin-bottom: 10px;
}

.upload-hint {
    color: #999;
    font-size: 14px;
}

.camera-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #8b7355 0%, #6d5d4b 100%);
    color: #f5f1e8;
    border: 2px solid #8b7355;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.camera-btn:hover {
    background: linear-gradient(135deg, #6d5d4b 0%, #5a4a3a 100%);
    color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#fileInput {
    display: none;
}

#cameraInput {
    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: 2px;
    border: 1px solid #d4c5b0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.change-image-btn {
    margin-top: 15px;
    width: auto;
    padding: 12px 24px;
    background: linear-gradient(135deg, #a0886f 0%, #8b7355 100%);
    font-size: 13px;
    border: 2px solid #a0886f;
}

.reset-btn {
    width: auto;
    padding: 16px 32px;
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    color: #ffffff;
    border: 2px solid #9e9e9e;
    border-radius: 2px;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.reset-btn:hover {
    background: linear-gradient(135deg, #757575 0%, #616161 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #8b7355 0%, #6d5d4b 100%);
    color: #f5f1e8;
    border: 2px solid #8b7355;
    border-radius: 2px;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

button:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d5d4b 0%, #5a4a3a 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    color: #ffffff;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #d4c5b0;
    border-color: #c4b5a0;
    color: #a0a0a0;
}

.result-section {
    margin-top: 60px;
    display: none;
    text-align: center;
    position: relative;
    padding-top: 40px;
}

.result-section h2 {
    color: #5a4a3a;
    margin-bottom: 50px;
    font-size: 26px;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-family: 'Georgia', serif;
}

.artwork-container {
    display: inline-block;
    position: relative;
}

#resultImage {
    max-width: 100%;
    max-height: 600px;
    display: block;
    margin: 0 auto;
    /* 額縁のスタイル */
    padding: 50px;
    background: linear-gradient(135deg, #f8f6f0 0%, #ffffff 50%, #f8f6f0 100%);
    border: 5px solid #8b7355;
    box-shadow: 
        /* 内側の影 - 深い額縁 */
        inset 0 0 0 3px #d4c5b0,
        inset 0 0 0 8px #8b7355,
        inset 0 0 0 10px #a0886f,
        inset 0 0 0 16px #f5f1e8,
        inset 0 0 20px rgba(0, 0, 0, 0.1),
        /* 外側の立体的な影 */
        0 3px 6px rgba(0, 0, 0, 0.1),
        0 6px 12px rgba(0, 0, 0, 0.1),
        0 12px 24px rgba(0, 0, 0, 0.12),
        0 24px 48px rgba(0, 0, 0, 0.18),
        /* 額縁の立体感と光沢 */
        -10px -10px 20px rgba(255, 255, 255, 0.4),
        10px 10px 20px rgba(0, 0, 0, 0.25);
    border-radius: 2px;
    position: relative;
}

/* 額縁の装飾的な角 */
#resultImage::before,
#resultImage::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #6d5d4b;
    opacity: 0.6;
}

#resultImage::before {
    top: 15px;
    left: 15px;
    border-right: none;
    border-bottom: none;
}

#resultImage::after {
    bottom: 15px;
    right: 15px;
    border-left: none;
    border-top: none;
}

/* 作品説明プレート */
.artwork-plate {
    background: linear-gradient(135deg, #f5f1e8 0%, #ffffff 100%);
    border: 1px solid #d4c5b0;
    border-radius: 2px;
    padding: 20px 30px;
    margin-top: 30px;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

.plate-title {
    font-size: 18px;
    font-weight: 500;
    color: #5a4a3a;
    margin-bottom: 8px;
    font-family: 'Georgia', serif;
    letter-spacing: 1px;
}

.title-loading {
    color: #8b7355;
    font-style: italic;
    font-size: 16px;
    animation: titlePulse 1.5s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.plate-subtitle {
    font-size: 14px;
    color: #8b7355;
    font-style: italic;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.plate-year {
    font-size: 13px;
    color: #a0886f;
    letter-spacing: 1px;
    border-top: 1px solid #e0d5c5;
    padding-top: 10px;
}

/* ギャラリーライト効果 */
.result-section::before {
    content: '';
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 150px;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.loading {
    text-align: center;
    color: #8b7355;
    font-weight: 300;
    font-size: 16px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 30px;
    display: none;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.error {
    background: linear-gradient(135deg, #f8f6f0 0%, #ffe8e8 100%);
    color: #8b4545;
    padding: 24px;
    border-radius: 2px;
    margin-top: 30px;
    display: none;
    border: 1px solid #d4a5a5;
    border-left: 4px solid #a05555;
    box-shadow: 0 4px 12px rgba(139, 69, 69, 0.1);
    font-size: 14px;
    line-height: 1.8;
    letter-spacing: 0.5px;
}

/* カメラモーダル */
.camera-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.camera-modal.active {
    display: flex;
}

.camera-modal-content {
    background: white;
    border-radius: 20px;
    padding: 20px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.camera-header h2 {
    color: #333;
    font-size: 24px;
    margin: 0;
}

.close-btn {
    background: #ff5252;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
    padding: 0;
}

.close-btn:hover {
    background: #ff1744;
}

#cameraVideo {
    width: 100%;
    max-height: 60vh;
    border-radius: 12px;
    background: #000;
    display: block;
}

.camera-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.capture-btn,
.switch-btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.capture-btn {
    background: #4CAF50;
    color: white;
}

.capture-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.switch-btn {
    background: #2196F3;
    color: white;
}

.switch-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
}

/* ダウンロードボタン */
.download-btn {
    width: auto;
    max-width: 400px;
    padding: 16px 32px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: #ffffff;
    border: 2px solid #4CAF50;
    border-radius: 2px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
    margin: 0 auto;
    display: block;
}

.download-btn:hover {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(76, 175, 80, 0.4);
}

.download-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}
