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

body {
    font-family: 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0d8f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    max-width: 800px;
    width: 100%;
    padding: 2rem 1.5rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    background: linear-gradient(90deg, #c9a0dc, #f6d365);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    margin-top: 0.5rem;
    color: #a89cc8;
    font-size: 0.95rem;
}

/* Form */
form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

label {
    font-size: 1.05rem;
    font-weight: 600;
}

textarea {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1rem;
    color: #e0d8f0;
    font-size: 1rem;
    resize: none;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: #c9a0dc;
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: #8878a8;
}

button {
    padding: 0.9rem;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
}

button:active {
    transform: scale(0.97);
}

#submit-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

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

.read-btn {
    display: block;
    margin: 2rem auto 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 1rem 2.5rem;
}

.retry-btn {
    display: block;
    margin: 1.5rem auto 0;
    background: rgba(255, 255, 255, 0.1);
    color: #c9a0dc;
    border: 1px solid rgba(201, 160, 220, 0.3) !important;
}

/* ===================== */
/* 부채꼴 카드 선택       */
/* ===================== */
.pick-guide {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #c9a0dc;
}

#pick-count {
    font-weight: 700;
}

.fan-container {
    position: relative;
    width: 100%;
    height: 520px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin: 0 auto;
    overflow: visible;
}

.fan-card {
    position: absolute;
    bottom: 0;
    width: 180px;
    height: 280px;
    border-radius: 8px;
    cursor: pointer;
    transform-origin: bottom center;
    transition: transform 0.3s ease, filter 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.fan-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    pointer-events: none;
}

.fan-card:hover {
    transform: var(--fan-rotate) translateY(-20px) !important;
    filter: brightness(1.2);
    z-index: 100 !important;
}

.fan-card.selected {
    box-shadow: 0 0 0 3px #f6d365, 0 0 20px rgba(246, 211, 101, 0.5);
    transform: var(--fan-rotate) translateY(-30px) !important;
    z-index: 99 !important;
}

.fan-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fan-card.disabled:hover {
    transform: var(--fan-rotate) !important;
    filter: none;
}

/* ===================== */
/* 로딩                   */
/* ===================== */
#loading-section {
    text-align: center;
    padding: 3rem 0;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(201, 160, 220, 0.2);
    border-top-color: #c9a0dc;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: #a89cc8;
    font-size: 1rem;
}

/* ===================== */
/* 결과                   */
/* ===================== */
.cards-display {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.card-slot {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 1.2rem 1rem;
    text-align: center;
    width: 200px;
    animation: fadeInUp 0.5s ease-out both;
}

.card-slot:nth-child(1) { animation-delay: 0.1s; }
.card-slot:nth-child(2) { animation-delay: 0.3s; }
.card-slot:nth-child(3) { animation-delay: 0.5s; }

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

.card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #a89cc8;
    margin-bottom: 0.5rem;
}

.card-img-wrap {
    margin: 0.5rem 0;
}

.card-img-wrap img {
    width: 120px;
    height: 187px;
    object-fit: cover;
    border-radius: 8px;
}

.card-img-wrap img.reversed {
    transform: rotate(180deg);
}

.card-name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.card-meaning {
    font-size: 0.8rem;
    color: #a89cc8;
}

.reading-text {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 1.5rem;
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 0.95rem;
    animation: fadeInUp 0.5s ease-out 0.7s both;
}

/* 공유 */
.share-area {
    text-align: center;
    margin-top: 1.5rem;
    position: relative;
}

.share-btn {
    background: linear-gradient(135deg, #f6d365, #fda085);
    color: #1a1a2e;
    padding: 0.8rem 2rem;
}

.share-toast {
    margin-top: 0.7rem;
    font-size: 0.85rem;
    color: #f6d365;
    animation: fadeInUp 0.3s ease-out;
}

/* Utility */
.hidden {
    display: none !important;
}

footer {
    text-align: center;
    margin-top: 3rem;
    font-size: 0.75rem;
    color: #6a6080;
}

/* Mobile */
@media (max-width: 640px) {
    .fan-container {
        height: 400px;
    }
    .fan-card {
        width: 120px;
        height: 187px;
    }
    .cards-display {
        flex-direction: column;
        align-items: center;
    }
    .card-slot {
        width: 100%;
        max-width: 280px;
    }
    header h1 {
        font-size: 1.6rem;
    }
}
