@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap');

:root {
    --background-color: #0b2036;
    --text-primary: #fff;
    --text-secondary: rgba(255, 255, 255, 0.87);
    --border-color: rgba(255, 255, 255, 0.10);
    --surface-color: rgba(255, 255, 255, 0.06);
    --accent-color: #47d19e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

/* Ensure the root background matches body to avoid white flash on overscroll */
html, body {
    background: linear-gradient(180deg, rgba(7, 20, 34, 1) 0%, rgba(10, 10, 10, 1) 100%);
    overscroll-behavior-y: contain; /* reduce navigation gestures / bounce side-effects where supported */
}

/* iOS specific improvements */
html, body {
    /* prevent iOS Safari from auto-zooming text on orientation change */
    -webkit-text-size-adjust: 100%;
    /* use the safe area to avoid content under notch */
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

body {
    color: var(--text-primary);
    font-family: 'Noto Sans JP', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: 16px;
    line-height: 1.6;
}

/* --- Welcome screen */
.welcome-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, rgba(7, 20, 34, 0.98), rgba(10, 10, 10, 0.96));
    z-index: 100;
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto
}

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

.welcome-screen .sky {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center
}

.welcome-screen .animation-svg {
    width: min(92vw, 1100px);
    height: auto;
    max-height: 60vh;
    display: block
}

.welcome-screen .animation-svg text {
    font-size: clamp(4rem, 8vw, 4rem) !important;
    font-weight: 700;
    letter-spacing: -0.02em;
    fill: var(--text-primary);
    text-anchor: middle;
    text-shadow: 0 6px 20px rgba(0, 0, 0, 0.6)
}

.welcome-screen .animation-svg tspan {
    opacity: 1;
    transition: opacity .2s ease-in-out
}

/* --- Main content */
.main-content {
    opacity: 0;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1) .6s
}

.main-content.visible {
    opacity: 1
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 4.5rem 2rem
}

/* --- Hero */
.hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    position: relative
}

.hero-section h1 {
    font-size: clamp(1.8rem, 6.2vw, 3.6rem);
    font-weight: 900;
    letter-spacing: .02em;
    line-height: 1.30;
    margin-bottom: 1rem;
    max-width: 900px;
    background: linear-gradient(135deg, var(--accent-color), #34d399, #10b981, #fff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 4px rgba(52, 211, 153, .15);
    position: relative;
    animation: gradientShift 3s ease-in-out infinite, gradientMove 6s linear infinite;
    background-position: 0% 50%;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
        text-shadow: 0 2px 4px rgba(52, 211, 153, .2)
    }

    50% {
        background-position: 100% 50%;
        text-shadow: 0 2px 6px rgba(52, 211, 153, .3)
    }

    100% {
        background-position: 0% 50%;
        text-shadow: 0 2px 4px rgba(52, 211, 153, .2)
    }
}

.hero-section p {
    font-size: clamp(1rem, 3.2vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 680px
}

.scroll-hint {
    position: absolute;
    bottom: 2rem;
    color: var(--text-secondary);
    font-size: .875rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    opacity: .95;
    animation: bounce 2s infinite
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0)
    }

    40% {
        transform: translateY(-10px)
    }

    60% {
        transform: translateY(-5px)
    }
}

/* --- Sections / cards */
.section-title {
    font-size: clamp(1.4rem, 4.2vw, 2.2rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 3.2rem;
    letter-spacing: -0.02em
}

.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background-color: var(--accent-color);
    margin: .75rem auto 0;
    border-radius: 2px
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.75rem
}

.rule-card {
    background-color: var(--surface-color);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 12px;
    padding: 1.6rem 1.8rem;
    transition: transform .28s ease, background-color .28s ease, box-shadow .28s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .55)
}

.rule-card:hover {
    transform: translateY(-6px);
    background-color: rgba(255, 255, 255, .08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .6)
}

.rule-card h3 {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: 1.5rem;
    margin-bottom: 1rem
}

.rule-card h3 .icon {
    font-size: 1.5rem
}

.rule-card p {
    color: var(--text-secondary);
    line-height: 1.75;
    font-size: 1.02rem
}

.gameplay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 900px;
    margin: 0 auto
}

.gameplay-card {
    background-color: var(--surface-color);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    transition: transform .3s ease, background-color .3s ease, box-shadow .3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    position: relative;
    overflow: hidden
}

.gameplay-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), rgba(52, 211, 153, .6))
}

.gameplay-card:hover {
    transform: translateY(-8px);
    background-color: rgba(255, 255, 255, .1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .6)
}

.card-icon {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 1rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: .1em
}

.card-content h4 {
    font-size: 1.4rem;
    margin-bottom: .5rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4
}

.card-content p {
    font-size: 1.1rem;
    margin-bottom: .5rem;
    line-height: 1.6
}

.card-subtitle {
    font-size: .9rem;
    color: var(--text-secondary);
    display: block;
    margin-top: .5rem
}

/* --- Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity .7s cubic-bezier(0.4, 0, 0.2, 1), transform .7s cubic-bezier(0.4, 0, 0.2, 1)
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0)
}

.reveal-delay-1 {
    transition-delay: .1s
}

.reveal-delay-2 {
    transition-delay: .2s
}

.reveal-delay-3 {
    transition-delay: .3s
}

/* --- Reincarnate effect */
.reincarnate {
    position: relative;
    display: inline-block;
    font-size: clamp(1.5rem, 8vw, 5rem);
    line-height: 1
}

.reincarnate h1 {
    position: relative;
    display: inline-block;
    color: transparent;
    -webkit-text-stroke: .5px #fff
}

.reincarnate .char {
    position: absolute;
    left: 0;
    top: 0;
    white-space: pre;
    color: var(--text-primary) !important;
    font: inherit;
    font-weight: 700;
    will-change: transform, opacity, filter;
    transition: transform .8s ease, opacity .8s ease, filter .8s ease;
    opacity: 1;
    z-index: 3;
    text-shadow: 0 0 10px rgba(52, 211, 153, .14), 0 0 22px rgba(52, 211, 153, .06)
}

.reincarnate .particle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, var(--accent-color));
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%) scale(.85);
    z-index: 2;
    filter: blur(.6px);
    mix-blend-mode: screen;
    transition: transform .7s ease, opacity .6s ease, left .6s linear, top .6s linear
}

.reincarnate.disperse .char {
    opacity: 0
}

.reincarnate.spark .particle {
    opacity: 1
}

.reincarnate.assemble .char {
    opacity: 1;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .45))
}

/* --- Footer --- */
.footer {
    background-color: #1f1f1f;
    color: #fff;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
    text-align: center;
    padding: 24px;
    max-width: 1280px;
    margin: 0 auto
}

.footer p {
    margin: 0
}

.footer:focus {
    outline: 2px solid #b8860b;
    outline-offset: 2px
}

/* --- Consolidated mobile tweaks --- */
@media (max-width:1000px) {

    html,
    body {
        font-size: 1rem
    }

    .hero-section h1 {
        font-size: clamp(1.5rem, 8vw, 3.2rem)
    }

    .hero-section p {
        font-size: 1.125rem
    }

    .section-title {
        font-size: clamp(1.6rem, 5.2vw, 2.4rem)
    }

    .container h2 {
        font-size: 1.4rem
    }

    .rule-card p,
    .card-content p,
    .card-subtitle {
        font-size: 1.125rem
    }

    .card-content h4 {
        font-size: 1.25rem
    }

    .card-icon {
        font-size: 2rem
    }

    .scroll-hint {
        font-size: 1rem;
        bottom: 1.2rem
    }
    
    .welcome-screen .animation-svg text {
        font-size: 4.6rem !important;
    }

    .welcome-screen h1,
    .reincarnate {
        font-size: clamp(2.5rem, 4vw, 3.7rem)
    }

    .endtitle {
        font-size: 1.0rem !important
    }

    .footer {
        font-size: 0.8rem;
        padding: 20px
    }

}

/* --- Sakura petals (花びら) --- */
/* Sakura: keep layer count low and avoid expensive will-change on many elements */
.sakura-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999; /* ensure petals float above everything */
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.9s ease;
    /* Use a separate containing layer for transforms to keep composite changes isolated */
    transform: translateZ(0);
}

/* Contain painting for modern browsers to limit repaint scope (Chrome/Firefox) */
.sakura-container, .reincarnate {
    contain: paint;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.sakura-petal {
    position: absolute;
    top: var(--start-top, -5vh);
    /* base size smaller; each petal will be scaled by --s */
    width: 14px;
    height: 16px;
    background: radial-gradient(circle at 30% 30%, #ffeef6 0%, #ffd0ea 35%, #ffb6da 70%);
    border-radius: 60% 40% 60% 40% / 60% 40% 60% 40%;
    transform-origin: 50% 50%;
    opacity: 0.98;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.12));
    mix-blend-mode: screen;
    /* limit will-change to transform and opacity only (cheaper) */
    will-change: transform, opacity;
    /* fall controls vertical movement, sway controls horizontal left oscillation, rotate handles rotation+scale */
    left: var(--start-left, 0px);
    animation: sakura-fall var(--fall-duration, 7s) linear forwards,
               sakura-sway var(--sway-duration, 3.5s) ease-in-out infinite,
               sakura-rotate var(--rot-duration, 4s) linear infinite;
}

@keyframes sakura-fall {
    0% { top: -12vh; opacity: 1; transform: translateY(0); }
    100% { top: 110vh; opacity: 0; transform: translateY(100vh); }
}

@keyframes sakura-sway {
    0% { transform: translateX(0) rotate(0deg); }
    50% { transform: translateX(-6px) rotate(10deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

@keyframes sakura-rotate {
    from { transform: rotate(0deg) scale(var(--s, 0.8)); }
    to { transform: rotate(360deg) scale(var(--s, 0.8)); }
}


/* reduce motion support */
@media (prefers-reduced-motion: reduce) {
    .sakura-petal {
        animation: none !important;
        display: none !important;
    }
}


/* ------------------------
   追加スタイル: ルール改善
   ------------------------ */

.quick-rules {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.04);
    padding: 1.25rem;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

/* 各カード内を横並びにしてアイコンと本文を分かりやすく */
.rule-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

/* 丸いアイコン */
.rule-icon {
    flex: 0 0 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(71,209,158,0.12), rgba(71,209,158,0.06));
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    margin-top: 2px;
}

/* 本文側の余白調整 */
.rule-body h3 {
    font-size: 1.125rem;
    margin: 0 0 0.35rem 0;
    color: var(--text-primary);
}

/* スタッフ案内の目立たせ方 */
.staff-note {
    margin-top: 1rem;
    text-align: center;
    color: rgba(255,255,255,0.75);
    font-size: 0.95rem;
    background: linear-gradient(90deg, rgba(255,255,255,0.01), rgba(255,255,255,0.00));
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.02);
}

/* レスポンシブ微調整 */
@media (max-width:700px) {
    .rule-row {
        align-items: center;
    }
    .rule-icon {
        flex-basis: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    .rule-body h3 {
        font-size: 1rem;
    }
}
