:root {
    --main-bg: #fdfdfd;
    --text-color: #333;
    --link-color: #0066cc;
    --accent-1: #ff6b6b; /* Red */
    --accent-2: #fd6262; /* Teal */
    --accent-3: #ffe66d; /* Yellow */
    --accent-4: #1a535c; /* Dark Blue */
    --board-color: #eaffea; /* Thin Yellow Green */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-color);
    line-height: 1.6;
    text-align: center;
}

/* カラフルな見出し */
h1 {
    color: var(--accent-1);
    font-size: 2rem;
    margin: 1rem 0;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.1);
}

h2 {
    color: var(--accent-4);
    border-bottom: 2px solid var(--accent-2);
    display: inline-block;
    padding-bottom: 5px;
    margin-top: 2rem;
}

h3 {
    color: var(--accent-2);
    margin-top: 1.5rem;
}

/* リンクの色 */
a {
    color: var(--link-color);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* レイアウト */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ゲームキャンバスエリア */
#game-container {
    position: relative;
    margin: 0 auto;
    display: inline-block;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border-radius: 20px;
    overflow: hidden;
    background-color: #8B4513; /* 木枠っぽい色 */
    padding: 10px;
}

canvas {
    background-color: var(--board-color);
    border-radius: 15px 15px 5px 5px;
    display: block;
    cursor: pointer;
    /* タッチ操作の無効化を防ぐ */
    touch-action: none;
    /* 明示的にキャンバスの表示サイズを制御（CSSで拡大縮小されても見た目が崩れにくい） */
    width: 100%;
    height: auto;
    max-width: 400px;
}

/* UIオーバーレイ */
#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    text-align: left;
    pointer-events: none;
    font-weight: bold;
    font-size: 1.2rem;
    color: #333;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
}

#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 10px;
    border: 3px solid var(--accent-1);
    display: none; /* JSで制御 */
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

#restart-btn {
    background-color: var(--accent-1);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

/* シェアボタンエリア */
.share-section {
    margin: 20px 0;
    padding: 15px;
    background: #eafcdc;
    border-radius: 10px;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.share-btn {
    padding: 10px 15px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
}
.share-btn:hover { opacity: 0.8; text-decoration: none; }

.btn-x { background-color: #61a6ff; }
.btn-fb { background-color: #0066eb; }
.btn-line { background-color: #00c300; }
.btn-email { background-color: #ffc65c; }
.btn-native { background-color: var(--accent-1); }

/* 説明文エリア */
.content-area {
    text-align: left;
    margin-top: 30px;
    line-height: 1.8;
}

/* フッターリンク */
.footer-links {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    background-color: #ffffe8;
    padding-bottom: 20px;
}
.footer-links ul { list-style: none; padding: 0; }
.footer-links li { display: inline; margin: 0 10px; }

/* レスポンシブ対応
   修正点: メディアクエリに max-width を追加して「小さい画面（主にスマホ）」に限定する。
   これにより、PCの狭いウィンドウ（例: 高さ600px以下）で本文が誤って非表示になる問題を防ぎます。
*/
@media (orientation: landscape) and (max-height: 600px) and (max-width: 900px) {
    /* スマホ横持ち時の最適化（幅が900px以下のデバイスに限定） */
    .container {
        max-width: 100%;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        padding: 5px;
    }
    h1 { font-size: 1.2rem; margin: 0.5rem 0; display: none; } /* ゲーム中はタイトル隠すなど */
    #game-container {
        height: 90vh;
        width: auto;
        /* アスペクト比を維持しつつ高さを画面に合わせる */
        aspect-ratio: 2 / 3;
    }
    canvas {
        width: 100%;
        height: 100%;
        max-width: none;
    }
    .content-area, .share-section, .footer-links {
            display: none; /* 横持ちゲーム中はコンテンツ非表示で見やすく */
    }
}

/* 小さい縦持ちスマホ向けの微調整（任意） */
@media (max-width: 480px) {
    h1 { font-size: 1.4rem; }
    #ui-overlay { font-size: 1rem; top: 12px; left: 12px; }
    #game-container { padding: 8px; border-radius: 12px; }
}