* {
    box-sizing: border-box;
}

body {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-family: "游ゴシック体", "Yu Gothic", "游ゴシック", YuGothic, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, "ＭＳ Ｐゴシック", MS PGothic, 'Noto Sans JP', sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content なし: 上から順に配置し、フッターだけ最下部へ */
    margin: 0;
    padding: 3vh 2vw 80px 2vw; /* 上3vh / 下80px(ボトムナビ分) */
    background-color: #f0f0f0;
    background: url('tarot_images/gray-table.jpg') no-repeat center center fixed;
    background-size: cover;
    color: #333;
    box-sizing: border-box;
    overflow-x: hidden;
}

h1 {
    color: #333;
    margin-top: 0;
    margin-bottom: 3vh; /* ロゴ→カード */
    text-align: center;
    line-height: 1;
}

.title-logo {
    max-width: 90%;
    height: auto;
    width: clamp(220px, 35vw, 320px); /* サンプルに合わせて大きめ */
    display: inline-block;
    vertical-align: bottom;
}

#app-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#controls {
    margin: 0 auto 3vh auto; /* ボタン→ガイド: 3vh */
    text-align: center;
    width: 100%;
    max-width: 90vw;
}

.draw-button {
    padding: clamp(0.7rem, 1.5vw, 1rem) clamp(2rem, 5vw, 4rem);
    /* パディングを横長に調整 */
    font-size: clamp(0.9rem, 2.2vw, 1.05rem);
    cursor: pointer;
    border: 1px solid #333;
    /* 境界線を細く */
    border-radius: 50px;
    background: #fff;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* シャドウを抑えめに */
    transition: all 0.3s ease;
    min-width: clamp(150px, 30vw, 250px);
}

.draw-button:hover {
    color: #fff;
    background: #000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}


#card-results {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 2vh auto;
    /* ロゴとの隙間はh1のmargin-bottomで確保するため0 */
    gap: 1vw;
    align-items: stretch;
    position: relative;
}

.card-container {
    border: 1px solid #ddd;
    padding: 1vw;
    width: 30%;
    text-align: center;
    background-color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    flex: 1 1 30%;
}

.card-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    background-color: #fafafa;
}

.card-image {
    width: clamp(105px, 30vw, 190px);
    height: clamp(157px, 45vw, 285px);
    margin: 0 auto clamp(0.2rem, 0.5vw, 0.6rem) auto;
    border-radius: 5px;
    display: block;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.card-name {
    font-weight: bold;
    margin-bottom: clamp(0.15rem, 0.4vw, 0.5rem);
    font-size: clamp(0.91rem, 3.25vw, 1.3rem);
    color: #444;
}

.card-orientation {
    font-style: italic;
    color: #777;
    font-size: 1em;
    margin-bottom: clamp(0.15rem, 0.4vw, 0.5rem);
}

.card-description {
    font-size: clamp(0.6rem, 2.2vw, 0.85rem);
    color: #555;
    margin-top: clamp(0.15rem, 0.4vw, 0.5rem);
    flex-grow: 1;
    overflow-y: auto;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 0.5em;
}

#shuffle-card-area {
    width: clamp(150px, 28vw, 220px);
    height: clamp(225px, 42vw, 330px);
    margin: 0 auto 5vh auto; /* カード→ボタン: 5vh */
    position: relative;
}

#shuffle-card-area .card-stack {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
}

.read-more-button {
    background-color: #795548;
    color: white;
    border: none;
    padding: clamp(0.3rem, 1vw, 0.5rem) clamp(0.6rem, 2vw, 1rem);
    margin-top: clamp(0.3rem, 1vw, 0.5rem);
    cursor: pointer;
    border-radius: 5px;
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    transition: background-color 0.3s ease;
}

.read-more-button:hover {
    background-color: #3f51b5;
}

/* =========================================
   ユーザーガイドリンク
   ========================================= */
.guide-link-area {
    text-align: center;
    margin-top: 0;
}

.guide-button {
    display: inline-block;
    padding: clamp(0.5rem, 1.2vw, 0.7rem) clamp(1.5rem, 4vw, 2.5rem);
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: #666;
    text-decoration: none;
    border: 1px solid #aaa;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.85);
    transition: all 0.3s ease;
    letter-spacing: 0.05em;
}

.guide-button:hover {
    background: #555;
    color: #fff;
    border-color: #555;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

footer {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    text-align: center;
    margin-top: auto; /* 残りスペースを吸収してフッターを最下部に固定 */
    padding: 10px 1rem;
    color: #777;
    width: 100%;
}

.version-display {
    font-size: clamp(0.5rem, 1.5vw, 0.6rem);
    color: #999;
    margin-top: 0.5em;
    opacity: 0.7;
}

#downloadArea {
    margin-top: 0.5vh;
    margin-bottom: 0.5vh;
    text-align: center;
    width: 100%;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
    flex-basis: 100%;
    order: 99;
    clear: both;
    position: relative;
    z-index: 1;
}

/* #filenameInput はモーダルに移行したため削除可能だが、万が一のために残す場合は後ほど整理 */

#downloadButton {
    min-width: clamp(150px, 30vw, 250px);
}

#downloadButton:hover {
    color: #fff;
    background: #000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#download-image-container {
    width: 100%;
}

#downloadAppraisalTitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    margin: 2vh 0;
}

#download-card-results {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    width: 95vw;
    max-width: 1200px;
    margin: 2vh auto;
    gap: clamp(0.05rem, 0.1vw, 0.2rem);
    overflow-x: auto;
    align-items: flex-start;
    position: relative;
}

.download-card-container {
    border: 1px solid #ddd;
    padding: clamp(0.2rem, 0.5vw, 0.6rem) clamp(0.02rem, 0.05vw, 0.1rem);
    width: clamp(120px, calc(33.33% - 0.1rem), 350px);
    min-width: 120px;
    min-height: clamp(200px, 40vh, 400px);
    text-align: center;
    background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 0 0 auto;
}

.download-card-container .card-image {
    width: clamp(105px, 30vw, 190px);
    height: clamp(157px, 45vw, 285px);
    margin: 0 auto clamp(0.2rem, 0.5vw, 0.6rem) auto;
    border-radius: 5px;
    object-fit: contain;
}

.download-card-container .card-name {
    font-weight: bold;
    margin-bottom: clamp(0.15rem, 0.4vw, 0.5rem);
    font-size: clamp(0.91rem, 3.25vw, 1.3rem);
    color: #444;
}

.download-card-container .card-orientation {
    font-style: italic;
    color: #777;
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    margin-bottom: clamp(0.15rem, 0.4vw, 0.5rem);
}

.download-card-container .card-description {
    font-size: clamp(0.6rem, 2.2vw, 0.85rem);
    color: #555;
    margin-top: clamp(0.15rem, 0.4vw, 0.5rem);
    flex-grow: 1;
    overflow-y: auto;
    text-align: center;
    line-height: 1.3;
}

#download-footer {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    text-align: center;
    margin-top: 2em;
    color: #777;
}

/* index用アニメーション：top_cards（10枚対応） */
.card-image.top_cards {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 5px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.card-image.top_cards:nth-child(1) {
    transform: rotate(-8deg) translate(-15px, 3px);
    animation: top_cards_yurayura1 2.0s infinite alternate ease-in-out;
    z-index: 1;
}

.card-image.top_cards:nth-child(2) {
    transform: rotate(-6deg) translate(-10px, 5px);
    animation: top_cards_yurayura2 2.13s infinite alternate ease-in-out;
    z-index: 2;
}

.card-image.top_cards:nth-child(3) {
    transform: rotate(-4deg) translate(-5px, 2px);
    animation: top_cards_yurayura3 2.27s infinite alternate ease-in-out;
    z-index: 3;
}

.card-image.top_cards:nth-child(4) {
    transform: rotate(-2deg) translate(-2px, 0px);
    animation: top_cards_yurayura4 2.07s infinite alternate ease-in-out;
    z-index: 4;
}

.card-image.top_cards:nth-child(5) {
    transform: rotate(0deg) translate(0px, -2px);
    animation: top_cards_yurayura5 2.2s infinite alternate ease-in-out;
    z-index: 5;
}

.card-image.top_cards:nth-child(6) {
    transform: rotate(2deg) translate(2px, 1px);
    animation: top_cards_yurayura6 2.15s infinite alternate ease-in-out;
    z-index: 6;
}

.card-image.top_cards:nth-child(7) {
    transform: rotate(4deg) translate(5px, 4px);
    animation: top_cards_yurayura7 2.08s infinite alternate ease-in-out;
    z-index: 7;
}

.card-image.top_cards:nth-child(8) {
    transform: rotate(6deg) translate(10px, -1px);
    animation: top_cards_yurayura8 2.22s infinite alternate ease-in-out;
    z-index: 8;
}

.card-image.top_cards:nth-child(9) {
    transform: rotate(8deg) translate(15px, 3px);
    animation: top_cards_yurayura9 2.18s infinite alternate ease-in-out;
    z-index: 9;
}

.card-image.top_cards:nth-child(10) {
    transform: rotate(10deg) translate(20px, -3px);
    animation: top_cards_yurayura10 2.25s infinite alternate ease-in-out;
    z-index: 10;
}

@keyframes top_cards_yurayura1 {
    0% {
        transform: rotate(-8deg) translate(-15px, 3px);
    }

    100% {
        transform: rotate(-10deg) translate(-19px, 7px);
    }
}

@keyframes top_cards_yurayura2 {
    0% {
        transform: rotate(-6deg) translate(-10px, 5px);
    }

    100% {
        transform: rotate(-8deg) translate(-14px, 9px);
    }
}

@keyframes top_cards_yurayura3 {
    0% {
        transform: rotate(-4deg) translate(-5px, 2px);
    }

    100% {
        transform: rotate(-6deg) translate(-9px, 6px);
    }
}

@keyframes top_cards_yurayura4 {
    0% {
        transform: rotate(-2deg) translate(-2px, 0px);
    }

    100% {
        transform: rotate(-4deg) translate(-6px, 4px);
    }
}

@keyframes top_cards_yurayura5 {
    0% {
        transform: rotate(0deg) translate(0px, -2px);
    }

    100% {
        transform: rotate(-2deg) translate(-4px, 2px);
    }
}

@keyframes top_cards_yurayura6 {
    0% {
        transform: rotate(2deg) translate(2px, 1px);
    }

    100% {
        transform: rotate(0deg) translate(-2px, 5px);
    }
}

@keyframes top_cards_yurayura7 {
    0% {
        transform: rotate(4deg) translate(5px, 4px);
    }

    100% {
        transform: rotate(2deg) translate(1px, 8px);
    }
}

@keyframes top_cards_yurayura8 {
    0% {
        transform: rotate(6deg) translate(10px, -1px);
    }

    100% {
        transform: rotate(4deg) translate(6px, 3px);
    }
}

@keyframes top_cards_yurayura9 {
    0% {
        transform: rotate(8deg) translate(15px, 3px);
    }

    100% {
        transform: rotate(6deg) translate(11px, 7px);
    }
}

@keyframes top_cards_yurayura10 {
    0% {
        transform: rotate(10deg) translate(20px, -3px);
    }

    100% {
        transform: rotate(8deg) translate(16px, 1px);
    }
}

/* mix_cards：動的に生成されるアニメーション */
.card-image.mix_cards {
    /* JavaScriptで動的にアニメーションが適用されるため、ここでは何も定義しない */
}

/* top_cards + mix_cards 両方のクラスを持つ場合も動的に適用 */
.card-image.top_cards.mix_cards {
    /* JavaScriptで動的にアニメーションが適用されるため、ここでは何も定義しない */
}

/* ダウンロード用レスポンシブ対応 */
@media (max-width: 768px) {
    #download-card-results {
        gap: 0.05rem;
        padding: 0 0.05rem;
    }

    .download-card-container {
        padding: 0.2rem 0.02rem;
        min-height: clamp(180px, 35vh, 300px);
    }

    .download-card-container .card-image {
        width: clamp(85px, 24vw, 125px);
        height: clamp(127px, 36vw, 187px);
    }

    .download-card-container .card-name {
        font-size: clamp(0.78rem, 3.9vw, 1.04rem);
    }

    .download-card-container .card-description {
        font-size: clamp(0.55rem, 2.8vw, 0.75rem);
    }
}

@media (max-width: 480px) {
    .download-card-container {
        padding: 0.15rem 0.02rem;
        min-height: clamp(150px, 30vh, 250px);
    }

    .download-card-container .card-image {
        width: clamp(70px, 20vw, 100px);
        height: clamp(105px, 30vw, 150px);
    }

    .download-card-container .card-name {
        font-size: clamp(0.65rem, 4.55vw, 0.91rem);
    }

    .download-card-container .card-description {
        font-size: clamp(0.5rem, 3vw, 0.65rem);
        line-height: 1.2;
    }
}

.explain-button {
    display: inline-block;
    padding: 0.2em 0.9em;
    font-size: 0.85em;
    min-width: 60px;
    max-width: 90px;
    width: auto;
    border: 1px solid #888;
    border-radius: 6px;
    background: #f3f3f3;
    color: #555;
    cursor: pointer;
    margin: 1em auto 1em auto;
    transition: background 0.2s, color 0.2s, border 0.2s;
}

.explain-button:hover {
    background: #e0e0e0;
    color: #222;
    border: 1px solid #555;
}

/* 4枚カード表示用レイアウト（ジャンプカードあり） */
.four-card-layout {
    justify-content: center;
}

.four-card-layout .card-container {
    width: 23%;
    flex: 0 0 23%;
}

@media (max-width: 768px) {
    .four-card-layout .card-container {
        width: 48%;
        /* 2列で表示 */
        flex: 0 0 48%;
    }
}

/* =========================================
   SPA View Switching Utils
   ========================================= */
.app-view {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* =========================================
   Jump Card Styles (migrated from jump_cards.html)
   ========================================= */
#jumpCardArea {
    background: rgba(255, 255, 255, 0.9);
    padding: 1em 2em 2.5em 2em;
    border-radius: 1.5em;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin: 2vh auto;
    max-width: clamp(300px, 90vw, 400px);
}

#jumpCardArea h2 {
    margin-top: 20px;
}

/* Jump Card View specific modifications */
#view-jump .card-image {
    width: 180px;
    height: 270px;
    object-fit: contain;
    margin-bottom: 1em;
    border-radius: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#view-jump .card-name {
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 0.5em;
}

#view-jump .card-orientation {
    margin-bottom: 0.5em;
    font-size: 1em;
}

#view-jump .card-description {
    margin-bottom: 1em;
}

#view-jump #downloadArea {
    margin-top: 30px;
    text-align: center;
    width: 100%;
}

/* セクション区切り線 (極細) */
.subtle-divider {
    width: 60%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.2);
    margin: 0.5em auto;
    border: none;
}