/* =========================================================
   1. グローバル基本設定
   ========================================================= */
:root {
    --ui-scale: 1;
    --hud-scale: 1;
}

/* ▼ iOS Safariでの強制文字拡大（Font Boosting）を無効化 */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: #050505;
    overflow: hidden;
    font-family: 'Orbitron', monospace;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    outline: none;
}


/* =========================================================
   2. メインUIコンテナ & HUD (Clean Sci-Fi Style)
   ========================================================= */
#ui {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 60;
    display: flex;
    flex-direction: column;
    padding: 16px 18px;
    box-sizing: border-box;
    /* 画面端にうっすらと暗いシャドウを落とし、HUDの立体感を出す */
    background: radial-gradient(circle at 50% 50%, transparent 60%, rgba(0, 10, 20, 0.4) 100%);
}

.hud-row {
    display: none; 
    justify-content: space-between;
    align-items: flex-start;
    width: min(100%, 1600px);
    margin: 0 auto;
    padding: 0 10px;
    box-sizing: border-box;
    gap: calc(28px * var(--hud-scale));
}

#info-box {
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--hud-scale));
}

#score-display {
    font-size: calc(22px * var(--hud-scale)); 
    color: #ffffff; /* 白ベースにシアンの光 */
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
    letter-spacing: calc(2px * var(--hud-scale));
    margin-bottom: 0;
    line-height: 1;
    /* 下に細いホログラム風のラインを引く */
    border-bottom: 1px solid rgba(0, 255, 255, 0.4);
    padding-bottom: 4px;
}

.sub-text {
    font-size: calc(10px * var(--hud-scale)); 
    color: rgba(180, 230, 255, 0.8);
    font-weight: normal;
    letter-spacing: 1px;
}

.hud-label {
    font-size: calc(10px * var(--hud-scale)); 
    color: rgba(180, 230, 255, 0.6);
    display: block;
    margin-bottom: calc(-2px * var(--hud-scale));
    line-height: 1.1;
    letter-spacing: 2px;
}

#stage-num {
    font-size: calc(24px * var(--hud-scale)); 
    color: #fff;
    font-weight: bold;
    line-height: 1;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
}

/* =========================================================
   3. ゲージ・バーコンポーネント (Clean Sci-Fi Style)
   ========================================================= */
/* --- コンテナと基本設定 --- */
#gauge-box,
#info-box > div {
    pointer-events: none; /* クリック判定を無効化し、ゲームプレイを邪魔しない */
}

#gauge-box {
    width: calc(120px * var(--hud-scale, 1)); 
    text-align: right;
}

/* --- ラベル（テキスト） --- */
.bar-label {
    font-size: calc(10px * var(--hud-scale, 1)); 
    letter-spacing: calc(2px * var(--hud-scale, 1));
    margin-bottom: calc(4px * var(--hud-scale, 1));
    display: block;
    color: rgba(200, 240, 255, 0.9); /* デフォルトのクリーンな白青 */
    line-height: 1.1;
    text-transform: uppercase;
    padding-right: 6px;
}

.bar-label.enemy,
#boss-name-label {
    color: rgba(255, 200, 200, 0.9); /* 敵対を示す薄い赤 */
}

/* --- フレーム（ゲージの外枠） --- */
.bar-frame,
.laser-bar-frame {
    width: 100%;
    height: calc(8px * var(--hud-scale, 1)); /* スマートに細く */
    background: rgba(0, 15, 30, 0.6); 
    border: 1.5px solid rgba(0, 255, 255, 0.2);
    border-radius: 2px; /* 少しだけ丸みを持たせて洗練させる */
    backdrop-filter: blur(4px);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    margin-bottom: calc(10px * var(--hud-scale, 1));
    overflow: hidden;
    box-sizing: border-box;
}

.laser-bar-frame {
    margin-bottom: 0;
}

.bar-frame.enemy,
.bar-frame.boss {
    border-color: rgba(255, 51, 51, 0.3);
}

#boss-ui-container {
    display: none;
    margin-top: calc(12px * var(--hud-scale, 1));
}

/* --- フィル（ゲージの中身） --- */
/* 全ゲージ共通のベース設定（.laser-bar-fill は外す） */
#shield-bar,
#enemy-bar,
#boss-hp-bar-inline,
#invuln-bar {
    height: 100%;
    transition: width 0.15s ease-out, background 0.2s ease-out, box-shadow 0.2s ease-out;
}

/* レーザー/OVERDRIVEゲージ（毎フレーム再生成されるためアニメーションはオフにする） */
.laser-bar-fill {
    height: 100%;
    /* transition を削除 */
    background: linear-gradient(90deg, rgba(0, 255, 255, 0.4), rgb(0, 255, 255));
    box-shadow: 0 0 calc(8px * var(--hud-scale, 1)) rgb(0, 255, 255);
}

/* シールドゲージ（通常時のエメラルドグリーン） */
#shield-bar {
    width: 100%;
    background: linear-gradient(90deg, rgba(0, 255, 180, 0.4), rgb(0, 255, 180));
    box-shadow: 0 0 calc(8px * var(--hud-scale, 1)) rgb(0, 255, 180);
}

/* 敵ゲージ（ネオンレッド） */
#enemy-bar {
    width: 100%;
    background: linear-gradient(90deg, rgba(255, 51, 51, 0.4), rgb(255, 51, 51));
    transition: width 0.5s ease-out; /* 敵の減りは少しゆっくり見せる */
    box-shadow: 0 0 calc(8px * var(--hud-scale, 1)) rgb(255, 51, 51);
}

/* ボスゲージ（ベースの赤。JSでボスの色に上書きされる） */
#boss-hp-bar-inline {
    width: 100%;
    background: linear-gradient(90deg, rgba(255, 51, 51, 0.4), rgb(255, 51, 51));
    box-shadow: 0 0 calc(12px * var(--hud-scale, 1)) rgb(255, 51, 51);
    transition: width 0.2s ease-out; /* ボス被弾時のスピード */
}

/* --- 無敵ゲージ (INVINCIBLE) --- */
#invuln-wrapper {
    display: none;
    margin-top: calc(2px * var(--hud-scale, 1));
}

#invuln-wrapper .bar-label {
    color: #ff0;
    text-shadow: 0 0 5px rgba(255, 255, 0, 0.5); /* お好みで光らせる */
}

#invuln-wrapper .bar-frame {
    border-color: rgba(255, 255, 0, 0.5);
    background: rgba(40, 40, 0, 0.5);
    /* 親要素に合わせて幅を可変スケール対応にする */
    width: calc(120px * var(--hud-scale, 1)); 
}

/* ※既存の #invuln-bar { width: 0%; } の部分を以下に上書き */
#invuln-bar {
    width: 0%; 
    /* 共通設定で height: 100% は既に適用されています */
    background: linear-gradient(90deg, rgba(255, 255, 0, 0.6), #ff0);
    box-shadow: 0 0 calc(8px * var(--hud-scale, 1)) #ff0;
}

/* レーザーゲージ（シアン） */
.laser-bar-fill {
    background: linear-gradient(90deg, rgba(0, 255, 255, 0.4), rgb(0, 255, 255));
    box-shadow: 0 0 calc(8px * var(--hud-scale, 1)) rgb(0, 255, 255);
}

/* --- 武器レベルブロック（通常状態） --- */
#weapon-display {
    width: calc(100px * var(--hud-scale, 1)); 
    height: calc(8px * var(--hud-scale, 1));
    display: flex;
    justify-content: space-between;
    margin-top: calc(4px * var(--hud-scale, 1));
}

.w-block {
    flex: 1;
    height: 100%;
    margin-right: calc(3px * var(--hud-scale, 1));
    border: 1px solid rgba(0, 255, 180, 0.2);
    border-radius: 1px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.w-block:last-child {
    margin-right: 0;
}

.w-block.active {
    background: rgb(0, 255, 180); 
    border-color: #ffffff; 
    box-shadow: 0 0 calc(6px * var(--hud-scale, 1)) rgb(0, 255, 180);
}

/* --- アニメーションと状態変化 --- */
/* シールドピンチ時（JSからクラスが付与される） */
.shield-critical {
    background: linear-gradient(90deg, rgba(255, 51, 51, 0.4), rgb(255, 51, 51)) !important;
}

@keyframes smooth-pulse {
    from { 
        opacity: 1; 
        box-shadow: 0 0 calc(10px * var(--hud-scale, 1)) rgb(255, 51, 51); 
    }
    to { 
        opacity: 0.4; 
        box-shadow: 0 0 calc(2px * var(--hud-scale, 1)) rgb(255, 51, 51); 
    }
}

/* =========================================================
   4. ゲーム中メッセージ
   ========================================================= */
#game-message-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    pointer-events: none;

    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;

    padding: 20px 24px 24vh;
    box-sizing: border-box;

    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);

    transition:
        opacity 0.45s ease,
        visibility 0.45s ease,
        transform 0.45s ease;
}

#game-message-overlay.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#game-message-kicker {
    margin-bottom: 8px;
    color: var(--msg-sub-color, rgba(235, 245, 255, 0.88));
    font-size: clamp(11px, 1.4vw, 15px);
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(0,255,255,0.18);

    opacity: 0;
    transform: translateY(10px);
    transition:
        opacity 0.35s ease 0.05s,
        transform 0.35s ease 0.05s;
}

#game-message-main {
    color: var(--msg-main-color, #fff);
    font-size: clamp(24px, 5vw, 42px);
    font-weight: 900;
    line-height: 1.08;
    letter-spacing: 0.10em;
    text-indent: 0.10em;
    text-shadow:
        0 0 15px var(--msg-glow-color, #0ff),
        0 0 30px var(--msg-glow-color, #0ff),
        0 0 60px var(--msg-glow-color, #0ff);
    white-space: pre-wrap;

    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transition:
        opacity 0.42s ease 0.08s,
        transform 0.42s ease 0.08s;
}

#game-message-sub {
    margin-top: 10px;
    color: var(--msg-sub-color, rgba(235, 245, 255, 0.82));
    font-size: clamp(11px, 2.1vw, 16px);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-indent: 0.16em;
    line-height: 1.4;
    text-shadow:
        0 0 8px rgba(255,255,255,0.22),
        0 0 18px rgba(0,255,255,0.16);

    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity 0.38s ease 0.16s,
        transform 0.38s ease 0.16s;
}

#game-message-overlay.show #game-message-kicker,
#game-message-overlay.show #game-message-main,
#game-message-overlay.show #game-message-sub {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#game-message-overlay.warning #game-message-main {
    color: #ff1f1f;
    text-shadow:
        0 0 5px rgba(255,0,0,1),      /* 1層目：ごく近くを強く光らせて輪郭を出す */
        0 0 15px rgba(255,0,0,0.7),   /* 2層目：少し広げる */
        0 0 30px rgba(255,40,40,0.4); /* 3層目：薄く遠くに配置 */
    animation: blink 1.0s infinite;
    font-weight: bold;                /* 文字自体を太くするのも効果的 */
}

#game-message-overlay.warning #game-message-kicker,
#game-message-overlay.warning #game-message-sub {
    color: rgba(255, 110, 110, 0.9);
}

#game-message-overlay.gold #game-message-main {
    color: #ffd700;
    text-shadow:
        0 0 12px rgba(255,215,0,0.7),
        0 0 28px rgba(255,170,0,0.45),
        0 0 56px rgba(255,170,0,0.25);
}

#game-message-overlay.compact {
    justify-content: flex-start;
    padding-top: 14vh;
    padding-bottom: 0;
}

#game-message-overlay.epic-clear #game-message-main,
#game-message-overlay.epic-clear #game-message-sub,
#game-message-overlay.epic-clear #game-message-kicker {
    transition:
        opacity 6s ease-out,
        transform 6s ease-out;
}

#game-message-overlay.epic-clear #game-message-main {
    color: #ffd700;
    text-shadow:
        0 0 12px rgba(255,215,0,0.78),
        0 0 28px rgba(255,170,0,0.52),
        0 0 56px rgba(255,170,0,0.30);
}

#game-message-overlay.epic-clear:not(.show) #game-message-kicker,
#game-message-overlay.epic-clear:not(.show) #game-message-main,
#game-message-overlay.epic-clear:not(.show) #game-message-sub {
    opacity: 0;
    transform: translateY(80px) scale(0.97);
}

#game-message-overlay.epic-clear.show #game-message-kicker,
#game-message-overlay.epic-clear.show #game-message-main,
#game-message-overlay.epic-clear.show #game-message-sub {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#game-message-overlay.story-fade {
    transition:
        opacity 1s ease,
        visibility 1s ease,
        transform 1s ease;
}



/* =========================================================
   6. ミニマップ
   ========================================================= */
#minimap-container {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin-top: calc(5px * var(--hud-scale));
    width: calc(100px * var(--hud-scale));
    height: calc(100px * var(--hud-scale));
    border: 1px solid rgba(0, 255, 255, 0.5);
    background: rgba(0, 10, 20, 0.6);
    backdrop-filter: blur(2px);
    z-index: 30;
    pointer-events: none;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================
   7. 操作コントローラー
   ========================================================= */
#controls {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    display: none;
    touch-action: none;
    pointer-events: auto;
}

.joystick-area {
    position: absolute;
    width: calc(144px * var(--ui-scale, 1));
    height: calc(140px * var(--ui-scale, 1));
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 255, 0.3);
    background: radial-gradient(circle, rgba(0, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.2) 70%);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.1), inset 0 0 10px rgba(0, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.joystick-area::before,
.joystick-area::after {
    content: '';
    position: absolute;
    background: rgba(0, 255, 255, 0.2);
}

.joystick-area::before {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.2), transparent);
}

.joystick-area::after {
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(0, 255, 255, 0.2), transparent);
}

.knob {
    width: calc(60px * var(--ui-scale, 1));
    height: calc(60px * var(--ui-scale, 1));
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.15);
    border: 2px solid #0ff;
    position: absolute;
    transform: translate(0, 0);
    transition: transform 0.05s;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    z-index: 2;
}

.knob::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(10px * var(--ui-scale, 1));
    height: calc(10px * var(--ui-scale, 1));
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #fff;
}

#launch-btn {
    position: absolute;
    width: calc(60px * var(--ui-scale, 1));
    height: calc(60px * var(--ui-scale, 1));
    right: calc(15px * var(--ui-scale, 1));
    bottom: calc(155px * var(--ui-scale, 1));
    border-radius: 50%;
    background: rgba(255, 255, 0, 0.1);
    border: 2px solid #ff0;
    color: #ff0;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: calc(11px * var(--ui-scale, 1));
    letter-spacing: calc(1px * var(--ui-scale, 1));
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.3), inset 0 0 10px rgba(255, 255, 0, 0.2);
    pointer-events: auto;
    text-shadow: 0 0 5px #ff0;
    z-index: 100;
    box-sizing: border-box;
}

#launch-btn::before {
    content: '';
    position: absolute;
    width: calc(70px * var(--ui-scale, 1));
    height: calc(70px * var(--ui-scale, 1));
    border: 1px dashed rgba(255, 255, 0, 0.4);
    border-radius: 50%;
    animation: rotate 4s linear infinite;
    box-sizing: border-box;
}

#launch-btn.active {
    background: #ff0;
    color: #000;
    transform: scale(0.85);
    box-shadow: 0 0 30px #ff0;
    text-shadow: none;
}

#stick-left {
    left: calc(10px * var(--ui-scale, 1));
    bottom: calc(10px * var(--ui-scale, 1));
}

#stick-right {
    right: calc(10px * var(--ui-scale, 1));
    bottom: calc(10px * var(--ui-scale, 1));
}

/* =========================================================
   8. 共通ボタン類
   ========================================================= */
.menu-btn {
    /* サイズと基本レイアウト */
    min-width: min(78vw, 320px);
    padding: 12px 20px;
    box-sizing: border-box;

    /* ★文字をセンターに配置するための重要設定 */
    display: flex;
    justify-content: center;  /* 左右中央 */
    align-items: center;      /* 上下中央 */
    text-align: center;       /* 複数行になった場合の保険 */

    /* フォント設定 */
    font-family: 'Orbitron', monospace;
    font-size: clamp(14px, 1.3vw, 17px);
    font-weight: 700;
    letter-spacing: 0.16em;
    /* letter-spacingを入れると右に寄るため、同じ分だけ左パディングを微調整 */
    text-indent: 0.16em; 

    color: #d9ffff;
    text-transform: uppercase;
    
    /* 背景と境界線 */
    background: linear-gradient(
        to bottom,
        rgba(8, 24, 32, 0.76),
        rgba(4, 12, 20, 0.88)
    );
    border: 1px solid rgba(120, 255, 255, 0.20);
    border-radius: 4px; /* シャープな幾何学デザインに変更 */
    
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.08);
}


/* ホバー・選択時の強調 */
.menu-btn:hover, .menu-btn.selected {
    background: linear-gradient(
        to bottom,
        rgba(12, 44, 56, 0.9),
        rgba(6, 22, 32, 1.0)
    );
    border-color: #0ff;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.3),
        inset 0 0 15px rgba(0, 255, 255, 0.1);
}

/* クリック（アクティブ）時 */
.menu-btn:active {
    transform: scale(0.96);
    filter: brightness(1.2);
}

.menu-btn.selected,
.track-item.selected {
    color: #fff !important;
    transform: scale(1.05);
    border-color: #fff !important;
}

.btn-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-top: 14px;
    flex-wrap: nowrap;
}

/* 小さなボタン（BACK, NEXTなど）用 */
.menu-btn.btn-small {
    min-width: 140px;
    padding: 8px 16px;
    font-size: 13px;
}

/* 特殊：提出・決定ボタン（ゴールド） */
#submit-score-btn {
    border-color: rgba(255, 215, 0, 0.5);
    color: #ffd700;
}
#submit-score-btn:hover {
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* 特殊：キャンセル・スキップボタン（グレー） */
#skip-score-btn, #btn-back, #btn-howto-back, #close-ranking-btn {
    border-color: rgba(255, 255, 255, 0.2);
    color: #aaa;
}

/* ---------- ポーズボタン ---------- */
#pause-btn {
    position: absolute;
    right: calc(30px * var(--ui-scale, 1));
    bottom: calc(240px * var(--ui-scale, 1));
    width: calc(40px * var(--ui-scale, 1));
    height: calc(40px * var(--ui-scale, 1));
    font-size: calc(18px * var(--ui-scale, 1));
    background: rgba(0, 20, 40, 0.8);
    border: 2px solid rgba(0, 255, 255, 0.5);
    color: #0ff;
    font-weight: bold;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    pointer-events: auto;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
    box-sizing: border-box;
}

/* ---------- フッター ---------- */
#menu-footer {
    margin-top: 18px;
    text-align: center;
    color: #7f8d96;
    font-size: clamp(11px, 0.95vw, 13px);
    line-height: 1.7;
    letter-spacing: 0.04em;
    position: relative;
    z-index: 2;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.06);
}

/* =========================================================
   9. 各種オーバーレイ画面
   ========================================================= */
/* ---------- 9.2 ポーズ画面 ---------- */
#pause-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 105;
    pointer-events: auto;
}

#pause-overlay h1 {
    color: #fff;
    text-shadow: 0 0 10px #fff;
    font-size: calc(40px * var(--ui-scale, 1)) !important;
    margin-bottom: calc(30px * var(--ui-scale, 1)) !important;
}

/* ---------- 9.4 名前入力画面 ---------- */
#name-input-area {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 220;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px 20px;
    box-sizing: border-box;
    pointer-events: auto;
    background:
        radial-gradient(circle at 50% 35%,
            rgba(0, 180, 255, 0.10) 0%,
            rgba(0, 0, 0, 0.20) 30%,
            rgba(0, 0, 0, 0.72) 68%,
            rgba(0, 0, 0, 0.92) 100%);
}

#name-input-area::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to bottom,
            rgba(255,255,255,0.03) 0%,
            rgba(255,255,255,0.00) 16%,
            rgba(0,255,255,0.03) 52%,
            rgba(0,0,0,0.12) 100%);
    mix-blend-mode: screen;
}

#name-input-area > * {
    position: relative;
    z-index: 1;
}

#name-input-area p {
    margin: 0 0 16px 0;
    text-align: center;
    color: #9fefff;
    font-size: clamp(14px, 1.2vw, 18px);
    line-height: 1.8;
    letter-spacing: 0.06em;
    text-shadow: 0 0 8px rgba(0,255,255,0.18);
}

#result-score-display {
    /* ▼ 確実な中央揃えのためのFlex指定とボックス計算の修正 */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: min(90vw, 460px);
    margin: 0 auto 20px;
    
    /* ▼ 左側にletter-spacingと同じ分の余白を足して視覚的中心を合わせる */
    padding: 16px 18px;
    padding-left: calc(18px + 0.08em);
    
    text-align: center;
    color: #fff;
    font-size: clamp(22px, 2.5vw, 34px);
    font-weight: 700;
    letter-spacing: 0.08em;
    background:
        linear-gradient(
            to bottom,
            rgba(10, 24, 34, 0.76),
            rgba(4, 10, 18, 0.92)
        );
    border-top: 1px solid rgba(120,255,255,0.28);
    border-bottom: 1px solid rgba(120,255,255,0.28);
    box-shadow:
        0 0 18px rgba(0,255,255,0.08),
        inset 0 0 16px rgba(120,255,255,0.04);
    text-shadow:
        0 0 8px rgba(255,255,255,0.28),
        0 0 16px rgba(0,255,255,0.16);
}

#player-name-input {
    display: block;
    width: min(90vw, 320px);
    background: rgba(0, 0, 0, 0.76);
    border: 1px solid rgba(120,255,255,0.58);
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: clamp(18px, 2vw, 24px);
    padding: 12px 14px;
    text-align: center;
    outline: none;
    margin: 0 auto 16px;
    box-sizing: border-box;
    box-shadow:
        0 0 12px rgba(0,255,255,0.16),
        inset 0 0 8px rgba(120,255,255,0.05);
}

#player-name-input::placeholder {
    color: #477;
}


/* =========================================================
   10. デバッグオーバーレイ
   ========================================================= */
#debugOverlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 9999;
    min-width: 150px;
    max-width: 360px;
    color: #00ffff;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.45;
    background: rgba(0, 0, 0, 0.80);
    border: 1px solid rgba(0, 255, 255, 0.85);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.18);
    white-space: pre-wrap;
    pointer-events: none;
    display: none;
}

/* =========================================================
   11. レスポンシブ設定
   - 通常 / portrait / landscape のみ
   ========================================================= */
@media (orientation: portrait) {

    #ui {
        padding: 12px 8px;
    }

    .hud-row {
        padding: 0 4px;
    }

    #game-message-overlay {
        padding: 16px 20px 27vh;
    }

    #game-message-kicker {
        font-size: clamp(8px, 2.2vw, 11px);
        letter-spacing: 0.22em;
    }

    #game-message-main {
        font-size: clamp(20px, 7vw, 34px);
        letter-spacing: 0.08em;
        text-indent: 0.08em;
        line-height: 1.1;
    }

    #game-message-sub {
        font-size: clamp(10px, 3.2vw, 14px);
        letter-spacing: 0.12em;
        text-indent: 0.12em;
        margin-top: 8px;
    }

    #game-message-overlay.compact {
        padding-top: 12vh;
    }



    #stick-left {
        left: calc(10px * var(--ui-scale, 1));
        bottom: calc(50px * var(--ui-scale, 1));
    }

    #stick-right {
        right: calc(10px * var(--ui-scale, 1));
        bottom: calc(50px * var(--ui-scale, 1));
    }

    #launch-btn {
        right: calc(5px * var(--ui-scale, 1));
        bottom: calc(220px * var(--ui-scale, 1));
    }

    #minimap-container {
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0;
    }

    #pause-btn {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        bottom: 15px;
    }

    #pause-btn:active {
        transform: translateX(-50%) scale(0.9);
    }

    #title-shell {
        min-width: 92vw;
        padding: 16px 10px 10px;
    }

    .btn-row {
        gap: 20px;
    }
    .menu-btn {
        min-width: 60vw;
    }

    .btn-small {
        min-width: 0;
        width: calc((100vw - 48px) / 2);
        max-width: 150px;
    }
}

@media (orientation: landscape) {
    #game-message-overlay {
        padding: 18px 28px 18vh;
    }

    #game-message-kicker {
        font-size: clamp(10px, 0.95vw, 13px);
    }

    #game-message-main {
        font-size: clamp(22px, 3vw, 42px);
        letter-spacing: 0.11em;
        text-indent: 0.11em;
    }

    #game-message-sub {
        font-size: clamp(10px, 1vw, 14px);
        letter-spacing: 0.14em;
        text-indent: 0.14em;
    }

    #game-message-overlay.compact {
        padding-top: 11vh;
    }


    #title-shell {
        margin-bottom: 20px;
        padding-top: 12px;
    }

    #menu-buttons-container {
        gap: 10px;
    }

    .menu-btn {
        min-width: min(46vw, 220px);
        padding: 10px 18px;
    }

    #menu-footer {
        margin-top: 16px;
    }

    #training-guide {
        padding-top: 25vh !important;
    }

    #btn-training-exit {
        position: absolute !important;
        bottom: 20px !important;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0 !important;
        background: rgba(0, 0, 0, 0.9) !important;
    }
}

/* =========================================================
   12. アニメーション
   ========================================================= */
@keyframes blink {
    50% {
        opacity: 0.5;
    }
}

@keyframes blink-anim {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

@keyframes clear-glow {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.8) scale(1.02);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        bottom: -100px;
        opacity: 0;
    }
    to {
        bottom: 20px;
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(5px);
    }
}

@keyframes ending-button-pulse {
    0%, 100% {
        opacity: 0.72;
        box-shadow:
            0 0 10px rgba(0, 255, 200, 0.12),
            inset 0 0 10px rgba(120, 255, 230, 0.05);
    }
    50% {
        opacity: 1;
        box-shadow:
            0 0 22px rgba(0, 255, 200, 0.28),
            inset 0 0 14px rgba(120, 255, 230, 0.10);
    }
}

@keyframes titlePulse {
    0%, 100% {
        text-shadow:
            0 0 8px rgba(180, 255, 255, 0.65),
            0 0 18px rgba(0, 255, 255, 0.50),
            0 0 42px rgba(0, 170, 255, 0.42),
            0 0 80px rgba(0, 90, 255, 0.22);
    }
    50% {
        text-shadow:
            0 0 12px rgba(220, 255, 255, 0.82),
            0 0 26px rgba(0, 255, 255, 0.62),
            0 0 56px rgba(0, 170, 255, 0.54),
            0 0 110px rgba(0, 90, 255, 0.30);
    }
}

@keyframes scanSweep {
    0%, 100% {
        transform: translate(-50%, -50%) scaleX(0.72);
        opacity: 0.30;
    }
    50% {
        transform: translate(-50%, -50%) scaleX(1);
        opacity: 0.95;
    }
}

/* =========================================================
   13. iOS インストールプロンプト
   ========================================================= */
#ios-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 350px;
    background: rgba(0, 10, 20, 0.95);
    border: 1px solid #0ff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
    padding: 15px;
    border-radius: 10px;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    animation: slideUp 0.5s ease-out;
}

.install-text {
    color: #fff;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.share-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid #fff;
    border-top: none;
    position: relative;
    margin: 0 2px;
}

.share-icon::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 8px;
    background: #fff;
}

.share-icon::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 4px;
    height: 4px;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
}

.arrow-down {
    color: #0ff;
    font-size: 16px;
    animation: bounce 1.5s infinite;
}

.close-btn {
    position: absolute;
    top: 5px;
    right: 10px;
    color: #555;
    font-size: 20px;
    cursor: pointer;
}

/* =========================================================
   14. ストーリー画面の言語切り替え
   ========================================================= */
.lang-ja .en-text {
    display: none !important;
}

.lang-en .ja-text {
    display: none !important;
}


/* =========================================================
   FPS表示UI (画面中央上部タップ用)
   ========================================================= */
#simple-fps-zone {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 50px;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* タッチ時の青枠を消す */
}

#simple-fps-text {
    color: #0ff;
    font-family: 'Orbitron', monospace;
    font-size: calc(14px * var(--ui-scale, 1));
    font-weight: 700;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.8);
    pointer-events: none; /* タッチ判定はzoneに任せる */
    transition: opacity 0.2s ease;
}