/* ===== CSS変数 ===== */
:root {
    --card-gradient: linear-gradient(135deg, #2a1810, #4a2c18);
    --flipped-gradient: linear-gradient(135deg, #f5f5dc, #e6ddb3);
    --gold-color: #d4af37;
    --brown-text: #8b4513;
}

/* ===== リセットとベース ===== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #e6e6e6;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
}

/* ===== 共通コンポーネント ===== */

/* ===== ヘッダー ===== */
.main-header {
    text-align: center;
    padding: 0.5rem 0;
    margin-bottom: 0;
}

.main-title {
    font-size: 3rem;
    margin: 0;
    background: linear-gradient(45deg, #4cc9f0, #7209b7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(76, 201, 240, 0.5);
    font-weight: bold;
}

/* ===== 選択肢エリア ===== */
.top-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

.options-section {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.options-grid {
    display: inline-flex;
    gap: 0.5rem;
}

.reset-container {
    position: absolute;
    right: 0;
}

.reset-btn {
    background: linear-gradient(45deg, #6c757d, #5a6268);
    color: white;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    opacity: 0.8;
    border-radius: 20px;
    border: none;
    cursor: pointer;
}

.option-btn {
    width: 45px;
    height: 65px;
    background: var(--card-gradient);
    border: 2px solid #8b7355;
    color: var(--gold-color);
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(212, 175, 55, 0.2);
    transition: all 0.3s ease;
    position: relative;
}

.option-btn:hover {
    border-color: var(--gold-color);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8), inset 0 2px 4px rgba(212, 175, 55, 0.3);
}

.option-btn.selected {
    background: var(--flipped-gradient);
    border-color: var(--gold-color);
    color: transparent;
    cursor: pointer;
    transform: rotateY(180deg);
    transition: all 0.6s ease;
    overflow: hidden;
    position: relative;
}

.option-btn.selected:has(.card-mini-image) {
    background: white;
}

.option-btn.selected .card-mini-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    transform: rotateY(180deg);
}

.option-btn.selected .card-mini-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--brown-text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transform: rotateY(180deg);
    background: var(--flipped-gradient);
    border-radius: 6px;
}

.option-btn.margin-left {
    margin-left: 1rem;
}


/* ===== カルーセルエリア ===== */
.carousel-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    position: relative;
    perspective: 1200px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.carousel-track {
    position: relative;
    width: 320px;
    height: 420px;
    transform-style: preserve-3d;
    transition: transform 0.6s ease-in-out;
}

.card-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    text-align: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.6s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.card-section.visible {
    opacity: 1;
}

.card-section.active {
    pointer-events: auto;
    opacity: 1;
    z-index: 2;
}

.card-section:not(.active) {
    pointer-events: none;
}

.effect-title {
    font-size: 1.8rem;
    margin: 0;
    text-shadow: 0 0 10px #4cc9f0;
    flex-shrink: 0;
}

.card-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    margin: 0.5rem 0;
}

.generate-btn {
    flex-shrink: 0;
    margin-top: 0;
}

.carousel-nav {
    background: rgba(0, 0, 0, 0.5);
    color: #4cc9f0;
    border: 2px solid #4cc9f0;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.carousel-nav:hover {
    background: rgba(76, 201, 240, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(76, 201, 240, 0.5);
}

.selected-card {
    width: 180px;
    height: 260px;
    background: var(--card-gradient);
    border: 3px solid #d4af37;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: bold;
    color: var(--gold-color);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.8),
        inset 0 2px 8px rgba(212, 175, 55, 0.2);
    transition: all 0.5s ease;
    position: relative;
}

.selected-card::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    pointer-events: none;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.selected-card.flipped {
    background: var(--flipped-gradient);
    color: var(--brown-text);
}

.generate-btn {
    background: linear-gradient(45deg, #4cc9f0, #4895ef);
    color: white;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(72, 149, 239, 0.4);
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.generate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(72, 149, 239, 0.6);
}

.generate-btn:active {
    transform: scale(0.95);
}

/* ===== 演出専用スタイル ===== */

/* スロット演出 */
.slot-machine {
    width: 100%;
    height: 180px;
    overflow: hidden;
    position: relative;
    border: 2px solid var(--gold-color);
    border-radius: 8px;
}

.slot-reel {
    display: flex;
    flex-direction: column;
    transition: transform 0.1s linear;
}

.slot-item {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold-color);
}


/* 全画面演出用オーバーレイ（背景を薄く） */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.fullscreen-overlay > * {
    pointer-events: auto; /* 演出要素のみクリック可能 */
}

/* スライド演出（全画面版） */
.fullscreen-slide-container {
    width: 100%;
    height: 150px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.9); /* 演出エリアのみ背景 */
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.fullscreen-slide-track {
    display: flex;
    transition: transform 0.1s linear;
    height: 100%;
}

.fullscreen-slide-item {
    min-width: 120px;
    height: 120px;
    margin: 0 20px;
    background: var(--card-gradient);
    border: 3px solid var(--gold-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    color: var(--gold-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}


.fullscreen-result-card {
    width: 50vw;
    max-width: 400px;
    height: 60vh;
    max-height: 600px;
    background: var(--card-gradient);
    border: 5px solid var(--gold-color);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    font-weight: bold;
    color: var(--gold-color);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.9),
        inset 0 4px 16px rgba(212, 175, 55, 0.3);
    animation: resultGlow 2s ease-in-out;
    transition: all 0.5s ease;
}

.fullscreen-result-card.flipped {
    background: var(--flipped-gradient);
    color: var(--brown-text);
}

@keyframes resultGlow {

    0%,
    100% {
        box-shadow:
            0 20px 60px rgba(0, 0, 0, 0.9),
            inset 0 4px 16px rgba(212, 175, 55, 0.3),
            0 0 30px var(--gold-color);
    }

    50% {
        box-shadow:
            0 25px 80px rgba(0, 0, 0, 0.9),
            inset 0 6px 20px rgba(212, 175, 55, 0.4),
            0 0 60px var(--gold-color);
    }
}

/* 星座演出 */
.constellation-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(ellipse at center, #000428 0%, #004e92 100%);
    overflow: hidden;
}

.star-field {
    position: relative;
    width: 100%;
    height: 100%;
}

.constellation {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.3;
    transition: opacity 1s ease;
}

.constellation.activating {
    opacity: 1;
    animation: constellationPulse 0.8s ease-in-out;
}

.constellation.completing {
    opacity: 1;
    z-index: 10;
}

.constellation.completing .star {
    animation: starActivate var(--delay, 0s) ease-out forwards;
}

.constellation.completing .star-line {
    animation: lineGrow var(--line-delay, 0s) ease-out forwards;
}

.constellation.fading {
    opacity: 0;
    transition: opacity 1s ease;
}

.star {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.star-core {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #fff 0%, #87ceeb 50%, transparent 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: #000;
    position: relative;
    z-index: 2;
}

.star-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.constellation-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.star-line {
    stroke: #87ceeb;
    stroke-width: 2;
    opacity: 0;
    filter: drop-shadow(0 0 3px #87ceeb);
}

.shooting-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.shooting-star {
    position: absolute;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, #fff 0%, #87ceeb 50%, #4cc9f0 80%, transparent 100%);
    border-radius: 50%;
    box-shadow: 0 0 30px #fff, 0 0 60px #87ceeb, 0 0 90px #4cc9f0;
    animation: shoot 1.2s ease-in forwards;
}

@keyframes constellationPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes starActivate {
    0% { 
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes lineGrow {
    0% { 
        opacity: 0;
        stroke-dasharray: 100;
        stroke-dashoffset: 100;
    }
    100% { 
        opacity: 1;
        stroke-dasharray: 100;
        stroke-dashoffset: 0;
    }
}

@keyframes shoot {
    0% {
        transform: translateX(0) translateY(0) scale(0.3);
        opacity: 0;
    }
    20% {
        transform: translateX(200px) translateY(150px) scale(1.2);
        opacity: 1;
    }
    80% {
        transform: translateX(800px) translateY(600px) scale(2);
        opacity: 0.8;
    }
    100% {
        transform: translateX(1000px) translateY(800px) scale(0);
        opacity: 0;
    }
}

.constellation.completing .star .star-core {
    background: radial-gradient(circle, #ffd700 0%, #ffed4e 50%, transparent 100%);
    color: #000;
    font-weight: bold;
}

.constellation.completing .star .star-glow {
    opacity: 1;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.8) 0%, transparent 70%);
    animation: starGlow 2s ease-in-out infinite;
}

.constellation.completing .star-line {
    stroke: #ffd700;
    stroke-width: 3;
    filter: drop-shadow(0 0 8px #ffd700);
}

@keyframes starGlow {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.3; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; }
}

/* 全画面カードフリップ演出 */
.fullscreen-card-flip-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-card-flip-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    width: 60vw;
    height: 40vh;
    max-width: 800px;
    max-height: 400px;
}

.fullscreen-flip-card {
    perspective: 1000px;
    cursor: pointer;
}

.fullscreen-flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.3s;
    transform-style: preserve-3d;
}

.fullscreen-flip-card.flipped .fullscreen-flip-card-inner {
    transform: rotateY(180deg);
}

.fullscreen-flip-card-front,
.fullscreen-flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: bold;
    font-size: 2rem;
}

.fullscreen-flip-card-front {
    background: var(--card-gradient);
    color: var(--gold-color);
    border: 3px solid var(--gold-color);
}

.fullscreen-flip-card-back {
    background: var(--flipped-gradient);
    color: var(--brown-text);
    transform: rotateY(180deg);
    border: 3px solid var(--gold-color);
}

.fullscreen-flip-card.final {
    animation: finalGlow 1s ease-in-out;
}

/* カードフリップ演出 */
.card-flip-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 5px;
    width: 100%;
    height: 180px;
}

.flip-card {
    perspective: 1000px;
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: bold;
}

.flip-card-front {
    background: var(--card-gradient);
    color: var(--gold-color);
    border: 1px solid var(--gold-color);
}

.flip-card-back {
    background: var(--flipped-gradient);
    color: var(--brown-text);
    transform: rotateY(180deg);
    border: 1px solid var(--gold-color);
}

.flip-card.final {
    animation: finalGlow 1s ease-in-out;
}

@keyframes finalGlow {

    0%,
    100% {
        box-shadow: 0 0 5px var(--gold-color);
    }

    50% {
        box-shadow: 0 0 20px var(--gold-color);
    }
}


/* ===== フッター ===== */
.footer {
    margin-top: 2rem;
    padding: 1rem;
    text-align: center;
}

.copyright {
    font-size: 0.7rem;
    color: rgba(212, 175, 55, 0.5);
    font-style: italic;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    body {
        gap: 1rem;
        padding: 1rem;
    }

    .options-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    .options-grid {
        gap: 0.3rem;
    }

    .option-btn {
        width: 35px;
        height: 50px;
        font-size: 1rem;
    }

    .card-section h1 {
        font-size: 2rem;
    }

    .selected-card {
        width: 140px;
        height: 200px;
        font-size: 3rem;
    }

    .generate-btn {
        padding: 0.8rem 2rem;
        font-size: 1.1rem;
    }
}