/* =========================================================
   ロード画面（毎回表示・5パターンからランダム）
   html[data-cr-loader="party|parade|space|peekaboo|dance"]
   ========================================================= */

/* ---------- 共通 ---------- */
#cr-loader { display: none; }
html.cr-loading { overflow: hidden; }
html.cr-loading #cr-loader,
#cr-loader.is-leaving {
    display: flex;
}
#cr-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    overflow: hidden;
    background-color: #FFD93D;
    background-image:
        radial-gradient(rgba(0, 0, 0, .14) 2px, transparent 2px),
        radial-gradient(circle at 50% 120%, #FFF6CC 0, #FFD93D 60%);
    background-size: 26px 26px, 100% 100%;
    font-family: 'M PLUS Rounded 1c', 'Noto Sans JP', sans-serif;
    clip-path: circle(150% at 50% 50%);
}
/* 選ばれたパターンだけ表示（ほかは画像も読み込まれない） */
.crl-scene { display: none; width: 100%; justify-content: center; align-items: center; }
html[data-cr-loader="party"] .crl-scene--party,
html[data-cr-loader="parade"] .crl-scene--parade,
html[data-cr-loader="space"] .crl-scene--space,
html[data-cr-loader="peekaboo"] .crl-scene--peekaboo,
html[data-cr-loader="dance"] .crl-scene--dance { display: flex; }

/* 退場：パターンごとに違う閉じ方でページが現れる */
#cr-loader.is-leaving { transition: clip-path .85s cubic-bezier(.7, 0, .3, 1) .25s; }
html[data-cr-loader="party"]    #cr-loader.is-leaving { clip-path: circle(0% at 50% 45%); }
html[data-cr-loader="parade"]   #cr-loader { clip-path: inset(0 0 0 0); }
html[data-cr-loader="parade"]   #cr-loader.is-leaving { clip-path: inset(0 0 0 100%); }
html[data-cr-loader="space"]    #cr-loader { clip-path: inset(0 0 0 0); }
html[data-cr-loader="space"]    #cr-loader.is-leaving { clip-path: inset(0 0 100% 0); }
html[data-cr-loader="peekaboo"] #cr-loader { clip-path: inset(0 0 0 0 round 0); }
html[data-cr-loader="peekaboo"] #cr-loader.is-leaving { clip-path: inset(50% 50% 50% 50% round 60px); }
html[data-cr-loader="dance"]    #cr-loader.is-leaving { clip-path: circle(0% at 100% 0%); }
#cr-loader.is-leaving .crl-char,
#cr-loader.is-leaving .crl-friend,
#cr-loader.is-leaving .crls-hero,
#cr-loader.is-leaving .crlk-pop,
#cr-loader.is-leaving .crld-dancer {
    animation: crl-fly-up .6s cubic-bezier(.5, -0.4, .7, 1) both !important;
}
#cr-loader.is-leaving .crlp-march { animation: crlp-dash .7s cubic-bezier(.5, 0, .9, .5) forwards !important; }
@keyframes crlp-dash { to { transform: translateX(120vw); } }
#cr-loader.is-leaving .crl-footer { opacity: 0; transition: opacity .2s; }
@keyframes crl-fly-up { to { transform: translateY(-110vh) rotate(25deg) scale(.6); } }

.crl-stage {
    position: relative;
    width: min(920px, 100%);
    height: min(56vh, 460px);
}
.crl-char,
.crl-friend { position: absolute; bottom: 0; }
.crl-char img,
.crl-friend img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(5px 6px 0 rgba(0, 0, 0, .18));
}
.crl-char { width: clamp(90px, 18vw, 180px); }
.crl-c1 { left: 2%;  bottom: 4%;  animation: crl-hop .62s ease-in-out infinite; }
.crl-c2 { left: 19%; bottom: 0;   animation: crl-shake .25s ease-in-out infinite; }
.crl-c3 { left: 50%; bottom: 10%; width: clamp(120px, 24vw, 240px); margin-left: calc(clamp(120px, 24vw, 240px) / -2); animation: crl-bigjump 1.1s cubic-bezier(.3, 0, .5, 1) infinite; }
.crl-c4 { right: 19%; bottom: 2%; animation: crl-hop .7s ease-in-out infinite .2s; }
.crl-c5 { right: 2%; bottom: 0;   animation: crl-bow 1.4s ease-in-out infinite; transform-origin: 50% 100%; }

.crl-friend { width: clamp(52px, 10vw, 100px); }
.crl-f1 { left: 34%; bottom: -2%; animation: crl-squish .5s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.crl-f2 { left: 64%; bottom: -2%; animation: crl-hop .5s ease-in-out infinite .1s; }
.crl-f3 { left: 30%; top: 2%; bottom: auto; animation: crl-flyaround 3.2s ease-in-out infinite; }
.crl-f4 { right: 32%; top: 6%; bottom: auto; animation: crl-flyaround 3.8s ease-in-out infinite reverse; }

.crl-bubble {
    position: absolute;
    top: -8%;
    left: 50%;
    padding: 4px 12px;
    background: #fff;
    border: 3px solid #111;
    border-radius: 999px;
    font-weight: 900;
    font-size: clamp(11px, 1.6vw, 16px);
    white-space: nowrap;
    box-shadow: 3px 3px 0 #111;
    transform: translate(-50%, 0) scale(0);
    animation: crl-bubble 2.4s ease-in-out infinite;
}
.crl-c2 .crl-bubble { animation-delay: .5s; }
.crl-c3 .crl-bubble { animation-delay: 1s; top: -14%; }
.crl-c4 .crl-bubble { animation-delay: 1.5s; }
.crl-c5 .crl-bubble { animation-delay: 1.9s; }

@keyframes crl-hop {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50%      { transform: translateY(-34px) rotate(4deg); }
}
@keyframes crl-bigjump {
    0%, 100% { transform: translateY(0) scale(1.05, .92); }
    15%      { transform: translateY(0) scale(.95, 1.06); }
    50%      { transform: translateY(-70px) rotate(-6deg); }
    85%      { transform: translateY(0) scale(1.06, .9); }
}
@keyframes crl-shake {
    0%, 100% { transform: translateY(0) rotate(-1.5deg); }
    50%      { transform: translateY(-3px) rotate(1.5deg); }
}
@keyframes crl-bow {
    0%, 60%, 100% { transform: rotate(0); }
    30%           { transform: rotate(12deg) translateY(4px); }
}
@keyframes crl-squish {
    from { transform: scale(1.12, .86); }
    to   { transform: scale(.92, 1.1) translateY(-10px); }
}
@keyframes crl-flyaround {
    0%, 100% { transform: translate(0, 0) rotate(-8deg); }
    25%      { transform: translate(40px, -20px) rotate(6deg); }
    50%      { transform: translate(80px, 10px) rotate(-4deg); }
    75%      { transform: translate(30px, 24px) rotate(8deg); }
}
@keyframes crl-bubble {
    0%, 8%   { transform: translate(-50%, 0) scale(0); }
    14%, 40% { transform: translate(-50%, -16px) scale(1); }
    48%, 100%{ transform: translate(-50%, -16px) scale(0); }
}

.crl-confetti { position: absolute; inset: 0; pointer-events: none; }
.crl-confetti i {
    position: absolute;
    top: -20px;
    left: calc(var(--i) * 5.6%);
    width: 12px;
    height: 18px;
    border: 2px solid #111;
    border-radius: 3px;
    background: hsl(calc(var(--i) * 47), 85%, 62%);
    animation: crl-fall calc(2.4s + var(--i) * .13s) linear infinite;
    animation-delay: calc(var(--i) * -.37s);
}
.crl-confetti i:nth-child(3n) { border-radius: 50%; width: 14px; height: 14px; }
@keyframes crl-fall {
    to { transform: translateY(110vh) rotate(720deg); }
}

.crl-footer {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(460px, 100%);
}
.crl-logo { display: flex; gap: 2px; font-size: clamp(2.2rem, 7vw, 3.6rem); font-weight: 900; line-height: 1; margin: 0; }
.crl-logo span {
    display: inline-block;
    -webkit-text-stroke: 2px #111;
    text-shadow: 4px 4px 0 #111;
    animation: crl-wave 1.2s ease-in-out infinite;
    animation-delay: calc(var(--d) * .09s);
}
.crl-logo span:nth-child(1), .crl-logo span:nth-child(2), .crl-logo span:nth-child(3) { color: #3B82F6; }
.crl-logo span:nth-child(4), .crl-logo span:nth-child(5) { color: #EC4899; }
.crl-logo span:nth-child(6), .crl-logo span:nth-child(7) { color: #F97316; }
.crl-logo .crl-sprout { -webkit-text-stroke: 0; text-shadow: none; font-size: .8em; }
@keyframes crl-wave {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-14px) rotate(-6deg); }
}
.crl-bar {
    position: relative;
    width: 100%;
    height: 22px;
    background: #fff;
    border: 4px solid #111;
    border-radius: 999px;
    box-shadow: 4px 4px 0 #111;
}
.crl-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: repeating-linear-gradient(-45deg, #10B981 0 12px, #34D399 12px 24px);
    background-size: 34px 34px;
    animation: crl-stripes .6s linear infinite;
    transition: width .3s ease;
}
@keyframes crl-stripes { to { background-position: 34px 0; } }
.crl-bar-kun {
    position: absolute;
    top: -40px;
    left: 0;
    width: 46px;
    height: 46px;
    margin-left: -23px;
    transition: left .3s ease;
    animation: crl-hop .4s ease-in-out infinite;
}
.crl-text { margin: 0; font-weight: 900; font-size: 1rem; }
.crl-skip {
    position: fixed;
    right: 16px;
    bottom: 16px;
    padding: 6px 16px;
    background: #fff;
    border: 3px solid #111;
    border-radius: 999px;
    box-shadow: 3px 3px 0 #111;
    font-weight: 900;
    font-size: .85rem;
    cursor: pointer;
}
.crl-skip:focus-visible { outline: 3px solid #3B82F6; outline-offset: 2px; }

/* ロード中はページ側の登場アニメを待たせる */
html.cr-loading .cr-hero > *,
html.cr-loading .cr-reveal.is-in { animation-play-state: paused; }

@media (max-width: 640px) {
    .crl-stage { height: 46vh; }
    .crl-c2, .crl-f2, .crl-f4 { display: none; }
    .crl-c1 { left: 0; }
    .crl-c5 { right: 0; }
    .crl-c4 { right: 22%; }
    .crl-f1 { left: 26%; }
}


/* ---------- 2. パレード ---------- */
html[data-cr-loader="parade"] #cr-loader {
    background-color: #A7F3D0;
    background-image:
        radial-gradient(rgba(0, 0, 0, .1) 2px, transparent 2px),
        linear-gradient(#BDE7FF 0, #D1FAE5 70%);
}
.crl-scene--parade { position: relative; height: min(52vh, 420px); }
.crlp-road {
    position: absolute;
    left: -16px; right: -16px; bottom: 0;
    height: 46px;
    background: repeating-linear-gradient(90deg, #E9C98F 0 40px, #DDBB7E 40px 80px);
    border-top: 5px solid #111;
    animation: crlp-road .6s linear infinite;
}
@keyframes crlp-road { to { background-position: -80px 0; } }
.crlp-march {
    position: absolute;
    bottom: 36px;
    left: 0;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    animation: crlp-march 7s linear infinite;
}
@keyframes crlp-march { from { transform: translateX(-100%); } to { transform: translateX(100vw); } }
.crlp-walker { width: clamp(70px, 12vw, 130px); }
.crlp-walker img {
    width: 100%; height: auto; display: block;
    filter: drop-shadow(4px 5px 0 rgba(0, 0, 0, .18));
    animation: crlp-step .5s ease-in-out infinite;
    animation-delay: calc(var(--i) * -.12s);
    transform-origin: 50% 100%;
}
@keyframes crlp-step {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50%      { transform: translateY(-16px) rotate(5deg); }
}
.crlp-flag {
    align-self: flex-start;
    margin-bottom: 40px;
    padding: 8px 16px;
    background: #EC4899;
    color: #fff;
    border: 4px solid #111;
    border-radius: 14px;
    box-shadow: 4px 4px 0 #111;
    font-weight: 900;
    font-size: clamp(12px, 1.8vw, 18px);
    white-space: nowrap;
    animation: crl-wave 1s ease-in-out infinite;
}
.crlp-clouds i {
    position: absolute;
    top: 10%;
    width: 120px; height: 40px;
    background: #fff;
    border: 3px solid #111;
    border-radius: 40px;
    animation: crlp-cloud 14s linear infinite;
}
.crlp-clouds i:nth-child(2) { top: 26%; width: 90px; animation-duration: 18s; animation-delay: -6s; }
.crlp-clouds i:nth-child(3) { top: 4%; width: 150px; animation-duration: 22s; animation-delay: -12s; }
@keyframes crlp-cloud { from { left: 105%; } to { left: -30%; } }

/* ---------- 3. 宇宙 ---------- */
html[data-cr-loader="space"] #cr-loader {
    background: radial-gradient(circle at 50% 40%, #4338CA 0, #1E1B4B 55%, #0B0A24 100%);
}
html[data-cr-loader="space"] .crl-text,
html[data-cr-loader="dance"] .crl-text { color: #fff; }
.crl-scene--space { position: relative; height: min(56vh, 460px); --orb: min(560px, 82vw, 52vh); }
.crls-stars i {
    position: absolute;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px #fff;
    animation: crls-twinkle 1.6s ease-in-out infinite;
    animation-delay: calc(var(--i) * -.23s);
}
@keyframes crls-twinkle { 0%, 100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.4); } }
.crls-shoot {
    position: absolute;
    top: 12%; left: 70%;
    width: 140px; height: 3px;
    background: linear-gradient(90deg, #fff, transparent);
    border-radius: 3px;
    transform: rotate(-25deg);
    animation: crls-shoot 2.4s ease-in infinite;
}
@keyframes crls-shoot {
    0%   { opacity: 0; translate: 0 0; }
    10%  { opacity: 1; }
    40%  { opacity: 0; translate: -420px 200px; }
    100% { opacity: 0; translate: -420px 200px; }
}
.crls-hero {
    position: relative;
    z-index: 2;
    width: clamp(130px, 24vw, 230px);
    animation: crls-fly 2.2s ease-in-out infinite;
}
.crls-hero img { width: 100%; height: auto; display: block; filter: drop-shadow(0 0 22px rgba(255, 217, 61, .7)); }
.crls-hero::after {
    content: "";
    position: absolute;
    left: 50%; bottom: -30px;
    width: 40%; height: 60px;
    margin-left: -20%;
    background: radial-gradient(ellipse at top, #FFD93D, rgba(249, 115, 22, .6) 40%, transparent 70%);
    filter: blur(4px);
    animation: crls-flame .15s ease-in-out infinite alternate;
    z-index: -1;
}
@keyframes crls-fly { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-26px) rotate(6deg); } }
@keyframes crls-flame { from { transform: scaleY(.8); } to { transform: scaleY(1.2); } }
.crls-orbit {
    position: absolute;
    left: 50%; top: 50%;
    width: var(--orb); height: var(--orb);
    margin: calc(var(--orb) / -2) 0 0 calc(var(--orb) / -2);
    border: 2px dashed rgba(255, 255, 255, .25);
    border-radius: 50%;
    animation: crls-spin 9s linear infinite;
}
.crls-planet {
    position: absolute;
    left: 50%; top: 50%;
    width: clamp(60px, 11vw, 104px);
    margin: calc(clamp(60px, 11vw, 104px) / -2);
    transform: rotate(calc(var(--i) * 90deg)) translateY(calc(var(--orb) / -2));
}
.crls-planet > div { animation: crls-spin 9s linear infinite reverse; }
.crls-planet img { width: 100%; height: auto; display: block; transform: rotate(calc(var(--i) * -90deg)); }
@keyframes crls-spin { to { rotate: 360deg; } }

/* ---------- 4. かくれんぼ ---------- */
html[data-cr-loader="peekaboo"] #cr-loader {
    background-color: #FBCFE8;
    background-image: radial-gradient(rgba(0, 0, 0, .1) 2px, transparent 2px);
    background-size: 24px 24px;
}
.crl-scene--peekaboo { flex-direction: column; gap: 12px; }
.crlk-title {
    margin: 0;
    font-weight: 900;
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    animation: crl-wave 1.4s ease-in-out infinite;
}
.crlk-grid {
    display: grid;
    grid-template-columns: repeat(3, clamp(90px, 22vw, 190px));
    gap: clamp(10px, 2.5vw, 26px);
}
.crlk-hole {
    position: relative;
    height: clamp(100px, 16vh, 170px);
    overflow: hidden;
    border-bottom: 6px solid #111;
}
.crlk-hole::after {
    /* 草むら */
    content: "";
    position: absolute;
    left: -6%; right: -6%; bottom: -14px;
    height: 34px;
    background: #22C55E;
    border: 4px solid #111;
    border-radius: 40px 40px 0 0;
    z-index: 2;
}
.crlk-pop {
    position: absolute;
    left: 10%; right: 10%; bottom: 0;
    transform: translateY(8%);
    animation: crlk-pop 2.4s cubic-bezier(.3, 1.5, .5, 1) infinite;
    animation-delay: calc(var(--i) * .37s);
}
.crlk-pop img { width: 100%; height: auto; display: block; }
@keyframes crlk-pop {
    0%, 30%   { transform: translateY(8%) rotate(-4deg); }
    15%       { transform: translateY(8%) rotate(4deg); }
    44%, 66%  { transform: translateY(105%); }
    80%, 100% { transform: translateY(8%) rotate(-4deg); }
}

/* ---------- 5. ダンス ---------- */
html[data-cr-loader="dance"] #cr-loader { background: #5B21B6; }
.crl-scene--dance { position: relative; height: min(56vh, 460px); align-items: flex-end; }
.crld-rays {
    position: absolute;
    left: 50%; top: 35%;
    width: 220vmax; height: 220vmax;
    margin: -110vmax 0 0 -110vmax;
    background: repeating-conic-gradient(rgba(255, 255, 255, .12) 0 10deg, transparent 10deg 20deg);
    animation: crls-spin 16s linear infinite;
}
.crld-ball {
    position: absolute;
    top: 0; left: 50%;
    width: 84px; height: 84px;
    margin-left: -42px;
    border: 4px solid #111;
    border-radius: 50%;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0 2px, transparent 2px 14px),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, .25) 0 2px, transparent 2px 14px),
        radial-gradient(circle at 35% 30%, #fff, #C4B5FD 45%, #7C3AED);
    box-shadow: 0 0 40px rgba(255, 255, 255, .6);
    transform-origin: 50% -200px;
    animation: crld-swing 2s ease-in-out infinite;
}
@keyframes crld-swing { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.crld-floor { position: relative; z-index: 1; display: flex; align-items: flex-end; gap: clamp(2px, 1.5vw, 16px); }
.crld-dancer { width: clamp(64px, 15vw, 150px); }
.crld-dancer img {
    width: 100%; height: auto; display: block;
    filter: drop-shadow(0 0 14px rgba(255, 255, 255, .45));
    transform-origin: 50% 100%;
    animation: crld-dance .9s ease-in-out infinite;
    animation-delay: calc(var(--i) * -.18s);
}
.crld-dancer:nth-child(even) img { animation-name: crld-dance2; }
@keyframes crld-dance {
    0%, 100% { transform: rotate(-12deg) translateY(0); }
    25%      { transform: rotate(0) translateY(-28px) scale(1.05); }
    50%      { transform: rotate(12deg) translateY(0); }
    75%      { transform: rotate(0) translateY(-10px); }
}
@keyframes crld-dance2 {
    0%, 100% { transform: scale(1.08, .9); }
    50%      { transform: scale(.94, 1.08) translateY(-30px) rotate(-8deg); }
}
.crld-notes i {
    position: absolute;
    bottom: 10%;
    left: calc(10% + var(--i) * 15%);
    color: #FDE68A;
    font-style: normal;
    font-weight: 900;
    font-size: clamp(20px, 3vw, 34px);
    animation: crld-note 3s ease-in infinite;
    animation-delay: calc(var(--i) * -.5s);
}
@keyframes crld-note {
    0%   { opacity: 0; transform: translateY(0) rotate(0); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-50vh) rotate(30deg); }
}

@media (max-width: 640px) {
    .crlp-flag { display: none; }
    .crld-dancer:nth-child(n+5) { display: none; }
}

/* 動きを減らす設定：ロード画面は出すが、大きな動きは止める */
@media (prefers-reduced-motion: reduce) {
    #cr-loader *, #cr-loader *::before, #cr-loader *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; }
    .crlp-march { left: 50%; transform: translateX(-50%); }
    .crlk-pop { transform: translateY(8%); }
}
