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

body {
    background: #0a1628;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

#game-container {
    position: relative;
    width: 100%;
}

#gameCanvas {
    display: block;
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 10px;
}

#overlay.hidden {
    display: none;
}

.screen {
    display: none;
    text-align: center;
    color: white;
    padding: 32px 44px;
    background: rgba(12, 22, 50, 0.93);
    border-radius: 18px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    min-width: 360px;
}

.key-sub {
    font-size: 0.7em;
    font-weight: normal;
    opacity: 0.75;
}

.screen.active {
    display: block;
}

#title-screen h1 {
    font-size: 3em;
    font-weight: 900;
    color: #fff;
    letter-spacing: 4px;
    margin-bottom: 14px;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}

#title-screen p {
    font-size: 1.0em;
    color: #aed6f1;
    line-height: 2.0;
    margin-bottom: 28px;
}

.key-hint {
    display: inline-block;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 0.88em;
    font-family: monospace;
    color: #fff;
    margin-right: 4px;
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 22px;
    font-size: 0.88em;
}

.rules-table th {
    color: #7fb3d3;
    font-size: 0.85em;
    letter-spacing: 1px;
    padding: 4px 0 6px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.rules-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    text-align: left;
    vertical-align: middle;
    line-height: 1.4;
}

.rules-table td:first-child {
    color: #dce9f5;
    white-space: nowrap;
    padding-right: 12px;
}

.rule-ok  { color: #2ecc71; font-weight: bold; }
.rule-ng  { color: #e74c3c; font-weight: bold; }
.rule-info { color: #95a5a6; }

.gameover-reason {
    font-size: 0.95em;
    color: #f0b27a;
    margin-bottom: 16px;
    min-height: 1.4em;
}

#gameover-screen h2 {
    font-size: 2.4em;
    font-weight: 900;
    color: #e74c3c;
    margin-bottom: 10px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.score-label {
    font-size: 0.95em;
    color: #aed6f1;
    margin-bottom: 6px;
}

.score-value {
    font-size: 3.2em;
    font-weight: 900;
    color: #f1c40f;
    margin-bottom: 28px;
}

.score-value .unit {
    font-size: 0.45em;
    color: #aed6f1;
    margin-left: 4px;
}

button {
    background: linear-gradient(135deg, #2980b9, #3498db);
    color: white;
    border: none;
    padding: 14px 44px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.45);
    transition: transform 0.1s, box-shadow 0.1s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(52, 152, 219, 0.6);
}

button:active {
    transform: translateY(1px);
}

/* 発射ボタン（スマホ・画面端）。デフォルトは非表示、スマホ横向きのプレイ中のみ表示 */
#fire-btn {
    display: none;
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 84px;
    height: 84px;
    padding: 0;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.6);
    color: #fff;
    font-size: 1em;
    font-weight: bold;
    letter-spacing: 1px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    z-index: 5;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

#fire-btn:active {
    background: rgba(231, 76, 60, 0.85);
    transform: none;
}

.game-description {
    margin-top: 40px;
    color: #cdd8e8;
}

.desc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.desc-block {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 24px;
}

.desc-block h2 {
    font-size: 1em;
    font-weight: bold;
    color: #7eb8e8;
    letter-spacing: 1px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.desc-block p {
    font-size: 0.9em;
    line-height: 1.8;
    color: #b0c4d8;
}

.desc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
}

.desc-table th {
    color: #7eb8e8;
    font-size: 0.85em;
    padding: 4px 8px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    text-align: left;
    white-space: nowrap;
}

.desc-table td {
    padding: 7px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #b0c4d8;
    vertical-align: top;
    line-height: 1.5;
}

.desc-table td:first-child {
    white-space: nowrap;
}

.pt-ok { color: #2ecc71; font-weight: bold; }
.pt-ng { color: #e74c3c; font-weight: bold; }

@media (max-width: 640px) {
    #title-screen h1 { font-size: 2.2em; }
    .screen { padding: 24px 28px; min-width: 240px; }
    .score-value { font-size: 2.6em; }
    .desc-grid { grid-template-columns: 1fr; }
}

/* ===== 横向き案内（スマホ縦のとき表示） ===== */
#rotate-prompt {
    display: none;
    position: absolute;   /* ゲーム画面（#game-container）の中だけを覆う */
    inset: 0;
    z-index: 10;          /* canvas・overlay・発射ボタンより前面 */
    background: #0a1628;
    color: #fff;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    border-radius: 10px;  /* canvasの角丸に合わせる */
}

#rotate-prompt .rotate-icon {
    font-size: 3em;
    margin-bottom: 12px;
    animation: rotate-hint 1.6s ease-in-out infinite;
}

#rotate-prompt p {
    font-size: 1.1em;
    line-height: 1.6;
    color: #aed6f1;
}

@keyframes rotate-hint {
    0%, 60%, 100% { transform: rotate(0deg); }
    30%           { transform: rotate(-90deg); }
}

/* スマホ（タッチ端末）縦向き：横向き案内を出す */
@media (pointer: coarse) and (orientation: portrait) {
    #rotate-prompt { display: flex; }
    /* 縦向きではタイトル／ゲームオーバー画面を隠す
       （短い縦画面ではスタートボタン等が案内からはみ出して押せてしまうため） */
    #overlay { display: none; }
}

/* スマホ（タッチ端末）横向き：ゲームを全画面に大きく表示 */
@media (pointer: coarse) and (orientation: landscape) {
    body { overflow: hidden; }

    .page {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    #game-container {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* モバイルのアドレスバーを考慮 */
        display: flex;
        align-items: center;
        justify-content: center;
        background: #0a1628;
        z-index: 1000;
    }

    #gameCanvas {
        border-radius: 0;
        box-shadow: none;
    }

    .game-description {
        display: none;
    }

    /* タイトル・ゲームオーバー画面を、低い横画面でも収まるようコンパクトに */
    #overlay {
        padding: 10px;
    }

    .screen {
        padding: 14px 24px;
        min-width: 0;
        max-width: 94vw;
        max-height: 92vh;
        overflow-y: auto;
    }

    #title-screen h1 { font-size: 1.5em; margin-bottom: 8px; }
    #title-screen p  { font-size: 0.8em; line-height: 1.5; margin-bottom: 12px; }
    .rules-table     { font-size: 0.72em; margin-bottom: 12px; }
    .rules-table th  { padding: 3px 0 4px; }
    .rules-table td  { padding: 4px 6px; }

    #gameover-screen h2 { font-size: 1.5em; margin-bottom: 6px; }
    .gameover-reason    { font-size: 0.82em; margin-bottom: 8px; }
    .score-label        { font-size: 0.78em; margin-bottom: 2px; }
    .score-value        { font-size: 1.5em; margin-bottom: 10px; }

    .screen button { padding: 9px 26px; font-size: 0.9em; }

    /* プレイ中だけ発射ボタンを表示 */
    body.is-playing #fire-btn { display: block; }
}
