/* 전체 스타일 및 연보라색 그라데이션 배경 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Jua', 'Gowun Dodum', sans-serif;
    background: linear-gradient(135deg, #e6d7ff 0%, #c8b6ff 50%, #b8c0ff 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #4a3e6d;
    overflow-x: hidden;
    position: relative;
}

/* 배경 장식 */
.background-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.cloud {
    position: absolute;
    font-size: 3rem;
    opacity: 0.6;
    animation: floatCloud 20s infinite linear;
}

.cloud-1 { top: 10%; left: -10%; animation-duration: 25s; }
.cloud-2 { top: 60%; left: -10%; animation-duration: 30s; animation-delay: 5s; }

@keyframes floatCloud {
    0% { transform: translateX(-10vw); }
    100% { transform: translateX(110vw); }
}

.star {
    position: absolute;
    font-size: 1.8rem;
    animation: twinkle 2s infinite alternate;
}

.star-1 { top: 15%; left: 15%; }
.star-2 { top: 25%; right: 18%; animation-delay: 0.7s; }
.star-3 { bottom: 15%; left: 20%; animation-delay: 1.3s; }

@keyframes twinkle {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1.2); opacity: 1; }
}

/* 메인 컨테이너 */
.container {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 850px;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(103, 80, 164, 0.2), 
                inset 0 0 15px rgba(255, 255, 255, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.7);
}

header {
    text-align: center;
    margin-bottom: 20px;
}

.title {
    font-size: 2.3rem;
    color: #5a3d7c;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8), 0 0 10px rgba(184, 150, 255, 0.5);
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1.1rem;
    color: #6c5a8c;
}

/* 어항 및 애니메이션 영역 */
.aquarium-container {
    position: relative;
    width: 100%;
    height: 300px;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

/* 네모난 어항 본체 */
.aquarium {
    width: 100%;
    max-width: 600px;
    height: 220px;
    position: relative;
}

.aquarium-glass {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(224, 242, 254, 0.6) 0%, rgba(186, 230, 253, 0.8) 100%);
    border: 4px solid #ffffff;
    border-radius: 16px 16px 24px 24px;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.25),
                inset 0 0 20px rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.aquarium-base {
    height: 12px;
    width: 104%;
    margin-left: -2%;
    background: #a78bfa;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* 어항 내부 소품 */
.seaweed {
    position: absolute;
    bottom: 5px;
    font-size: 2rem;
    user-select: none;
    animation: sway 3s ease-in-out infinite alternate;
    transform-origin: bottom center;
}

.seaweed-left { left: 20px; }
.seaweed-right { right: 20px; animation-delay: 1.5s; }

@keyframes sway {
    0% { transform: rotate(-8deg); }
    100% { transform: rotate(8deg); }
}

.starfish {
    position: absolute;
    bottom: 8px;
    left: 80px;
    font-size: 1.5rem;
}

.castle {
    position: absolute;
    bottom: 8px;
    right: 70px;
    font-size: 2.2rem;
}

/* 공기방울 효과 */
.bubbles {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    top: 0;
    left: 0;
}

.bubbles span {
    position: absolute;
    bottom: -20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.8);
    animation: animateBubble 8s linear infinite;
}

.bubbles span:nth-child(even) {
    width: 12px;
    height: 12px;
    left: calc(var(--i) * 4%);
    animation-duration: 6s;
}

.bubbles span:nth-child(odd) {
    width: 8px;
    height: 8px;
    left: calc(var(--i) * 4%);
    animation-duration: 9s;
}

@keyframes animateBubble {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }
    10% { opacity: 0.8; }
    100% {
        transform: translateY(-240px) scale(1.5);
        opacity: 0;
    }
}

/* 어항 속 헤엄치는 웨이비들 */
.wavy-pool {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 2;
}

.swimming-wavy {
    position: absolute;
    width: 48px;
    height: 48px;
    object-fit: contain;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* 어항 위로 튀어오르는 당첨 캐릭터 및 말풍선 */
.winner-display {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.winner-display.hidden {
    opacity: 0;
    transform: translate(-50%, 60px) scale(0.3);
    pointer-events: none;
}

.winner-display.jump {
    animation: jumpUp 0.8s ease-out forwards;
}

@keyframes jumpUp {
    0% {
        opacity: 0;
        transform: translate(-50%, 80px) scale(0.5);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -40px) scale(1.15);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -20px) scale(1);
    }
}

.speech-bubble {
    position: relative;
    background: #ffffff;
    border: 3px solid #8b5cf6;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #5b21b6;
    box-shadow: 0 6px 15px rgba(139, 92, 246, 0.3);
    margin-bottom: 12px;
    white-space: nowrap;
    animation: bounceBubble 1s infinite alternate ease-in-out;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 10px 0;
    border-style: solid;
    border-color: #8b5cf6 transparent;
    display: block;
    width: 0;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 8px 0;
    border-style: solid;
    border-color: #ffffff transparent;
    display: block;
    width: 0;
    z-index: 1;
}

@keyframes bounceBubble {
    0% { transform: translateY(0); }
    100% { transform: translateY(-5px); }
}

.winner-wavy {
    width: 110px;
    height: 110px;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(124, 58, 237, 0.4));
}

/* 컨트롤 패널 */
.control-panel {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-section label {
    font-size: 1.05rem;
    font-weight: bold;
    color: #4c1d95;
}

textarea {
    width: 100%;
    height: 80px;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #ddd6fe;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    color: #3b0764;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
    background: rgba(255, 255, 255, 0.9);
}

textarea:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* 웨이비 뽑기 버튼 */
.action-section {
    display: flex;
    justify-content: center;
    margin: 5px 0;
}

.draw-button {
    background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    font-size: 1.4rem;
    font-family: 'Jua', sans-serif;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4), 
                inset 0 2px 4px rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.draw-button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5), 
                inset 0 2px 4px rgba(255, 255, 255, 0.6);
}

.draw-button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.4);
}

.draw-button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 뽑기 히스토리 */
.history-section {
    margin-top: 5px;
    border-top: 1px dashed #ddd6fe;
    padding-top: 12px;
}

.history-section h3 {
    font-size: 1rem;
    color: #5b21b6;
    margin-bottom: 8px;
}

#history-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 80px;
    overflow-y: auto;
}

#history-list li {
    background: #f3e8ff;
    color: #6b21a8;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid #e9d5ff;
    animation: fadeIn 0.3s ease-out;
}

#history-list li.empty-history {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 0;
}

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