html, body {
    margin: 0;
    padding: 0;
    color: rgba(255, 255, 255, 0.87);
    background-color: #000;
    overscroll-behavior: none;
    touch-action: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    height: 100%;
}

/* === 仮想コントロール === */
#virtual-controls {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* === 縦持ち警告オーバーレイ === */
/* デフォルト（PC・横持ち）では非表示。判定は src/main.ts setupOrientationGuard が body class で行う */
#orientation-warning {
    display: none;
}

/* スマホ縦持ち時はゲーム本体を完全に隠して警告のみ表示 */
body.is-portrait-mobile #app {
    display: none;
}

body.is-portrait-mobile #orientation-warning {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    inset: 0;
    background: #0b1020;
    color: #fff;
    z-index: 9999;
    text-align: center;
    padding: 24px;
    font-family: sans-serif;
}

body.is-portrait-mobile #orientation-warning .rotate-icon {
    width: 80px;
    height: 56px;
    border: 3px solid #fff;
    border-radius: 8px;
    margin-bottom: 28px;
    font-size: 0;
    animation: rotate-hint 2.4s ease-in-out infinite;
}

body.is-portrait-mobile #orientation-warning .title {
    font-size: 22px;
    font-weight: bold;
    margin: 0 0 10px;
    letter-spacing: 0.05em;
}

body.is-portrait-mobile #orientation-warning .hint {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.65);
    margin: 0;
}

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

/* メモリHUD: 画面左上 */
#memory-hud {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 10px);
    left: calc(env(safe-area-inset-left) + 10px);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    padding: 4px 10px;
    font-family: sans-serif;
    font-size: 13px;
    line-height: 1.4;
    pointer-events: none;
    user-select: none;
}

/* D-Pad: 画面左下、親指届く範囲 */
#dpad {
    position: absolute;
    left: calc(env(safe-area-inset-left) + 10px);
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    width: 144px;
    height: 144px;
    pointer-events: none;
}

.dpad-btn {
    position: absolute;
    width: 48px;
    height: 48px;
    background: rgba(20, 20, 30, 0.55);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    font-size: 18px;
    line-height: 44px;
    text-align: center;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    padding: 0;
}

.dpad-btn:active,
.dpad-btn.is-pressed {
    background: rgba(80, 100, 160, 0.85);
}

.dpad-up    { top: 0;    left: 48px; }
.dpad-left  { top: 48px; left: 0; }
.dpad-right { top: 48px; left: 96px; }
.dpad-down  { top: 96px; left: 48px; }

/* Action ボタン: 画面右下、親指届く範囲 */
#action-btn {
    position: absolute;
    right: calc(env(safe-area-inset-right) + 14px);
    bottom: calc(env(safe-area-inset-bottom) + 30px);
    width: 72px;
    height: 72px;
    background: rgba(180, 80, 80, 0.7);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    font-size: 22px;
    font-weight: bold;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    padding: 0;
}

#action-btn:active,
#action-btn.is-pressed {
    background: rgba(220, 120, 120, 0.95);
}

/* PC・マウス端末では仮想コントロールを薄く（消すと使えないのでデフォルト表示） */
@media (hover: hover) and (pointer: fine) {
    #virtual-controls {
        opacity: 0.5;
    }
}

/* === 全画面ボタン: 画面右上 === */
#fullscreen-btn {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 10px);
    right: calc(env(safe-area-inset-right) + 10px);
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fullscreen-btn:active,
#fullscreen-btn.is-pressed {
    background: rgba(80, 100, 160, 0.85);
}

/* PWA standalone (= ホーム画面起動) のときは案内不要なので隠す */
@media (display-mode: standalone) {
    #fullscreen-btn {
        display: none;
    }
}

/* Fullscreen API でブラウザを全画面化中も隠す（main.ts が body class を付ける） */
body.is-fullscreen #fullscreen-btn {
    display: none;
}

/* === 全画面ヘルプモーダル (iPhone 用) === */
#fullscreen-help[hidden] {
    display: none;
}

#fullscreen-help {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: sans-serif;
    color: #fff;
}

#fullscreen-help .fs-help-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
}

#fullscreen-help .fs-help-panel {
    position: relative;
    max-width: 480px;
    width: 100%;
    background: #11162a;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 20px 22px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

#fullscreen-help h2 {
    margin: 0 0 12px;
    font-size: 16px;
    letter-spacing: 0.04em;
}

#fullscreen-help .fs-help-steps {
    list-style: decimal;
    padding-left: 20px;
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.6;
}

#fullscreen-help .fs-help-steps li + li {
    margin-top: 12px;
}

#fullscreen-help .fs-help-steps p {
    margin: 4px 0 0;
    color: rgba(255, 255, 255, 0.78);
}

#fullscreen-help .fs-key {
    display: inline-block;
    padding: 1px 6px;
    margin: 0 2px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 12px;
}

#fullscreen-help .fs-help-close {
    display: block;
    margin: 0 auto;
    padding: 8px 24px;
    background: rgba(80, 100, 160, 0.85);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
