/* 全体のスタイリング */
body {
    font-family: 'Cinzel', 'Noto Serif JP', serif;
    background: radial-gradient(circle at center, #2b2b36 0%, #0a0a0f 100%);
    background-attachment: fixed;
    color: #e0e0e0;
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-x: hidden;
}

h1 {
    color: #d4af37;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    margin-top: 10px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 2.2rem;
    letter-spacing: 2px;
}

/* エラーメッセージ */
#messageBox {
    color: #ff6b6b;
    text-align: center;
    height: 20px;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.5);
}

/* カード表示エリアの演出 (3Dフリップ) */
.arena {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    margin-top: 10px;
    z-index: 10;
}

/* 召喚陣 (カードの背後) */
.summon-circle {
    position: absolute;
    top: 210px; /* カードの中心付近に配置 */
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    width: 350px;
    height: 350px;
    border: 2px dashed #d4af37;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.5), inset 0 0 40px rgba(212, 175, 55, 0.5);
    z-index: 0;
}

.summon-circle::before, .summon-circle::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(212, 175, 55, 0.8);
}
.summon-circle::before { width: 90%; height: 90%; }
.summon-circle::after { width: 70%; height: 70%; border: 3px double rgba(212, 175, 55, 0.6); }

.is-summoning .summon-circle {
    opacity: 1;
    animation: spin 4s linear infinite, pulseGlow 2s ease-in-out infinite alternate;
}

@keyframes spin {
    100% { transform: translate(-50%, -50%) rotate(360deg) scale(1); }
    0% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
@keyframes pulseGlow {
    0% { box-shadow: 0 0 20px rgba(212, 175, 55, 0.3), inset 0 0 20px rgba(212, 175, 55, 0.3); }
    100% { box-shadow: 0 0 60px rgba(212, 175, 55, 0.8), inset 0 0 60px rgba(212, 175, 55, 0.8); }
}

/* カード本体の3D空間 */
.card-scene {
    width: 300px;
    height: 419px; /* MTGカードのアスペクト比に近似 */
    perspective: 1000px;
    z-index: 1;
}

.card-container {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.card-container.is-flipped {
    transform: rotateY(180deg);
}

/* 召喚中のカードの揺れ */
.card-container.is-summoning {
    animation: floatShake 0.5s ease-in-out infinite;
}

@keyframes floatShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-2px, 3px) rotate(-1deg); }
    50% { transform: translate(2px, -2px) rotate(1deg); }
    75% { transform: translate(-1px, -3px) rotate(0deg); }
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 14px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.8);
}

/* カード裏面（初期状態）のデザイン */
.card-back {
    background-color: #1a1a1a;
    border: 12px solid #2a2a2a;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: radial-gradient(#333 1px, transparent 1px);
    background-size: 10px 10px;
}

.card-back-logo {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: url('icon.png') no-repeat center / cover;
    border: 2px solid #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5), inset 0 0 15px #000;
}

/* カード表面 */
.card-front {
    transform: rotateY(180deg);
    background: #000;
}

.card-front img {
    width: 100%;
    height: 100%;
    border-radius: 14px;
    object-fit: cover;
    display: block;
}

/* フリップ完了時のフラッシュエフェクト */
.card-container.flash-effect .card-front img {
    animation: appearFlash 1.5s ease-out forwards;
}

@keyframes appearFlash {
    0% { filter: brightness(3) contrast(1.5); box-shadow: 0 0 50px #fff; }
    50% { filter: brightness(1.5) contrast(1.2); box-shadow: 0 0 30px #d4af37; }
    100% { filter: brightness(1) contrast(1); box-shadow: 0 0 15px rgba(212, 175, 55, 0.5); }
}

/* カード情報テキスト */
.card-info {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    text-align: center;
    margin-top: 25px;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 10px;
    border: 1px solid #444;
    max-width: 400px;
    width: 100%;
    box-sizing: border-box;
}

.card-info.show {
    opacity: 1;
    transform: translateY(0);
}

.card-info h2 {
    margin: 0 0 5px 0;
    color: #fff;
    font-size: 1.2rem;
}

.card-info p {
    margin: 0;
    color: #aaa;
    font-size: 0.9rem;
}

/* 召喚アクションエリア */
.action-area {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 30px;
    z-index: 10;
}

/* 召喚ボタン */
.summon-btn {
    padding: 18px 40px;
    font-size: 1.5rem;
    font-family: inherit;
    background: linear-gradient(135deg, #5c3a21, #d4af37, #5c3a21);
    background-size: 200% 200%;
    color: #fff;
    border: 2px solid #ffd700;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
    box-shadow: 0 5px 20px rgba(212, 175, 55, 0.5);
    transition: all 0.2s ease;
    width: 80%;
    max-width: 350px;
    letter-spacing: 3px;
}

.summon-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.7);
    animation: btnGradient 3s ease infinite;
}

.summon-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.4);
}

.summon-btn:disabled {
    background: #333;
    border-color: #555;
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
}

/* 条件指定アコーディオンエリア */
.filter-section {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.filter-toggle-btn {
    width: 100%;
    background: rgba(20, 20, 30, 0.8);
    border: 1px solid #555;
    color: #d4af37;
    padding: 15px;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    transition: all 0.3s;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.filter-toggle-btn:hover {
    background: rgba(40, 40, 50, 0.9);
    border-color: #d4af37;
    color: #fff;
}

.filter-content {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1), opacity 0.4s ease-out, margin 0.4s ease-out;
    opacity: 0;
}

.filter-content.open {
    max-height: 1000px; /* 十分な高さを確保 */
    opacity: 1;
    margin-top: 15px;
    transition: max-height 0.6s ease-in-out, opacity 0.4s ease-in, margin 0.4s ease-in;
}

/* コントロールパネル本体 */
.controls {
    background: rgba(20, 20, 30, 0.7);
    border: 1px solid #444;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 25px;
    backdrop-filter: blur(5px);
    box-sizing: border-box;
}

.control-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.control-group .title {
    font-weight: bold;
    color: #d4af37;
    width: 100px;
    flex-shrink: 0;
    font-size: 1.1rem;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.control-note {
    font-size: 0.8rem;
    color: #888;
    width: 100%;
    margin-top: -10px;
    margin-bottom: 5px;
    margin-left: 112px;
}

/* ボタン群のカスタムデザイン (チェックボックス＆ラジオボタン共用) */
.toggle-btn {
    display: none;
}

.toggle-label {
    padding: 8px 16px;
    border: 1px solid #555;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.4);
    color: #aaa;
    user-select: none;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.toggle-label:hover {
    border-color: #888;
    color: #ddd;
}

.toggle-btn:checked + .toggle-label {
    border-color: #d4af37;
    color: #fff;
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    font-weight: bold;
}

/* レスポンシブ調整 */
@media (max-width: 480px) {
    .card-scene {
        width: 260px;
        height: 363px;
    }
    .summon-circle {
        width: 300px;
        height: 300px;
        top: 180px;
    }
    .summon-btn {
        padding: 15px 20px;
        font-size: 1.3rem;
        width: 90%;
    }
    .control-group {
        flex-direction: column;
        align-items: flex-start;
    }
    .control-group .title {
        width: 100%;
        margin-bottom: 5px;
    }
    .control-note {
        margin-left: 0;
    }
    .toggle-label {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}
