:root {
    --primary: #ec4899;
    --apple-green: #89b33c;
    --score-red: #e11d48;
    --vh: 1vh;
    --pg-top: 215px; /* Moved slightly up as requested */
    --pg-bottom: 30px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    font-family: 'Outfit', sans-serif;
}

html,
body {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #000;
    overscroll-behavior: none;
    touch-action: none;
}

#app-container {
    width: 100%;
    /* [V63] Removed max-width to allow full-width on mobile */
    height: 100%;
    height: 100dvh;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    background: #000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0 !important;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Hide butterflies in Photo Zone and Login */
body:has(#photo-zone-screen.active) .butterfly,
body:has(#login-screen.active) .butterfly,
body:has(#eye-game-screen.active) .butterfly {
    display: none !important;
}

.hidden {
    display: none !important;
}

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.overlay.active {
    display: flex;
}

/* --- Premium Start Screen --- */
.stars-bg {
    position: absolute;
    inset: 0;
    background: #0f172a url('https://www.transparenttextures.com/patterns/stardust.png');
    opacity: 0.5;
    animation: drift 60s linear infinite;
}

@keyframes drift {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 1000px 1000px;
    }
}

/* --- Unified Start Screen (Puzzle Sync) --- */
.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100dvh;
    /* Use 100dvh for true centering */
    padding: 20px;
    z-index: 10;
    position: relative;
    text-align: center;
    box-sizing: border-box;
}

.start-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 30px;
    animation: startLogoFloat 3.5s ease-in-out infinite;
}

.start-logo {
    width: auto;
    max-width: 280px;
    height: auto;
    max-height: 110px;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.6));
}

.start-btn-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

@keyframes startLogoFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.start-btn-primary {
    width: 240px;
    height: 68px;
    background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
    color: white !important;
    border: none !important;
    border-radius: 34px !important;
    font-size: 1.5rem !important;
    font-weight: 950 !important;
    cursor: pointer;
    box-shadow: 0 8px 0 #9d174d, 0 15px 30px rgba(236, 72, 153, 0.5) !important;
    transition: transform 0.1s;
    margin-bottom: 25px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.start-btn-primary:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #9d174d, 0 10px 20px rgba(236, 72, 153, 0.3) !important;
}

.start-secondary-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 60px;
}

.start-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 24px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.start-btn-secondary:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.start-footer-mini {
    position: absolute;
    bottom: 25px;
    text-align: center;
    width: 100%;
    pointer-events: none;
    z-index: 20;
}

.version-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.25);
    margin-bottom: 4px;
}

.copyright {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.15);
}

.login-logo-mini {
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
}

.login-logo-mini img {
    width: 90px;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.login-desc {
    color: #94a3b8;
    font-size: 1rem;
    margin-bottom: 25px;
    font-weight: 700;
}

.login-submit {
    width: 100% !important;
    height: 60px !important;
    margin-top: 20px !important;
    font-size: 1.3rem !important;
}

.login-policy-note {
    margin-top: 25px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
}

.login-policy-note span {
    text-decoration: underline;
    cursor: pointer;
}

.game-footer {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ver-info {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
}

.footer-icon-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.footer-icon-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}


/* --- MASTER 3D HUD STYLE (Puzzle Sync) --- */
.game-hud {
    position: relative;
    padding: 30px 8px 2px !important;
    /* [V68] Final top alignment for notch-capable mobile devices */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* 행 간격 축소 */
    width: 100%;
}

.hud-row-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    width: 100%;
}

/* Base style for all 3D tiles & buttons */
.hud-tile,
.header-icon-btn-3d {
    background: #111827 !important;
    border: none !important;
    border-radius: 12px !important;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    cursor: pointer;
    transform: perspective(800px) rotateX(15deg);
    transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 2px 0 #1f2937,
        0 6px 12px rgba(0, 0, 0, 0.4);
}

.hud-tile:active,
.header-icon-btn-3d:active {
    transform: perspective(800px) rotateX(5deg) translateY(2px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 1px 0 #1f2937,
        0 2px 4px rgba(0, 0, 0, 0.4);
}

.hud-label {
    font-size: 10px !important;
    font-weight: 1000 !important;
    color: #f472b6 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
    line-height: 1;
}

.hud-value {
    font-size: 1.1rem;
    font-weight: 950;
    color: #ffffff;
    line-height: 1;
}

#level-val {
    color: #fbbf24;
}

/* LUCKY TILE (Semi-transparent & Standard size) */
.lucky-tile {
    min-width: 45px;
    height: 48px;
    background: rgba(17, 24, 39, 0.4) !important;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.lucky-tile .hud-label {
    font-size: 10px !important;
    font-weight: 1000 !important;
    color: #f472b6 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
    line-height: 1;
}

#lucky-img {
    width: 26px !important;
    height: 26px !important;
    object-fit: contain !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Stat Tiles */
.stage-tile {
    width: 55px;
    height: 44px;
}

.score-tile {
    flex: 1.2;
    height: 44px;
}

.target-tile {
    flex: 1;
    height: 44px;
}

/* HUD Icons (Settings & Reset) */
.header-icon-btn-3d {
    width: 44px;
    /* Sufficient width for large icons */
    height: 44px;
    color: white;
}

.header-icon-btn-3d .val {
    font-size: 1.6rem;
    /* Slightly resized to fit 44px height */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-row-2 {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.health-container {
    flex: 1;
    height: 30px;
    background: #111827;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    transform: none;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ec4899, #be185d);
    width: 100%;
    transition: width 0.3s ease-out;
}

.health-container::after {
    content: 'ENERGY';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 950;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 1px;
}

/* Specific Reset button size in Row 2 - adjusted for the new icon */
#reset-btn-hud {
    width: 50px;
    height: 38px;
    transform: none;
}

#reset-btn-hud .val {
    font-size: 1.6rem;
    /* Good size for the U-turn arrow */
}

/* --- Character Layout Cleanup --- */
#game-playground {
    position: absolute;
    inset: 0;
    padding: 0;
    z-index: 50;
}

.char-item {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    border-radius: 30%;
    background: transparent;
    overflow: hidden;
    transition: opacity 0.2s;
}

.char-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.guide-text-3d {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 4px #c026d3, 0 8px #9333ea, 0 12px 15px rgba(0, 0, 0, 0.5);
    letter-spacing: -0.5px;
}

.focused {
    border: 4px solid #fff59d !important;
    outline: 2px solid #fbc02d;
    box-shadow:
        0 0 20px rgba(255, 235, 59, 1),
        inset 0 0 10px rgba(0, 0, 0, 0.2),
        0 15px 30px rgba(0, 0, 0, 0.4) !important;
    z-index: 500 !important;
}

/* Character Backgrounds */
.bg-pink {
    background: #fce7f3 !important;
}

.bg-blue {
    background: #e0f2fe !important;
}

.bg-yellow {
    background: #fefce8 !important;
}

.bg-green {
    background: #f0fdf4 !important;
}

.bg-purple {
    background: #f5f3ff !important;
}

.bg-orange {
    background: #fff7ed !important;
}

/* --- Premium Login Card --- */
#login-screen {
    position: absolute;
    inset: 0;
    z-index: 2000;
    display: none;
    background: radial-gradient(circle at center, #1e1b4b 0%, #030712 100%);
    justify-content: center;
    align-items: center;
}

#login-screen.active {
    display: flex;
}

/* --- Unified Premium Card Style --- */
.glass-card {
    width: 85%;
    max-width: 320px;
    padding: 20px;
    background: linear-gradient(145deg, rgba(30, 27, 75, 0.9) 0%, rgba(49, 46, 129, 0.9) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-height: 85%;
    overflow-y: auto;
    color: #f3f4f6;
    display: flex;
    flex-direction: column;
}

/* Explicitly defining both to ensure consistency */
.login-card,
.settings-card,
.transition-card,
.reward-card {
    width: 85%;
    max-width: 340px;
    padding: 25px 20px;
    background: linear-gradient(145deg, rgba(30, 27, 75, 0.9) 0%, rgba(49, 46, 129, 0.9) 100%) !important;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 32px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    text-align: center;
    max-height: 92vh;
    overflow-y: auto;
    color: #f3f4f6;
    display: flex;
    flex-direction: column;
    animation: card-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Compact Login Overrides */
.login-compact {
    padding: 10px 20px !important;
}

.login-compact .login-logo-mini img {
    height: 60px !important;
    width: auto;
    margin-bottom: 2px !important;
}

.login-compact .login-title {
    margin: 2px 0 10px 0 !important;
    font-size: 1.1rem !important;
    letter-spacing: 2px;
}

.login-compact .input-group {
    margin-bottom: 8px !important;
    text-align: left;
}

.login-compact .input-group label {
    font-size: 0.6rem !important;
    margin-bottom: 2px !important;
    display: block;
    opacity: 0.8;
}

.login-compact input {
    height: 38px !important;
    font-size: 0.85rem !important;
    padding: 0 12px !important;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    width: 100%;
}

.login-compact .login-submit {
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    padding: 12px !important;
    font-size: 0.95rem !important;
}

.login-compact .login-policy-note {
    font-size: 0.6rem !important;
    margin-top: 5px;
    opacity: 0.6;
}

.login-compact .login-policy-note span {
    text-decoration: underline;
    cursor: pointer;
}

@keyframes card-pop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.login-title,
.settings-title {
    color: white;
    font-size: 1.6rem;
    font-weight: 950;
    margin-bottom: 20px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.settings-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 25px;
}

.option-btn {
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-btn,
.start-btn-secondary {
    width: 100%;
    height: 52px;
    margin-top: 10px;
    border: none;
    border-radius: 26px;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-btn.primary {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.menu-btn.secondary,
.start-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.menu-btn:active,
.start-btn-secondary:active {
    transform: scale(0.96);
    filter: brightness(0.9);
}

.option-btn.active {
    background: rgba(236, 72, 153, 0.2);
    border-color: rgba(236, 72, 153, 0.4);
    color: #f472b6;
}

.policy-links {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-btn.tertiary {
    display: block;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    height: auto;
}

.social-login-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.social-btn {
    height: 48px;
    border-radius: 12px;
    border: none;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.social-btn.gmail,
.social-btn.google {
    background: #ffffff;
    color: #3c4043;
    border: 1px solid #dadce0;
}

.social-btn.apple {
    background: #000000;
    color: #ffffff;
}

.social-btn.naver {
    background: #03C75A;
    color: #ffffff;
}

.social-btn.kakao {
    background: #FEE500;
    color: #191919;
}

.social-btn:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

#policy-content {
    display: none;
    position: absolute;
    inset: 0;
    background: #1e1b4b;
    border-radius: 25px;
    padding: 20px;
    flex-direction: column;
    z-index: 100;
}

#policy-title {
    margin-bottom: 15px;
    font-weight: 900;
    font-size: 1.1rem;
    color: #fff;
    text-align: center;
}

#policy-text {
    flex: 1;
    overflow-y: auto;
    text-align: left;
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.guest-form {
    text-align: left;
}

.input-group {
    margin-bottom: 8px;
}

.input-group label {
    display: block;
    font-size: 0.65rem;
    font-weight: 900;
    color: #94a3b8;
    margin-bottom: 2px;
    padding-left: 5px;
}

.input-group input {
    width: 100%;
    height: 44px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    padding: 0 12px;
    font-size: 0.9rem;
}

/* --- Premium 3D LUCKY Badge --- */
.combo-text {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translate(-50%, -50%) scale(0.5);
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #fff;
    border: 3px solid #ffffff;
    border-radius: 40px;
    font-size: 1.6rem;
    font-weight: 950;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    box-shadow:
        0 0 0 3px rgba(251, 191, 36, 0.3),
        0 10px 25px rgba(0, 0, 0, 0.5),
        inset 0 3px 0 rgba(255, 255, 255, 0.6);
    z-index: 10000;
    white-space: nowrap;
    animation: double-3d-pop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: none;
}

@keyframes double-3d-pop {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-20deg);
        opacity: 0;
    }

    30% {
        transform: translate(-50%, -50%) scale(0.8) rotate(5deg);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -50%) scale(0.6) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -120%) scale(0.55);
        opacity: 0;
    }
}

/* --- FORCE HIDE WEBGAZER UI --- */
#webgazerVideoContainer,
#webgazerVideoFeed,
#webgazerFaceOverlay,
#webgazerFaceFeedbackBox,
.webgazerPredictionPoint {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
}