/* ==================== ローディング画面 ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

/* ドット絵の子供 */
.pixel-child {
    width: 64px;
    height: 80px;
    margin: 0 auto 20px;
    position: relative;
    image-rendering: pixelated;
    animation: studyAnimation 2s ease-in-out infinite;
}

/* 子供の体 */
.child-body {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* 頭 */
.head {
    width: 32px;
    height: 32px;
    background: #f4c2a1;
    position: relative;
    margin: 0 auto;
}

/* 髪 */
.hair {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 12px;
    background: #4a4a4a;
}

/* 目 */
.eyes {
    position: absolute;
    top: 14px;
    left: 8px;
    right: 8px;
    height: 4px;
    display: flex;
    justify-content: space-between;
}

.eye {
    width: 4px;
    height: 4px;
    background: #333;
}

/* 体 */
.body-part {
    width: 24px;
    height: 32px;
    background: #5a9fd4;
    margin: 0 auto;
    position: relative;
}

/* 腕 */
.arms {
    position: absolute;
    top: 4px;
    left: -4px;
    right: -4px;
    height: 16px;
}

.arm {
    width: 4px;
    height: 16px;
    background: #f4c2a1;
    position: absolute;
}

.arm.left {
    left: 0;
    transform-origin: top center;
    animation: writeLeft 2s ease-in-out infinite;
}

.arm.right {
    right: 0;
}

/* 机 */
.desk {
    width: 48px;
    height: 8px;
    background: #8b6f47;
    margin: -4px auto 0;
    position: relative;
    z-index: 1;
}

/* 本 */
.book {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 4px;
    background: #ff6b6b;
    z-index: 2;
}

/* 電球アイコン */
.lightbulb {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 24px;
    height: 32px;
    opacity: 0;
    animation: lightbulbPop 2s ease-in-out infinite;
}

.bulb {
    width: 16px;
    height: 20px;
    background: #ffd93d;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 20px #ffd93d;
}

.bulb::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 4px;
    background: #666;
}

/* 光線 */
.rays {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ray {
    position: absolute;
    width: 2px;
    height: 8px;
    background: #ffd93d;
}

.ray:nth-child(1) { transform: rotate(0deg) translateY(-16px); }
.ray:nth-child(2) { transform: rotate(45deg) translateY(-16px); }
.ray:nth-child(3) { transform: rotate(90deg) translateY(-16px); }
.ray:nth-child(4) { transform: rotate(135deg) translateY(-16px); }
.ray:nth-child(5) { transform: rotate(180deg) translateY(-16px); }
.ray:nth-child(6) { transform: rotate(225deg) translateY(-16px); }
.ray:nth-child(7) { transform: rotate(270deg) translateY(-16px); }
.ray:nth-child(8) { transform: rotate(315deg) translateY(-16px); }

/* ローディングテキスト */
.loading-text {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 20px;
    font-family: 'Kosugi Maru', sans-serif;
}

.loading-dots {
    display: inline-block;
    width: 60px;
    text-align: left;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

/* アニメーション */
@keyframes studyAnimation {
    0%, 20% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-2px);
    }
    30%, 100% {
        transform: translateY(0);
    }
}

@keyframes writeLeft {
    0%, 60% {
        transform: rotate(0deg);
    }
    70% {
        transform: rotate(-10deg);
    }
    80% {
        transform: rotate(5deg);
    }
    90%, 100% {
        transform: rotate(0deg);
    }
}

@keyframes lightbulbPop {
    0%, 60% {
        transform: translateX(-50%) scale(0);
        opacity: 0;
    }
    70% {
        transform: translateX(-50%) scale(1.2);
        opacity: 1;
    }
    80% {
        transform: translateX(-50%) scale(0.9);
        opacity: 1;
    }
    90%, 100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

/* スマートフォン対応 */
@media (max-width: 768px) {
    .loading-text {
        font-size: 1.2rem;
    }
    
    .pixel-child {
        transform: scale(0.8);
    }
}