/* ===== リセット & 基本 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #a8a8b8;
    --accent: #e94560;
    --accent-light: #ff6b81;
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
    --rarity-n: #888;
    --rarity-r: #4a9eff;
    --rarity-sr: #b44aff;
    --rarity-ssr: #ffd700;
    --rarity-ur: #ff4a4a;
    --success: #4ecdc4;
    --warning: #ffe66d;
    --nav-height: 60px;
    --header-height: 50px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
}

/* ===== ヘッダー ===== */
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.game-title {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-right {
    display: flex;
    gap: 8px;
}

.currency {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
}

.currency.premium {
    background: linear-gradient(135deg, rgba(233,69,96,0.3), rgba(255,107,129,0.3));
    color: var(--accent-light);
}

/* ===== メインコンテンツ ===== */
#main-content {
    flex: 1;
    padding: 12px;
    padding-bottom: calc(var(--nav-height) + 12px);
    overflow-y: auto;
}

/* ===== ボトムナビ ===== */
#bottom-nav {
    display: flex;
    justify-content: space-around;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255,255,255,0.1);
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    z-index: 100;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

/* ===== カード ===== */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ===== ボタン ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.btn-gold {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    width: auto;
}

/* ===== キャラカード ===== */
.char-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 4px solid var(--rarity-n);
    cursor: pointer;
    transition: background 0.2s;
}

.char-card:active {
    background: rgba(15, 52, 96, 0.8);
}

.char-card[data-rarity="1"] { border-left-color: var(--rarity-n); }
.char-card[data-rarity="2"] { border-left-color: var(--rarity-r); }
.char-card[data-rarity="3"] { border-left-color: var(--rarity-sr); }
.char-card[data-rarity="4"] { border-left-color: var(--rarity-ssr); }
.char-card[data-rarity="5"] { border-left-color: var(--rarity-ur); }

.char-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.char-avatar[data-rarity="1"] { background: rgba(136,136,136,0.3); }
.char-avatar[data-rarity="2"] { background: rgba(74,158,255,0.3); }
.char-avatar[data-rarity="3"] { background: rgba(180,74,255,0.3); }
.char-avatar[data-rarity="4"] { background: rgba(255,215,0,0.3); }
.char-avatar[data-rarity="5"] { background: rgba(255,74,74,0.3); }

.char-info {
    flex: 1;
    min-width: 0;
}

.char-name {
    font-size: 14px;
    font-weight: 600;
}

.char-rarity {
    font-size: 11px;
    margin-top: 2px;
}

.rarity-n { color: var(--rarity-n); }
.rarity-r { color: var(--rarity-r); }
.rarity-sr { color: var(--rarity-sr); }
.rarity-ssr { color: var(--rarity-ssr); }
.rarity-ur { color: var(--rarity-ur); }

.char-stats {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-secondary);
}

.char-level {
    font-size: 12px;
    font-weight: 600;
    color: var(--gold);
}

/* ===== レアリティバッジ ===== */
.rarity-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.rarity-badge.n { background: var(--rarity-n); color: white; }
.rarity-badge.r { background: var(--rarity-r); color: white; }
.rarity-badge.sr { background: var(--rarity-sr); color: white; }
.rarity-badge.ssr { background: var(--rarity-ssr); color: #1a1a2e; }
.rarity-badge.ur { background: var(--rarity-ur); color: white; }

/* ===== ガチャ画面 ===== */
.gacha-banner {
    background: linear-gradient(135deg, var(--bg-card), rgba(233,69,96,0.2));
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 12px;
}

.gacha-banner-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.gacha-rates {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.gacha-rate {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
}

.gacha-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.gacha-buttons .btn {
    flex: 1;
}

/* ===== トーナメント ===== */
.tournament-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
}

.tournament-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.tournament-status.recruiting { background: var(--success); color: #1a1a2e; }
.tournament-status.in_progress { background: var(--warning); color: #1a1a2e; }
.tournament-status.finished { background: var(--text-secondary); color: #1a1a2e; }

.bracket {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
}

.bracket-match {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
}

.bracket-vs {
    margin: 0 8px;
    color: var(--accent);
    font-weight: 700;
}

.bracket-winner {
    color: var(--gold);
    font-weight: 600;
}

/* ===== ショップ ===== */
.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
}

.shop-item-info {
    flex: 1;
}

.shop-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

/* ===== オーバーレイ ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.overlay.hidden {
    display: none;
}

/* ===== バトル演出 ===== */
.battle-arena {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.battle-char {
    text-align: center;
    flex: 1;
}

.battle-char .name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.battle-char .hp-bar {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.battle-char .hp-fill {
    height: 100%;
    background: var(--success);
    transition: width 0.3s;
    border-radius: 4px;
}

.battle-char .hp-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.battle-vs {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
}

.battle-log {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.battle-log .turn-action {
    padding: 2px 0;
}

.battle-log .damage {
    color: var(--accent);
    font-weight: 600;
}

.battle-log .skill {
    color: var(--rarity-sr);
}

.battle-result {
    text-align: center;
    margin-bottom: 20px;
}

.battle-result .winner-text {
    font-size: 24px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255,215,0,0.5);
}

/* ===== ガチャ演出 ===== */
.gacha-animation {
    width: 100%;
    text-align: center;
}

.gacha-animation .opening {
    font-size: 48px;
    animation: gachaOpen 1s ease-out;
}

@keyframes gachaOpen {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.gacha-results {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 100%;
}

.gacha-result-card {
    width: 80px;
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    animation: cardReveal 0.3s ease-out forwards;
    opacity: 0;
}

.gacha-result-card.new {
    box-shadow: 0 0 10px rgba(255,215,0,0.5);
}

@keyframes cardReveal {
    from { transform: rotateY(90deg); opacity: 0; }
    to { transform: rotateY(0); opacity: 1; }
}

.gacha-result-card .char-icon {
    font-size: 32px;
    margin-bottom: 4px;
}

.gacha-result-card .char-name {
    font-size: 10px;
    word-break: break-all;
}

/* ===== ユーティリティ ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }

/* ===== ローディング ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== ホーム画面 ===== */
.home-welcome {
    text-align: center;
    padding: 20px;
}

.home-welcome h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.home-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}

.home-action-btn {
    background: var(--bg-card);
    border: none;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
}

.home-action-btn:active {
    background: rgba(15,52,96,0.8);
}

.home-action-btn .icon {
    font-size: 32px;
    display: block;
    margin-bottom: 4px;
}

.home-action-btn .label {
    font-size: 12px;
    font-weight: 600;
}

/* ===== 広告報酬セクション ===== */
.ad-reward-section {
    background: linear-gradient(135deg, var(--bg-card), rgba(78, 205, 196, 0.2));
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.ad-reward-section .remaining {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== キャラ詳細モーダル ===== */
.char-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.char-detail {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
}

.char-detail .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0;
}

.stat-item {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.stat-item .stat-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.stat-item .stat-value {
    font-size: 18px;
    font-weight: 700;
}
