@import url('https://fonts.googleapis.com/css2?family=Inter:wght@700;900&family=Noto+Sans+JP:wght@400;700;900&display=swap');

:root {
    --vocal: #ff4d7a; --dance: #4da3ff; --visual: #ffc107;
    --accent: #ff66aa; --bg: #fdfdfd; --text: #333333;
    --rarity-ssr: #af52de; --rarity-sr: #ff9500; --rarity-r: #007aff; --rarity-n: #8e8e93;
    --joker-gold: linear-gradient(135deg, #ffd700 0%, #f79d00 100%);
}

/* 基本設定 */
* { box-sizing: border-box; font-family: 'Noto Sans JP', sans-serif; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body { background: #f0f2f5; color: var(--text); margin: 0; display: flex; justify-content: center; height: 100dvh; overflow: hidden; }

#game-outer { width: 100%; max-width: 450px; position: relative; display: flex; flex-direction: column; background: var(--bg); box-shadow: 0 0 50px rgba(0,0,0,0.05); }
#game-container { flex: 1; display: flex; flex-direction: column; padding: 12px; background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%); position: relative; overflow: hidden; }

/* --- ヘッダー --- */
.header-card { background: #fff; border-radius: 16px; padding: 10px; margin-bottom: 8px; border: 1px solid #eee; flex-shrink: 0; }
.stamina-row { display: flex; align-items: center; justify-content: space-between; font-weight: bold; font-size: 0.65em; color: #999; margin-bottom: 4px; }
.stamina-bar { height: 4px; background: #f0f0f0; border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.stamina-fill { height: 100%; background: var(--accent); transition: width 0.5s; }
.params-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.param-chip { background: #fafafa; padding: 6px 2px; border-radius: 8px; text-align: center; border-bottom: 2px solid #eee; }
.param-label { font-size: 0.45em; color: #bbb; font-weight: 900; display: block; }
.param-val { font-size: 0.85em; font-weight: 900; color: #444; }

.live-active #stamina-area { display: none; }
.live-active .header-card { margin-bottom: 6px; padding: 8px 10px; }

/* --- シーン共通 --- */
.scene { display: none; flex-direction: column; flex: 1; opacity: 0; transition: 0.3s; overflow: hidden; min-height: 0; }
.scene.active { display: flex; opacity: 1; }
.title-sub { font-size: 0.6em; color: var(--accent); font-weight: 900; letter-spacing: 2px; text-align: center; }
.title-main { font-size: 1.3em; font-weight: 900; text-align: center; margin: 4px 0 8px; }
.scene-desc { font-size: 0.7em; color: #888; text-align: center; line-height: 1.4; margin-bottom: 12px; }

/* 育成ボタン */
.focus-group { display: flex; gap: 8px; margin: 10px 0 15px; width: 100%; }
.focus-btn { flex: 1; background: #fff; border: 1px solid #eee; padding: 15px 5px; border-radius: 12px; cursor: pointer; font-weight: 900; font-size: 0.8em; color: #ccc; transition: 0.2s; }
.focus-btn.selected { border-color: var(--accent); color: var(--accent); background: #fff9fb; box-shadow: 0 4px 10px rgba(255,102,170,0.1); transform: translateY(-2px); }

/* --- デッキ編成：スロット内情報の密度向上 --- */
.deck-slots-container { flex-shrink: 0; padding-bottom: 8px; border-bottom: 1px solid #eee; margin-bottom: 8px; }
.deck-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.deck-slot { width: 100%; height: 74px; background: #fff; border: 1px dashed #ddd; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; padding: 4px; overflow: hidden; position: relative; }
.deck-slot.filled { border: 1.5px solid var(--accent); background: #fff9fb; justify-content: flex-start; }
.slot-t-name { color: var(--accent); font-weight: 900; font-size: 0.62em; line-height: 1.1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; margin-bottom: 2px; }
.slot-meta { display: flex; gap: 2px; justify-content: center; margin-bottom: 2px; transform: scale(0.8); }
.slot-effect { font-size: 0.4em; color: #777; line-height: 1.1; text-align: center; width: 100%; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.skill-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 0; min-height: 0; overscroll-behavior: contain; }

/* --- ライブUI --- */
.live-header { text-align: center; padding: 0; flex-shrink: 0; }
.score-val { font-size: 3.2em; font-weight: 900; letter-spacing: -3px; color: #333; margin: 0; line-height: 1; }
.gauge-bg { width: 100%; height: 5px; background: #eee; border-radius: 3px; margin: 8px 0 4px; overflow: hidden; }
.gauge-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--dance), var(--accent)); transition: width 0.8s ease-out; }
.live-info-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.65em; font-weight: 900; color: #999; margin-bottom: 4px; }
.live-turn-display { color: var(--accent); letter-spacing: 1px; }

.live-status-bar { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; font-size: 0.6em; font-weight: 900; color: #888; background: rgba(0,0,0,0.03); padding: 4px; border-radius: 15px; min-height: 22px; }
.status-item span { color: var(--accent); }

.monitor-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 6px; flex-shrink: 0; }
.monitor-item { 
    background: #fff; border: 1px solid #eee; font-size: 0.55em; text-align: center; color: #bbb; 
    padding: 4px 0; border-radius: 6px; cursor: pointer; transition: 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.monitor-item.active { border: 2px solid var(--accent); background: #fff9fb; color: var(--accent); transform: scale(1.08); z-index: 2; box-shadow: 0 4px 8px rgba(255,102,170,0.2); }
.monitor-item.viewing { border: 2px solid #444; color: #444; background: #f0f0f0; }

.skill-count-badge { font-size: 0.7em; background: #eee; color: #888; padding: 1px 3px; border-radius: 3px; font-weight: 900; }
.monitor-item.active .skill-count-badge { background: var(--accent); color: #fff; }
.monitor-item.viewing .skill-count-badge { background: #444; color: #fff; }

.active-skill-box { background: rgba(255,255,255,0.8); border: 1px solid #eee; border-radius: 10px; padding: 8px; min-height: 40px; font-size: 0.65em; color: #666; margin-bottom: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; flex-shrink: 0; line-height: 1.4; }

/* 役表示エリア：高さを確保 */
.combo-preview-area { height: 40px; display: flex; align-items: center; justify-content: center; font-weight: 900; color: var(--accent); font-size: 1em; flex-shrink: 0; }

/* 手札：カード位置を下げて被りを防止 */
.hand { display: flex; justify-content: center; gap: 6px; height: 95px; margin-top: 5px; margin-bottom: 12px; perspective: 1000px; flex-shrink: 0; }
.card { width: 18.5%; height: 90px; background: #fff; border-radius: 10px; position: relative; border: 1px solid rgba(0,0,0,0.08); transition: 0.3s cubic-bezier(0.23, 1, 0.32, 1); box-shadow: 0 3px 8px rgba(0,0,0,0.08); overflow: hidden; }

.card-vocal { background: linear-gradient(135deg, #fff 40%, #fff0f3 100%); border-bottom: 3px solid var(--vocal); }
.card-dance { background: linear-gradient(135deg, #fff 40%, #f0f7ff 100%); border-bottom: 3px solid var(--dance); }
.card-visual { background: linear-gradient(135deg, #fff 40%, #fffcf0 100%); border-bottom: 3px solid var(--visual); }
.card-joker { background: var(--joker-gold); color: #fff; border-bottom: 3px solid #d4af37; }
.card.selected { transform: translateY(-12px); border: 2.5px solid var(--accent); box-shadow: 0 10px 20px rgba(255,102,170,0.2); }

.card .num { font-family: 'Inter', sans-serif; font-size: 1.8em; font-weight: 900; position: absolute; top: 2px; left: 6px; letter-spacing: -1.5px; z-index: 2; }
.card .suit { position: absolute; bottom: 5px; right: 5px; font-size: 1.4em; z-index: 2; }
.suit-bg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 3.5em; opacity: 0.05; z-index: 1; }

/* --- リストアイテム --- */
.skill-card-item { background: #fff; border: 1px solid #eee; border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.skill-card-item div:last-child { font-size: 0.62em !important; color: #888; margin-top: 4px; line-height: 1.3; }
.skill-card-item.selected-in-deck { opacity: 0.35; filter: grayscale(0.8); pointer-events: none; }

.tag-turn { min-width: 30px; height: 16px; background: #444; color: #fff; font-size: 0.5em; border-radius: 3px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; margin-right: 5px; }
.rarity-badge { font-size: 0.5em; font-weight: 900; padding: 1px 5px; border-radius: 3px; color: #fff; text-transform: uppercase; display: inline-flex; align-items: center; }
.badge-SSR { background: var(--rarity-ssr); } .badge-SR { background: var(--rarity-sr); } .badge-R { background: var(--rarity-r); } .badge-N { background: var(--rarity-n); }
.card-badge-icon { font-size: 0.4em; padding: 1px 3px; border-radius: 3px; margin-left: 2px; color: #fff; display: inline-flex; font-weight: 900; }
.badge-focus { background: #5ac8fa; } .badge-impression { background: #ffcc00; } .badge-motivation { background: #ff9500; }

/* --- ボタン --- */
.btn-primary { width: 100%; padding: 16px; border-radius: 40px; border: none; font-size: 1em; font-weight: 900; background: #222; color: #fff; cursor: pointer; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.btn-secondary { background: #fff; border: 1px solid #ddd; color: #888; width: 100%; padding: 12px; border-radius: 40px; font-weight: 700; font-size: 0.8em; margin-bottom: 8px; cursor: pointer; flex-shrink: 0; }
.btn-compact { padding: 6px; font-size: 0.62em; margin-bottom: 4px; border-radius: 30px; }
.btn-mini-text { height: 32px; padding: 0; font-size: 0.72em; border: none; background: transparent; color: #bbb; }

/* --- モーダル --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.9); z-index: 5000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.modal-content { width: 92%; max-width: 380px; background: #fff; border-radius: 16px; padding: 20px; border: 1px solid #eee; box-shadow: 0 10px 30px rgba(0,0,0,0.1); overflow-y: auto; max-height: 85vh; -webkit-overflow-scrolling: touch; }

.result-line { opacity: 0; transform: translateY(8px); display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f8f9fa; font-size: 0.85em; font-weight: bold; }
.result-line.show { opacity: 1; transform: translateY(0); transition: 0.3s; }
.result-line span:last-child { font-family: 'Inter', sans-serif; font-weight: 900; }

.drum-box { font-size: 3em; font-weight: 900; padding: 20px; color: var(--accent); border: 2px solid var(--accent); border-radius: 16px; margin: 15px 0; background: #fff9fb; text-align: center; }

.badge-pop { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); background: #fff; border: 2px solid var(--accent); padding: 10px 20px; border-radius: 30px; font-weight: 900; color: var(--accent); animation: popAndFade 1.5s forwards; z-index: 9999; box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.stamina-pop { border-color: var(--dance); color: var(--dance); }

@keyframes popAndFade { 0% { opacity: 0; transform: translate(-50%, -30%); } 20% { opacity: 1; transform: translate(-50%, -50%); } 80% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-50%, -70%); } }

.hidden { display: none !important; }
::-webkit-scrollbar { width: 0; }

/* バッジ出現アニメーション */
@keyframes badge-shine {
    0% { transform: scale(0); opacity: 0; filter: brightness(5); }
    60% { transform: scale(1.4); opacity: 1; filter: brightness(2); }
    100% { transform: scale(1); opacity: 1; filter: brightness(1); }
}

.badge-anim {
    opacity: 0; /* 最初は非表示 */
    animation: badge-shine 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}