:root {
    --bg-color: #05050f;
    --text-color: #e0d8e8;
    --gold: #d4af37;
    --gold-light: #f3e5ab;
    --gold-dark: #aa8529;
    --purple-deep: #2a0a4a;
    --purple-glow: rgba(138, 43, 226, 0.6);
    --card-bg: #1a1a2e;
    
    --font-en: 'Cinzel Decorative', cursive;
    --font-ja: 'Noto Serif JP', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-ja);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Animations */
.stars, .twinkling, .clouds {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    display: block;
    z-index: -1;
}

.stars {
    background: #000 url('https://cdn.pixabay.com/photo/2016/06/02/02/33/triangles-1430105_1280.png') repeat top center;
    z-index: -3;
    opacity: 0.3;
}

.twinkling {
    background: transparent url('https://cdn.pixabay.com/photo/2012/11/28/10/53/stars-67616_1280.jpg') repeat top center;
    z-index: -2;
    animation: move-twink-back 200s linear infinite;
    mix-blend-mode: screen;
    opacity: 0.2;
}

@keyframes move-twink-back {
    from {background-position: 0 0;}
    to {background-position: -10000px 5000px;}
}

/* Layout */
.container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 1;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.title {
    font-family: var(--font-en);
    font-size: 3.5rem;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-dark);
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--gold-light);
    letter-spacing: 1px;
    opacity: 0.8;
}

/* Deck & Cards */
.deck-container {
    height: 350px;
    position: relative;
    margin-bottom: 3rem;
    perspective: 1000px;
}

.deck {
    position: relative;
    width: 200px;
    height: 320px;
    transform-style: preserve-3d;
}

.card-back {
    background: linear-gradient(135deg, var(--purple-deep) 0%, #110522 100%);
    border: 2px solid var(--gold-dark);
    border-radius: 12px;
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.2), 0 10px 20px rgba(0,0,0,0.5);
    background-image: 
        radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.8) 100%),
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(212, 175, 55, 0.05) 10px, rgba(212, 175, 55, 0.05) 20px);
}

.card-back::after {
    content: "✬";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    color: var(--gold);
    opacity: 0.7;
    text-shadow: 0 0 15px var(--gold);
}

.card-back::before {
    content: '';
    position: absolute;
    top: 15px; left: 15px; right: 15px; bottom: 15px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 6px;
}

.deck-card {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
}

.deck-card:nth-child(1) { transform: translateZ(-10px) rotate(-3deg); }
.deck-card:nth-child(2) { transform: translateZ(-5px) rotate(1deg); }
.deck-card:nth-child(3) { transform: translateZ(0) rotate(-1deg); }

.deck-container:hover .deck-card:nth-child(3) {
    transform: translateZ(20px) translateY(-15px) rotate(-1deg);
    box-shadow: 0 0 30px var(--purple-glow);
}

/* Buttons */
.mystic-button {
    background: transparent;
    border: 1px solid var(--gold);
    padding: 1rem 3rem;
    border-radius: 50px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    background: rgba(42, 10, 74, 0.4);
    backdrop-filter: blur(5px);
}

.button-text {
    font-family: var(--font-ja);
    font-size: 1.2rem;
    color: var(--gold-light);
    letter-spacing: 3px;
    position: relative;
    z-index: 2;
    font-weight: bold;
}

.button-glow {
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, var(--purple-glow) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.mystic-button:hover {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
    border-color: var(--gold-light);
}

.mystic-button:hover .button-glow {
    opacity: 1;
    animation: spin 4s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.mystic-button.ghost {
    background: transparent;
    border-color: rgba(212, 175, 55, 0.5);
    padding: 0.8rem 2rem;
}
.mystic-button.ghost .button-text {
    font-size: 1rem;
}

/* Loading Animation */
.magic-circle {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    border: 2px dashed var(--gold);
    position: relative;
    animation: rotate-circle 10s linear infinite;
    margin-bottom: 2rem;
    box-shadow: 0 0 40px var(--purple-glow);
}

.magic-circle::before {
    content: '';
    position: absolute;
    top: 15px; left: 15px; right: 15px; bottom: 15px;
    border: 1px solid var(--gold-light);
    border-radius: 50%;
}

.magic-circle::after {
    content: '✡';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    color: var(--gold);
    animation: pulse 2s ease-in-out infinite;
}

.loading-text {
    font-size: 1.2rem;
    color: var(--gold-light);
    letter-spacing: 2px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes rotate-circle {
    100% { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.9); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); text-shadow: 0 0 20px var(--gold); }
}


/* Result Screen */
.result-layout {
    display: flex;
    gap: 4rem;
    max-width: 900px;
    width: 100%;
    align-items: center;
}

.card-display {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    perspective: 1200px;
}

.tarot-card {
    width: 260px;
    height: 440px;
    position: relative;
    transform-style: preserve-3d;
}

.tarot-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tarot-card.flipped .tarot-card-inner {
    transform: rotateY(180deg);
}

.tarot-card.flipped.reversed .tarot-card-inner {
    transform: rotateY(180deg) rotateZ(180deg);
}

.tarot-card-front, .tarot-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

.tarot-card-back {
    transform: rotateY(180deg);
    background: var(--card-bg);
    border: 3px solid var(--gold);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
    padding: 10px;
}

.tarot-card-back svg {
    width: 100%;
    height: 100%;
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 6px;
    background: #0d0914;
}

.position-badge {
    margin-top: 2rem;
    padding: 0.5rem 1.5rem;
    background: rgba(0,0,0,0.6);
    border: 1px solid var(--gold);
    border-radius: 20px;
    color: var(--gold-light);
    font-weight: bold;
    letter-spacing: 2px;
    box-shadow: 0 0 10px var(--purple-glow);
    opacity: 0;
    transition: opacity 1s ease 1.5s; /* カードフリップ後に表示 */
}

.position-badge.show {
    opacity: 1;
}

/* Reading Display */
.reading-display {
    flex: 1;
    background: rgba(20, 10, 35, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5), inset 0 0 20px rgba(138, 43, 226, 0.1);
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s ease 2s; /* カードフリップ＆バッジ表示後に表示 */
}

.reading-display.show {
    opacity: 1;
    transform: translateY(0);
}

.card-name-en {
    font-family: var(--font-en);
    color: var(--gold);
    font-size: 2rem;
    margin-bottom: 0.2rem;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.card-name-ja {
    font-size: 1.5rem;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.keyword-box {
    margin-bottom: 2rem;
}

.keyword-label {
    color: var(--gold-dark);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.5rem;
}

.keywords {
    font-size: 1.2rem;
    color: var(--gold-light);
    font-weight: bold;
    letter-spacing: 1px;
}

.reading-title {
    color: var(--gold);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.reading-title::before, .reading-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.description-text {
    line-height: 1.8;
    color: #d8cde6;
    margin-bottom: 2.5rem;
    font-size: 1.05rem;
}

/* Responsive */
@media (max-width: 768px) {
    .result-layout {
        flex-direction: column;
        gap: 2rem;
    }
    
    .card-display {
        flex: 0 0 auto;
    }
    
    .tarot-card {
        width: 200px;
        height: 340px;
    }
    
    .app-header {
        margin-bottom: 1.5rem;
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .reading-display {
        padding: 1.5rem;
    }
}
