/* style-anim.css - VMO Board Game: Animations & Effects */

/* --- シェイク演出 --- */
.shake {
    animation: shakeAnim 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeAnim {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.shake-hard {
    animation: shakeHardAnim 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeHardAnim {
    0% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-5px, -5px) rotate(-3deg); }
    20% { transform: translate(5px, 5px) rotate(3deg); }
    30% { transform: translate(-8px, 5px) rotate(-5deg); }
    40% { transform: translate(8px, -5px) rotate(5deg); }
    50% { transform: translate(-5px, 0px) rotate(-3deg); }
    60% { transform: translate(5px, 0px) rotate(3deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* --- フラッシュ演出 --- */
#flash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    /* transitionを削除してラグを排除 */
}

.flash-active-red {
    background-color: rgba(255, 0, 0, 0.5);
    opacity: 1 !important;
    /* 即座に発光し、0.15秒で消え去る設定 */
    animation: flashFade 0.15s cubic-bezier(0, 1, 1, 1) forwards;
}

@keyframes flashFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- その他の汎用アニメーション --- */
@keyframes blinkRed {
    from { opacity: 0.6; }
    to { opacity: 1; text-shadow: 0 0 5px red; }
}

@keyframes blinkGreen {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; box-shadow: 0 0 8px #4ade80; }
}

@keyframes rollAnim {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseBtn {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- バトル演出 (ダメージ・回復ポップアップ) --- */
.item-effect-float {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2000;
    font-family: 'Teko', sans-serif;
    font-weight: bold;
    font-size: 2rem;
    white-space: nowrap;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.anim-heal {
    color: #4ade80;
    text-shadow: 0 0 5px #22c55e;
    animation: floatUpHeal 1.2s ease-out forwards;
}

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

.anim-damage {
    font-size: 4rem;
    color: #fff;
    text-shadow: 0 0 10px #ef4444;
    animation: explosion 0.6s ease-out forwards;
}

@keyframes explosion {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.5) rotate(10deg); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(2); }
}

/* バフ (赤色オーラ) */
.anim-buff {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #ef4444;
    box-shadow: 0 0 20px #b91c1c;
    opacity: 0;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.3) 0%, rgba(0,0,0,0) 70%);
    animation: buffRing 0.8s ease-out forwards;
}

/* デバフ (青色オーラ) */
.anim-debuff {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #3b82f6;
    box-shadow: 0 0 20px #1d4ed8;
    opacity: 0;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.3) 0%, rgba(0,0,0,0) 70%);
    animation: buffRing 0.8s ease-out forwards;
}

/* 毒/状態異常 (紫色オーラ) */
.anim-poison {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #a855f7;
    box-shadow: 0 0 20px #7e22ce;
    opacity: 0;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.3) 0%, rgba(0,0,0,0) 70%);
    animation: buffRing 0.8s ease-out forwards;
}

/* 浄化/蘇生 (黄色オーラ) */
.anim-cure {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #fbbf24;
    box-shadow: 0 0 20px #d97706;
    opacity: 0;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.3) 0%, rgba(0,0,0,0) 70%);
    animation: buffRing 0.8s ease-out forwards;
}

/* シールド (水色オーラ) ★新規追加 */
.anim-shield {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #0ea5e9; /* Sky Blue */
    box-shadow: 0 0 20px #0284c7;
    opacity: 0;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.3) 0%, rgba(0,0,0,0) 70%);
    animation: buffRing 0.8s ease-out forwards;
}

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

/* --- 属性カラーテキスト --- */
.text-fire { color: #ef4444; text-shadow: 0 0 5px #7f1d1d; }
.text-water { color: #3b82f6; text-shadow: 0 0 5px #1e3a8a; }
.text-grass { color: #22c55e; text-shadow: 0 0 5px #14532d; }
.text-light { color: #fbbf24; text-shadow: 0 0 5px #78350f; }
.text-dark  { color: #a855f7; text-shadow: 0 0 5px #4c1d95; }

/* --- イベントカード演出 (Event Overlay) --- */
.event-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.event-overlay.active { display: flex; }

.event-card-big {
    width: 85%;
    max-width: 340px;
    background: #0f172a;
    border-radius: 12px;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    position: relative;
    transform: scale(0.5);
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    transform-style: preserve-3d;
    height: auto;
    min-height: 450px;
    border: none;
    box-shadow: none;
}

.event-card-big.positive #event-front-face {
    border: 3px solid #22c55e;
    background: linear-gradient(160deg, #064e3b 0%, #0f172a 40%);
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.4);
}

.event-card-big.negative #event-front-face {
    border: 3px solid #ef4444;
    background: linear-gradient(160deg, #7f1d1d 0%, #0f172a 40%);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4);
}

/* ★画像表示用の正方形コンテナ */
.ev-image-box {
    width: 100%;
    aspect-ratio: 1 / 1; /* 正方形 */
    background: #000;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 2px solid #928b8b;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ev-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ev-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ev-icon { font-size: 1.2rem; }

.ev-type {
    font-family: 'Teko', sans-serif;
    font-size: 1.4rem;
    color: #fff;
    letter-spacing: 0.1em;
}

.ev-title {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: bold;
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.2;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.ev-body {
    flex-grow: 1;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e2e8f0;
    text-align: center;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
}

.ev-footer {
    width: 100%;
    text-align: center;
    margin-top: 15px;
    font-family: 'Teko', sans-serif;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    animation: pulseText 1.5s infinite;
}

@keyframes pulseText {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* --- JS制御用の表面コンテンツ透明化 --- */
#event-front-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    border-radius: 12px;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    backface-visibility: hidden;
    z-index: 2;

    background: #0f172a;
    border: 1px solid #334155;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);

    opacity: 1;
    transition: opacity 0.2s ease;
}
#event-front-face.visible-face {
    opacity: 1;
}

/* --- ターン演出 (Turn Overlay & Cards) --- */
.turn-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2500;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.turn-overlay.active { display: flex; }

.turn-msg {
    font-family: 'Teko', sans-serif;
    font-size: 3rem;
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    margin-bottom: 20px;
    opacity: 1;
    transition: opacity 0.5s;
}

.turn-card-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 140px;
    width: 100%;
    perspective: 1000px;
}

.turn-card-visual {
    width: auto;
    height: 110px;
    aspect-ratio: 80/110;
    max-width: 15vw;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s;
    margin: 0 2px;
    will-change: transform;
    flex-shrink: 1;
    min-width: 0;
}

.turn-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    border: 1px solid #64748b;
    overflow: hidden;
    background: #0f172a;
    z-index: 2;
    padding: 2px;
    box-sizing: border-box;
}

.turn-face.boss-card {
    border-color: #ef4444;
    background: linear-gradient(to bottom, #450a0a, #1a0505);
}

.turn-face.player-card {
    border-color: #3b82f6;
    background: linear-gradient(to bottom, #0f172a, #020617);
}

.t-header {
    width: 100%;
    font-family: 'Teko', sans-serif;
    font-size: 0.7rem;
    text-align: center;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 0;
    margin-bottom: 2px;
}

.boss-card .t-header { color: #fca5a5; }

.t-img {
    width: 100%;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.2);
}

.t-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.t-img-icon { font-size: 2rem; }

/* ターンオーダーカードのモンスター名。
   名前が長いキャラ（ザルディヴァ等）が省略されないよう、
   UI._fitTurnCardName() が実測して font-size を縮める（下限0.38rem）。
   ここでの font-size は初期値、ellipsis は万一収まらなかった場合の保険。 */
.t-name {
    width: 100%;
    text-align: center;
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-size: 0.6rem;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 0;
    background: rgba(0, 0, 0, 0.4);
    line-height: 1.2;
}

/* --- カード裏面 (共通設定) --- */
.turn-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;

    transform: rotateY(180deg) translateZ(1px);

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    border-radius: 6px;
    border: 2px solid #475569;

    background-color: #1e293b;
    background-image: url('img/card.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.turn-back::after {
    content: none !important;
}

/* --- 各カードの裏面バリエーション (枠線色のみ) --- */
.turn-back.card-back-event {
    border: 2px solid #ef4444 !important;
    /* 背景画像は card.webp (共通) のままで、枠線だけ赤くして区別 */
}

.turn-back.card-back-skill {
    border: 2px solid #3b82f6 !important;
}

.turn-back.card-back-item {
    border: 2px solid #a855f7 !important;
}


/* --- その他のアニメーション用クラス --- */
.turn-card-visual.flipped { transform: rotateY(180deg); }
.turn-card-visual.gathered { margin: 0 -80px; transition: margin 0.4s ease-in-out; }
.turn-card-visual.shuffling { animation: none; }

.draw-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2600;
    pointer-events: none;
    perspective: 1200px;
}

.draw-card {
    position: absolute;
    width: 120px;
    height: 170px;
    left: 50%;
    top: 50%;
    transform-style: preserve-3d;
    transition: top 0.6s cubic-bezier(0.16, 1, 0.3, 1), left 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s ease-in-out, opacity 0.3s;
}

.draw-card .turn-face,
.draw-card .turn-back {
    border-width: 2px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

/* --- ドラフト画面 (報酬・アイテム選択) --- */
.draft-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
    padding-bottom: 25%;
    box-sizing: border-box;
    perspective: 1200px;
}

.draft-overlay.active { opacity: 1; pointer-events: auto; }

.draft-title {
    font-family: 'Teko', sans-serif;
    font-size: 2.2rem;
    color: #fbbf24;
    text-shadow: 0 0 10px #d97706;
    margin-bottom: 20px;
    text-align: center;
}

.draft-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    margin-bottom: 20px;
}

.draft-card {
    width: 110px;
    height: 160px;
    background: #0f172a;
    border: 2px solid #475569;
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
    box-sizing: border-box;
    transform-style: preserve-3d;
}

.draft-card:hover {
    transform: translateY(-5px);
    border-color: #fbbf24;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

.draft-card.selected {
    transform: scale(1.1);
    border-color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.6);
    background: #064e3b;
    z-index: 10;
}

.draft-card.type-skill { border-color: #3b82f6; }
.draft-card.type-skill:hover { border-color: #60a5fa; box-shadow: 0 0 15px rgba(59, 130, 246, 0.4); }

.draft-card.type-item { border-color: #a855f7; }
.draft-card.type-item:hover { border-color: #d8b4fe; box-shadow: 0 0 15px rgba(168, 85, 247, 0.4); }

.d-icon {
    font-size: 2.5rem;
    margin-top: 5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* 画像表示用のスタイル */
.d-img-container {
    width: 60px;
    height: 60px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.d-img-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.5));
    border: 2px solid #928b8b;
    border-radius: 4px;
    background-color: rgba(0,0,0,0.3);
    box-sizing: border-box;

}

/* ★修正: 技名(アイテム名)のサイズ縮小 */
.d-name {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: bold;
    font-size: 0.65rem; /* 0.8rem -> 0.65rem */
    text-align: center;
    margin: 8px 0 5px 0;
    color: #fff;
    line-height: 1.2;
}

/* ★新規追加: ドラフトカードの威力表記 (POW / HEAL / SHIELD)
   カード右上に絶対配置し、説明文の表示領域を圧迫しないようにする */
.d-pow {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 3;
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-family: 'Teko', sans-serif;
    line-height: 1;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid currentColor;
    pointer-events: none;
}

.d-pow .d-pow-label {
    font-size: 0.5rem;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.d-pow .d-pow-val {
    font-size: 0.85rem;
    font-weight: bold;
}

.d-pow.atk { color: #f87171; }
.d-pow.heal { color: #4ade80; }
.d-pow.shield { color: #60a5fa; }

/* ★修正: 説明文コンテナのフレックス化 */
.d-desc {
    font-size: 0.65rem;
    color: #cbd5e1;
    text-align: center;
    line-height: 1.3;
    flex-grow: 1;

    display: flex;
    flex-direction: row;
    flex-wrap: wrap;       /* 折り返し許可 */
    align-items: center;
    align-content: center; /* 複数行になった場合の垂直中央寄せ */
    justify-content: center;
    padding: 0 2px;
    overflow: hidden;      /* カードからはみ出さないようにする */
}

/* ★新規追加: 必要ダイス部分 */
.d-req {
    color: #fbbf24;
    font-weight: bold;
    margin-right: 4px;
}

.draft-confirm-btn {
    padding: 10px 40px;
    font-family: 'Teko', sans-serif;
    font-size: 1.5rem;
    color: #fff;
    background: #22c55e;
    border: none;
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
    pointer-events: none;
    margin-top: 10px;
}

.draft-confirm-btn.active {
    opacity: 1;
    pointer-events: auto;
}

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

/* --- アイテム使用時の波紋 (シンプル版) --- */
.anim-ripple-blue {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 5px solid #60a5fa; /* 明るい青 */
    box-shadow: 0 0 15px #3b82f6;
    opacity: 0;
    pointer-events: none;
    background: transparent;
    animation: rippleSimple 0.6s ease-out forwards;
}

@keyframes rippleSimple {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); border-width: 5px; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(2.0); border-width: 0px; }
}

/* --- style-anim.css 追加: スキル入れ替え画面の調整 --- */

/* "NEW SKILL" ラベル */
.draft-new-label {
    font-family: 'Teko', sans-serif;
    color: #fbbf24;
    font-size: 1.2rem;
    text-shadow: 0 0 5px rgba(251, 191, 36, 0.5);
    margin-left: 2px;
}

/* ドラフト画面内のアクションパネル微調整 */
.draft-overlay .btn-action {
    /* 戦闘画面より少しコンパクトに見せたい場合 */
    min-height: 42px;
    padding: 4px 8px;
}

/* 必要ダイスの表示位置調整（ドラフト画面内） */
.draft-overlay .act-req {
    width: 45px; /* 少し幅を詰める */
}
