body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fdf2e9;
    font-family: "Sawarabi Mincho", serif;
    overflow: hidden;
    touch-action: none;
    transition: background 1.5s ease;
}

body.kamikichi {
    background: radial-gradient(circle, #2c3e50, #000000);
}

body.gingakichi {
    background: linear-gradient(45deg, #0f0c29, #302b63, #24243e);
}

body.mu {
    background: #ffffff;
}

.app-container {
    text-align: center;
    width: 100%;
}

/* おみくじの箱 */
#omikuji-wrapper {
    position: relative;
    width: 140px;
    margin: 50px auto;
    transition: transform 0.1s ease;
    /* スムーズな動き */
}

/* パワーゲージ */
#power-gauge-container {
    width: 200px;
    height: 10px;
    background: rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    border-radius: 5px;
    overflow: hidden;
    opacity: 0.6;
    transition: opacity 0.3s;
}

#power-gauge {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #f1c40f, #e67e22);
    transition: width 0.1s;
}

#power-gauge.max {
    background: linear-gradient(90deg, #ff0000, #ff00ff, #00ffff);
    animation: rainbow 0.2s infinite;
}

@keyframes rainbow {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

.box {
    width: 140px;
    height: 220px;
    /* 全体の高さ */
    margin-top: 60px;
    /* 天面が高くなる分下げる */
    /* 木目の側面グラデーション */
    background: linear-gradient(90deg,
            #cbb08a 0%,
            #e6ccaa 20%,
            #f2dfc3 50%,
            #e6ccaa 80%,
            #cbb08a 100%);
    /* 上部と下部を六角形に */
    /* 上部と下部を六角形に */
    clip-path: polygon(25% 0%, 75% 0%,
            /* 天面との接合部 */
            100% 10%, 100% 90%,
            75% 100%, 25% 100%,
            0% 90%, 0% 10%);
    border-radius: 0 0 20px 20px;

    display: flex;
    align-items: center;
    justify-content: center;
    color: #3e2723;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 25px 35px rgba(0, 0, 0, 0.25);
    cursor: grab;
    z-index: 10;
    position: relative;
    border: none;
    transition: transform 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
}

/* 奥の側面（六角柱の裏側） */
/* 奥の側面（六角柱の裏側） */
.box-back {
    display: none;
    /* ユーザー要望により非表示（正面視点風にする） */
    position: absolute;
    top: -25px;
    /* 天面の高さの半分くらい */
    left: 0;
    width: 140px;
    height: 70px;
    /* 高さ増やして隙間を埋める */
    background: linear-gradient(90deg, #d4c4b0 0%, #e6ccaa 20%, #f2dfc3 50%, #e6ccaa 80%, #d4c4b0 100%);
    z-index: 1;
    clip-path: polygon(15% 0%, 85% 0%, 100% 60%, 0% 60%);
    /* 下辺の位置を調整 */
}

/* 天面（六角形） */
.box::before {
    content: "";
    position: absolute;
    top: -35px;
    /* 高さを減らしたので位置も下げる */
    left: 0;
    width: 140px;
    height: 50px;
    /* 高さを減らして斜め視点に */
    /* 楕円の穴（少し大きく） */
    background: radial-gradient(ellipse at center, transparent 9px 6px, #e6ccaa 10px 7px);
    /* 正しい六角形 */
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    z-index: 12;
    box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.15);
}

/* 棒が出る穴（棒の後ろにある暗闇） */
.box-hole {
    display: block;
    position: absolute;
    top: 18px;
    /* 天面の高さに合わせて調整 */
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 10px;
    background: #3e2723;
    border-radius: 50%;
    z-index: 2;
    /* 棒より後ろ */
    pointer-events: none;
}

/* 側面上部の枠（焦げ茶） */
.box-border-top {
    position: absolute;
    top: -5px;
    left: 0;
    width: 100%;
    height: 10px;
    background: #5d4037;
    z-index: 11;
}

/* 側面下部の枠（焦げ茶） */
.box-border-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: #5d4037;
    z-index: 11;
    border-radius: 0 0 20px 20px;
}

.kanji {
    writing-mode: horizontal-tb;
    font-family: "Sawarabi Mincho", serif;
    background: #fff;
    padding: 10px 10px;
    border: 1px solid #7f8c8d;
    /* 枠線を少し濃く */
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    height: 80%;
    /* 高さをさらに増やす */
    width: 45%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 11;
    line-height: 1.2;
}

.label-en {
    font-family: serif;
    font-size: 0.9rem;
    margin-bottom: 20px;
    /* 余白を空ける */
    color: #3e2723;
}

.label-jp {
    writing-mode: vertical-rl;
    /* 縦書き */
    text-orientation: upright;
    font-size: 1.6rem;
    letter-spacing: 5px;
    color: #3e2723;
    font-weight: bold;
    height: auto;
    /* 高さは自動 */
    width: auto;
}

/* Lorcleは横書き、おみくじは縦書きにしたい場合、HTML構造に合わせてCSSで制御 */
/* HTMLが <span class="kanji">Lorcle<br>おみくじ</span> の場合 */


.stick.pop-out {
    opacity: 1;
    transform: translateY(-160px);
}

/* 結果表示 */
.hidden {
    display: none;
    transform: translateY(20px);
    opacity: 0;
}

.show {
    display: block;
    animation: fadeIn 0.8s forwards;
    margin-top: 80px;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 大吉エフェクト */
.text-gold {
    color: #ffd700;
    font-size: 5rem;
    font-weight: 900;
    text-shadow: 0 0 5px rgba(241, 196, 15, 0.5);
    /* 光彩を半分に */
    background: linear-gradient(to bottom, #fff, #ffd700, #daa520);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gold-shine 2s infinite alternate ease-in-out, intense-bounce 1s infinite alternate;
    /* 動きをよりゆっくりに */
}

@keyframes gold-shine {
    from {
        filter: brightness(1) drop-shadow(0 0 2px rgba(255, 215, 0, 0.3));
    }

    to {
        filter: brightness(1.1) drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
    }
}

@keyframes intense-bounce {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.15);
    }
}

.daikichi-aura {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
    /* 濃度を半分に */
    pointer-events: none;
    z-index: 998;
    animation: aura-pulse 2.0s infinite alternate;
}

@keyframes aura-pulse {
    0% {
        opacity: 0.05;
    }

    100% {
        opacity: 0.2;
    }
}

.daikichi-glow {
    display: none;
    /* 重複したエフェクトを無効化 */
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes bounce {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

#share-btn {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
}

/* script.jsで結果表示時にこのクラスを付与する */
.stick.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* 結果エリアをカード風にする */
#result-area {
    background: white;
    border: 4px double #c0392b;
    /* 二重線で和風に */
    padding: 20px;
    margin: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 木札の再現：画像を使わずCSSで木目を表現 */
/* 木札の再現：画像を使わずCSSで木目を表現 */
.stick {
    width: 20px;
    height: 140px;
    /* 箱からはみ出さないように短く */
    background: linear-gradient(90deg, #d39d67, #f39c12 40%, #d39d67);
    border-radius: 2px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 30px;
    /* 天面が低くなったので棒も上げる */
    left: 60px;
    /* 中央 (140/2 - 20/2 = 60) */
    z-index: 5;
    /* 箱より後ろ、天面(z-12)より後ろ。でも穴(透過)からは見える */
}

/* お札（カード）のデザイン */
.omikuji-card {
    background: #fffdf0;
    /* 和紙っぽい色 */
    border: 2px solid #c0392b;
    outline: 6px double #c0392b;
    /* 二重線 */
    outline-offset: -10px;
    padding: 40px 20px;
    max-width: 280px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card-header {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 10px;
}

.card-divider {
    height: 2px;
    background: #c0392b;
    margin: 20px auto;
    width: 60%;
}

/* 各ランクのテキストエフェクト */
.text-kami {
    font-size: 5rem;
    font-weight: 900;
    background: linear-gradient(to bottom, #ffffff, #f1c40f, #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px #fff) drop-shadow(0 0 40px #f1c40f);
    animation: kami-float 2s infinite ease-in-out;
}

@keyframes kami-float {

    0%,
    100% {
        transform: translateY(0) scale(1.1);
    }

    50% {
        transform: translateY(-20px) scale(1.2);
    }
}

.text-ginga {
    font-size: 4.5rem;
    color: #fff;
    text-shadow: 0 0 10px #fff, 0 0 20px #00d2ff, 0 0 40px #3a7bd5;
    animation: ginga-glow 1.5s infinite alternate;
}

@keyframes ginga-glow {
    from {
        opacity: 0.8;
    }

    to {
        opacity: 1;
        text-shadow: 0 0 20px #fff, 0 0 40px #00d2ff, 0 0 60px #3a7bd5;
    }
}

.text-mu {
    font-size: 4rem;
    color: #000;
    letter-spacing: 2rem;
    filter: grayscale(1);
    opacity: 0.5;
}

.screen-shake {
    animation: intense-shake 0.1s infinite;
}

@keyframes intense-shake {
    0% {
        transform: translate(2px, 2px) rotate(0deg);
    }

    25% {
        transform: translate(-2px, -2px) rotate(1deg);
    }

    50% {
        transform: translate(-3px, 1px) rotate(-1deg);
    }

    75% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    100% {
        transform: translate(3px, 2px) rotate(0deg);
    }
}

/* 爆発演出用フラッシュ */
#flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 10000;
}

.flash-active {
    animation: flash-anim 0.3s ease-out;
    /* フラッシュを短縮 */
}

@keyframes flash-anim {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}


/* じわっと表示されるアニメーション */
.jiwari {
    opacity: 0;
    filter: blur(10px);
    /* 最初はぼかす */
    transition: opacity 2.0s ease, filter 2.0s ease;
    /* 2秒かけてじわっと */
}

.jiwari.fade-in {
    opacity: 1;
    filter: blur(0px);
    /* ぼかしがなくなる */
}

/* ラッキーアイテムは少し遅れて出す */
#item-text {
    opacity: 0;
    transition: opacity 1.5s ease 1.0s;
    /* 1秒待ってから1.5秒かけて表示 */
}

#item-text.fade-in {
    opacity: 1;
}

.action-buttons {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    /* 縦に並べる */
    gap: 15px;
}

#open-app-btn {
    background: transparent;
    color: #c0392b;
    /* アプリのテーマカラーに合わせる */
    border: 2px solid #c0392b;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    /* 最初は隠しておく */
}

#open-app-btn:active {
    background: rgba(192, 57, 43, 0.1);
}


/* ボタンエリアのレイアウト調整 */
.action-buttons {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#share-btn {
    padding: 12px 30px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    width: fit-content;
}

/* リンクをボタン風に見せる設定 */
.secondary-btn-link {
    background: transparent;
    color: #c0392b;
    border: 2px solid #c0392b;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    opacity: 0;
    transition: background 0.3s;
}

.secondary-btn-link:active {
    background: rgba(192, 57, 43, 0.1);
}

.footer-msg {
    margin-top: 20px;
    font-size: 0.8rem;
    color: #666;
}