/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-bg: #0d0d1a;
    --color-text: #f0e6d3;
    --color-gold: #D4AF37;
    --color-gold-light: #F8E8A0;
    --color-chisa: #F8C8DC;
    --color-yogami: #6B3FA0;
    --color-yogami-gold: #D4AF37;
    --color-suzune: #E63946;
    --font-main: 'Noto Serif JP', serif;
    --theme-color: var(--color-gold);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* safe-area paddingはabsolute子に効かないため、各画面要素で個別に対応 */
}

/* ===== Particle Canvas ===== */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ===== Screen System ===== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    z-index: 2;
    /* ノベル画面以外でsafe-area対応 */
    padding:
        env(safe-area-inset-top, 0px)
        env(safe-area-inset-right, 0px)
        env(safe-area-inset-bottom, 0px)
        env(safe-area-inset-left, 0px);
}

/* ノベル画面・相談画面はCG背景をフルスクリーンにするためpaddingとスクロールを解除 */
#screen-fortune-menu,
#screen-input,
#screen-loading,
#screen-result,
#screen-omikuji,
#screen-consultation-input,
#screen-consultation-loading,
#screen-consultation-result {
    padding: 0;
    overflow-y: hidden;
    justify-content: center;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Buttons ===== */
.btn-primary {
    font-family: var(--font-main);
    font-size: 1.2rem;
    padding: 16px 48px;
    border: 2px solid var(--color-gold);
    background: transparent;
    color: var(--color-gold);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
}

.btn-primary:hover {
    background: var(--color-gold);
    color: var(--color-bg);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

.btn-glow {
    animation: btnGlow 2s ease-in-out infinite alternate;
}

/* --- TOPページ統一ボタン --- */
.btn-title-unified {
    display: block;
    width: 80%;
    max-width: 320px;
    margin: 0 auto;
    padding: 14px 24px;
    font-family: 'Noto Serif JP', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-gold);
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--color-gold);
    border-radius: 10px;
    letter-spacing: 0.08em;
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 44px;
}
.btn-title-unified:hover {
    background: rgba(212, 175, 55, 0.15);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.3);
    transform: scale(1.03);
}
.btn-title-main {
    animation: btnGlow 2s ease-in-out infinite alternate;
}
.btn-title-sub {
    border-color: rgba(212, 175, 55, 0.5);
    color: rgba(212, 175, 55, 0.7);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: none;
    font-size: 1rem;
}
.btn-title-sub:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
}

.btn-back {
    position: absolute;
    bottom: 20px;
    left: 20px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    padding: 8px 20px;
    border: 1px solid rgba(240, 230, 211, 0.3);
    background: rgba(0, 0, 0, 0.5);
    color: var(--color-text);
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
}

.btn-back:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
}

.btn-back.btn-back-novel {
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    bottom: auto;
    z-index: 25;
}

.btn-result {
    font-family: var(--font-main);
    font-size: 0.9rem;
    padding: 10px 20px;
    border: 1px solid rgba(212, 175, 55, 0.5);
    background: rgba(0, 0, 0, 0.4);
    color: var(--color-gold);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
}

.btn-result:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--color-gold);
}

.btn-save {
    border-color: rgba(240, 230, 211, 0.3);
    color: rgba(240, 230, 211, 0.7);
}

.btn-save:hover {
    border-color: rgba(240, 230, 211, 0.6);
    color: var(--color-text);
}

/* ===== Title Screen ===== */
#screen-title {
    background: linear-gradient(180deg, #1a0a2e 0%, #2d1b4e 40%, #1a0a2e 100%);
}

.title-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
}

.title-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.title-text {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 700;
    background: linear-gradient(180deg, var(--color-gold-light) 0%, var(--color-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 0.15em;
}

.title-subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: rgba(240, 230, 211, 0.6);
    letter-spacing: 0.3em;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .btn-primary {
        font-size: 1rem;
        padding: 14px 36px;
    }

    /* モバイルではコンテンツ溢れ対策: 中央寄せ→上寄せ＋スクロール */
    .screen {
        justify-content: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .btn-primary {
        font-size: 0.95rem;
        padding: 12px 28px;
    }
    .title-content {
        gap: 32px;
    }
    .btn-title-unified {
        font-size: 1rem;
        padding: 12px 20px;
    }
    .btn-back {
        bottom: 14px;
        left: 14px;
        font-size: 0.8rem;
        padding: 6px 14px;
    }
}
