/**
 * Myst Echo - メインスタイル
 */

/* ============================================
   基本スタイル
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.myst-echo-draw-container {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    /* パフォーマンス最適化：背景アニメーションを無効化 */
    /* animation: bgGradientShift 20s ease infinite; */
    margin: 0 !important;
    padding: 0 !important;
}

/* カード引きページでのみ全画面表示 */
body.myst-echo-draw-page .myst-echo-draw-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.myst-echo-draw-page.admin-bar .myst-echo-draw-container {
    top: 0 !important;
    padding-top: 32px !important;
    box-sizing: border-box;
    height: 100vh !important;
}

@keyframes bgGradientShift {
    0% { background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); }
    33% { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
    66% { background: linear-gradient(135deg, #2d1b69 0%, #4a148c 50%, #6a1b9a 100%); }
    100% { background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); }
}

/* ============================================
   body スタイル（カード引きページのみ）
   ============================================ */
body.myst-echo-draw-page {
    overflow: hidden !important;
    display: flex !important;
    -webkit-perspective: 1000px;
    perspective: 1000px;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
}

body.myst-echo-draw-page.admin-bar {
    padding-top: 0 !important;
}

body.myst-echo-draw-page #wpadminbar {
    display: none !important;
}

html.myst-echo-draw-page,
html body.myst-echo-draw-page {
    height: 100%;
    touch-action: none;
}


/* ============================================
   引き情報表示
   ============================================ */
.myst-echo-draw-info {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100;
    color: #fff;
    padding: 0 20px;
}

.remaining-draws {
    font-size: 16px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.remaining-draws .no-draws {
    color: #ff6b6b;
}

.remaining-draws .admin-unlimited {
    color: #4ade80;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.6);
}

/* ============================================
   引き回数なし時の表示
   ============================================ */
.myst-echo-no-draws {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    color: #fff;
    padding: 40px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.myst-echo-no-draws p {
    font-size: 20px;
    margin-bottom: 30px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.myst-echo-no-draws .myst-echo-button {
    font-size: 18px;
    padding: 15px 40px;
}

/* ============================================
   カードセット情報
   ============================================ */
.myst-echo-card-set-info {
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100;
    color: #fff;
}

.myst-echo-card-set-info h2 {
    font-size: 24px;
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.card-set-description {
    font-size: 14px;
    opacity: 0.8;
}

/* ============================================
   ガイダンスメッセージ
   ============================================ */
.myst-echo-guidance {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    text-align: center;
}

.guidance-text {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    padding: 20px 40px;
    border-radius: 50px;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(138, 43, 226, 0.4);
    box-shadow: 0 8px 32px rgba(138, 43, 226, 0.3), 0 0 40px rgba(138, 43, 226, 0.2);
}

.guidance-text.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.guidance-text.active.visible {
    display: block;
}

#guidance-selected {
    background: rgba(138, 43, 226, 0.3);
    border-color: rgba(138, 43, 226, 0.6);
    box-shadow: 0 8px 32px rgba(138, 43, 226, 0.5), 0 0 60px rgba(138, 43, 226, 0.4);
}

.guidance-icon {
    display: inline-block;
    margin-right: 12px;
    font-size: 24px;
    vertical-align: middle;
    animation: iconFloat 2s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.guidance-message {
    display: inline-block;
    vertical-align: middle;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
}

/* ============================================
   選択確認メッセージ
   ============================================ */
.selection-confirmation {
    position: fixed;
    transform: translate(-50%, -50%);
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.selection-confirmation.active {
    opacity: 1;
    animation: confirmationPop 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes confirmationPop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.confirmation-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    animation: confirmationGlow 0.8s ease-out;
}

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

.confirmation-message {
    position: relative;
    background: rgba(138, 43, 226, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    border-radius: 40px;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px rgba(138, 43, 226, 0.6);
}

.confirmation-icon {
    display: inline-block;
    margin-right: 10px;
    font-size: 24px;
    vertical-align: middle;
    animation: iconSpin 0.6s ease-out;
}

@keyframes iconSpin {
    0% { transform: rotate(0deg) scale(0); }
    50% { transform: rotate(180deg) scale(1.3); }
    100% { transform: rotate(360deg) scale(1); }
}

.confirmation-text {
    vertical-align: middle;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* ============================================
   選択時の波紋エフェクト
   ============================================ */
.selection-ripple {
    position: fixed;
    width: 0;
    height: 0;
    border-radius: 50%;
    border: 3px solid rgba(138, 43, 226, 0.6);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 250;
    opacity: 1;
    transition: all 1s ease-out;
}

.selection-ripple.expand {
    width: 600px;
    height: 600px;
    opacity: 0;
    border-width: 2px;
}

/* ============================================
   魔法陣（背景演出）
   ============================================ */
.myst-echo-magic-circle {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.1) 0%, transparent 70%);
    border: 2px solid rgba(138, 43, 226, 0.2);
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
    z-index: 1;
}

.myst-echo-magic-circle::before,
.myst-echo-magic-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.myst-echo-magic-circle::before {
    width: 80%;
    height: 80%;
}

.myst-echo-magic-circle::after {
    width: 60%;
    height: 60%;
    border-style: dashed;
}

.myst-echo-magic-circle.active {
    opacity: 1;
    animation: magicCirclePulse 4s ease-in-out infinite;
}

@keyframes magicCirclePulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.08) rotate(180deg);
        opacity: 0.7;
    }
}

/* 魔法陣の追加装飾（回転アニメーション） */
.myst-echo-magic-circle.active::before {
    animation: magicCircleRotate 20s linear infinite;
}

.myst-echo-magic-circle.active::after {
    animation: magicCircleRotateReverse 15s linear infinite;
}

@keyframes magicCircleRotate {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes magicCircleRotateReverse {
    0% { transform: translate(-50%, -50%) rotate(360deg); }
    100% { transform: translate(-50%, -50%) rotate(0deg); }
}

/* ============================================
   カード選択エリア（横一列に広がる）
   ============================================ */
.myst-echo-card-selection-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    overflow: hidden;
}

.myst-echo-card-selection-area.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.cards-spread-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   カードアイテム（横一列配置）
   ============================================ */
.myst-echo-card-spread-item {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160px;
    height: 224px;
    transform-origin: center center;
    cursor: pointer;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    transform-style: preserve-3d;
    perspective: 1000px;
    /* 初期状態でもカードは表示されるように（JavaScriptで制御） */
    opacity: 1;
}

/* カード出現アニメーション（横に広がる） */
.myst-echo-card-spread-item.card-appear {
    opacity: 1;
}

/* カードホバー時の基本スタイル（JavaScriptで詳細な位置を制御） */
.myst-echo-card-spread-item.card-hovered {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* カード選択時（回転して表を向く） */
.myst-echo-card-spread-item.card-selected {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 選ばれた瞬間の強調 */
.myst-echo-card-spread-item.card-just-chosen {
    animation: cardJustChosen 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes cardJustChosen {
    0% {
        transform: scale(1.2);
    }
    30% {
        transform: scale(1.4);
        filter: brightness(1.5);
    }
    60% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1.3);
    }
}

/* 他のカードを暗く（より上品に） */
.myst-echo-card-spread-item.dimmed {
    opacity: 0.15;
    filter: blur(4px) brightness(0.4);
    transform: scale(0.85) !important;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* カードが選ばれなかった（消える） */
.myst-echo-card-spread-item.card-dismissed {
    pointer-events: none;
}

/* 選ばれたカードの証 */
.card-chosen-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(138, 43, 226, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 30px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px rgba(138, 43, 226, 0.6);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.myst-echo-card-spread-item.card-selected .card-chosen-mark {
    opacity: 1;
    animation: chosenMarkAppear 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

@keyframes chosenMarkAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-10deg);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

.chosen-icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 20px;
    vertical-align: middle;
    animation: starTwinkle 1s ease-in-out infinite;
}

@keyframes starTwinkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.3) rotate(180deg); }
}

.chosen-text {
    vertical-align: middle;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
}

/* カード番号バッジ（3D transformの影響を受けないように反転を補正） */
.card-number-badge {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.9) 0%, rgba(255, 255, 255, 0.9) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50; /* カードより前面に */
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    /* 3D transformの影響を打ち消すために反転 */
    transform-style: preserve-3d;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}

/* カードが裏向き（rotateY(180deg)）の時、バッジも反転させて正しく見えるように */
.myst-echo-card-spread-item .card-number-badge {
    transform: rotateY(180deg); /* カードの裏向きを補正 */
}

/* カードが表を向いた時（選択後）は正しい向きに */
.myst-echo-card-spread-item.card-selected.card-flipped .card-number-badge {
    transform: rotateY(0deg);
}

.myst-echo-card-spread-item.card-hovered .card-number-badge {
    transform: rotateY(180deg) scale(1.2);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.6);
}

.myst-echo-card-spread-item.card-selected .card-number-badge {
    transform: rotateY(180deg) scale(1.5);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.9) 0%, rgba(255, 255, 255, 0.9) 100%);
    box-shadow: 0 8px 24px rgba(255, 215, 0, 0.8);
    animation: badgePulse 0.6s ease-out;
}

@keyframes badgePulse {
    0% { transform: scale(1.5); }
    50% { transform: scale(2); }
    100% { transform: scale(1.5); }
}

.card-number {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* カードの裏面 */
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b69 50%, #4a148c 100%);
    border-radius: 16px;
    backface-visibility: visible !important; /* 裏面でも表示されるように */
    -webkit-backface-visibility: visible !important;
    border: 3px solid rgba(138, 43, 226, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(138, 43, 226, 0.3);
    overflow: visible; /* 装飾が見えるように */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1; /* 裏面が前面に */
    /* カードが表示されるように */
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* 裏面の画像（選択時に追加される） */
/* 裏面の画像（選択時に追加される） */
.card-back-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    opacity: 0.5; /* 裏面の装飾の上に表示 */
    z-index: 2; /* 装飾より前面に */
    pointer-events: none;
    backface-visibility: visible; /* 裏面でも表示されるように */
    -webkit-backface-visibility: visible;
}

/* カードが表を向いている時は裏面画像を非表示 */
.myst-echo-card-spread-item.card-selected.card-flipped .card-back-image {
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* ホバー時：裏面のまま、光のエフェクトでフォーカスを表現 */
.myst-echo-card-spread-item.card-hovered .card-back {
    border-color: rgba(138, 43, 226, 0.9);
    border-width: 4px;
    box-shadow: 
        0 12px 48px rgba(138, 43, 226, 0.8), 
        inset 0 0 30px rgba(138, 43, 226, 0.5),
        0 0 60px rgba(138, 43, 226, 0.6);
    animation: cardBackGlow 2s ease-in-out infinite;
}

@keyframes cardBackGlow {
    0%, 100% {
        box-shadow: 
            0 12px 48px rgba(138, 43, 226, 0.8), 
            inset 0 0 30px rgba(138, 43, 226, 0.5),
            0 0 60px rgba(138, 43, 226, 0.6);
    }
    50% {
        box-shadow: 
            0 16px 60px rgba(138, 43, 226, 1), 
            inset 0 0 40px rgba(138, 43, 226, 0.7),
            0 0 80px rgba(138, 43, 226, 0.9);
    }
}

.card-back-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 2px, transparent 2px),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 2px, transparent 2px);
    background-size: 40px 40px;
    opacity: 0.5;
}

/* 裏面の神秘的な装飾 */
.card-back-ornament {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    opacity: 0.6;
    transition: all 0.4s ease;
}

.card-back-ornament::before,
.card-back-ornament::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
}

.card-back-ornament::before {
    width: 60px;
    height: 60px;
}

.card-back-ornament::after {
    width: 40px;
    height: 40px;
    border-style: dashed;
}

/* ホバー時：装飾を強調 */
.myst-echo-card-spread-item.card-hovered .card-back-ornament {
    opacity: 1;
    width: 100px;
    height: 100px;
    border-color: rgba(138, 43, 226, 0.6);
    border-width: 3px;
    animation: ornamentPulse 2s ease-in-out infinite;
}

@keyframes ornamentPulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0.8;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.1) rotate(180deg);
        opacity: 1;
    }
}

.myst-echo-card-spread-item.card-hovered .card-back-ornament::before {
    border-color: rgba(138, 43, 226, 0.4);
}

.myst-echo-card-spread-item.card-hovered .card-back-ornament::after {
    border-color: rgba(138, 43, 226, 0.5);
}

.card-back-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0.4;
    transition: all 0.4s ease;
    animation: backGlowPulse 2s ease-in-out infinite;
}

@keyframes backGlowPulse {
    0%, 100% { 
        opacity: 0.4; 
        transform: translate(-50%, -50%) scale(1); 
    }
    50% { 
        opacity: 0.7; 
        transform: translate(-50%, -50%) scale(1.2); 
    }
}

/* ホバー時：裏面のグローを強化 */
.myst-echo-card-spread-item.card-hovered .card-back-glow {
    width: 180px;
    height: 180px;
    opacity: 0.8;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.6) 0%, rgba(255, 255, 255, 0.2) 40%, transparent 70%);
    animation: backGlowPulseHover 1.5s ease-in-out infinite;
}

@keyframes backGlowPulseHover {
    0%, 100% { 
        opacity: 0.7; 
        transform: translate(-50%, -50%) scale(1); 
    }
    50% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1.3); 
    }
}

/* カードの表面（選択時に動的に追加される） */
.card-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transform: rotateY(180deg); /* 初期状態は裏向き */
    border-radius: 16px;
    overflow: hidden;
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    z-index: 2;
}

/* カードの表面が追加された時 */
.myst-echo-card-spread-item .card-front {
    opacity: 1;
}

/* 選択時に表を向ける */
.myst-echo-card-spread-item.card-selected.card-flipped .card-front {
    transform: rotateY(0deg);
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.myst-echo-card-spread-item.card-selected.card-flipped .card-back {
    transform: rotateY(180deg);
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* カードが表を向いている時は裏面画像を非表示 */
.myst-echo-card-spread-item.card-selected.card-flipped .card-back-image {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* 裏面の画像（選択時に追加される・2箇所目） */
.card-back-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    opacity: 0.5; /* 裏面の装飾の上に表示 */
    z-index: 2; /* 装飾より前面に */
    pointer-events: none;
    backface-visibility: visible; /* 裏面でも表示されるように */
    -webkit-backface-visibility: visible;
}

/* カードが表を向いている時は裏面画像を非表示 */
.myst-echo-card-spread-item.card-selected.card-flipped .card-back-image {
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* カード周囲のフォーカスリング（ホバー時のフォーカス表示用） */
.card-focus-ring {
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    border-radius: 20px;
    border: 3px solid rgba(138, 43, 226, 0);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: -1;
    box-shadow: 0 0 0 0 rgba(138, 43, 226, 0);
}

.myst-echo-card-spread-item.card-hovered .card-focus-ring {
    opacity: 1;
    border-color: rgba(138, 43, 226, 0.8);
    box-shadow: 
        0 0 30px rgba(138, 43, 226, 0.6),
        inset 0 0 30px rgba(138, 43, 226, 0.2);
    animation: focusRingPulse 2s ease-in-out infinite;
}

@keyframes focusRingPulse {
    0%, 100% { 
        transform: scale(1);
        border-color: rgba(138, 43, 226, 0.8);
        box-shadow: 
            0 0 30px rgba(138, 43, 226, 0.6),
            inset 0 0 30px rgba(138, 43, 226, 0.2);
    }
    50% { 
        transform: scale(1.05);
        border-color: rgba(138, 43, 226, 1);
        box-shadow: 
            0 0 50px rgba(138, 43, 226, 0.9),
            inset 0 0 50px rgba(138, 43, 226, 0.4);
    }
}

/* カード表面のグロー（選択後に使用） */
.card-glow-effect {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.6) 0%, transparent 70%);
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: -1;
}

.myst-echo-card-spread-item.card-selected .card-glow-effect {
    opacity: 0.8;
    animation: cardGlowPulse 2s ease-in-out infinite;
}

@keyframes cardGlowPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* 選択ヒント */
.card-select-prompt {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.95) 0%, rgba(102, 126, 234, 0.95) 100%);
    backdrop-filter: blur(15px);
    padding: 14px 28px;
    border-radius: 35px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 8px 32px rgba(138, 43, 226, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
}

.myst-echo-card-spread-item.card-hovered .card-select-prompt {
    opacity: 1;
    bottom: -80px;
    animation: promptFloat 2s ease-in-out infinite;
    transform: translateX(-50%) scale(1.05);
}

@keyframes promptFloat {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

.card-select-prompt .prompt-icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 18px;
    animation: promptBounce 1s ease-in-out infinite;
}

@keyframes promptBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.card-select-prompt .prompt-text {
    vertical-align: middle;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
}


/* ============================================
   カードラッパー
   ============================================ */
.myst-echo-card-wrapper {
    position: absolute;
    left: 0;
    top: 0;
    width: 120px;
    height: 170px;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.myst-echo-card-wrapper.card-hovered {
    z-index: 100;
    transform: scale(1.15) translateZ(50px) !important;
}

.myst-echo-card-wrapper.card-selected {
    z-index: 1000;
    transform: scale(2) translateZ(400px) !important;
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.myst-echo-card-wrapper.bringing-to-center {
    animation: cardBringToCenter 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.myst-echo-card-wrapper.fade-out {
    opacity: 0;
    transform: scale(0.8) translateZ(-100px) !important;
    transition: all 0.8s ease;
}

@keyframes cardBringToCenter {
    0% {
        transform: translateZ(0) scale(1);
    }
    100% {
        transform: translateZ(400px) scale(2);
    }
}

/* ============================================
   カード本体
   ============================================ */
.myst-echo-card-item {
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
    /* パフォーマンス最適化：画像のレンダリング品質を下げる */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* 軽量化：影を簡素化 */
    -webkit-box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 10px rgba(138, 43, 226, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 10px rgba(138, 43, 226, 0.2);
    -webkit-box-reflect: below 8px linear-gradient(transparent, transparent, rgba(0, 0, 0, 0.3));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden;
}

.myst-echo-card-wrapper.card-hovered .myst-echo-card-item {
    -webkit-box-shadow: 0 12px 48px rgba(138, 43, 226, 0.6), 0 0 40px rgba(255, 255, 255, 0.5), inset 0 0 30px rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 48px rgba(138, 43, 226, 0.6), 0 0 40px rgba(255, 255, 255, 0.5), inset 0 0 30px rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* ============================================
   カードの光るエフェクト
   ============================================ */
.card-glow {
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border-radius: 16px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.4) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: -1;
}

.myst-echo-card-wrapper.card-hovered .card-glow {
    opacity: 0.7; /* 軽量化：不透明度を下げる */
    /* パフォーマンス最適化：パルスアニメーションを軽量化 */
    /* animation: cardGlowPulse 2s ease-in-out infinite; */
}

@keyframes cardGlowPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* ============================================
   カードホバーエフェクト
   ============================================ */
.card-hover-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: -1;
    border-radius: 50%;
}

.myst-echo-card-wrapper.card-hovered .card-hover-effect {
    opacity: 0.5; /* 軽量化：不透明度を下げる */
    /* パフォーマンス最適化：回転アニメーションを無効化 */
    /* animation: hoverEffectRotate 4s linear infinite; */
    /* will-change: transform; */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

@keyframes hoverEffectRotate {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================
   カード選択ヒント
   ============================================ */
.card-select-hint {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.card-select-hint .hint-icon {
    display: inline-block;
    margin-right: 6px;
    /* パフォーマンス最適化：パルスアニメーションを無効化 */
    /* animation: hintPulse 1.5s ease-in-out infinite; */
}

.myst-echo-card-wrapper.card-hovered .card-select-hint {
    opacity: 1;
    bottom: -50px;
}

.card-select-hint .hint-text {
    font-weight: 500;
    letter-spacing: 0.5px;
}

.myst-echo-center-text {
    font-family: serif;
    position: absolute;
    top: 100%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) rotateX(90deg);
    transform: translate(-50%, -50%) rotateX(90deg);
    color: #fff;
    font-size: 18px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.myst-echo-ground {
    width: 900px;
    height: 900px;
    position: absolute;
    top: 100%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) rotateX(90deg);
    transform: translate(-50%, -50%) rotateX(90deg);
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

/* ============================================
   回転アニメーション
   ============================================ */
@-webkit-keyframes spin {
    from {
        -webkit-transform: rotateY(0deg);
        transform: rotateY(0deg);
    }
    to {
        -webkit-transform: rotateY(360deg);
        transform: rotateY(360deg);
    }
}

@keyframes spin {
    from {
        -webkit-transform: rotateY(0deg);
        transform: rotateY(0deg);
    }
    to {
        -webkit-transform: rotateY(360deg);
        transform: rotateY(360deg);
    }
}

@-webkit-keyframes spinRevert {
    from {
        -webkit-transform: rotateY(360deg);
        transform: rotateY(360deg);
    }
    to {
        -webkit-transform: rotateY(0deg);
        transform: rotateY(0deg);
    }
}

@keyframes spinRevert {
    from {
        -webkit-transform: rotateY(360deg);
        transform: rotateY(360deg);
    }
    to {
        -webkit-transform: rotateY(0deg);
        transform: rotateY(0deg);
    }
}

.myst-echo-spin-inner.auto-rotate {
    -webkit-animation: spin 80s infinite linear; /* より遅くして軽量化 */
    animation: spin 80s infinite linear;
    /* パフォーマンス最適化 */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
    /* will-changeはアニメーション中のみ必要 */
}

.myst-echo-spin-inner.auto-rotate-reverse {
    -webkit-animation: spinRevert 80s infinite linear; /* より遅くして軽量化 */
    animation: spinRevert 80s infinite linear;
    /* パフォーマンス最適化 */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
}

/* 回転をGPU加速で最適化 */
.myst-echo-spin-inner {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* カードアイテムのパフォーマンス最適化 */
.myst-echo-card-wrapper {
    /* will-changeはホバー時のみ必要 */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.myst-echo-card-wrapper.card-hovered {
    will-change: transform; /* ホバー時のみwill-changeを使用 */
}

.myst-echo-card-item {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ============================================
   選択されたカード表示
   ============================================ */
/* ============================================
   選択オーバーレイ
   ============================================ */
.myst-echo-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 150;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.myst-echo-selection-overlay.active {
    opacity: 1;
}

.selection-highlight {
    position: absolute;
    width: 200px;
    height: 280px;
    transform: translate(-50%, -50%);
    border: 3px solid rgba(138, 43, 226, 0.6);
    border-radius: 16px;
    box-shadow: 0 0 60px rgba(138, 43, 226, 0.8), inset 0 0 40px rgba(138, 43, 226, 0.3);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.myst-echo-selection-overlay.active .selection-highlight {
    opacity: 1;
    /* パフォーマンス最適化：パルスアニメーションを無効化 */
    /* animation: selectionHighlightPulse 2s ease-in-out infinite; */
}

@keyframes selectionHighlightPulse {
    0%, 100% {
        box-shadow: 0 0 60px rgba(138, 43, 226, 0.8), inset 0 0 40px rgba(138, 43, 226, 0.3);
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        box-shadow: 0 0 80px rgba(138, 43, 226, 1), inset 0 0 60px rgba(138, 43, 226, 0.5);
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.selection-ring {
    position: absolute;
    width: 250px;
    height: 330px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.myst-echo-selection-overlay.active .selection-ring {
    opacity: 0.6; /* 軽量化：不透明度を下げる */
    /* パフォーマンス最適化：回転アニメーションを無効化 */
    /* animation: selectionRingRotate 5s linear infinite; */
    /* will-change: transform; */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

@keyframes selectionRingRotate {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.myst-echo-selection-overlay.confirming .selection-highlight,
.myst-echo-selection-overlay.confirming .selection-ring {
    animation: selectionConfirm 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* ============================================
   選択されたカード表示
   ============================================ */
.myst-echo-selected-content {
    position: fixed;
    z-index: 1000;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: none;
    width: 100%;
    max-width: 600px;
    padding: 40px;
}

.myst-echo-selected-content.active {
    display: block;
}

.selected-card-aura {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    /* パフォーマンス最適化：パルスアニメーションを無効化 */
    /* animation: auraPulse 3s ease-in-out infinite; */
    pointer-events: none;
    opacity: 0.5; /* 軽量化 */
}

.myst-echo-selected-inner {
    text-align: center;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.myst-echo-selected-inner.fade-in {
    opacity: 1;
    transform: scale(1);
}

.selected-card-message {
    margin-bottom: 30px;
}

.message-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
    /* パフォーマンス最適化：フロートアニメーションを無効化 */
    /* animation: messageIconFloat 3s ease-in-out infinite; */
}

.message-text {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

.message-hint {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
    letter-spacing: 0.5px;
}

.selected-card-image-wrapper {
    position: relative;
    display: inline-block;
    opacity: 0;
    transform: scale(0.9) rotateY(180deg);
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.selected-card-image-wrapper.revealed {
    opacity: 1;
    transform: scale(1) rotateY(0deg);
}

.card-aura-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    border-radius: 20px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.2) 0%, transparent 70%);
    /* パフォーマンス最適化：パルスアニメーションを無効化 */
    /* animation: cardAuraPulse 2s ease-in-out infinite; */
    pointer-events: none;
    opacity: 0.5; /* 軽量化 */
}

.card-aura-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140%;
    height: 140%;
    border-radius: 20px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    /* パフォーマンス最適化：回転アニメーションを無効化 */
    /* animation: cardGlowRotate 4s linear infinite; */
    pointer-events: none;
    opacity: 0.3; /* 軽量化 */
}

.selected-card-image {
    position: relative;
    width: 380px;
    max-width: 90vw;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(138, 43, 226, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.selected-card-image:hover {
    transform: scale(1.05);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7), 0 0 60px rgba(138, 43, 226, 0.7);
}

.selected-card-image-wrapper.flipping .selected-card-image {
    transform: rotateY(180deg);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.selected-card-image-wrapper.flipped {
    transform: scale(0.9);
    opacity: 0.8;
}

/* ============================================
   動画表示
   ============================================ */
.myst-echo-video-container {
    position: fixed;
    z-index: 998;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.myst-echo-video-container.active {
    display: block;
}

.myst-echo-video-inner {
    width: 380px;
    max-width: 90vw;
}

.myst-echo-video-inner video {
    width: 100%;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

/* ============================================
   結果表示
   ============================================ */
.myst-echo-result-phase {
    position: fixed;
    z-index: 997;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
}

.myst-echo-result-phase.active {
    display: flex;
}

.myst-echo-result-content {
    text-align: center;
    color: #fff;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 600px;
    animation: fadeInUp 1s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.myst-echo-card-name {
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.myst-echo-card-message {
    font-size: 18px;
    line-height: 1.8;
    margin-bottom: 30px;
    white-space: pre-line;
}

.myst-echo-result-actions {
    margin-top: 30px;
}

/* ============================================
   エフェクト
   ============================================ */
/* ============================================
   エフェクト（パフォーマンス最適化：軽量化）
   ============================================ */
.myst-echo-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    /* パフォーマンス最適化：パーティクルを簡素化 */
    background-image: 
        radial-gradient(2px 2px at 50% 50%, rgba(255, 255, 255, 0.15), transparent);
    background-size: 200% 200%;
    /* アニメーションを無効化 */
    /* animation: particleMove 20s ease infinite; */
    opacity: 0.4; /* 軽量化 */
}

.myst-echo-light-effect {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 2;
    /* パフォーマンス最適化：回転アニメーションを無効化 */
    /* animation: lightRotate 30s linear infinite; */
    opacity: 0.2; /* 軽量化 */
}

/* ============================================
   ボタン
   ============================================ */
.myst-echo-button {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.myst-echo-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    color: #fff;
}

/* ============================================
   Fadeアニメーション
   ============================================ */
.fade-in {
    animation: fadeIn 1.5s ease forwards;
}

.fade-out {
    animation: fadeOut 1.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ============================================
   レスポンシブ
   ============================================ */
@media (max-width: 768px) {
    .myst-echo-card-item {
        width: 100px;
        height: 140px;
    }
    
    .myst-echo-selected-inner img {
        width: 300px;
    }
    
    .myst-echo-card-set-info h2 {
        font-size: 20px;
    }
}

