/* ===== Base & Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== Canvas ===== */
#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

/* ===== Glass Panel ===== */
.glass-panel {
    background: rgba(10, 10, 30, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ===== Joystick ===== */
#joystick-container .back {
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.3) 100%) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
}

#joystick-container .front {
    background: radial-gradient(circle, rgba(255,255,255,0.7) 0%, rgba(200,200,255,0.4) 100%) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    box-shadow: 0 0 20px rgba(100, 150, 255, 0.3) !important;
}

/* ===== Modals ===== */
#start-screen,
#room-complete-modal,
#game-over-modal,
#pause-menu,
#level-complete-modal,
#all-clear-modal {
    display: flex;
}

.hidden {
    display: none !important;
}

/* ===== Game Button ===== */
.game-btn {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: none;
    color: white;
    letter-spacing: 0.05em;
}

.game-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s;
}

.game-btn:hover::before {
    left: 100%;
}

.game-btn:active {
    transform: scale(0.95);
}

/* ===== Loading Spinner ===== */
.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Title Animation ===== */
.animate-title {
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(255, 200, 50, 0.3));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(255, 200, 50, 0.6));
        transform: scale(1.02);
    }
}

/* ===== Danger Pulse ===== */
.animate-danger {
    animation: dangerPulse 0.8s ease-in-out infinite;
}

@keyframes dangerPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        text-shadow: 0 0 10px rgba(255, 50, 50, 0.5);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.08);
        text-shadow: 0 0 25px rgba(255, 50, 50, 0.8), 0 0 50px rgba(255, 0, 0, 0.3);
    }
}

/* ===== Bounce Slow ===== */
.animate-bounce-slow {
    animation: bounceSlow 2s ease-in-out infinite;
}

@keyframes bounceSlow {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-8px); }
}

/* ===== Star Animation ===== */
.star-animate {
    animation: starPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes starPop {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-30deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* ===== Life Icon ===== */
.life-icon {
    transition: all 0.3s ease;
}

.life-icon.lost {
    color: #374151;
    transform: scale(0.8);
    opacity: 0.4;
    filter: grayscale(1);
}

/* ===== Caught Flash ===== */
#caught-flash {
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease;
}

#caught-flash.active {
    opacity: 1;
    animation: caughtFlash 0.6s ease-out forwards;
}

@keyframes caughtFlash {
    0% { opacity: 0.6; }
    20% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* ===== Progress Bar Shimmer ===== */
#progress-bar {
    position: relative;
    overflow: hidden;
}

#progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -50%; }
    100% { left: 150%; }
}

/* ===== Action Button Glow ===== */
#action-button {
    position: relative;
}

#action-button::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent, rgba(96, 165, 250, 0.4), transparent, rgba(96, 165, 250, 0.2), transparent);
    animation: buttonGlow 3s linear infinite;
    z-index: -1;
}

@keyframes buttonGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Throw Button ===== */
#throw-button {
    position: relative;
}

#throw-button::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent, rgba(245, 158, 11, 0.4), transparent, rgba(245, 158, 11, 0.2), transparent);
    animation: buttonGlow 3s linear infinite;
    z-index: -1;
}

/* ===== Door Button ===== */
#door-button {
    position: relative;
}

#door-button::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent, rgba(16, 185, 129, 0.4), transparent, rgba(16, 185, 129, 0.2), transparent);
    animation: buttonGlow 3s linear infinite;
    z-index: -1;
}

/* ===== Minimap ===== */
#minimap {
    opacity: 0.75;
    transition: opacity 0.3s;
}

#minimap:hover {
    opacity: 1;
}

@media (max-width: 640px) {
    #minimap {
        width: 70px !important;
        height: 112px !important;
        opacity: 0.65;
    }
}

/* ===== Score Pop ===== */
.score-pop {
    position: absolute;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 100;
    animation: scorePop 1s ease-out forwards;
}

@keyframes scorePop {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    60% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

/* ===== Wolf HP Pulse when low ===== */
@keyframes wolfHPPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== Phase indicator pulse ===== */
#phase-indicator {
    transition: color 0.3s ease;
}

/* ===== Screen Transitions ===== */
#start-screen,
#room-complete-modal,
#game-over-modal,
#pause-menu,
#level-complete-modal,
#all-clear-modal {
    transition: opacity 0.4s ease;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    #joystick-container {
        bottom: 2rem !important;
        left: 1rem !important;
    }

    /* 相位指示器在手机上调整位置 */
    .absolute.bottom-44.left-4 {
        bottom: 10rem !important;
        left: 0.5rem !important;
        max-width: 180px !important;
    }

    #action-button {
        bottom: 2rem !important;
        right: 7rem !important;
        width: 5rem !important;
        height: 5rem !important;
    }

    #throw-button {
        bottom: 2rem !important;
        right: 13rem !important;
        width: 4rem !important;
        height: 4rem !important;
    }

    #door-button {
        bottom: 8rem !important;
        right: 7rem !important;
        width: 4rem !important;
        height: 4rem !important;
    }

    .glass-panel {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

/* ===== Wolf Mode HUD ===== */
#wolf-mode-hud {
    transition: opacity 0.3s ease;
}

#wolf-door-hint {
    pointer-events: none;
}

#wolf-door-hint .glass-panel {
    animation: bounceSlow 2s ease-in-out infinite;
}

/* Wolf catch icon animation */
#wolf-catch-icons .ri-ghost-fill {
    animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* ===== Knock Warning Animation ===== */
#knock-warning-panel {
    animation: knockShake 0.3s ease-in-out infinite;
}

@keyframes knockShake {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    25% { transform: translateX(calc(-50% + 3px)) translateY(-2px); }
    75% { transform: translateX(calc(-50% - 3px)) translateY(2px); }
}

#knock-warning-bar {
    position: relative;
    overflow: hidden;
}

#knock-warning-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 0.8s infinite;
}

/* ===== Character Selection Cards ===== */
.char-card {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.char-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.char-card:hover {
    transform: translateY(-4px);
}

.char-card-selected {
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.3), inset 0 0 20px rgba(96, 165, 250, 0.05);
}

.char-card-selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 1rem;
    font-weight: bold;
    color: #60a5fa;
    text-shadow: 0 0 6px rgba(96, 165, 250, 0.6);
}

#char-wolf.char-card-selected {
    border-color: rgba(239, 68, 68, 0.6) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), inset 0 0 20px rgba(239, 68, 68, 0.05);
}

#char-wolf.char-card-selected::after {
    color: #ef4444;
    text-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

/* ===== Task Mini-game Styles ===== */
#task-minigame-area {
    transition: background-color 0.15s ease;
}

#task-minigame-area span {
    transition: all 0.15s ease;
}

#task-title {
    text-shadow: 0 0 8px rgba(250, 204, 21, 0.3);
}

#task-combo {
    animation: comboGlow 0.5s ease-in-out infinite alternate;
}

@keyframes comboGlow {
    0% { opacity: 0.7; }
    100% { opacity: 1; text-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
}

#progress-container {
    z-index: 20;
}

@media (max-width: 640px) {
    #progress-container {
        width: 90% !important;
        max-width: 320px;
    }
}
