
:root {
    --bg-color: #f0f2f5;
    --container-bg: white;
    --text-color: #333;
    --heading-color: #4a4a4a;
    --subtext-color: #6c757d;
    --button-bg: #007bff;
    --button-hover: #0056b3;
    --display-bg: #f8f9fa;
    --display-border: #e9ecef;
    --display-text: #495057;
    --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --heading-color: #ffffff;
    --subtext-color: #b0b0b0;
    --button-bg: #375a7f;
    --button-hover: #2b4764;
    --display-bg: #3d3d3d;
    --display-border: #444;
    --display-text: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Gothic A1', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    background: var(--container-bg);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 25px var(--shadow);
    max-width: 500px;
    width: 90%;
    position: relative;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

h1 {
    color: var(--heading-color);
    margin-bottom: 0.5rem;
}

p {
    color: var(--subtext-color);
    margin-bottom: 2rem;
}

#fortune-button {
    background-color: var(--button-bg);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}

#fortune-button:disabled {
    background-color: var(--subtext-color);
    cursor: default;
    box-shadow: none;
    transform: none;
}

#fortune-button:hover:not(:disabled) {
    background-color: var(--button-hover);
    transform: translateY(-2px);
}

#fortune-button:active:not(:disabled) {
    transform: translateY(1px);
}

.streak-badge {
    background: #ffec99;
    color: #856404;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 1rem;
    box-shadow: 0 2px 5px var(--shadow);
}

[data-theme="dark"] .streak-badge {
    background: #4a4220;
    color: #ffd700;
}

.fortune-card {
    background: var(--display-bg);
    border: 1px solid var(--display-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: center;
    box-shadow: 0 4px 15px var(--shadow);
    animation: fadeIn 0.5s ease-out;
}

.fortune-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    color: var(--heading-color);
}

.fortune-card p {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.lucky-items {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--subtext-color);
}

.lucky-items b {
    color: var(--button-bg);
}

.share-button {
    background: transparent;
    border: 1px solid var(--button-bg);
    color: var(--button-bg);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-button:hover {
    background: var(--button-bg);
    color: white;
}

.contact-section {
    margin-top: 3rem;
    text-align: left;
}

.contact-section hr {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), var(--display-border), rgba(0, 0, 0, 0));
    margin-bottom: 2rem;
}

.contact-section h3 {
    text-align: center;
    color: var(--heading-color);
    margin-bottom: 1.5rem;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--display-border);
    border-radius: 8px;
    background-color: var(--display-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--button-bg);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.file-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-label {
    display: inline-block;
    padding: 10px 15px;
    background-color: var(--display-bg);
    border: 1px dashed var(--display-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.3s ease;
    color: var(--subtext-color);
}

.file-label:hover {
    border-color: var(--button-bg);
    color: var(--button-bg);
}

.file-input {
    display: none;
}

.file-name {
    font-size: 0.8rem;
    color: var(--subtext-color);
    text-align: center;
    word-break: break-all;
}

.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1rem;
    width: 100%;
    min-height: 0;
    transition: min-height 0.3s ease;
}

.preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    aspect-ratio: 1/1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    background: var(--display-bg);
    animation: fadeIn 0.3s ease-out;
    /* 더 부드러운 가속도 곡선 적용 */
    transition: 
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
        opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
        width 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
        margin 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-item.removing {
    opacity: 0;
    transform: scale(0);
    width: 0 !important;
    margin-right: -10px !important; /* gap 크기만큼 음수 마진을 주어 완벽히 밀착 */
    margin-left: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    pointer-events: none;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-photo-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: background 0.2s ease;
}

.remove-photo-btn:hover {
    background: #dc3545;
}

.submit-button {
    background-color: var(--button-bg);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.submit-button:disabled {
    background-color: var(--subtext-color);
    cursor: not-allowed;
    transform: none;
}

.form-status {
    margin-top: 1rem;
    padding: 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    text-align: center;
    display: none;
}

.form-status.success {
    display: block;
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid #28a745;
}

.form-status.error {
    display: block;
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid #dc3545;
}

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

@media (max-width: 480px) {
    .container {
        padding: 1.5rem;
    }
    h1 {
        font-size: 1.8rem;
    }
    #fortune-button {
        padding: 12px 25px;
    }
}
