/* style.css for Candy World Game (Removed Enemy Fallback Background Colors) */

/* --- 基本リセット & 変数定義 --- */
:root {
    --font-family-base: 'Noto Sans JP', sans-serif;
    --font-family-heading: 'M PLUS Rounded 1c', sans-serif;
    /* 見出し用 */
    --font-family-pixel: 'Press Start 2P', cursive;
    /* アクセント用ピクセルフォント */

    --color-text: #555;
    --color-heading: #4a4a4a;
    --color-link: #ff69b4;
    /* ディープピンク */
    --color-link-hover: #ff1493;
    /* より濃いピンク */

    --color-bg: #fff0f5;
    /* ラベンダーブラッシュ (薄いピンク) */
    --color-bg-section: #ffffff;
    /* 白 */
    --color-bg-accent: #ffe4e1;
    /* ミスティローズ (やや濃いピンク) */
    --color-border: #eee;

    --color-candy-pink: #ffb6c1;
    /* ライトピンク */
    --color-candy-blue: #add8e6;
    /* ライトブルー */
    --color-candy-yellow: #fffacd;
    /* レモンシフォン */
    --color-candy-green: #98fb98;
    /* ペールグリーン */

    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.08);
    --border-radius-medium: 8px;
    --border-radius-large: 15px;
    --container-width: 960px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.7;
    font-size: 16px;
}

/* --- コンテナ --- */
.container {
    max-width: var(--container-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* --- ヘッダー --- */
.site-header {
    background: linear-gradient(135deg, var(--color-candy-pink), var(--color-candy-blue));
    padding: 20px 0;
    text-align: center;
    border-bottom: 5px dotted var(--color-bg-accent);
}

.site-header h1 {
    font-family: var(--font-family-pixel);
    /* ピクセルフォント適用 */
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin: 0;
}

.site-header h1 a {
    color: inherit;
    /* 親要素の色を継承 */
    text-decoration: none;
}

.site-header .subtitle {
    color: rgba(255, 255, 255, 0.9);
    margin-top: 5px;
    font-size: 0.9rem;
}

/* --- メインコンテンツ --- */
.main-content {
    padding-top: 40px;
    padding-bottom: 40px;
}

/* --- セクション共通スタイル --- */
.game-section,
.content-section,
.ad-section {
    background-color: var(--color-bg-section);
    padding: 30px;
    margin-bottom: 40px;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--color-border);
}

/* --- 見出しスタイル --- */
h2 {
    font-family: var(--font-family-heading);
    font-size: 1.8rem;
    color: var(--color-heading);
    margin-bottom: 25px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 3px dashed var(--color-candy-pink);
    position: relative;
}

/* 見出しの装飾（例：キャンディ風） */
h2::before,
h2::after {
    content: '🍬';
    /* キャンディ絵文字 */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0.8;
}

h2::before {
    left: -5px;
}

h2::after {
    right: -5px;
}


/* --- ゲーム情報セクション --- */
#game-info .intro-text {
    margin-bottom: 20px;
    text-align: center;
}

#game-info .credits {
    font-size: 0.85rem;
    color: #777;
    margin-top: 15px;
    border-top: 1px dotted var(--color-border);
    padding-top: 15px;
}

/* --- ゲームエリアセクション --- */
#game-area {
    text-align: center;
}

#game-area label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--color-heading);
}

#game-area input[type="text"] {
    padding: 10px 15px;
    border: 2px solid var(--color-candy-blue);
    border-radius: var(--border-radius-medium);
    margin-bottom: 20px;
    font-size: 1rem;
    width: 100%;
    max-width: 300px;
    /* 最大幅 */
}

.game-container {
    position: relative;
    /* 子要素の絶対配置の基準 */
    max-width: 800px;
    /* ゲームエリアの最大幅 */
    margin: 20px auto;
    /* 中央寄せ */
    border: 5px solid var(--color-candy-green);
    /* ゲーム画面の枠 */
    border-radius: var(--border-radius-medium);
    overflow: hidden;
    /* はみ出しを隠す */
    aspect-ratio: 16 / 9;
    /* 16:9 の比率を維持 (必要に応じて調整) */
    height: auto;
    /* 高さは自動 */
    background-color: #f0f8ff;
    /* ゲーム背景色 (画像がない場合の代替) */
}

/* #gamePlaceholder と #game は JS で display が制御される */
#gamePlaceholder img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* コンテナに合わせて調整 */
}

#game {
    /* 基本的なサイズや背景は維持、position:relative はコンテナに移動 */
    width: 100%;
    height: 100%;
    /* コンテナに合わせる */
    background: url('../img/game1background.jpg') center/cover no-repeat;
    /* 背景画像 */
    position: relative;
    /* 子要素の絶対配置基準 */
    overflow: hidden;
    /* ゲーム要素がはみ出さないように */
    cursor: crosshair;
    /* ゲーム中のカーソル */
    outline: none;
    /* フォーカス時の枠線を消す */
}

/* ゲーム内要素のスタイル (JSでの制御を考慮) */
.player {
    position: absolute;
    /* JS制御 */
    width: 50px;
    /* JSでの衝突判定に影響 */
    height: 50px;
    /* JSでの衝突判定に影響 */
    background-image: url('../img/player.png');
    /* プレイヤー画像 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
    /* 他の要素より手前に */
}

/* ダメージ時エフェクト */
.player.hit {
    animation: blink 0.2s linear;
}

/* 無敵時エフェクト */
.player.invincible-effect {
    animation: glow 1s infinite alternate;
    opacity: 0.8;
}

.sub {
    position: absolute;
    /* JS制御 */
    width: 30px;
    /* JSでの衝突判定に影響 */
    height: 30px;
    /* JSでの衝突判定に影響 */
    background-image: url('../img/sub.png');
    /* サブ機画像 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 9;
    /* プレイヤーより少し後ろ */
}

.bullet,
.sub-bullet {
    position: absolute;
    /* JS制御 */
    width: 10px;
    /* 画像サイズに合わせて調整 */
    height: 10px;
    /* 画像サイズに合わせて調整 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 5;
    /* 敵より手前、プレイヤーより後ろ */
}

.bullet {
    background-image: url('../img/bullet.png');
    /* 弾の画像 */
}

.sub-bullet {
    background-image: url('../img/sub-bullet.png');
    /* サブ弾の画像 */
}

.trap,
.boss,
.mini-boss {
    position: absolute;
    /* JS制御 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 8;
    /* 弾より後ろ、アイテムより手前 */
}

/* ★★★ 敵の可視化対策 (背景色削除) ★★★ */
.trap {
    width: 40px;
    height: 40px;
    background-image: url('../img/trap.png');
    /* トラップ画像 */
    /* background-color: #8a2be2; */
    /* ★削除 */
}

.boss {
    width: 120px;
    height: 120px;
    background-image: url('../img/boss.png');
    /* ボス画像 */
    /* background-color: #dc143c; */
    /* ★削除 */
}

.mini-boss {
    width: 70px;
    height: 70px;
    background-image: url('../img/mini-boss.png');
    /* ミニボス画像 */
    /* background-color: #ff8c00; */
    /* ★削除 */
}

/* 敵ヒットエフェクト */
.boss.hit,
.mini-boss.hit {
    animation: blink 0.1s linear;
}

.item {
    position: absolute;
    /* JS制御 */
    width: 35px;
    /* JSでの衝突判定に影響 */
    height: 35px;
    /* JSでの衝突判定に影響 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: item-float 1.5s infinite alternate ease-in-out;
    /* ふわふわ浮くアニメーション */
    z-index: 7;
    /* 敵より後ろ */
}

.item.heal {
    background-image: url('../img/heal.png');
    /* 回復アイテム画像 */
}

.item.invincible {
    background-image: url('../img/invincible.png');
    /* 無敵アイテム画像 */
}

.item.weapon {
    background-image: url('../img/item-weapon.png');
    /* 武器アイテム画像 */
}

.item.subitem {
    background-image: url('../img/item-sub.png');
    /* サブアイテム画像 */
}

/* ★★★ HPバー (視認性向上 & 色変更) ★★★ */
#hp-bar {
    position: absolute;
    bottom: 15px;
    left: 15px;
    width: 200px;
    height: 20px;
    background-color: red;
    /* 外側の背景を赤に */
    border: 2px solid #fff;
    border-radius: 8px;
    overflow: hidden;
    z-index: 20;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#hp-bar-inner {
    height: 100%;
    background-color: lime;
    /* 内側は常に緑色 */
    width: 100%;
    transition: width 0.3s ease;
    /* width の transition のみ */
    border-radius: 5px;
}

/* スコア・弾数表示 (視認性向上) */
#bulletCount,
#subBulletCount {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.6);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: var(--font-family-pixel);
    min-width: 60px;
    text-align: right;
    z-index: 20;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#subBulletCount {
    top: 65px;
}

.score-display {
    font-family: var(--font-family-pixel);
    font-size: 2rem;
    color: var(--color-link-hover);
    margin-top: 15px;
    text-align: center;
}

/* ゲームオーバー表示 (装飾強化) */
.gameover-display {
    display: none;
    /* 初期非表示はJS制御 */
    font-family: var(--font-family-pixel);
    font-size: 2.5rem;
    color: #fff;
    text-align: center;
    text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    padding: 30px 40px;
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    border: 5px solid #000;
    border-radius: 0;
    box-shadow:
        inset 0 0 0 5px rgba(255, 255, 255, 0.5),
        0 0 0 10px #ff4b2b,
        10px 10px 10px rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    margin-top: 0;
    animation: gameover-appear 0.5s ease-out;
}

/* ゲームオーバー表示のアニメーション */
@keyframes gameover-appear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}


/* --- 関連動画セクション --- */
#related-videos .video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin-bottom: 20px;
    border-radius: var(--border-radius-medium);
    box-shadow: var(--shadow-light);
}

#related-videos iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- SNSフィードセクション --- */
#social-feed .twitter-feed {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Twitter埋め込みのスタイル調整 */
.twitter-tweet {
    margin: 0 auto !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--border-radius-medium) !important;
    box-shadow: none !important;
}

/* --- 広告セクション --- */
.ad-section {
    text-align: center;
}

/* --- フッター --- */
.site-footer {
    background-color: var(--color-bg-accent);
    color: var(--color-text);
    padding: 30px 0;
    text-align: center;
    margin-top: 40px;
    border-top: 5px dotted var(--color-candy-blue);
}

.site-footer p {
    margin-bottom: 15px;
    font-size: 0.9rem;
}

/* SNSシェアボタン */
.social-buttons {
    margin-bottom: 20px;
}

.social-button {
    display: inline-block;
    margin: 5px;
    padding: 8px 15px;
    border-radius: 20px;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    transition: opacity 0.3s ease;
}

.social-button:hover {
    opacity: 0.8;
    text-decoration: none;
}

.social-button.facebook {
    background-color: #1877f2;
}

.social-button.x {
    background-color: #1da1f2;
}

.social-button.bluesky {
    background-color: #007bff;
}

.social-button.pocket {
    background-color: #ef3f56;
}

.social-button.line {
    background-color: #00c300;
}

.social-button.pinterest {
    background-color: #e60023;
}

/* --- アニメーション --- */
@keyframes blink {
    50% {
        opacity: 0.3;
    }
}

@keyframes glow {
    from {
        filter: brightness(1.2) drop-shadow(0 0 5px gold);
    }

    to {
        filter: brightness(1.4) drop-shadow(0 0 10px gold);
    }
}

@keyframes item-float {
    from {
        transform: translateY(-3px);
    }

    to {
        transform: translateY(3px);
    }
}

/* --- レスポンシブ対応 --- */
@media (max-width: 768px) {
    .site-header h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    .game-container {
        max-width: 100%;
    }

    .score-display {
        font-size: 1.5rem;
    }

    .gameover-display {
        font-size: 2rem;
        padding: 20px 30px;
        border-width: 4px;
        box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.5), 0 0 0 8px #ff4b2b, 8px 8px 8px rgba(0, 0, 0, 0.5);
    }

    #social-feed .twitter-feed {
        grid-template-columns: 1fr;
    }

    #hp-bar {
        width: 150px;
        height: 18px;
        bottom: 10px;
        left: 10px;
        border-width: 1px;
    }

    #bulletCount,
    #subBulletCount {
        font-size: 1.2rem;
        padding: 6px 10px;
        min-width: 50px;
        top: 10px;
        right: 10px;
    }

    #subBulletCount {
        top: 50px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .site-header h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .game-section,
    .content-section,
    .ad-section {
        padding: 20px;
    }

    #game-area input[type="text"] {
        max-width: 90%;
    }

    .social-button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .score-display {
        font-size: 1.3rem;
    }

    .gameover-display {
        font-size: 1.5rem;
        padding: 15px 20px;
        border-width: 3px;
        box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 6px #ff4b2b, 6px 6px 6px rgba(0, 0, 0, 0.5);
    }

    #hp-bar {
        width: 120px;
        height: 15px;
    }

    #bulletCount,
    #subBulletCount {
        font-size: 1rem;
        padding: 5px 8px;
    }

    #subBulletCount {
        top: 45px;
    }
}