:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 40%);
}

/* 픽셀 배경 스타일 */
.pixel-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url('bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    image-rendering: auto;
    /* 초정밀 도트는 브라우저 고유 안티앨리어싱으로 선명도를 높임 */
    animation: backgroundSway 120s linear infinite;

    filter: contrast(1.05) saturate(1.1) brightness(1.05);
    /* 노을 색감을 위해 소폭 조정 */
}

/* 사이트 정보 섹션 스타일 */
.info-sections {
    margin-top: 4rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 1s ease-out;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.info-card {
    text-align: left;
}

.info-card h3 {
    font-size: 1.25rem;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-card p {
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 0.95rem;
}

.info-card ul {
    list-style: none;
}

.info-card li {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-card li::before {
    content: "⚡";
    font-size: 0.8rem;
}

.info-card li strong {
    color: var(--text-main);
}

.visitor-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem 2.5rem;
    background: rgba(99, 102, 241, 0.35);
    border-radius: 15px;
    backdrop-filter: blur(15px);
    border: 2px solid rgba(99, 102, 241, 0.6);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.3);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.8),
        0 0 40px rgba(99, 102, 241, 0.5),
        0 2px 10px rgba(0, 0, 0, 0.8);
    letter-spacing: 1px;
}

.stat-divider {
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    font-weight: 200;
}

@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes backgroundSway {

    0%,
    100% {
        transform: scale(1.1) translate(0, 0);
    }

    25% {
        transform: scale(1.15) translate(-15px, -10px);
    }

    50% {
        transform: scale(1.15) translate(-15px, -10px);
    }

    75% {
        transform: scale(1.18) translate(-5px, 10px);
    }
}

/* 날아다니는 새 스타일 */
.bird {
    position: fixed;
    width: 12px;
    height: 8px;
    background-image: url('data:image/svg+xml;utf8,<svg width="12" height="8" viewBox="0 0 12 8" xmlns="http://www.w3.org/2000/svg"><path d="M0,4 L4,0 L8,4 L12,0" fill="none" stroke="black" stroke-width="2" /></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: -1;
    pointer-events: none;
    animation: flyAcross var(--duration) linear infinite, flap 0.4s ease-in-out infinite alternate;
}

@keyframes flyAcross {
    from {
        left: -50px;
        top: var(--start-y);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    to {
        left: 110vw;
        top: var(--end-y);
        opacity: 0;
    }
}

@keyframes flap {
    from {
        transform: scaleY(1);
    }

    to {
        transform: scaleY(0.3);
    }
}

.pixel-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary);
    opacity: 0.3;
    image-rendering: pixelated;
    pointer-events: none;
    animation: float-pixel var(--duration) linear infinite;
}

@keyframes float-pixel {
    from {
        transform: translateY(110vh) translateX(0);
    }

    to {
        transform: translateY(-10vh) translateX(calc(var(--drift) * 1px));
    }
}

.container {
    width: 100%;
    max-width: 800px;
    /* 정보 섹션 추가에 따른 너비 확장 */
    padding: 2rem;
    margin: 4rem auto;
    /* 상하 여백 및 중앙 정렬 */
    text-align: center;
}

header {
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    transition: background 0.3s ease;
}

.subtitle {
    color: rgba(255, 255, 255, 0.95);
    /* 더 밝은 색상으로 변경 */
    font-weight: 500;
    /* 굵기 소폭 상향 */
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    /* 배경과의 분리감 강화 */
    margin-top: 0.5rem;
}

.glass {
    background: rgba(15, 23, 42, 0.85);
    /* 좀 더 어두운 배경으로 대비 강화 */
    backdrop-filter: blur(20px);
    /* 블러 강화 */
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.hidden {
    display: none !important;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.birth-container {
    display: flex;
    gap: 0.5rem;
}

.birth-container input {
    flex: 1;
    text-align: center;
    padding: 1rem 0.5rem;
    min-width: 60px;
}

#birth-year {
    flex: 2;
    min-width: 80px;
}

.length-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.length-option {
    flex: 1;
    min-width: 120px;
    padding: 0.8rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.length-option:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
}

.length-option input[type="radio"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.length-option input[type="radio"]:checked+span {
    font-weight: 700;
    color: var(--primary);
}

.length-option span {
    font-size: 0.9rem;
    color: var(--text-main);
}

.input-group {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    padding-left: 0.5rem;
}

input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.generate-btn {
    position: relative;
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 1rem;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.5);
}

.generate-btn:active {
    transform: translateY(0);
}

.result-container {
    margin-top: 2rem;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-container.hidden {
    display: none;
}

/* 히스토리 컨테이너 스타일 */
.history-container {
    margin-top: 2rem;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
    text-align: center;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.history-item {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    transform: translateX(5px);
}

.history-item-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.clear-history-btn {
    width: 100%;
    padding: 0.8rem;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    color: #fef2f2;
}

.result-length-options {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin: 1.5rem 0 1rem 0;
}

.result-length-btn {
    padding: 0.6rem 1.2rem;
    background: rgba(99, 102, 241, 0.15);
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.result-length-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.result-length-btn input[type="radio"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.result-length-btn input[type="radio"]:checked+span {
    font-weight: 700;
    color: var(--primary);
}

.result-length-btn span {
    font-size: 0.9rem;
    color: var(--text-main);
}

.nickname-text {
    font-size: 2.2rem;
    font-weight: 900;
    margin: 1.5rem 0;
    color: white;
    text-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

.result-label {
    color: var(--text-muted);
}

.result-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.action-btn {
    flex: 1;
    padding: 0.8rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.primary {
    background: var(--primary);
    border: none;
    color: white;
}

.action-btn.secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.action-btn:hover {
    filter: brightness(1.2);
}

footer {
    margin-top: 4rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    /* 더 밝은 색상으로 변경 */
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
    /* 가독성 향상을 위한 그림자 추가 */
    font-weight: 400;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 로딩 컨테이너 스타일 */
.loading-container {
    margin-top: 2rem;
    animation: fadeIn 0.3s ease;
}

.loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    filter: drop-shadow(0 0 10px var(--primary));
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

/* 타이핑 애니메이션 커서 */
.nickname-text::after {
    content: '|';
    animation: blink 0.7s infinite;
    margin-left: 5px;
    color: var(--primary);
}

.nickname-text.typing-done::after {
    display: none;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }
}