/* 現代のトレンドを取り入れたウルトラモダン・ポータルスタイル */
:root {
    --bg-main: #090d16;
    --bg-card: rgba(22, 28, 45, 0.75);
    --bg-card-hover: rgba(30, 41, 69, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(139, 92, 246, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    --card-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(16px);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.98);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-hover: rgba(99, 102, 241, 0.4);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --card-glow: 0 8px 24px 0 rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 背景アンビエントグラデーション */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.ambient-circle-1 {
    position: absolute;
    top: -10%;
    left: 15%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(0,0,0,0) 70%);
    filter: blur(80px);
    animation: pulse 12s infinite alternate;
}
.ambient-circle-2 {
    position: absolute;
    bottom: 5%;
    right: 10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, rgba(0,0,0,0) 70%);
    filter: blur(80px);
    animation: pulse 15s infinite alternate-reverse;
}

@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.15) translate(40px, 30px); }
}

/* カスタムスクロールバー */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.6);
}

/* ヘッダーナビゲーション */
.navbar-glass {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    background: rgba(9, 13, 22, 0.75);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
[data-theme="light"] .navbar-glass {
    background: rgba(255, 255, 255, 0.8);
}

/* ヒーローカルーセル / バナー */
.hero-gradient {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 50%, rgba(236, 72, 153, 0.2) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* カテゴリピル */
.category-pill {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
}
.category-pill:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateY(-2px);
}
.category-pill.active {
    background: var(--accent-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
}

/* ゲームカード */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--card-glow);
}
.game-card:hover {
    transform: translateY(-6px);
    border-color: var(--border-color-hover);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35), 0 0 20px rgba(139, 92, 246, 0.2);
}
.game-card .thumb-box {
    position: relative;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(circle at center, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.3) 100%);
}
.game-card .thumb-icon {
    font-size: 3.5rem;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.3));
}
.game-card:hover .thumb-icon {
    transform: scale(1.18) rotate(6deg);
}
.game-card .play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 13, 22, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.game-card:hover .play-overlay {
    opacity: 1;
}

/* お気に入りボタン */
.fav-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}
.fav-btn:hover {
    transform: scale(1.15);
    color: #f59e0b;
}
.fav-btn.active {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.25);
    border-color: #f59e0b;
}

/* ゲームモーダル */
.game-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 13, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}
.game-modal.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-window {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    width: 100%;
    max-width: 960px;
    height: 90vh;
    max-height: 840px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 40px rgba(139, 92, 246, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.game-modal.active .modal-window {
    transform: scale(1);
}

/* ゲーム画面キャンバスコンテナ */
.canvas-wrapper {
    flex: 1;
    position: relative;
    background: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#gameCanvas {
    background: transparent;
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* DOMゲーム用コンテナ */
#gameDOMContainer {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 16px;
}

/* 実績解除トースト */
.achievement-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 150;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    backdrop-filter: blur(12px);
    transform: translateY(120%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.achievement-toast.show {
    transform: translateY(0);
}

/* グリッドレイアウト */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* レスポンシブ調整 */
@media (max-width: 640px) {
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    .game-card .thumb-box {
        height: 100px;
    }
    .game-card .thumb-icon {
        font-size: 2.5rem;
    }
    .modal-window {
        height: 98vh;
        border-radius: 16px;
        padding: 0;
    }
}

/* 広告コンテナスタイル */
.ad-section {
    width: 100%;
    overflow: hidden;
}
.ad-section iframe {
    max-width: 100% !important;
}

