@charset "UTF-8";

/* =========================================
   ★リセット・基本設定（ここが修正の肝です）
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box; /* 余白を含めて幅を計算する設定 */
}

:root {
    --primary: #3498db;
    --accent: #e67e22;
    --bg: #f0f4f8;
    --text: #333;
    --white: #ffffff;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    touch-action: manipulation;
    overflow-x: hidden; /* 万が一のはみ出し防止 */
    width: 100%;
}

/* --- ヘッダー --- */
header {
    background-color: var(--white);
    padding: 10px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    text-align: center;
    border-bottom: 3px solid var(--primary);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.site-logo-link {
    display: inline-block;
    transition: opacity 0.2s;
    line-height: 0;
}
.site-logo-link:hover {
    opacity: 0.8;
}

.site-logo-img {
    height: 60px;
    width: auto;
}

/* --- メインエリア --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    width: 100%;
}

/* --- コンテナ（記事枠） --- */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

/* --- ゲームコンテナ --- */
.game-container {
    background: var(--white);
    width: 100%;
    max-width: 480px;
    padding: 30px 20px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
    position: relative;
    margin: 0 auto;
}

/* --- ボタン共通 --- */
.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 100%;
    font-size: 1.5rem;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    transition: transform 0.1s;
}
.btn-primary:active { transform: translateY(4px); box-shadow: none; }

/* --- ランキング --- */
.ranking-area {
    margin-top: 20px;
    background: #fff;
    border-radius: 10px;
    padding: 15px;
    text-align: left;
    border: 2px solid #eee;
}
.ranking-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.ranking-table th { border-bottom: 2px solid #ddd; padding: 5px; color: #888; }
.ranking-table td { border-bottom: 1px solid #eee; padding: 8px 5px; }
.rank-num { font-weight: bold; color: var(--accent); width: 30px; }
.rank-score { font-weight: bold; text-align: right; }

.input-group { margin: 15px 0; display: flex; gap: 5px; }
.name-input {
    flex: 1; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 1rem;
}
.send-btn {
    background: var(--primary); color: white; border: none; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-weight: bold;
}
.send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* --- 広告スペース --- */
.ad-space {
    width: 100%;
    max-width: 336px;
    height: 280px;
    background: #e9ecef;
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.8rem;
    border-radius: 8px;
    margin-left: auto;
    margin-right: auto;
}

/* --- アニメーション --- */
.screen { display: none; }
.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- フッター（修正箇所） --- */
footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    background: var(--white);
    border-top: 1px solid #ddd;
    width: 100%;
    /* box-sizing: border-box; が全体に効いているので、width:100%でもはみ出しません */
}
footer a { color: #888; text-decoration: none; margin: 0 10px; }

/* --- PC向け調整 --- */
@media screen and (min-width: 768px) {
    main {
        padding: 40px;
    }
    .game-container {
        box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    }
}