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

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

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

.bg-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), rgba(255,255,255,0.08) 70%);
    box-shadow: inset 0 0 10px rgba(255,255,255,0.4);
}

.bg-bubble-1 { width: 90px; height: 90px; top: 8%; left: 4%; }
.bg-bubble-2 { width: 40px; height: 40px; top: 20%; left: 10%; }
.bg-bubble-3 { width: 55px; height: 55px; top: 65%; left: 6%; }
.bg-bubble-4 { width: 70px; height: 70px; top: 12%; right: 6%; }

.bg-sparkle {
    position: absolute;
    color: #fff;
    opacity: 0.85;
    font-size: 1.3rem;
    animation: twinkle 2.4s infinite alternate ease-in-out;
    text-shadow: 0 0 6px rgba(255,255,255,0.8);
}

.bg-sparkle-1 { top: 30%; left: 8%; font-size: 1rem; animation-delay: .3s; }
.bg-sparkle-2 { top: 55%; left: 16%; font-size: 0.8rem; animation-delay: 1s; }
.bg-sparkle-3 { bottom: 8%; left: 3%; font-size: 1.4rem; animation-delay: .7s; }
.bg-sparkle-4 { top: 45%; right: 5%; font-size: 1.1rem; animation-delay: 1.4s; }

@keyframes twinkle {
    0% { transform: scale(0.75); opacity: 0.35; }
    100% { transform: scale(1.15); opacity: 1; }
}

/* 화면 전체에서 위로 보글보글 떠오르는 거품 */
.rise-bubble {
    position: absolute;
    left: var(--x);
    bottom: -40px;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.95), rgba(255,255,255,0.15) 65%, rgba(255,255,255,0.05) 100%);
    box-shadow: inset 0 0 4px rgba(255,255,255,0.8);
    opacity: 0;
    animation: riseBubble var(--dur) ease-in infinite;
    animation-delay: var(--delay);
}

@keyframes riseBubble {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    8% {
        opacity: 0.85;
    }
    50% {
        transform: translateY(-52vh) translateX(14px);
    }
    92% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-105vh) translateX(-10px);
        opacity: 0;
    }
}

/* 배경 전체에서 은은하게 헤엄치는 웨이비들 */
.bg-wavy-pool {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.bg-swim-wavy {
    position: absolute;
    width: 46px;
    height: 46px;
    object-fit: contain;
    opacity: 0.4;
    filter: drop-shadow(0 3px 5px rgba(50, 30, 100, 0.12));
    will-change: transform;
}

/* 메인 컨테이너 */
.container {
    position: relative;
    z-index: 1;
    width: 94%;
    max-width: 1220px;
    margin: 20px auto;
    padding: 28px 30px 34px;
}

header {
    position: relative;
    text-align: center;
    margin-bottom: 60px;
}

.title {
    display: inline-block;
    font-size: clamp(1.8rem, 4.6vw, 3rem);
    letter-spacing: 1px;
    color: #6b3fd4;
    -webkit-text-stroke: 7px #ffffff;
    paint-order: stroke fill;
    text-shadow: 0 4px 0 rgba(120, 90, 200, 0.25), 0 0 18px rgba(255, 255, 255, 0.6);
}

.title-sparkle {
    position: absolute;
    top: 50%;
    color: #fdfcff;
    font-size: 1.4rem;
    text-shadow: 0 0 8px rgba(255,255,255,0.9);
    animation: twinkle 2s infinite alternate ease-in-out;
}

.title-sparkle-left { left: 6%; transform: translateY(-50%); }
.title-sparkle-right { right: 6%; transform: translateY(-50%); animation-delay: .6s; }

/* 좌/우 2단 레이아웃 */
.game-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 34px;
    flex-wrap: wrap;
}

.aquarium-column {
    flex: 1 1 680px;
    max-width: 740px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

/* 네모난 어항 본체 */
.aquarium {
    width: 100%;
    height: auto;
    position: relative;
}

.aquarium-glass {
    width: 100%;
    height: 280px;
    background: linear-gradient(180deg, rgba(230, 246, 255, 0.55) 0%, rgba(179, 220, 255, 0.75) 100%);
    border: 5px solid #ffffff;
    border-radius: 22px;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.28),
                inset 0 0 22px rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.aquarium-base {
    position: relative;
    height: 130px;
    width: 108%;
    margin-left: -4%;
    margin-top: 22px;
    background: linear-gradient(180deg, #b7a4f9 0%, #8a67e6 55%, #7752d6 100%);
    border-radius: 26px;
    box-shadow: 0 10px 20px rgba(70, 40, 140, 0.35),
                inset 0 2px 3px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.aquarium-base::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -10px;
    transform: translateX(-50%);
    width: 70%;
    height: 14px;
    background: radial-gradient(ellipse at center, rgba(60, 30, 110, 0.35) 0%, rgba(60, 30, 110, 0) 75%);
    border-radius: 50%;
}

/* 받침대 안 wavy 장식 */
.base-deco {
    position: relative;
    width: 62px;
    height: 62px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(50, 20, 100, 0.35));
    animation: baseDecoBob 2.6s ease-in-out infinite alternate;
}

.base-deco-left {
    margin-right: 4px;
    animation-delay: 0s;
}

.base-deco-right {
    margin-left: 4px;
    transform: scaleX(-1);
    animation-delay: 1.1s;
}

@keyframes baseDecoBob {
    0% { transform: translateY(0) rotate(-4deg); }
    100% { transform: translateY(-6px) rotate(4deg); }
}

.base-deco-right {
    animation-name: baseDecoBobFlip;
}

@keyframes baseDecoBobFlip {
    0% { transform: scaleX(-1) translateY(0) rotate(-4deg); }
    100% { transform: scaleX(-1) translateY(-6px) rotate(4deg); }
}

/* 클릭 시 뿅뿅 튀어오르는 웨이비 파티클 (어항+받침대 전체 위에 표시) */
.pop-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 15;
}

.pop-wavy {
    position: absolute;
    width: 64px;
    height: 64px;
    object-fit: contain;
    left: 50%;
    top: 78%;
    opacity: 0;
    filter: drop-shadow(0 4px 8px rgba(50, 20, 100, 0.45));
    animation: popWavy 1.3s cubic-bezier(0.22, 0.7, 0.3, 1) forwards;
}

@keyframes popWavy {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
    }
    12% {
        opacity: 1;
        transform: translate(calc(-50% + var(--dx) * 0.25), calc(-50% - var(--dy) * 0.3)) scale(1.05) rotate(calc(var(--rot) * 0.3));
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--dx)), calc(-50% - var(--dy))) scale(0.85) rotate(var(--rot));
    }
}

/* 사이트 아무 곳이나 클릭 시 뿅 튀어오르는 전역 클릭 효과 */
.click-pop-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 999;
}

.click-pop-wavy {
    position: absolute;
    width: 40px;
    height: 40px;
    object-fit: contain;
    transform: translate(-50%, -50%);
    opacity: 0;
    filter: drop-shadow(0 3px 6px rgba(50, 20, 100, 0.4));
    animation: clickPopWavy 0.9s cubic-bezier(0.22, 0.7, 0.3, 1) forwards;
}

@keyframes clickPopWavy {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
    }
    18% {
        opacity: 1;
        transform: translate(calc(-50% + var(--cdx) * 0.2), calc(-50% - var(--cdy) * 0.35)) scale(1.1) rotate(calc(var(--crot) * 0.3));
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--cdx)), calc(-50% - var(--cdy))) scale(0.8) rotate(var(--crot));
    }
}

/* 어항 속 모래 바닥 */
.sand {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 22%;
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255, 250, 235, 0.85) 55%);
    border-radius: 0 0 22px 22px;
    z-index: 0;
}

.rock {
    position: absolute;
    bottom: 6px;
    right: 18%;
    width: 46px;
    height: 26px;
    background: linear-gradient(160deg, #cdb8f5, #a98cf0);
    border-radius: 50% 50% 45% 45%;
    box-shadow: inset -4px -4px 6px rgba(90, 60, 160, 0.3);
    z-index: 1;
}

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

.seaweed-left { left: 14px; }
.seaweed-right { right: 10px; animation-delay: 1.5s; }
.seaweed-right2 { right: 26px; animation-delay: .8s; }

.seaweed svg { display: block; width: 34px; height: 52px; }
.seaweed-right2 svg { width: 26px; height: 40px; }

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

.starfish {
    position: absolute;
    bottom: 6px;
    z-index: 1;
}

.starfish svg { display: block; width: 24px; height: 24px; }

.starfish-left { left: 32%; }
.starfish-right { right: 24%; }

.castle {
    position: absolute;
    bottom: 6px;
    left: 22%;
    z-index: 1;
}

.castle svg { display: block; width: 52px; height: 43px; overflow: visible; }

/* 공기방울 효과 */
.bubbles {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 2;
    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: 10px;
    height: 10px;
    left: calc(var(--i) * 4%);
    animation-duration: 6s;
}

.bubbles span:nth-child(odd) {
    width: 7px;
    height: 7px;
    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(-220px) scale(1.5);
        opacity: 0;
    }
}

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

.swimming-wavy {
    position: absolute;
    width: 58px;
    height: 58px;
    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: -70px;
    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 24px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #5b21b6;
    box-shadow: 0 6px 15px rgba(139, 92, 246, 0.3);
    margin-bottom: 10px;
    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: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(124, 58, 237, 0.4));
    position: relative;
    z-index: 2;
}

.winner-wavy-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.winner-halo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 170px;
    height: 170px;
    transform: translate(-50%, -50%) scale(0.85);
    background: radial-gradient(circle, rgba(255, 250, 210, 0.95) 0%, rgba(255, 231, 160, 0.55) 35%, rgba(255, 231, 160, 0) 72%);
    border-radius: 50%;
    z-index: 1;
    animation: haloPulse 1.6s ease-in-out infinite alternate;
}

@keyframes haloPulse {
    0% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.75; }
    100% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

/* 뽑기 버튼 */
.draw-button {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #b3a3f7 0%, #7c5cec 100%);
    color: white;
    border: 4px solid #ffffff;
    padding: 16px 46px;
    font-size: 1.6rem;
    font-family: 'Jua', sans-serif;
    letter-spacing: 1px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(124, 58, 237, 0.45),
                inset 0 2px 4px rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
}

.draw-button .wave-icon {
    width: 32px;
    height: 22px;
    opacity: 0.85;
}

.draw-button .wave-icon.flip {
    transform: scaleX(-1);
}

.draw-button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 22px rgba(124, 58, 237, 0.55),
                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;
}

/* 컨트롤 패널 (우측) */
.control-panel {
    flex: 1 1 300px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding-top: 30px;
}

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

.input-section label {
    font-size: 1.15rem;
    color: #3f2d73;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.input-pill {
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 4px 14px rgba(80, 50, 150, 0.18);
    padding: 4px;
}

textarea {
    width: 100%;
    height: 110px;
    padding: 14px 18px;
    border-radius: 18px;
    border: none;
    font-family: 'Jua', sans-serif;
    font-size: 1.02rem;
    color: #3b0764;
    outline: none;
    resize: vertical;
    background: transparent;
}

textarea::placeholder {
    color: #b9aee0;
}

/* 닉네임 미입력 시 경고 효과 (alert 대신 사용, OBS 브라우저 소스 호환) */
.input-pill:has(.input-shake) {
    animation: shakePill 0.4s ease;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.45), 0 4px 14px rgba(80, 50, 150, 0.18);
}

.input-shake::placeholder {
    color: #ef4444;
}

@keyframes shakePill {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* 뽑기 로그 */
.history-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-section h3 {
    font-size: 1.15rem;
    font-weight: normal;
    color: #3f2d73;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

#history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 180px;
    max-height: 240px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    padding: 16px 18px;
}

#history-list li {
    color: #3f2d73;
    font-size: 1.02rem;
    animation: fadeIn 0.3s ease-out;
}

#history-list li.empty-history {
    color: #7a6ba8;
}

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

/* 사이트 전체를 바닷속처럼 보이게 하는 하단 고정 바다 바닥 (뷰포트 맨 아래 고정, 모서리 위주 배치) */
.seafloor {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.seafloor-sand {
    position: absolute;
    left: -5%;
    bottom: -60px;
    width: 110%;
    height: 110px;
    background: linear-gradient(180deg, rgba(255, 250, 240, 0) 0%, rgba(255, 250, 240, 0.5) 55%, rgba(250, 240, 220, 0.75) 100%);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.floor-cluster {
    position: absolute;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.floor-cluster-left {
    left: 1%;
}

.floor-cluster-right {
    right: 1%;
}

.floor-cluster-mid {
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.6;
}

.floor-deco-big {
    width: 50px;
    height: 76px;
    flex-shrink: 0;
    animation: sway 3.4s ease-in-out infinite alternate;
    transform-origin: bottom center;
}

.floor-deco-small {
    width: 34px;
    height: 52px;
    flex-shrink: 0;
    animation: sway 3.8s ease-in-out infinite alternate;
    animation-delay: 1.1s;
    transform-origin: bottom center;
}

.floor-rock {
    flex-shrink: 0;
    width: 56px;
    height: 30px;
    background: linear-gradient(160deg, #cdb8f5, #a98cf0);
    border-radius: 50% 50% 45% 45%;
    box-shadow: inset -5px -5px 8px rgba(90, 60, 160, 0.3);
}

.floor-rock-1 { width: 72px; height: 38px; }
.floor-rock-2 { width: 42px; height: 22px; margin-bottom: 4px; }
.floor-rock-3 { width: 46px; height: 24px; margin-bottom: 6px; }
.floor-rock-4 { width: 72px; height: 38px; }
.floor-rock-tiny { width: 22px; height: 12px; }

.floor-shell {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    margin-bottom: 6px;
    background: radial-gradient(circle at 35% 30%, #fff0d9, #ffcf9e 60%, #ffb56b 100%);
    border-radius: 50% 50% 50% 0;
    box-shadow: inset -3px -3px 5px rgba(200, 120, 40, 0.35);
    transform: rotate(-20deg);
}

.floor-shell-2 { transform: rotate(25deg); margin-bottom: 8px; }

@media (max-width: 720px) {
    .seafloor { height: 80px; }
    .floor-deco-big, .floor-deco-small, .floor-rock, .floor-shell {
        transform: scale(0.7);
        transform-origin: bottom center;
    }
    .floor-cluster-mid { display: none; }
}

/* 모바일 대응 */
@media (max-width: 720px) {
    .game-row {
        flex-direction: column;
        align-items: center;
    }
    .control-panel {
        max-width: 100%;
        width: 100%;
    }
}
