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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.8);
    color: #4a9eff;
}

/* ゲームヘッダー */
.game-header {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.info-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.label {
    font-size: 0.9em;
    color: #aaa;
}

.value {
    font-size: 1.5em;
    font-weight: bold;
    color: #4a9eff;
}

.value.coins {
    color: #ffd700;
}

.hp-bar-container {
    position: relative;
    width: 100%;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    overflow: hidden;
}

.hp-bar {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, #0f0, #0f0);
    transition: width 0.3s ease;
}

.hp-text {
    position: absolute;
    width: 100%;
    text-align: center;
    line-height: 30px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

/* メインゲームエリア */
.game-main {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
}

.canvas-container {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 10px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
}

.skill-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: background 0.3s ease;
}

.skill-effect.slow {
    background: rgba(100, 100, 255, 0.2);
}

.skill-effect.boost {
    background: rgba(255, 215, 0, 0.1);
}

/* サイドバー */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-section {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
}

.control-section h3 {
    margin-bottom: 10px;
    color: #4a9eff;
    font-size: 1.2em;
}

.control-section h4 {
    margin-bottom: 10px;
    color: #aaa;
    font-size: 1em;
}

/* タワーボタン */
.towers-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.tower-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tower-btn:hover:not(:disabled) {
    background: rgba(74, 158, 255, 0.2);
    border-color: #4a9eff;
    transform: translateY(-2px);
}

.tower-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tower-btn.selected {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
    box-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
}

.tower-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.tower-name {
    font-weight: bold;
    font-size: 0.9em;
}

.tower-cost {
    color: #ffd700;
    font-size: 0.9em;
}

.tower-cost::after {
    content: '💰';
    margin-left: 3px;
}

.tower-stats {
    font-size: 0.75em;
    color: #aaa;
}

/* スキルボタン */
.skills-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skill-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(160, 74, 255, 0.3);
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
    gap: 5px;
    align-items: center;
    position: relative;
}

.skill-btn:hover:not(:disabled) {
    background: rgba(160, 74, 255, 0.2);
    border-color: #a04aff;
    transform: translateX(5px);
}

.skill-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-icon {
    grid-row: 1 / 3;
    font-size: 2em;
    text-align: center;
}

.skill-name {
    font-weight: bold;
    font-size: 0.9em;
}

.skill-cooldown-bar {
    grid-column: 2;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.skill-cooldown-fill {
    height: 100%;
    background: linear-gradient(90deg, #a04aff, #4a9eff);
    width: 100%;
    transition: width 0.1s linear;
}

.skill-cooldown-text {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 0.75em;
    color: #aaa;
}

/* ウェーブコントロール */
.start-wave-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    font-weight: bold;
    background: linear-gradient(135deg, #0f0, #0a0);
    border: 2px solid #0f0;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-wave-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0f0, #0c0);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transform: scale(1.05);
}

.start-wave-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    border-color: #666;
    color: #666;
    cursor: not-allowed;
}

.wave-info {
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    font-size: 0.9em;
    color: #aaa;
    min-height: 40px;
}

/* 凡例 */
.legend {
    font-size: 0.9em;
}

.enemy-legend {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.enemy-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* メッセージ */
.messages {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 10px;
    min-height: 50px;
    font-size: 1.1em;
    text-align: center;
    color: #4a9eff;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border: 2px solid #4a9eff;
    border-radius: 10px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    color: #4a9eff;
    margin-bottom: 15px;
}

#towerModalBody {
    margin-bottom: 20px;
    line-height: 1.8;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upgrade-btn {
    background: rgba(0, 255, 0, 0.1);
    border-color: #0f0;
    color: #0f0;
}

.upgrade-btn:hover:not(:disabled) {
    background: rgba(0, 255, 0, 0.3);
}

.sell-btn {
    background: rgba(255, 165, 0, 0.1);
    border-color: #ffa500;
    color: #ffa500;
}

.sell-btn:hover {
    background: rgba(255, 165, 0, 0.3);
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: #aaa;
    color: #aaa;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* レスポンシブ */
@media (max-width: 1200px) {
    .game-main {
        grid-template-columns: 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .control-section {
        flex: 1;
        min-width: 250px;
    }
}
