/* ========== PLAYER STYLES ========== */
/* Player page, hunt viewer, elf helper, effects */

/* ========== PAGE LAYOUT ========== */

.player-page {
    background: linear-gradient(180deg, #0f2027 0%, #1a472a 50%, #2d5a3d 100%);
}

.player-container {
    max-width: 600px;
    margin: 0 auto;
}

.player-page .card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.player-page .back-btn {
    color: var(--gold);
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.player-page .back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========== LOGIN LAYOUT ========== */

#login-screen h1 {
    margin-bottom: 24px;
}

#waiting-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#waiting-screen .login-panel {
    width: 100%;
    max-width: 400px;
}

.login-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.login-panel {
    width: 100%;
    max-width: 400px;
}

.login-panel .tabs {
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 4px;
}

.login-panel .tab {
    background: transparent;
    color: #666;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-panel .tab:hover {
    background: rgba(0, 0, 0, 0.05);
}

.login-panel .tab.active {
    background: var(--secondary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.code-input-group {
    display: flex;
    gap: 10px;
}

.code-input {
    text-transform: uppercase;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 4px;
    font-family: monospace;
}

.code-error {
    color: var(--primary);
    text-align: center;
    margin-top: 8px;
}

.btn-cancel-add {
    width: 100%;
    margin-top: 16px;
}

@media (orientation: landscape) and (max-height: 500px) {
    .login-layout {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 30px;
    }

    .login-layout .avatar-picker {
        margin-bottom: 0;
    }

    .login-panel {
        max-width: 350px;
    }
}

/* ========== COMPLETION SCREEN ========== */

.completion {
    text-align: center;
    padding: 40px 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 400px;
}

.completion h1 {
    font-size: 3rem;
    margin-bottom: 20px;
}

.completion p {
    color: var(--white);
    font-size: 1.3rem;
}

/* ========== SNOW & CONFETTI EFFECTS ========== */

.snow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: white;
    font-size: 1.2rem;
    opacity: 0.8;
    animation: snowfall 8s linear infinite;
}

@keyframes snowfall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.3;
    }
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100vh);
        opacity: 0;
    }
}

/* ========== HUNT VIEWER (Fullscreen Image Experience) ========== */

.hunt-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #0f2027 0%, #1a472a 50%, #2d5a3d 100%);
    overflow: hidden;
}

.hunt-images {
    width: 100%;
    height: 100%;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.hunt-images.dragging {
    scroll-snap-type: none !important;
    scroll-behavior: auto !important;
}

.hunt-images.dragging .hunt-image-item {
    scroll-snap-align: none !important;
}

.hunt-images::-webkit-scrollbar {
    display: none;
}

.hunt-image-item {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hunt-image-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Hotspot indicators on hunt images */
.hunt-image-item .hotspot-indicator {
    position: absolute;
    border: 3px solid var(--gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.4),
                0 0 25px rgba(212, 175, 55, 0.5);
    animation: pulse-hotspot 2s ease-in-out infinite;
}

/* ========== CLUE OVERLAY (Frosted Glass) ========== */

.clue-overlay {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 10px 16px;
    max-width: calc(100% - 120px); /* Leave room for logout button */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    user-select: none;
    -webkit-user-select: none;
    animation: clue-pulse 0.6s ease-out 0.2s;
}

@keyframes clue-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5);
    }
    100% {
        box-shadow: 0 0 0 15px rgba(255, 255, 255, 0);
    }
}

.clue-overlay.collapsed {
    padding: 10px;
    border-radius: 50%;
}

.clue-overlay.collapsed .clue-text,
.clue-overlay.collapsed .clue-progress {
    display: none;
}

.clue-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: white;
}

.clue-icon svg {
    width: 100%;
    height: 100%;
}

.clue-text {
    font-size: 0.95rem;
    color: white;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.clue-progress {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    flex-shrink: 0;
}

/* ========== IMAGE INDICATOR DOTS ========== */

.image-dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 100;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    cursor: pointer;
}

.image-dots .image-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.image-dots .image-dot.active {
    background: white;
    transform: scale(1.2);
}

/* ========== HUNT PROGRESS ========== */

.hunt-progress {
    display: none;
}

.hunt-progress .progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    transition: all 0.3s ease;
}

.hunt-progress .progress-dot.current {
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold);
}

.hunt-progress .progress-dot.completed {
    background: var(--secondary);
}

/* ========== ELF HELPER (Clippy-style assistant) ========== */

.elf-helper {
    position: fixed;
    bottom: 80px;
    left: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 500;
    pointer-events: none;
    transition: bottom 0.3s ease, left 0.3s ease;
}

.elf-helper.hidden {
    display: none;
}

.elf-helper.slide-in {
    animation: elfSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.elf-helper.slide-out {
    animation: elfSlideOut 0.4s ease-in forwards;
}

@keyframes elfSlideIn {
    0% {
        transform: translateX(-150%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes elfSlideOut {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-150%);
        opacity: 0;
    }
}

.elf-image {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    animation: elfBounce 2s ease-in-out infinite;
    pointer-events: auto;
    cursor: pointer;
}

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

.elf-speech-container {
    position: relative;
    margin-bottom: 8px;
    animation: speechPop 0.3s ease-out 0.3s both;
}

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

.elf-speech {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px 16px;
    max-width: 240px;
    color: var(--secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2),
                0 0 0 2px var(--gold);
    position: relative;
}

.elf-speech-tail {
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid rgba(255, 255, 255, 0.95);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* ========== RESPONSIVE: ELF HELPER ========== */

@media (orientation: landscape) and (max-height: 500px) {
    .elf-helper {
        bottom: 12px;
        left: 12px;
    }

    .elf-image {
        width: 100px;
    }

    .elf-speech {
        max-width: 220px;
        font-size: 0.85rem;
        padding: 10px 14px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .elf-helper {
        bottom: 24px;
        left: 24px;
    }

    .elf-image {
        width: 120px;
    }

    .elf-speech {
        max-width: 300px;
        font-size: 1rem;
    }
}

@media (min-width: 1024px) {
    .elf-helper {
        bottom: 120px;
        left: 32px;
    }

    .elf-image {
        width: 150px;
    }

    .elf-speech {
        max-width: 320px;
        font-size: 1.05rem;
        padding: 14px 18px;
    }
}

/* ========== PLAYER STACK (Multi-player management) ========== */

.player-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: 200;
}

.player-avatar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-name-label {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: nameSlideInOut 6s ease-in-out forwards;
}

@keyframes nameSlideInOut {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }
    8% {
        opacity: 1;
        transform: translateX(0);
    }
    83% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(20px);
    }
}

.player-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    position: relative;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.player-avatar:hover {
    transform: scale(1.05);
}

.player-avatar.active {
    border-color: var(--gold);
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.4),
                0 4px 12px rgba(0, 0, 0, 0.3);
}

.player-avatar .player-initial {
    text-transform: uppercase;
}

.player-avatar .progress-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--primary);
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.player-avatar.complete .progress-badge {
    background: var(--secondary);
    font-size: 0.75rem;
    padding: 2px 6px;
}

.player-add-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-add-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

/* ========== RESPONSIVE: PLAYER STACK ========== */

@media (orientation: landscape) and (max-height: 500px) {
    .player-stack {
        bottom: 12px;
        right: 12px;
        flex-direction: row;
        align-items: flex-end;
        gap: 8px;
    }

    .player-avatar-wrapper {
        flex-direction: column;
        gap: 4px;
    }

    .player-name-label {
        font-size: 0.7rem;
        padding: 3px 8px;
        order: -1;
        animation: nameSlideUpDown 6s ease-in-out forwards;
    }

    @keyframes nameSlideUpDown {
        0% {
            opacity: 0;
            transform: translateY(20px);
        }
        8% {
            opacity: 1;
            transform: translateY(0);
        }
        83% {
            opacity: 1;
            transform: translateY(0);
        }
        100% {
            opacity: 0;
            transform: translateY(20px);
        }
    }

    .player-avatar,
    .player-add-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .player-avatar .progress-badge {
        font-size: 0.55rem;
        padding: 1px 4px;
        min-width: 20px;
    }
}

/* ========== AVATAR PICKER (Login Screen) ========== */

.avatar-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.avatar-picker-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-image: url('/avatars.png');
    background-size: 700% 400%; /* 7 columns x 4 rows */
    background-position: 0% 0%;
    border: 4px solid var(--gold);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.avatar-picker-circle:hover {
    transform: scale(1.05);
}

.avatar-picker-circle:active {
    transform: scale(0.95);
}

.avatar-picker-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    margin-top: 8px;
}

/* ========== AVATAR SPRITE (Player Stack) ========== */

.player-avatar.has-avatar {
    background-image: url('/avatars.png');
    background-size: 700% 400%; /* 7 columns x 4 rows */
    background-color: transparent;
}

.player-avatar.has-avatar .player-initial {
    display: none;
}

/* ========== LOGOUT BUTTON ========== */

.logout-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 300;
}

.logout-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    color: white;
}

.logout-btn.hidden {
    display: none;
}
