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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #fff;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-info {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.info-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.score-display {
    display: flex;
    gap: 20px;
    font-size: 1.2rem;
    font-weight: bold;
}

.player-score {
    color: #3b82f6;
}

.enemy-score {
    color: #ef4444;
}

.turn-display {
    font-size: 1.1rem;
    font-weight: bold;
    color: #4b5563;
}

.unit-info {
    border-top: 2px solid #e5e7eb;
    padding-top: 10px;
}

.unit-info h3 {
    font-size: 1rem;
    color: #4b5563;
    margin-bottom: 5px;
}

#selected-unit-info {
    color: #6b7280;
    font-size: 0.9rem;
}

#game-board {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 500px;
}

.hex-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hex-row {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.hex {
    width: 50px;
    height: 58px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.hex-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.hex-shape {
    width: 100%;
    height: 100%;
    background: #f3f4f6;
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: 2px solid #d1d5db;
    transition: all 0.2s;
}

.hex.selectable .hex-shape {
    background: #dbeafe;
    border-color: #60a5fa;
}

.hex.selectable:hover .hex-shape {
    background: #bfdbfe;
    transform: scale(1.1);
}

.hex.selected .hex-shape {
    background: #93c5fd;
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.hex.move-target .hex-shape {
    background: #fef3c7;
    border-color: #fbbf24;
    animation: pulse 1s infinite;
}

.hex.move-target:hover .hex-shape {
    background: #fde68a;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.hex-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.unit {
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.unit.player {
    color: #3b82f6;
}

.unit.enemy {
    color: #ef4444;
}

.unit-hp {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: bold;
}

.crystal {
    font-size: 1.3rem;
    animation: sparkle 2s infinite;
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        filter: brightness(1.5);
    }
}

.ability-indicator {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 0.7rem;
    background: rgba(147, 51, 234, 0.9);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.rules-content {
    text-align: left;
    color: #4b5563;
}

.rules-content h3 {
    color: #667eea;
    margin-top: 15px;
    margin-bottom: 10px;
}

.rules-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.rules-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.ability-buttons {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.ability-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
    background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%);
}

.ability-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

.ability-btn:disabled:hover {
    transform: none;
}

/* 戦闘ログ */
.battle-log {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 150px;
    overflow-y: auto;
}

.battle-log h3 {
    font-size: 1rem;
    color: #4b5563;
    margin-bottom: 10px;
}

.log-entry {
    padding: 5px 10px;
    margin-bottom: 5px;
    border-radius: 5px;
    font-size: 0.85rem;
    line-height: 1.4;
    border-left: 3px solid transparent;
    background: rgba(0, 0, 0, 0.02);
}

.log-entry.player {
    border-left-color: #3b82f6;
    color: #1e40af;
}

.log-entry.enemy {
    border-left-color: #ef4444;
    color: #991b1b;
}

.log-entry.system {
    border-left-color: #8b5cf6;
    color: #5b21b6;
}

.log-entry.crystal {
    border-left-color: #f59e0b;
    color: #92400e;
}

/* シールドエフェクト */
.unit.shielded::after {
    content: '🛡️';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.8rem;
    animation: shield-glow 1s infinite;
}

@keyframes shield-glow {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* 移動アニメーション */
@keyframes moveUnit {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.unit.moving {
    animation: moveUnit 0.5s ease-in-out;
}

/* 攻撃アニメーション */
@keyframes attackFlash {
    0%, 100% {
        filter: brightness(1);
    }
    25%, 75% {
        filter: brightness(2) drop-shadow(0 0 10px red);
    }
    50% {
        filter: brightness(1.5);
    }
}

.unit.attacking {
    animation: attackFlash 0.6s ease-in-out;
}

/* ダメージエフェクト */
@keyframes damageShake {
    0%, 100% {
        transform: translate(-50%, -50%);
    }
    25% {
        transform: translate(-48%, -50%);
    }
    75% {
        transform: translate(-52%, -50%);
    }
}

.unit.damaged {
    animation: damageShake 0.3s ease-in-out;
}

/* クリスタル取得エフェクト */
@keyframes crystalCollect {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(2) rotate(180deg);
        opacity: 0.5;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

.crystal.collecting {
    animation: crystalCollect 0.8s ease-out forwards;
}

/* ヘックスグリッドのグラデーション改善 */
.hex-shape {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.hex.selectable .hex-shape {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.hex.selected .hex-shape {
    background: linear-gradient(135deg, #93c5fd 0%, #60a5fa 100%);
}

.hex.move-target .hex-shape {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

/* 地形タイプ */
.hex.terrain-forest .hex-shape {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: #34d399;
}

.hex.terrain-mountain .hex-shape {
    background: linear-gradient(135deg, #e7e5e4 0%, #d6d3d1 100%);
    border-color: #78716c;
}

/* ターン切替アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.turn-display {
    animation: fadeIn 0.5s ease-out;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .game-info {
        padding: 10px;
    }

    .info-panel {
        flex-direction: column;
        gap: 10px;
    }

    .score-display {
        font-size: 1rem;
        gap: 15px;
    }

    .turn-display {
        font-size: 1rem;
    }

    .hex {
        width: 40px;
        height: 46px;
    }

    .hex-content {
        font-size: 0.8rem;
    }

    .unit {
        font-size: 1.2rem;
    }

    .unit-hp {
        font-size: 0.6rem;
        padding: 1px 3px;
    }

    .ability-indicator {
        font-size: 0.6rem;
        padding: 1px 3px;
    }

    .crystal {
        font-size: 1rem;
    }

    .battle-log {
        max-height: 120px;
        padding: 10px;
        font-size: 0.8rem;
    }

    .log-entry {
        font-size: 0.75rem;
        padding: 3px 6px;
    }

    button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .ability-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}
