/* ===== 기본 리셋 및 변수 ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #f472b6;
    --accent: #22d3ee;
    --bg-dark: #0f0f23;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --border-glow: rgba(99, 102, 241, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== 컨테이너 ===== */
.container {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ===== 배경 효과 ===== */
.bg-blur {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: -1;
}

.floating-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    font-size: 2rem;
    opacity: 0.3;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    top: 20%;
    right: 15%;
    animation-delay: -3s;
}

.shape-3 {
    top: 60%;
    left: 5%;
    animation-delay: -6s;
}

.shape-4 {
    top: 70%;
    right: 10%;
    animation-delay: -9s;
}

.shape-5 {
    top: 40%;
    left: 20%;
    animation-delay: -12s;
}

.shape-6 {
    top: 85%;
    right: 25%;
    animation-delay: -15s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-20px) rotate(10deg);
    }

    50% {
        transform: translateY(0) rotate(0deg);
    }

    75% {
        transform: translateY(20px) rotate(-10deg);
    }
}

/* ===== 메인 컨텐츠 ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    /* 가로 배치로 변경 */
    align-items: flex-start;
    /* 상단 정렬 */
    justify-content: center;
    gap: 3rem;
    /* 사이드바와 메인 컨텐츠 사이 간격 */
    padding: 2rem;
    position: relative;
    z-index: 1;
    max-width: 1400px;
    /* 너무 넓어지지 않도록 제한 */
    margin: 0 auto;
    width: 100%;
}

/* ===== 메인 컨텐츠 래퍼 ===== */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* ===== 헤더 ===== */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.title .emoji {
    -webkit-text-fill-color: initial;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* ===== 슬롯 머신 ===== */
.slot-machine {
    margin-bottom: 2.5rem;
}

.slot-container {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.slot-window {
    width: 200px;
    height: 80px;
    background: rgba(30, 30, 50, 0.9);
    border: 2px solid var(--border-glow);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-glow);
}

.slot-window::before,
.slot-window::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 20px;
    z-index: 2;
    pointer-events: none;
}

.slot-window::before {
    top: 0;
    background: rgba(15, 15, 35, 0.7);
}

.slot-window::after {
    bottom: 0;
    background: rgba(15, 15, 35, 0.7);
}

.slot-reel {
    display: flex;
    flex-direction: column;
    transition: transform 0.1s ease-out;
}

.slot-item {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 0 0.5rem;
    text-align: center;
    color: var(--text-primary);
    word-break: keep-all;
    line-height: 1.2;
    overflow: hidden;
}

.slot-item.final {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px rgba(34, 211, 238, 0.5);
    }

    to {
        text-shadow: 0 0 20px rgba(34, 211, 238, 0.8), 0 0 30px rgba(34, 211, 238, 0.4);
    }
}

.slot-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== 스핀 버튼 ===== */
.button-container {
    margin-bottom: 3rem;
}

.spin-button {
    position: relative;
    padding: 1.2rem 3rem;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'Noto Sans KR', sans-serif;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.spin-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 25px rgba(99, 102, 241, 0.5),
        0 0 0 5px rgba(99, 102, 241, 0.2);
}

.spin-button:active {
    transform: translateY(0);
}

.spin-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.spin-button.spinning {
    animation: shake 0.5s infinite;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.button-glow {
    display: none;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* ===== 히스토리 섹션 (사이드바) ===== */
.history-section {
    width: 320px;
    /* 고정 너비 */
    flex-shrink: 0;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 1.5rem;
    position: sticky;
    /* 스크롤 시 따라오도록 설정 */
    top: 2rem;
    max-height: calc(100vh - 4rem);
    /* 화면 높이에 맞게 조절 */
    display: flex;
    flex-direction: column;
}

.history-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding: 0.5rem;
    padding-bottom: 1rem;
    /* 여백 추가하여 그림자 잘림 방지 */
    margin: -0.5rem;
    margin-bottom: 0;
    /* 하단 여백 상쇄 제거 */
    flex: 1;
    /* 남은 높이 차지 */
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.history-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-item.new-entry {
    animation: newEntryHighlight 1.5s ease-out;
    position: relative;
    overflow-x: clip;
}

.history-item.new-entry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    animation: shine 1.5s ease-out;
}

@keyframes newEntryHighlight {
    0% {
        opacity: 0;
        transform: scale(0.95);
        border-color: var(--accent);
        box-shadow: 0 0 30px rgba(34, 211, 238, 0.4);
        background: rgba(34, 211, 238, 0.15);
    }

    60% {
        border-color: var(--accent);
        box-shadow: 0 0 15px rgba(34, 211, 238, 0.2);
        background: rgba(34, 211, 238, 0.08);
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
        /* Return to original styles implicitly or naturally */
    }
}

@keyframes shine {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.history-item:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--border-glow);
}

.history-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.history-menus {
    flex: 1;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.history-menu-tag {
    padding: 0.4rem 0.8rem;
    background: rgba(34, 211, 238, 0.15);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--accent);
    transition: all 0.3s ease;
}

/* 중복 메뉴 하이라이트 */
.history-menu-tag.duplicate {
    background: rgba(251, 146, 60, 0.25);
    border-color: rgba(251, 146, 60, 0.6);
    color: #fb923c;
    animation: duplicatePulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(251, 146, 60, 0.3);
}

@keyframes duplicatePulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(251, 146, 60, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(251, 146, 60, 0.5), 0 0 30px rgba(251, 146, 60, 0.2);
    }
}

.history-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ===== 푸터 ===== */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.footer span {
    color: var(--accent);
    font-weight: 700;
}

/* ===== 반응형 ===== */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        gap: 2rem;
    }

    .history-section {
        width: 100%;
        position: static;
        /* 모바일에서는 sticky 해제 */
        max-height: 400px;
        order: 2;
        /* 모바일에서는 아래로 배치 (선택 사항) */
    }

    .content-wrapper {
        order: 1;
    }

    .slot-container {
        flex-direction: column;
        align-items: center;
    }

    .slot-window {
        width: 280px;
    }

    .history-section {
        margin: 0;
        padding: 1.5rem;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .history-time {
        align-self: flex-end;
    }
}

/* ===== 확률 정보 섹션 ===== */
.probability-info {
    max-width: 600px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 2rem;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

.prob-title {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.prob-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prob-list li {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.prob-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.prob-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.prob-text strong {
    color: var(--text-primary);
    display: inline;
    margin-right: 0.5rem;
}