/* ================================
   애니팡 게임 스타일 - 다크 테마
================================ */

.anipang-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.anipang-container h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.anipang-container .page-desc {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* 메인 레이아웃 */
.anipang-main-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
}

/* 게임 영역 */
.anipang-game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.anipang-game-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.anipang-game-card h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-align: center;
}

.anipang-game-desc {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.95rem;
    text-align: center;
}

/* 게임 상태 표시 */
.anipang-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 12px;
}

.anipang-score {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    color: var(--gold-primary);
    font-weight: 700;
}

.anipang-score .score-icon {
    font-size: 1.4rem;
}

.anipang-combo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    color: var(--neon-green);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.anipang-combo.active {
    opacity: 1;
    animation: comboPulse 0.5s ease-out;
}

@keyframes comboPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* 사운드 컨트롤 */
.anipang-sound-control {
    display: flex;
    align-items: center;
}

.anipang-sound-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.anipang-sound-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.anipang-sound-btn.muted {
    opacity: 0.6;
    background: rgba(255, 59, 48, 0.1);
}

.anipang-sound-btn.muted:hover {
    background: rgba(255, 59, 48, 0.2);
}


.anipang-count-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--text-primary);
}

.anipang-count-display .count-icon {
    font-size: 1.2rem;
}

.anipang-count-display strong {
    color: var(--gold-primary);
}

/* 타이머 표시 */
.anipang-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--neon-green);
    font-variant-numeric: tabular-nums;
}

.anipang-timer.warning {
    color: #ff9500;
    animation: timerPulse 0.5s ease-in-out infinite;
}

.anipang-timer.danger {
    color: #ff3b30;
    animation: timerPulse 0.3s ease-in-out infinite;
}

@keyframes timerPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* 게임 보드 */
.anipang-board-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.anipang-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    padding: 10px;
    background: linear-gradient(145deg, rgba(30, 30, 35, 0.9), rgba(20, 20, 25, 0.95));
    border-radius: 12px;
    border: 2px solid rgba(212, 175, 55, 0.3);
    box-shadow:
        inset 0 2px 10px rgba(0, 0, 0, 0.5),
        0 4px 20px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

/* 블록 셀 */
.anipang-cell {
    width: 65px;
    height: 65px;
    border-radius: 12px;
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
    background-size: 90%;
    background-position: center;
    background-repeat: no-repeat;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.anipang-cell:active {
    cursor: grabbing;
}

.anipang-cell:hover {
    transform: scale(1.08);
    z-index: 10;
}

.anipang-cell.selected {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    z-index: 20;
}

.anipang-cell.hint {
    animation: hintPulse 1s ease-in-out infinite;
}

@keyframes hintPulse {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    }
}

/* 블록 타입별 스타일 - PokeAPI 스프라이트 사용 */
.anipang-cell[data-type="1"] {
    background-color: #FFDC5D;
    background-image: url('https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/25.png');
}

.anipang-cell[data-type="2"] {
    background-color: #6BB5F0;
    background-image: url('https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/393.png');
}

.anipang-cell[data-type="3"] {
    background-color: #A8D5A2;
    background-image: url('https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/906.png');
}

.anipang-cell[data-type="4"] {
    background-color: #FF8A65;
    background-image: url('https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/909.png');
}

.anipang-cell[data-type="5"] {
    background-color: #9575CD;
    background-image: url('https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/94.png');
}

.anipang-cell[data-type="6"] {
    background-color: #D4A373;
    background-image: url('https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/133.png');
}

/* 특수 블록 */
.anipang-cell.special-stripe-h::after,
.anipang-cell.special-stripe-v::after {
    content: '';
    position: absolute;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
}

.anipang-cell.special-stripe-h::after {
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    transform: translateY(-50%);
}

.anipang-cell.special-stripe-v::after {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
}

.anipang-cell.special-bomb {
    box-shadow: 0 0 10px rgba(255, 100, 50, 0.8);
}

.anipang-cell.special-bomb::after {
    content: '💣';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.anipang-cell.special-rainbow {
    background: linear-gradient(45deg,
            #ff6b6b, #feca57, #48dbfb, #ff9ff3, #54a0ff, #5f27cd);
    background-size: 200% 200%;
    animation: rainbowShift 2s linear infinite;
}

@keyframes rainbowShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* 매치 애니메이션 */
.anipang-cell.matched {
    animation: matchPop 0.3s ease-out forwards;
}

@keyframes matchPop {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* 낙하 애니메이션 */
.anipang-cell.falling {
    animation: fallDown 0.3s ease-in;
}

@keyframes fallDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* 교환 애니메이션 */
.anipang-cell.swapping {
    transition: transform 0.2s ease-in-out;
}

/* 게임 버튼 */
.anipang-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.anipang-buttons.in-game {
    display: none;
}

.anipang-btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.anipang-btn-start {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-light));
    color: #000;
}

.anipang-btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.anipang-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 순위 사이드바 */
.anipang-ranking-sidebar {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.anipang-ranking-sidebar h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.anipang-ranking-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.anipang-ranking-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.anipang-ranking-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.anipang-ranking-item.rank-1 {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(240, 208, 96, 0.1));
    border: 1px solid var(--gold-primary);
}

.anipang-ranking-item.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.2), rgba(220, 220, 220, 0.1));
    border: 1px solid rgba(192, 192, 192, 0.5);
}

.anipang-ranking-item.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.2), rgba(222, 184, 135, 0.1));
    border: 1px solid rgba(205, 127, 50, 0.5);
}

.anipang-ranking-rank {
    font-size: 0.95rem;
    font-weight: 700;
    min-width: 28px;
    flex-shrink: 0;
    color: var(--gold-primary);
}

.anipang-ranking-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.anipang-ranking-avatar.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.anipang-ranking-nickname {
    flex: 1;
    min-width: 0;
    max-width: 85px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.anipang-ranking-score {
    flex-shrink: 0;
    margin-left: 4px;
    font-size: 0.9rem;
    color: var(--gold-primary);
    font-weight: 600;
}

/* 명예의 전당 */
.anipang-ranking-sidebar .hall-of-fame-title {
    font-size: 1rem;
    margin-top: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.anipang-hall-of-fame-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.anipang-hall-of-fame-list .empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 12px 0;
}

.anipang-hall-of-fame-list .anipang-ranking-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 0.9rem;
}

/* 점수 팝업 */
.anipang-score-popup {
    position: fixed;
    pointer-events: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: scorePopup 1s ease-out forwards;
    z-index: 1000;
}

@keyframes scorePopup {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* 게임 오버 오버레이 */
.anipang-game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 100;
}

.anipang-game-over h3 {
    font-size: 2rem;
    color: var(--gold-primary);
    margin-bottom: 20px;
}

.anipang-game-over .final-score {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 30px;
}

/* 모바일 반응형 */
@media (max-width: 900px) {
    .anipang-main-layout {
        grid-template-columns: 1fr;
    }

    .anipang-ranking-sidebar {
        position: static;
        margin-top: 20px;
        order: 2;
    }

    .anipang-game-area {
        order: 1;
    }
}

@media (max-width: 768px) {
    .anipang-container {
        padding: 8px;
        margin: 0;
        border-radius: 0;
        max-width: 100%;
    }

    .anipang-container h2 {
        font-size: 1.2rem;
        margin-bottom: 5px;
    }

    .anipang-container .page-desc {
        font-size: 0.85rem;
        margin-bottom: 10px;
    }

    .anipang-game-card {
        padding: 10px;
        border-radius: 10px;
    }

    .anipang-game-card h3 {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .anipang-game-desc {
        font-size: 0.8rem;
        margin-bottom: 10px;
        display: none;
        /* 모바일에서 설명 숨김 */
    }

    /* 보드 컨테이너 - 화면 전체 너비 사용 */
    .anipang-board-container {
        margin: 8px 0;
        width: 100%;
    }

    .anipang-board {
        /* 보드가 화면 너비를 꽉 채움 */
        width: calc(100vw - 36px);
        height: calc(100vw - 36px);
        gap: 3px;
        padding: 6px;
        margin: 0 auto;
    }

    .anipang-cell {
        /* 크기는 grid의 1fr로 자동 결정 */
        width: 100%;
        height: 100%;
        border-radius: 8px;
        background-size: 85%;
    }

    .anipang-status-bar {
        padding: 8px 10px;
        gap: 10px;
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .anipang-score {
        font-size: 1rem;
    }

    .anipang-timer {
        font-size: 1.1rem;
    }

    .anipang-count-display {
        font-size: 0.85rem;
    }

    .anipang-buttons {
        margin-bottom: 8px;
    }

    .anipang-btn {
        padding: 10px 24px;
        font-size: 0.95rem;
    }

    /* 순위 섹션 간소화 */
    .anipang-ranking-sidebar {
        padding: 15px;
    }

    .anipang-ranking-sidebar h4 {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .anipang-ranking-item {
        padding: 8px 10px 8px 12px;
    }
}

@media (max-width: 480px) {
    .anipang-container {
        padding: 6px;
    }

    .anipang-game-card {
        padding: 8px;
    }

    .anipang-board {
        /* 더 작은 여백으로 더 큰 보드 */
        width: calc(100vw - 24px);
        height: calc(100vw - 24px);
        gap: 2px;
        padding: 4px;
    }

    .anipang-cell {
        border-radius: 6px;
        background-size: 80%;
    }

    .anipang-status-bar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 6px;
    }

    .anipang-score,
    .anipang-timer,
    .anipang-count-display {
        font-size: 0.85rem;
    }

    .anipang-combo {
        font-size: 0.8rem;
    }
}

/* 매우 작은 화면 (아이폰 SE 등) */
@media (max-width: 375px) {
    .anipang-board {
        width: calc(100vw - 16px);
        height: calc(100vw - 16px);
        gap: 2px;
        padding: 3px;
    }

    .anipang-cell {
        border-radius: 5px;
        background-size: 75%;
    }
}