﻿body {
    margin: 0;
    padding: 0;
    background-color: #050510;
    color: #fff;
    font-family: 'Yuji Mai', serif;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
}

#gameContainer {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, 95vw);
    height: min(900px, calc(100vh - 40px));
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.1);
    z-index: 100;
    background-image: url('../drawable/bg_steam.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

canvas {
    /* background: linear-gradient(to bottom, #0a0a1a, #1a1a2e); REMOVE old background */
    background: transparent;
    border: 2px solid #333;
    border-radius: 4px;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.score-label {
    font-size: 14px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#score {
    font-size: 32px;
    font-weight: bold;
    color: #eee;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: none;
    background: rgba(0, 0, 0, 0.9);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #333;
    backdrop-filter: blur(5px);
    width: 90%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    box-sizing: border-box;
}

#gameOver h1 {
    margin: 10px 0;
    font-size: 28px;
    color: #ff0055;
    text-shadow: 0 0 20px rgba(255, 0, 85, 0.5);
}

#gameOver p {
    margin: 5px 0 15px;
}

#highScoreForm {
    margin-bottom: 10px;
}

.input-group {
    margin-bottom: 8px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 3px;
    color: #aaa;
    font-size: 12px;
}

button {
    background: linear-gradient(45deg, #00d2ff, #3a7bd5);
    border: none;
    padding: 10px 30px;
    color: white;
    font-size: 16px;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 210, 255, 0.6);
}

input[type="text"] {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #333;
    border-radius: 5px;
    color: #fff;
    font-size: 14px;
    box-sizing: border-box;
}

#leaderboard {
    margin-top: 15px;
    max-height: 150px;
    overflow-y: auto;
    text-align: left;
    border-top: 1px solid #333;
    padding-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 5px;
    text-align: left;
    border-bottom: 1px solid #222;
}

th {
    color: #0ff;
}

.comment-cell {
    color: #aaa;
    font-style: italic;
}

.small-btn {
    background: rgba(0, 200, 255, 0.3);
    border: 1px solid #0ff;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    color: #0ff;
    width: 100%;
    margin-bottom: 10px;
}

.small-btn:hover {
    background: rgba(0, 200, 255, 0.5);
}

/* Ad Script Layout Protection */
/* These rules prevent injected ad scripts from breaking the game layout */

/* Isolate any script-injected elements that appear as direct body children */
body>div:not(#gameContainer),
body>script+div,
body>br {
    position: absolute !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 10px 0 !important;
    z-index: 1 !important;
    pointer-events: auto !important;
}

/* Hide any br tags that might be injected */
body>br {
    display: none !important;
}

/* Style for ad containers to keep them below the game */
body>div[style*="z-index: 9999"],
body>div>div[style*="z-index: 9999"] {
    position: fixed !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 1 !important;
    max-width: 100vw !important;
    overflow: hidden !important;
}

/* Prevent ads from affecting body overflow */
body {
    overflow-x: hidden !important;
}

/* Ensure game container is always visible above ads */
#gameContainer {
    z-index: 100 !important;
}

/* スマホ対応：横幅一杯に広げる */
@media (max-width: 1000px) {
    #gameContainer {
        width: 100vw !important;
        height: 90dvh !important;
        /* 少し小さくして余裕を持たせる */
        left: 0 !important;
        bottom: 0 !important;
        /* 下寄せ */
        top: auto !important;
        padding-bottom: 0px !important;
        /* 下部に余白を追加 */
        transform: none !important;
        box-shadow: none !important;
    }

    canvas {
        border-radius: 0 !important;
        border: none !important;
    }

    #gameOver {
        max-height: 90vh !important;
    }
}