:root {
    --naruto-dpr: 1;
    --naruto-logical-w: 640px;
    --naruto-logical-h: 960px;
    --naruto-design-w: 686px;
    --naruto-design-h: 1208px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}

body {
    position: relative;
    background: radial-gradient(circle at center, #182338 0%, #0b111e 55%, #05080f 100%);
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100dvh;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

/* Ambient Wide-Screen PC/Tablet Village Scroll Backdrop */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(10, 15, 28, 0.45) 0%, rgba(5, 8, 15, 0.92) 78%),
        url("../assets/textures/background/background_01.webp");
    background-size: cover;
    background-position: center top;
    filter: blur(14px) saturate(1.15) brightness(0.48);
    transform: scale(1.06) translateZ(0);
    will-change: transform;
    contain: strict;
    pointer-events: none;
    z-index: 0;
}

#game-wrapper {
    position: relative;
    z-index: 10;
    width: min(calc(100vw - var(--safe-area-left) - var(--safe-area-right)), calc((100dvh - var(--safe-area-top) - var(--safe-area-bottom)) * 686 / 1208));
    height: min(calc(100dvh - var(--safe-area-top) - var(--safe-area-bottom)), calc((100vw - var(--safe-area-left) - var(--safe-area-right)) * 1208 / 686));
    aspect-ratio: 686 / 1208;
    background: #000;
    border: 2px solid rgba(217, 119, 6, 0.55);
    box-shadow:
        0 16px 56px rgba(0, 0, 0, 0.92),
        0 0 28px rgba(217, 119, 6, 0.22),
        inset 0 0 0 1px rgba(251, 191, 36, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    object-fit: fill;
    background-color: #0b1320;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
    display: block;
    touch-action: none;
    transform: translateZ(0);
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("../assets/ccbResources/loginbackground.png?v=20261107_hd14") center center / cover no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    transition: opacity 0.5s ease;
    padding: 5.5% 0 6.5% 0;
    box-sizing: border-box;
    overflow: hidden;
}

.splash-logo-img {
    width: 72%;
    max-width: 430px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 18px rgba(251, 146, 60, 0.35));
    animation: splashLogoHeroPulse 3.0s ease-in-out infinite;
    user-select: none;
    pointer-events: none;
    z-index: 2;
}

@keyframes splashLogoHeroPulse {
    0%, 100% {
        transform: translateY(0px) scale(1.0);
        filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 16px rgba(168, 85, 247, 0.38));
    }
    50% {
        transform: translateY(-6px) scale(1.038);
        filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 24px rgba(251, 191, 36, 0.55));
    }
}

.splash-center-stage {
    position: relative;
    width: 190px;
    height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: auto;
    margin-bottom: 12px;
    z-index: 2;
}

.splash-rasengan-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    background: url("../assets/ccbResources/loading_rasengan.png") center center / contain no-repeat;
    animation: splashRasenganSpin 6s linear infinite;
    opacity: 0.94;
    pointer-events: none;
}

.splash-chibi-runner {
    position: relative;
    width: 84px;
    height: 119px;
    background-image: url("../assets/ccbResources/loading_naruto_run_strip.png");
    background-repeat: no-repeat;
    background-size: 588px 119px;
    animation: splashChibiRun 0.65s steps(7) infinite;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75));
    z-index: 3;
}

@keyframes splashRasenganSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes splashChibiRun {
    from { background-position: 0px 0; }
    to { background-position: -588px 0; }
}

.loader-box {
    position: relative;
    text-align: center;
    width: 88%;
    max-width: 490px;
    min-height: 68px;
    aspect-ratio: 519 / 90;
    background: url("../assets/ccbResources/loading_scroll_bg.png") center center / 100% 100% no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 13% 10px 13%;
    box-sizing: border-box;
    z-index: 2;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.78));
}

@media (max-width: 720px) {
    body {
        background: radial-gradient(circle at center, #141c2f 0%, #070b14 70%, #03050a 100%);
    }
    body::before {
        opacity: 0.45;
    }
    #game-wrapper {
        border: none;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.75);
    }
    .loader-box {
        min-height: 62px;
        padding: 6px 11% 8px 11%;
    }
    #loading-status {
        font-size: 12px;
    }
}

.progress-bar-bg {
    width: 100%;
    height: 18px;
    background: url("../assets/ccbResources/loading_bar_frame.png") center center / 100% 100% no-repeat;
    border-radius: 9px;
    overflow: hidden;
    margin-bottom: 5px;
    padding: 3px 4px;
    box-sizing: border-box;
}

#progress-bar-fill {
    width: 4%;
    height: 100%;
    background: url("../assets/ccbResources/loading_bar_fill.png") left center / 100% 100% no-repeat;
    border-radius: 6px;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.85);
    transition: width 0.25s ease;
}

#loading-status {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 3px #000, 0 0 5px #000;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

#loading-meta {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    color: #fde68a;
    text-shadow: 0 1px 3px #000, 0 0 4px #000;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

#loading-tip {
    width: 88%;
    max-width: 480px;
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(6, 10, 22, 0.72);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    color: #e2e8f0;
    text-align: center;
    line-height: 1.35;
    text-shadow: 0 1px 2px #000;
    z-index: 2;
}

#hud-controls {
    display: none;
}

#btn-fullscreen {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.75);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

#btn-fullscreen:hover {
    background: rgba(30, 41, 59, 0.9);
    color: #fff;
}

#socket-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
}

.status-connected { color: #34d399; }
.status-disconnected { color: #f87171; }

