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

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: #0b0c10;
    color: #c5c6c7;
    font-family: 'Outfit', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 800px;
    aspect-ratio: 1 / 1;
    background: #1f2833;
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(102, 252, 241, 0.2);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    /* コンテナに合わせて伸縮 */
    height: 100%;
    /* コンテナに合わせて伸縮 */
    border-radius: 12px;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 30px;
    background: linear-gradient(to bottom, rgba(11, 12, 16, 0.95) 0%, transparent 100%);
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 0 10px rgba(102, 252, 241, 0.5);
    margin-bottom: 5px;
}

.logo span {
    color: #66fcf1;
}

.fuel-container {
    width: 300px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.fuel-container .label {
    font-size: 14px;
    font-family: 'Press Start 2P', monospace;
    color: #ff4c4c;
    text-shadow: 0 0 5px rgba(255, 76, 76, 0.5);
}

.fuel-bar-wrap {
    flex-grow: 1;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #ff4c4c;
    border-radius: 4px;
    overflow: hidden;
}

.fuel-bar-inner {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff4c4c, #ffa62b);
    transition: width 0.1s linear, background-color 0.3s;
}

.stat-box {
    text-align: left;
}

.speed-box {
    text-align: right;
}

.stat-box .label {
    display: block;
    font-size: 10px;
    color: #45a29e;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.stat-box .value {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: #66fcf1;
    text-shadow: 0 0 8px rgba(102, 252, 241, 0.4);
}

.stat-box .unit {
    font-size: 10px;
    color: #c5c6c7;
    font-family: 'Outfit', sans-serif;
}

/* --- KABUKI MODE インジケーター（無敵カウントダウン） --- */
.kabuki-indicator {
    position: absolute;
    top: 75px;
    /* ヘッダーの直下あたり */
    left: 50%;
    transform: translateX(-50%);
    display: none;
    /* 通常時は非表示 */
    flex-direction: column;
    align-items: center;
    background: rgba(255, 215, 0, 0.2);
    border: 3px solid #ffd700;
    padding: 10px 30px;
    border-radius: 12px;
    box-shadow: 0 0 20px #ffd700, inset 0 0 10px #ffd700;
    animation: flash 1s infinite alternate;
    pointer-events: none;
    /* タップの邪魔にならないように */
}

@keyframes flash {
    from {
        opacity: 0.8;
        box-shadow: 0 0 10px #ffd700;
    }

    to {
        opacity: 1;
        box-shadow: 0 0 30px #ffd700;
    }
}

.kabuki-indicator.active {
    display: flex;
    /* 発動中のみ表示 */
}

.kabuki-label {
    font-size: 14px;
    font-family: 'Press Start 2P', monospace;
    color: #fff;
    text-shadow: 0 0 10px #ffd700;
}

.kabuki-value {
    font-size: 40px;
    font-family: 'Press Start 2P', monospace;
    color: #fff;
    text-shadow: 0 0 15px #ff5500;
}

.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(11, 12, 16, 0.9);
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #45a29e;
    box-shadow: 0 0 30px rgba(31, 40, 51, 0.9);
    pointer-events: auto;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    backdrop-filter: blur(5px);
}

.overlay.active {
    display: flex;
}

.overlay h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 28px;
    color: #fff;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}

.overlay p {
    color: #c5c6c7;
    font-size: 14px;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
}

.item .color.enemy {
    color: #ff0055;
    text-shadow: 0 0 5px #ff0055;
    font-size: 20px;
}

.item .color.energy {
    color: #4cd137;
    text-shadow: 0 0 5px #4cd137;
    font-size: 20px;
}

.glow-btn {
    background: transparent;
    color: #66fcf1;
    border: 2px solid #66fcf1;
    padding: 10px 24px;
    font-size: 16px;
    font-family: 'Press Start 2P', monospace;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 5px;
}

.glow-btn:hover {
    background: #66fcf1;
    color: #0b0c10;
    box-shadow: 0 0 20px rgba(102, 252, 241, 0.6);
}

.title-red {
    color: #ff4c4c !important;
    text-shadow: 0 0 20px rgba(255, 76, 76, 0.6) !important;
}

/* 黄色基調のタイトルとボタン */
.title-yellow {
    color: #ffd700 !important;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6) !important;
    font-size: 40px !important;
}

.yellow-btn {
    color: #ffd700;
    border-color: #ffd700;
}

.yellow-btn:hover {
    background: #ffd700;
    color: #0b0c10;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

/* --- バーチャルパッド（タッチ操作用ボタン） --- */
#virtual-gamepad {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 50;
}

.pad-group {
    pointer-events: auto;
    display: flex;
    gap: 15px;
}

.pad-group.vertical {
    flex-direction: column;
}

.pad-group.horizontal {
    flex-direction: row;
}

.btn-ctrl {
    background: rgba(102, 252, 241, 0.1);
    border: 2px solid rgba(102, 252, 241, 0.6);
    color: #66fcf1;
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    backdrop-filter: blur(5px);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(102, 252, 241, 0.2);
}

.btn-ctrl.wide {
    width: 80px;
    height: 60px;
    font-size: 14px;
    border-radius: 12px;
}

.btn-ctrl:active {
    background: rgba(102, 252, 241, 0.5);
    transform: scale(0.95);
}

/* スマホ表示向けのUI縮小調整 */
@media (max-width: 600px) {
    .header {
        padding: 8px 5px;
        /* 左右の余白を極力詰める */
    }

    .stat-box .label {
        font-size: 8px;
        /* ラベルも少し小さく */
    }

    .stat-box .value {
        font-size: 12px;
        /* 7桁になったので14pxから少し縮小 */
    }

    .stat-box .unit {
        font-size: 9px;
    }

    .logo {
        font-size: 12px;
        /* 14pxから少し縮小 */
    }

    .fuel-container {
        width: 180px;
        /* 140pxより広げつつ、横はみ出しを防ぐベスト幅 */
        gap: 5px;
    }

    .fuel-container .label {
        font-size: 10px;
        /* 14pxから縮小してバーの領域を確保 */
    }

    /* スマホ時のMUTEKIカウントダウン縮小 */
    .kabuki-indicator {
        top: 55px;
        padding: 5px 20px;
    }

    .kabuki-label {
        font-size: 10px;
    }

    .kabuki-value {
        font-size: 28px;
    }

    .overlay h2 {
        font-size: 20px;
    }

    .title-red,
    .title-yellow {
        font-size: 30px !important;
    }
}