/* ================================
   くらげの海防衛戦 - スタイルシート
   ================================ */

:root {
    --primary: #38bdf8;
    --primary-dark: #0284c7;
    --secondary: #f0abfc;
    --danger: #ef4444;
    --success: #22c55e;
    --ice: #a78bfa;
    --fire: #fb7185;

    --bg-dark: #0c1929;
    --bg-card: rgba(20, 50, 80, 0.8);
    --bg-glass: rgba(56, 189, 248, 0.1);

    --text-primary: #ffffff;
    --text-secondary: #7dd3fc;

    --border-glow: rgba(56, 189, 248, 0.5);
    --shadow-glow: 0 0 30px rgba(56, 189, 248, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* タッチデバイスでのスクロール改善 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at top, rgba(56, 189, 248, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='1' fill='rgba(255,255,255,0.05)'/%3E%3C/svg%3E");
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* 泡のアニメーション背景 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 10% 80%, rgba(56, 189, 248, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 90% 20%, rgba(168, 85, 247, 0.1) 0%, transparent 30%);
    pointer-events: none;
    z-index: -1;
}

/* ================================
   ゲームコンテナ
   ================================ */

.game-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ================================
   ヘッダー
   ================================ */

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    margin-bottom: 10px;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.game-header h1 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(56, 189, 248, 0.5);
}

.stats {
    display: flex;
    gap: 30px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
}

/* ================================
   メインエリア
   ================================ */

.game-main {
    display: flex;
    gap: 15px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ================================
   ゲームボード
   ================================ */

.game-board-wrapper {
    position: relative;
    flex: 1;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    overflow: hidden;
}

.ingame-stats {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 20px;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 12px;
    border: 2px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.ingame-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ingame-stat-icon {
    font-size: 1.3rem;
}

.ingame-stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #38bdf8;
    min-width: 50px;
    text-align: left;
}

.wave-control {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

/* ゲーム内コントロールボタン */
.game-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 100;
}

.game-control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border: 2px solid;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    min-width: 100px;
}

.game-control-btn .btn-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.game-control-btn .btn-label {
    font-size: 14px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.evolution-btn {
    border-color: rgba(168, 85, 247, 0.6);
}

.evolution-btn:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(147, 51, 234, 0.3));
    border-color: rgba(168, 85, 247, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4);
}

.training-btn {
    border-color: rgba(59, 130, 246, 0.6);
}

.training-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(37, 99, 235, 0.3));
    border-color: rgba(59, 130, 246, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.economy-btn {
    border-color: rgba(251, 191, 36, 0.6);
}

.economy-btn:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.3));
    border-color: rgba(251, 191, 36, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.4);
}

.game-control-btn:active {
    transform: translateY(0);
}

/* 音量コントロール */
.volume-control {
    position: absolute;
    bottom: 100px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 2px solid rgba(56, 189, 248, 0.3);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    font-size: 0.8rem;
    z-index: 99;
}

.volume-control label {
    color: var(--text-secondary);
    white-space: nowrap;
}

.volume-control input[type="range"] {
    width: 80px;
    height: 5px;
    background: rgba(56, 189, 248, 0.2);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.5);
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.5);
}

.volume-control input[type="range"]:hover::-webkit-slider-thumb {
    box-shadow: 0 3px 10px rgba(56, 189, 248, 0.7);
    transform: scale(1.1);
}

.volume-control input[type="range"]:hover::-moz-range-thumb {
    box-shadow: 0 3px 10px rgba(56, 189, 248, 0.7);
    transform: scale(1.1);
}

.volume-control #volumeValue {
    color: var(--text-primary);
    font-weight: bold;
    min-width: 35px;
    text-align: right;
}

/* ボーナス表示 */
.bonus-display {
    position: absolute;
    bottom: 60px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 165, 0, 0.15));
    border: 1.5px solid rgba(255, 215, 0, 0.5);
    border-radius: 6px;
    backdrop-filter: blur(10px);
    font-size: 0.75rem;
    z-index: 99;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.bonus-icon {
    font-size: 1rem;
}

.bonus-text {
    color: #ffd700;
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.75rem;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    /* タッチデバイス対応 */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.game-overlay {
    /* タイトル/リザルト表示中はヘッダーやパネルも含めて画面全体を覆う */
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgb(12, 25, 41);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
}

.overlay-content.hidden {
    display: none !important;
}

.overlay-content h2 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-content p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.wave-selector {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.wave-selector label {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.wave-selector select {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    padding: 10px 20px;
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 2px solid var(--border-glow);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.wave-selector select:hover {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.15);
}

.wave-selector select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 20px rgba(240, 171, 252, 0.3);
}

.btn-start {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 15px 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(56, 189, 248, 0.4);
}

.btn-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(56, 189, 248, 0.6);
}

/* ================================
   タワーパネル
   ================================ */

.tower-panel {
    width: 280px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    padding: 15px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 100%;
}

.tower-panel h2 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 12px;
    text-align: center;
    color: var(--secondary);
    flex-shrink: 0;
}

.tower-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.tower-card {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: var(--bg-glass);
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    /* タッチ操作改善 */
    user-select: none;
    -webkit-user-select: none;
}

.tower-card:hover,
.tower-card:active {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.15);
    transform: translateX(5px);
}

.tower-card.selected {
    border-color: var(--secondary);
    background: rgba(240, 171, 252, 0.15);
    box-shadow: 0 0 20px rgba(240, 171, 252, 0.3);
}

.tower-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tower-icon {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border-radius: 8px;
    background: var(--bg-dark);
    flex-shrink: 0;
}

.tower-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tower-icon.basic {
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
}

.tower-icon.fire {
    box-shadow: 0 0 15px rgba(251, 113, 133, 0.5);
}

.tower-icon.ice {
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.5);
}

.tower-info h3 {
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.tower-info p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.tower-stats {
    display: flex;
    gap: 8px;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.tower-cost {
    margin-top: 5px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--secondary);
    font-weight: 700;
}

/* ================================
   コントロールボタン
   ================================ */

.controls {
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.controls-bottom {
    max-width: 1000px;
    margin: 20px auto;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.controls-bottom .btn-evolution,
.controls-bottom .btn-training,
.controls-bottom .btn-economy {
    width: auto;
    min-width: 180px;
    flex: 1;
    max-width: 250px;
}

.btn-training {
    width: 100%;
    padding: 15px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(167, 139, 250, 0.4);
}

.btn-training:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(167, 139, 250, 0.6);
}

.btn-economy {
    width: 100%;
    padding: 15px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(251, 191, 36, 0.4);
}

.btn-economy:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.6);
}

.btn-manual {
    width: 100%;
    padding: 15px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(56, 189, 248, 0.4);
}

.btn-manual:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.6);
}

.btn-reward {
    width: 100%;
    padding: 15px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(251, 191, 36, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

.btn-reward:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.6);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 5px 20px rgba(251, 191, 36, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 8px 30px rgba(251, 191, 36, 0.6);
    }
}

.btn-wave {
    width: 100%;
    padding: 15px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(34, 197, 94, 0.4);
}

.btn-wave:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.6);
}

/* ゲーム内ボタン */
.btn-wave-ingame,
.btn-reward-ingame,
.btn-speed-control {
    padding: 12px 20px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.btn-wave-ingame {
    background: linear-gradient(135deg, var(--success), #16a34a);
    min-width: 180px;
}

.btn-wave-ingame:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.6);
}

.btn-reward-ingame {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    animation: pulse-reward 2s ease-in-out infinite;
    min-width: 180px;
}

.btn-reward-ingame:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.6);
}

.btn-speed-control {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    min-width: 180px;
}

.btn-speed-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.btn-wave-ingame:disabled,
.btn-reward-ingame:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: none;
}

.btn-wave:disabled {
    background: #333;
    box-shadow: none;
    cursor: not-allowed;
}

/* ================================
   英才教育モーダル
   ================================ */

.training-modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 25, 41, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.training-modal.hidden {
    display: none;
}

.training-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    padding: 30px;
    max-width: 600px;
    width: 90%;
}

.training-content h2 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.training-content p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.9rem;
}

.training-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.training-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.training-item:hover {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.15);
}

.training-icon {
    font-size: 2.5rem;
    min-width: 60px;
    text-align: center;
}

.training-details {
    flex: 1;
}

.training-details h3 {
    font-size: 1rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.training-details p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: left;
}

.training-level {
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 600;
}

.btn-train {
    padding: 10px 25px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-train:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4);
}

.btn-train:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

/* 新しい一括教育UI用スタイル */
.training-summary {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.training-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-row {
    display: flex;
    gap: 15px;
}

.stat-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-glass);
    border-radius: 10px;
    border: 2px solid rgba(56, 189, 248, 0.2);
}

.stat-icon {
    font-size: 2rem;
}

.stat-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.training-action {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1));
    border-radius: 12px;
    border: 2px solid rgba(139, 92, 246, 0.3);
}

.training-description {
    text-align: center;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.btn-train-all {
    padding: 15px 30px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--secondary), #9333ea);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(139, 92, 246, 0.4);
}

.btn-train-all:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6);
}

.btn-train-all:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-close-training {
    width: 100%;
    padding: 12px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close-training:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(100, 116, 139, 0.4);
}

/* ================================
   内政モーダル
   ================================ */

.economy-modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 25, 41, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.economy-modal.hidden {
    display: none;
}

.economy-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    padding: 30px;
    max-width: 500px;
    width: 90%;
}

.economy-content h2 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-align: center;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.economy-content p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.9rem;
}

.economy-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.economy-info:hover {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
}

.economy-icon {
    font-size: 3rem;
    min-width: 70px;
    text-align: center;
}

.economy-details {
    flex: 1;
}

.economy-details h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.economy-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: left;
}

.economy-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.economy-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.economy-stat .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.economy-stat .stat-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fbbf24;
}

.economy-level {
    font-size: 0.75rem;
    color: #fbbf24;
    font-weight: 600;
}

.btn-invest {
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-invest:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4);
}

.btn-invest:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

.btn-close-economy {
    width: 100%;
    padding: 12px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close-economy:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(100, 116, 139, 0.4);
}

/* ================================
   進化モーダル
   ================================ */

.evolution-modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 25, 41, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.evolution-modal.hidden {
    display: none;
}

.evolution-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    padding: 30px;
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.evolution-content h2 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-align: center;
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
}

.evolution-content > p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.evolution-info {
    margin-bottom: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 10px;
}

/* スクロールバーのスタイル */
.evolution-info::-webkit-scrollbar {
    width: 8px;
}

.evolution-info::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.evolution-info::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.5);
    border-radius: 4px;
}

.evolution-info::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.7);
}

.evolution-level-display {
    text-align: center;
    padding: 15px;
    background: var(--bg-glass);
    border-radius: 12px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.evolution-level-display strong {
    color: #a78bfa;
    font-size: 1.3rem;
}

.evolution-details {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.evolution-stage {
    padding: 20px;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.evolution-stage.current {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.evolution-stage.next {
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
}

.evolution-stage.locked {
    opacity: 0.6;
}

.evolution-stage-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.evolution-stage-features {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.evolution-feature {
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.btn-evolve {
    width: 100%;
    padding: 15px;
    margin-bottom: 0;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-evolve:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(167, 139, 250, 0.4);
}

.btn-evolve:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

/* モーダル閉じるボタン（右上の✕ボタン） */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    background: rgba(100, 116, 139, 0.3);
    border: 2px solid rgba(100, 116, 139, 0.5);
    border-radius: 50%;
    color: #94a3b8;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
    transform: rotate(90deg);
}

.btn-evolution {
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    border: 2px solid #a78bfa;
}

.btn-evolution:hover {
    box-shadow: 0 5px 15px rgba(167, 139, 250, 0.4);
}

/* ================================
   タッチデバイス対応
   ================================ */

/* 全てのボタンにタッチ対応 */
[class^="btn-"]:active:not(:disabled),
[class*=" btn-"]:active:not(:disabled) {
    transform: scale(0.98);
    opacity: 0.9;
}

/* モバイルデバイスでのホバー効果を無効化 */
@media (hover: none) {
    .tower-card:hover,
    [class^="btn-"]:hover,
    [class*=" btn-"]:hover {
        transform: none;
    }

    .tower-card:active {
        transform: scale(0.98);
    }
}

/* ================================
   フッター
   ================================ */

.game-footer-compact {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 100;
    pointer-events: auto;
    display: flex;
    gap: 8px;
}

.shuffle-bgm-btn {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
}

.shuffle-bgm-btn:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.manual-link {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    text-decoration: none;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.manual-link:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* ================================
   アップデート情報モーダル
   ================================ */

.update-modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 25, 41, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 2000;
}

.update-modal.hidden {
    display: none;
}

.update-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    padding: 30px;
    max-width: 650px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.update-content h2 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 20px;
    text-align: center;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.update-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.update-section {
    padding: 20px;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 2px solid rgba(56, 189, 248, 0.3);
}

.update-section h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.update-section ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.update-section li {
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
    color: var(--text-secondary);
    line-height: 1.6;
}

.update-section li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.update-section li strong {
    color: var(--text-primary);
}

.btn-close-update {
    width: 100%;
    padding: 12px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close-update:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.4);
}

/* スクロールバーのスタイル */
.update-content::-webkit-scrollbar {
    width: 8px;
}

.update-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.update-content::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.5);
    border-radius: 4px;
}

.update-content::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.7);
}

/* ================================
   アニメーション
   ================================ */

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes bubble {
    0% {
        transform: translateY(100%) scale(0);
        opacity: 0;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        transform: translateY(-100vh) scale(1);
        opacity: 0;
    }
}

/* ================================
   レスポンシブ
   ================================ */

@media (max-width: 1100px) {
    .game-main {
        flex-direction: column;
    }

    .tower-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 15px;
    }

    .tower-panel h2 {
        width: 100%;
    }

    .tower-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .tower-card {
        flex: 1;
        min-width: 200px;
    }

    .controls {
        width: 100%;
        margin-top: 15px;
        padding-top: 0;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .game-header h1 {
        font-size: 1.3rem;
        text-align: center;
    }

    .stats {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .stat {
        flex: 1 1 calc(50% - 8px);
        min-width: 120px;
        padding: 8px;
        font-size: 0.85rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .game-main {
        flex-direction: column;
    }

    .game-board-wrapper {
        width: 100%;
        max-width: 100%;
    }

    #gameCanvas {
        width: 100% !important;
        height: auto !important;
        max-height: 60vh;
        aspect-ratio: 5 / 3;
    }

    .controls {
        width: 100%;
        margin-top: 15px;
    }

    .tower-selection {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tower-button {
        padding: 10px;
        font-size: 0.85rem;
    }

    .tower-icon {
        font-size: 1.5rem;
    }

    .tower-info {
        font-size: 0.7rem;
    }

    .action-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .btn {
        padding: 12px;
        font-size: 0.9rem;
    }

    /* モーダルのスマホ対応 */
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px;
    }

    .modal h2 {
        font-size: 1.3rem;
    }

    .upgrade-options {
        flex-direction: column;
    }

    .upgrade-option {
        padding: 15px;
    }

    /* タワー詳細モーダル */
    .tower-details h3 {
        font-size: 1.1rem;
    }

    .tower-stats {
        gap: 10px;
    }

    .tower-stat {
        padding: 8px;
        font-size: 0.85rem;
    }

    /* 英才教育モーダル */
    .training-stats {
        gap: 10px;
    }

    .stat-item {
        flex-direction: column;
        text-align: center;
        padding: 10px;
    }

    .btn-train-individual {
        width: 100%;
        padding: 10px;
        font-size: 0.85rem;
    }

    /* ゲームオーバーレイ */
    .overlay-content h2 {
        font-size: 1.5rem;
    }

    .overlay-content p {
        font-size: 0.9rem;
    }

    /* ボーナス選択 */
    .bonus-options {
        flex-direction: column;
        gap: 10px;
    }

    .bonus-option {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.1rem;
    }

    .stats {
        gap: 6px;
    }

    .stat {
        flex: 1 1 100%;
        min-width: 100%;
    }

    #gameCanvas {
        max-height: 50vh;
    }

    .tower-selection {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 15px;
    }

    .modal h2 {
        font-size: 1.1rem;
    }

    .btn {
        padding: 10px;
        font-size: 0.85rem;
    }
}

/* タッチデバイス用の調整 */
@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .tower-button:active,
    .upgrade-option:active,
    .bonus-option:active {
        transform: scale(0.95);
    }

    /* タッチ領域を広げる */
    .tower-button,
    .btn {
        min-height: 44px;
    }
}

/* 横向きモバイル対応 */
@media (max-width: 896px) and (orientation: landscape) {
    .game-container {
        padding: 10px;
    }

    .game-main {
        flex-direction: row;
    }

    #gameCanvas {
        max-height: 80vh;
    }

    .controls {
        width: 300px;
        margin-top: 0;
        margin-left: 15px;
    }

    .modal-content {
        max-height: 85vh;
    }
}

/* ================================
   スタート画面
   ================================ */
.start-screen {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
    /* タイトルロゴ入りのキービジュアル。画像全体を見せ、余白は黒幕（レターボックス） */
    background:
        linear-gradient(to bottom, rgba(5, 15, 35, 0) 55%, rgba(5, 15, 35, 0.7) 100%),
        url('assets/title-screen.jpg') center / contain no-repeat;
    background-color: #000;
}

/* ゆっくり立ちのぼる泡 */
.start-screen::before {
    content: '';
    position: absolute;
    inset: 0 0 -660px 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.25) 2px, transparent 3px),
        radial-gradient(circle, rgba(255, 255, 255, 0.15) 1.5px, transparent 2.5px);
    background-size: 220px 220px, 140px 140px;
    background-position: 30px 40px, 90px 110px;
    animation: bubblesRise 24s linear infinite;
}

@keyframes bubblesRise {
    to {
        transform: translateY(-660px);
    }
}

.start-screen-content {
    max-width: 800px;
    width: 100%;
    text-align: center;
    position: relative;
}

/* タイトルロゴは背景画像に含まれるため、ヒーロー画像と見出しは非表示
   （h1はSEO・スクリーンリーダー用に残す） */
.title-hero {
    display: none;
}

.start-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* 難易度選択 */
.difficulty-selection {
    margin-bottom: 20px;
}

.difficulty-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.difficulty-btn {
    flex: 1;
    max-width: 200px;
    padding: 18px 20px;
    background: rgba(8, 22, 42, 0.7);
    border: 3px solid rgba(56, 189, 248, 0.3);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.difficulty-btn:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 5px 20px rgba(56, 189, 248, 0.3);
}

.difficulty-btn.selected {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.25);
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.5);
    transform: scale(1.05);
}

.difficulty-label {
    font-size: 28px;
    font-weight: bold;
}

.difficulty-normal .difficulty-label {
    color: #22c55e;
}

.difficulty-hard .difficulty-label {
    color: #ef4444;
}

/* スタート画面のアクション */
.start-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.btn-start-game {
    width: 100%;
    max-width: 350px;
    padding: 20px 40px;
    font-size: 28px;
    font-weight: bold;
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    border: none;
    border-radius: 15px;
    color: white;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(56, 189, 248, 0.4);
    transition: all 0.3s ease;
}

.btn-start-game:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(56, 189, 248, 0.6);
}

.sub-buttons {
    display: flex;
    gap: 15px;
    width: 100%;
    max-width: 350px;
}

.btn-sub {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: bold;
    background: rgba(20, 50, 80, 0.6);
    border: 2px solid rgba(56, 189, 248, 0.3);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.btn-sub:hover {
    border-color: #38bdf8;
    box-shadow: 0 3px 10px rgba(56, 189, 248, 0.3);
    transform: translateY(-2px);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .difficulty-buttons {
        flex-direction: column;
    }

    .difficulty-btn {
        max-width: 100%;
    }
}