body {
    background-color: #050505;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(0, 20, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%2300ff00' fill-opacity='0.1' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: cover, 56px 98px;
    color: #fff;
    font-family: 'Press Start 2P', cursive, sans-serif;
    text-align: center;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    image-rendering: pixelated;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 360px;
    height: 440px; /* canvasの高さに固定 */
    border: 2px solid #0f0;
    box-shadow:
        0 0 10px #0f0,
        0 0 20px #0f0,
        inset 0 0 20px rgba(0, 255, 0, 0.2);
    border-radius: 5px;
    overflow: hidden;
    background-color: #000; /* 背景色を追加 */
}

#game-container::before {
    content: "";
    position: absolute;
    top: -25%;
    left: -25%;
    width: 150%;
    height: 150%;
    background-image: url('images/background.png');
    background-size: cover;
    background-position: center;
    z-index: 1;
    animation: bgAnim 20s ease-in-out infinite alternate;
}

#pause-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #0f0;
    border: 1px solid #0f0;
    border-radius: 5px;
    font-family: sans-serif; /* アイコン表示のため *//
    font-size: 18px;
    line-height: 28px; /* 中央揃え */
    text-align: center;
    cursor: pointer;
    z-index: 5; /* canvasより手前 */
    display: none; /* ゲーム開始時に表示 */
}

#pause-button:hover {
    background-color: #0f0;
    color: #000;
}

@keyframes bgAnim {
    0% { transform: rotate(-2deg) scale(1.1); }
    100% { transform: rotate(2deg) scale(1.2); }
}

#gameCanvas {
    position: relative;
    z-index: 2;
}

.hidden {
    display: none !important; /* 確実に非表示にする */
}

#game-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 360px; /* game-containerの幅に合わせる */
    padding: 10px 0;
    margin-bottom: 10px; /* game-containerとの間に余白 */
    background-color: #111;
    border: 2px solid #0f0;
    border-radius: 5px;
}

#game-info span {
    flex-grow: 1;
    text-align: center;
    font-size: 14px;
    color: #aaa;
}

#game-info #score {
    color: #fff;
    text-shadow: 0 0 5px #fff;
}

#game-info #lives-display {
    display: flex;
    justify-content: center;
    align-items: center;
}

#lives-display svg {
    width: 20px;
    height: 20px;
}

#start-screen,
#message-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    box-sizing: border-box;
    text-align: center;
    z-index: 10;
}

#start-screen h2,
#message-container h2 {
    color: #0f0;
    text-shadow: 0 0 10px #0f0;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

#start-button,
#restart-button {
    background-color: transparent;
    color: #0f0;
    border: 2px solid #0f0;
    padding: 15px 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    cursor: pointer;
    margin-top: 20px;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    transition: all 0.2s ease;
}

#start-button:hover,
#restart-button:hover {
    background-color: #0f0;
    color: #000;
    box-shadow: 0 0 20px #0f0;
}

#start-button:active,
#restart-button:active {
    transform: scale(0.95);
}

/* ローディング画面のスタイル */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 99999; /* 最前面に表示 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.5s ease;
}
#loading-bg {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: url('images/background.png');
    background-size: cover;
    background-position: center;
    opacity: 0.5;
    animation: bg-rotate-scale 300s infinite linear alternate;
    z-index: -1;
    image-rendering: pixelated;
}
@keyframes bg-rotate-scale {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.5); }
    100% { transform: rotate(360deg) scale(1); }
}
#loading-title {
    font-family: 'Press Start 2P', cursive;
    color: #fff;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 4px 4px 0 #ff00ff;
    line-height: 1.5;
    position: relative;
    z-index: 10;
}
.title-char {
    display: inline-block;
    transition: transform 0.2s, opacity 0.2s;
}
.title-char.destroyed {
    opacity: 0;
    transform: scale(1.5);
    pointer-events: none;
}
#loading-ship-container {
    position: absolute;
    bottom: 10%;
    width: 40px;
    height: 40px;
    z-index: 20;
    transform: translateX(-50%);
}
#loading-ship-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}
.loading-missile {
    position: absolute;
    width: 4px;
    height: 12px;
    background-color: #00ff00;
    box-shadow: 0 0 5px #00ff00;
    border-radius: 2px;
    z-index: 15;
}
#loading-play-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    padding: 0.6rem 1.2rem;
    background-color: #000;
    color: #0f0;
    border: 4px solid #0f0;
    cursor: pointer;
    animation: btn-glow 1.5s infinite alternate;
    margin-top: 20px;
    position: relative;
    z-index: 30;
    box-shadow: 0 0 10px #0f0;
    text-shadow: 0 0 5px #0f0;
}
@keyframes btn-glow {
    0% { box-shadow: 0 0 10px #0f0; text-shadow: 0 0 5px #0f0; }
    100% { box-shadow: 0 0 25px #0f0, inset 0 0 10px #0f0; text-shadow: 0 0 15px #0f0; }
}
#loading-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #fff;
    text-align: center;
    margin-top: 5px;
    white-space: nowrap;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
#sound-warning {
    font-family: 'Press Start 2P', cursive, sans-serif;
    font-size: 10px;
    color: #ff0;
    text-align: center;
    white-space: nowrap;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.8;
}
#loading-message {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
}
footer {
    width: 360px;
    font-family: 'Teko', sans-serif;
    font-size: 0.8rem;
    margin-top: 10px;
    line-height: 1.5;
}
