/* リセットと基本設定 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #080915;
    color: #e2e8f0;
    font-family: 'Rajdhani', 'Inter', sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* グリッドスクロール背景 */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(18, 24, 48, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 24, 48, 0.3) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center top;
    z-index: -1;
    pointer-events: none;
    animation: gridScroll 20s linear infinite;
}

@keyframes gridScroll {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 800px;
    }
}

/* アプリケーションコンテナ */
#app-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* ヘッダーとネオンテキスト */
header {
    margin-bottom: 20px;
    text-align: center;
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 10px;
}

.neon-text-blue {
    color: #00f0ff;
    text-shadow: 
        0 0 5px rgba(0, 240, 255, 0.5),
        0 0 10px rgba(0, 240, 255, 0.5),
        0 0 20px rgba(0, 240, 255, 0.8),
        0 0 40px rgba(0, 240, 255, 0.9);
}

.neon-text-pink {
    color: #ff007f;
    text-shadow: 
        0 0 5px rgba(255, 0, 127, 0.5),
        0 0 10px rgba(255, 0, 127, 0.5),
        0 0 20px rgba(255, 0, 127, 0.8),
        0 0 40px rgba(255, 0, 127, 0.9);
}

.neon-text-purple {
    color: #bd00ff;
    text-shadow: 
        0 0 5px rgba(189, 0, 255, 0.5),
        0 0 10px rgba(189, 0, 255, 0.5),
        0 0 20px rgba(189, 0, 255, 0.8);
}

.neon-text-red {
    color: #ff003c;
    text-shadow: 
        0 0 5px rgba(255, 0, 60, 0.5),
        0 0 10px rgba(255, 0, 60, 0.5),
        0 0 20px rgba(255, 0, 60, 0.8),
        0 0 40px rgba(255, 0, 60, 0.9);
}

.neon-text-cyan {
    color: #00ffff;
    text-shadow: 
        0 0 5px rgba(0, 255, 255, 0.5),
        0 0 10px rgba(0, 255, 255, 0.8);
}

/* ゲームエリア */
#game-area {
    position: relative;
    width: 100%;
    background: rgba(10, 12, 28, 0.85);
    border: 2px solid #1a1f3c;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.8),
        inset 0 0 15px rgba(26, 31, 60, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* HUD パネル */
.hud-panel {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 500px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(18, 22, 47, 0.6);
    border: 1px solid #232b5c;
    border-radius: 8px;
}

.hud-pause-btn {
    background: transparent;
    border: 1px solid #00f0ff;
    color: #00f0ff;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 240, 255, 0.2);
    transition: all 0.2s ease;
    align-self: center;
    line-height: 1;
}

.hud-pause-btn:hover {
    background: rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.hud-item {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.hud-label {
    color: #64748b;
    margin-right: 8px;
}

.hud-val {
    font-weight: 700;
}

/* Canvas ラッパー */
.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #00f0ff;
    box-shadow: 
        0 0 10px rgba(0, 240, 255, 0.3),
        inset 0 0 10px rgba(0, 240, 255, 0.2);
    margin-bottom: 15px;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    background-color: #060713;
}

/* オーバーレイスクリーン (難易度選択やゲームオーバー画面) */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 7, 19, 0.93);
    backdrop-filter: blur(8px);
    z-index: 10;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
}

.overlay-screen.active {
    display: flex;
}

.overlay-screen h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    letter-spacing: 2px;
    margin-bottom: 30px;
}

/* ボタンのデザイン */
.difficulty-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    padding: 12px 28px;
    font-size: 1rem;
    background: transparent;
    border: 2px solid;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.neon-btn-cyan {
    color: #00f0ff;
    border-color: #00f0ff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.neon-btn-cyan:hover {
    background: #00f0ff;
    color: #05050a;
    box-shadow: 
        0 0 20px rgba(0, 240, 255, 0.6),
        0 0 40px rgba(0, 240, 255, 0.4);
}

.neon-btn-pink {
    color: #ff007f;
    border-color: #ff007f;
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.2);
}

.neon-btn-pink:hover {
    background: #ff007f;
    color: #05050a;
    box-shadow: 
        0 0 20px rgba(255, 0, 127, 0.6),
        0 0 40px rgba(255, 0, 127, 0.4);
}

.neon-btn-purple {
    color: #bd00ff;
    border-color: #bd00ff;
    box-shadow: 0 0 10px rgba(189, 0, 255, 0.2);
}

.neon-btn-purple:hover {
    background: #bd00ff;
    color: #05050a;
    box-shadow: 
        0 0 20px rgba(189, 0, 255, 0.6),
        0 0 40px rgba(189, 0, 255, 0.4);
}

.instructions {
    max-width: 520px;
    line-height: 1.6;
    color: #94a3b8;
    font-size: 0.95rem;
    border-top: 1px solid #1a203c;
    padding-top: 20px;
}

.instructions p {
    margin-bottom: 8px;
}

.item-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #1a203c;
}

.legend-badge-wrapper {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.legend-badge {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 20px;
    text-align: center;
    border: 1px solid;
    border-radius: 50%;
    font-size: 0.8rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    margin-right: 6px;
    background: rgba(6, 7, 19, 0.6);
}

/* 結果画面のテキスト */
.final-score-text {
    font-size: 1.5rem;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

/* コントロールパネル (アクションボタン) */
.control-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    padding: 10px 20px;
    background: rgba(18, 22, 47, 0.4);
    border: 1px solid #1e264f;
    border-radius: 8px;
}

.neon-btn-action {
    color: #39ff14;
    border-color: #39ff14;
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.1);
    min-width: 220px;
    position: relative;
    overflow: hidden;
}

.neon-btn-action:not(.disabled):hover {
    background: #39ff14;
    color: #05050a;
    box-shadow: 
        0 0 15px rgba(57, 255, 20, 0.5),
        0 0 30px rgba(57, 255, 20, 0.3);
}

.neon-btn-action.disabled {
    color: #475569;
    border-color: #334155;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.5;
}

/* 活性時のパルスアニメーション */
.neon-btn-action.active-ready {
    animation: neonPulse 1.5s infinite;
}

@keyframes neonPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(57, 255, 20, 0.3);
        background: rgba(57, 255, 20, 0.05);
    }
    50% {
        box-shadow: 
            0 0 20px rgba(57, 255, 20, 0.7),
            0 0 35px rgba(57, 255, 20, 0.4);
        background: rgba(57, 255, 20, 0.15);
    }
}

/* スマホ用タッチ操作パネル */
#touch-control-area {
    display: none; /* デフォルト非表示 */
    width: 100%;
    max-width: 500px;
    height: 100px;
    background: rgba(0, 240, 255, 0.03);
    border: 1px dashed rgba(0, 240, 255, 0.25);
    border-radius: 8px;
    margin-top: 15px;
    position: relative;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: none; /* ブラウザのスクロールやズームを防止 */
    cursor: pointer;
}

#touch-control-area:active {
    background: rgba(0, 240, 255, 0.08);
    border-style: solid;
}

.touch-hint {
    font-size: 0.95rem;
    color: rgba(0, 240, 255, 0.45);
    letter-spacing: 2px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    pointer-events: none;
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.2);
}

/* タッチデバイスまたは狭い幅のときに表示 */
@media (max-width: 768px), (pointer: coarse) {
    #touch-control-area {
        display: flex;
    }
}

/* フィーバーモード時のゲームエリア枠線フラッシュ */
#game-area.fever-mode {
    border-color: #fffb00;
    box-shadow: 
        0 0 25px rgba(255, 251, 0, 0.6),
        inset 0 0 25px rgba(255, 251, 0, 0.3);
    animation: feverAreaGlow 0.5s linear infinite alternate;
}

@keyframes feverAreaGlow {
    0% {
        border-color: #fffb00;
        box-shadow: 
            0 0 15px rgba(255, 251, 0, 0.4),
            inset 0 0 15px rgba(255, 251, 0, 0.2);
    }
    100% {
        border-color: #ff007f;
        box-shadow: 
            0 0 30px rgba(255, 0, 127, 0.8),
            inset 0 0 20px rgba(255, 0, 127, 0.4);
    }
}

/* フッター */
footer {
    margin-top: 20px;
    text-align: center;
    color: #475569;
    font-size: 0.85rem;
}

/* ライフUP時のHUD拡大発光エフェクト */
.hud-val-glow {
    display: inline-block;
    animation: hudLivesGlow 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes hudLivesGlow {
    0% {
        transform: scale(1);
        color: #ff007f;
        text-shadow: 0 0 5px rgba(255, 0, 127, 0.5);
    }
    20% {
        transform: scale(1.6);
        color: #ffffff;
        text-shadow: 
            0 0 10px #ff007f,
            0 0 25px #ff007f,
            0 0 40px #ff007f;
    }
    100% {
        transform: scale(1);
        color: #ff007f;
        text-shadow: 
            0 0 5px rgba(255, 0, 127, 0.5),
            0 0 10px rgba(255, 0, 127, 0.5);
    }
}
