/* ===== Design Tokens ===== */
:root {
    --bg-cream: #F5EFE0;
    --bg-card: rgba(255, 252, 245, 0.85);
    --text-ink: #2C1810;
    --text-muted: #6B5B4F;
    --accent-red: #B03A2E;
    --accent-gold: #C8A951;
    --accent-gold-light: #E8D5A3;
    --border-light: rgba(184, 134, 11, 0.2);
    --shadow: 0 4px 24px rgba(44, 24, 16, 0.08);
    --shadow-hover: 0 8px 32px rgba(44, 24, 16, 0.14);
    --radius: 12px;
    --el-wood: #3A7D44;
    --el-fire: #C0392B;
    --el-earth: #A0845A;
    --el-metal: #8C8C8C;
    --el-water: #2E5A88;
    --font: 'Noto Serif KR', serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-cream);
    color: var(--text-ink);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    line-height: 1.7;
}

/* ===== Background Decorations ===== */
.bg-pattern {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(192, 57, 43, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(200, 169, 81, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(44, 24, 16, 0.01) 0%, transparent 70%);
}

.cloud {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    border-radius: 50%;
    opacity: 0.03;
    background: var(--text-ink);
    filter: blur(40px);
}
.cloud-1 { width: 400px; height: 120px; top: 10%; left: -5%; animation: cloudFloat 30s ease-in-out infinite; }
.cloud-2 { width: 350px; height: 100px; top: 40%; right: -8%; animation: cloudFloat 25s ease-in-out infinite reverse; }
.cloud-3 { width: 300px; height: 90px; bottom: 15%; left: 10%; animation: cloudFloat 35s ease-in-out infinite 5s; }

@keyframes cloudFloat {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(60px); }
}

/* ===== Container ===== */
.container {
    position: relative;
    z-index: 1;
    max-width: 560px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 36px;
}

.header-ornament {
    font-size: 1.4rem;
    color: var(--accent-gold);
    margin-bottom: 8px;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

h1 {
    font-size: 2.6rem;
    font-weight: 900;
    color: var(--accent-red);
    letter-spacing: 4px;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.85rem;
    letter-spacing: 10px;
    color: var(--accent-gold);
    margin-top: 4px;
    font-weight: 400;
}

.tagline {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* ===== Card ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 28px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.section-title {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-red);
    margin-bottom: 24px;
    letter-spacing: 2px;
}

.section-title::before,
.section-title::after {
    content: ' — ';
    color: var(--accent-gold);
}

/* ===== Calendar Type Radios ===== */
.calendar-type {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 16px;
}

.radio-label, .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
}

.radio-label input, .checkbox-label input { display: none; }

.radio-custom {
    width: 20px; height: 20px;
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    position: relative;
    transition: border-color 0.3s;
    flex-shrink: 0;
}

.radio-label input:checked + .radio-custom {
    border-color: var(--accent-red);
}

.radio-label input:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent-red);
}

.checkbox-custom {
    width: 20px; height: 20px;
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    position: relative;
    transition: all 0.3s;
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: -2px; left: 2px;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.leap-month-row {
    text-align: center;
    margin-bottom: 16px;
}

/* ===== Date Inputs ===== */
.date-inputs {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.time-input {
    margin-bottom: 24px;
}

.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group.full-width { width: 100%; }

.input-group label {
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

select {
    font-family: var(--font);
    font-size: 1rem;
    padding: 10px 12px;
    border: 1.5px solid var(--border-light);
    border-radius: 8px;
    background: rgba(255,255,255,0.7);
    color: var(--text-ink);
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B5B4F' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(200, 169, 81, 0.15);
}

/* ===== Buttons ===== */
.btn-primary {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-red), #8B2500);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 4px;
    transition: transform 0.2s, box-shadow 0.3s;
    box-shadow: 0 4px 16px rgba(176, 58, 46, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(176, 58, 46, 0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-hanja {
    font-size: 0.7rem;
    letter-spacing: 6px;
    opacity: 0.7;
    font-weight: 400;
    margin-top: 2px;
}

.btn-secondary {
    font-family: var(--font);
    font-size: 1rem;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--accent-gold), #A0845A);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: transform 0.2s, box-shadow 0.3s;
    box-shadow: 0 3px 12px rgba(200, 169, 81, 0.25);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(200, 169, 81, 0.35);
}

.btn-outline {
    display: block;
    width: 100%;
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 14px;
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s;
}

.btn-outline:hover {
    border-color: var(--accent-gold);
    color: var(--accent-red);
    background: rgba(255,255,255,0.5);
}

/* ===== Result Section ===== */
.result-section {
    animation: fadeSlideUp 0.6s ease-out;
}

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

.date-info {
    text-align: center;
    padding: 16px 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.date-info p + p { margin-top: 2px; }

/* ===== Four Pillars ===== */
.pillars-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.pillar {
    text-align: center;
    animation: pillarReveal 0.5s ease-out backwards;
}

.pillar:nth-child(1) { animation-delay: 0.1s; }
.pillar:nth-child(2) { animation-delay: 0.25s; }
.pillar:nth-child(3) { animation-delay: 0.4s; }
.pillar:nth-child(4) { animation-delay: 0.55s; }

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

.pillar-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.3;
}

.hanja-small {
    font-size: 0.7rem;
    color: var(--accent-gold);
}

.pillar-card {
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.5);
    transition: transform 0.3s, box-shadow 0.3s;
}

.pillar-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stem, .branch {
    padding: 12px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stem { border-bottom: 1px solid var(--border-light); }

.char-kr {
    font-size: 1.5rem;
    font-weight: 900;
}

.char-hj {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.element-badge {
    font-size: 0.65rem;
    padding: 1px 8px;
    border-radius: 10px;
    margin-top: 2px;
    font-weight: 700;
    letter-spacing: 1px;
}

.element-badge.wood { background: rgba(58,125,68,0.12); color: var(--el-wood); }
.element-badge.fire { background: rgba(192,57,43,0.12); color: var(--el-fire); }
.element-badge.earth { background: rgba(160,132,90,0.12); color: var(--el-earth); }
.element-badge.metal { background: rgba(140,140,140,0.15); color: var(--el-metal); }
.element-badge.water { background: rgba(46,90,136,0.12); color: var(--el-water); }

.pillar.unknown .pillar-card {
    opacity: 0.4;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(0,0,0,0.02) 8px,
        rgba(0,0,0,0.02) 16px
    );
}

/* ===== Five Elements Summary ===== */
.elements-summary {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.element-count {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--border-light);
}

.element-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
}

/* ===== Lotto Section ===== */
.lotto-section { text-align: center; }

.lotto-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    opacity: 0.8;
}

.lotto-balls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    min-height: 56px;
}

.lotto-ball {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    box-shadow: inset 0 -3px 6px rgba(0,0,0,0.15), 0 3px 8px rgba(0,0,0,0.1);
    animation: ballBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    position: relative;
    overflow: hidden;
}

.lotto-ball::before {
    content: '';
    position: absolute;
    top: 6px; left: 10px;
    width: 16px; height: 10px;
    background: rgba(255,255,255,0.35);
    border-radius: 50%;
    transform: rotate(-20deg);
}

.lotto-ball:nth-child(1) { animation-delay: 0.05s; }
.lotto-ball:nth-child(2) { animation-delay: 0.12s; }
.lotto-ball:nth-child(3) { animation-delay: 0.19s; }
.lotto-ball:nth-child(4) { animation-delay: 0.26s; }
.lotto-ball:nth-child(5) { animation-delay: 0.33s; }
.lotto-ball:nth-child(6) { animation-delay: 0.40s; }

@keyframes ballBounce {
    from { opacity: 0; transform: scale(0.3) translateY(-30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ball-yellow { background: linear-gradient(145deg, #F9C74F, #D4920B); }
.ball-blue { background: linear-gradient(145deg, #69C8F2, #3A8FBF); }
.ball-red { background: linear-gradient(145deg, #F87171, #C0392B); }
.ball-gray { background: linear-gradient(145deg, #A0A0A0, #6B6B6B); }
.ball-green { background: linear-gradient(145deg, #A3D977, #5B9A2F); }

.lotto-actions {
    display: flex;
    justify-content: center;
}

/* ===== AdSense ===== */
.ad-wrap {
    margin: 0 auto 24px;
    max-width: 100%;
    min-height: 0;
    text-align: center;
    overflow: hidden;
}

.ad-wrap ins.adsbygoogle {
    display: block !important;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 36px;
    padding: 20px;
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.7;
    line-height: 1.8;
}

.footer-hanja {
    font-size: 1rem;
    letter-spacing: 16px;
    color: var(--accent-gold);
    margin-top: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    html { font-size: 16px; }
    .container { padding: 24px 16px 40px; }
    h1 { font-size: 2.2rem; }
    .card { padding: 22px 18px; }
    .date-inputs { grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; }
    .pillars-grid { gap: 6px; }
    .char-kr { font-size: 1.3rem; }
    .stem, .branch { padding: 10px 2px; }
    .lotto-ball { width: 46px; height: 46px; font-size: 1.05rem; }
    .calendar-type { gap: 20px; }
}

@media (min-width: 768px) {
    html { font-size: 19px; }
    .lotto-ball { width: 58px; height: 58px; font-size: 1.3rem; }
}
