* {
    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;
    margin: 0;
    padding: 2vh 2vw;
    background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
    color: #333;
}
h1 {
    color: #333;
    margin-bottom: 2vh;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    text-align: center;
}

#controls {
    margin-bottom: 3vh;
    text-align: center;
    width: 100%;
    max-width: 90vw;
}
.draw-button {
    padding: clamp(0.8rem, 2vw, 1.2rem) clamp(1.5rem, 4vw, 2.5rem);
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    cursor: pointer;
    border: 2px solid #000;
    border-radius: 0;
    background: #fff;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
    min-width: clamp(120px, 20vw, 200px);
}
.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: 2vh auto;
    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(100px, 20vw, 150px);
    height: clamp(150px, 30vw, 225px);
    margin: 2vh auto 2em auto;
    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;
}
footer {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    text-align: center;
    margin-top: 2em;
    color: #777;
    width: 100%;
    padding: 0 1rem;
}

.version-display {
    font-size: clamp(0.5rem, 1.5vw, 0.6rem);
    color: #999;
    margin-top: 0.5em;
    opacity: 0.7;
}
#downloadArea {
    margin-top: 3vh;
    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 {
    padding: clamp(0.6rem, 1.5vw, 1rem);
    font-size: clamp(0.9rem, 2.2vw, 1rem);
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-right: clamp(0.5rem, 1vw, 1rem);
    width: clamp(200px, 40vw, 300px);
    text-align: center;
}
#downloadButton {
    padding: clamp(0.8rem, 2vw, 1.2rem) clamp(1.5rem, 4vw, 2.5rem);
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    cursor: pointer;
    border: 2px solid #000;
    border-radius: 0;
    background: #fff;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
    min-width: clamp(150px, 25vw, 200px);
}
#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;
}