@keyframes sparkleEffect {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2) rotate(360deg);
        opacity: 0;
    }
}

@keyframes iceEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
        filter: blur(0px);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.9;
        filter: blur(2px);
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
        filter: blur(5px);
    }
}

@keyframes fireEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    25% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
    75% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.4;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

@keyframes healEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.8);
        opacity: 0;
    }
}* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

.game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-screen {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 500px;
    max-height: 730px;
    background: linear-gradient(45deg, #2c1810 0%, #1a0f08 100%);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

/* 横画面での中央寄せ */
@media (orientation: landscape) {
    .game-screen {
        aspect-ratio: 13/19;
        height: 90vh;
        width: auto;
    }
}

/* 縦画面での全画面表示 */
@media (orientation: portrait) {
    .game-screen {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }
}

.game-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.hud {
    background: rgba(0,0,0,0.8);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #8b4513;
}

.player-stats, .enemy-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hp-bar, .enemy-hp-bar {
    width: 120px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    width: 100%;
    transition: width 0.3s ease;
}

.enemy-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff8800, #ffaa00);
    width: 100%;
    transition: width 0.3s ease;
}

.hp-text, .enemy-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.battle-field {
    flex: 1;
    position: relative;
    overflow: hidden;
    /* 背景は JavaScript で動的に設定 */
}

.enemy-area {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.enemy {
    position: relative;
    text-align: center;
}



.enemy-damage {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
}

@keyframes enemyFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.magic-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
    color: #ffffff;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    z-index: 20;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.magic-info.show {
    opacity: 1;
}

#magicCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 5;
}

.magic-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.ui-panel {
    background: rgba(0,0,0,0.9);
    padding: 15px;
    border-top: 2px solid #8b4513;
}

.mode-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    padding: 10px 15px;
    background: rgba(255,255,255,0.2);
    color: #cccccc;
    border: 2px solid #8b4513;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: linear-gradient(45deg, #8b4513, #daa520);
    color: white;
    box-shadow: 0 0 10px rgba(218, 165, 32, 0.5);
}

.mode-btn:hover {
    transform: scale(1.05);
}

.mode-btn:active {
    transform: scale(0.95);
}

.spell-guide h3 {
    color: #ffd700;
    margin-bottom: 10px;
    text-align: center;
    font-size: 16px;
}

.debug-info {
    color: #ffb347;
    font-size: 14px;
    text-align: center;
    margin-bottom: 10px;
    padding: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    border: 1px solid #8b4513;
}

.spell-patterns {
display: grid;
grid-template-columns: 1fr;
gap: 5px;
    margin-bottom: 10px;
    }

.pattern {
    color: #cccccc;
    font-size: 10px;
    text-align: center;
    padding: 2px;
}

.clear-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(45deg, #ff4444, #ff6666);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.clear-btn:hover {
    transform: scale(1.05);
}

.clear-btn:active {
    transform: scale(0.95);
}

/* タイトル画面 */
.title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    color: white;
}

.title-screen h1 {
    font-size: 36px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    background: linear-gradient(45deg, #ffd700, #ffb347);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-screen p {
    font-size: 18px;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.start-btn {
    padding: 15px 30px;
    font-size: 18px;
    background: linear-gradient(45deg, #ff4444, #ff6666);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.start-btn:hover {
    transform: scale(1.1);
}

.start-btn:active {
    transform: scale(0.9);
}

/* ゲームクリア画面 */
.clear-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: none;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    color: white;
}

.clear-screen h1 {
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 10px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.6);
    padding: 15px 30px;
    border-radius: 15px;
    border: 3px solid #ffd700;
    box-shadow: 0 0 20px rgba(255,215,0,0.8);
}

.clear-screen p {
    font-size: 16px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 10px;
}

.clear-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.restart-btn, .website-btn {
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
    font-weight: bold;
}

.restart-btn {
    background: linear-gradient(45deg, #ff4444, #ff6666);
    color: white;
}

.website-btn {
    background: linear-gradient(45deg, #ffd700, #ffb347);
    color: #8b4513;
}

.restart-btn:hover, .website-btn:hover {
    transform: scale(1.1);
}

.restart-btn:active, .website-btn:active {
    transform: scale(0.9);
}

/* ゲームオーバー画面 */
.gameover-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #8b0000 0%, #dc143c 100%);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    color: white;
}

.gameover-screen h1 {
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.gameover-screen p {
    font-size: 16px;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* エフェクト */
.magic-effect {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: magicBlast 0.8s ease-out forwards;
}

@keyframes magicBlast {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.damage-number {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    animation: damageFloat 1s ease-out forwards;
}

@keyframes damageFloat {
    0% {
        transform: translateY(0px);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

@keyframes sparkleEffect {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2) rotate(360deg);
        opacity: 0;
    }
}

@keyframes iceEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
        filter: blur(0px);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.9;
        filter: blur(2px);
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
        filter: blur(5px);
    }
}

@keyframes fireEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    25% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
    75% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.4;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

@keyframes healEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.8);
        opacity: 0;
    }
}

/* タッチデバイス対応 */
@media (hover: none) and (pointer: coarse) {
    .clear-btn:hover, .start-btn:hover, .restart-btn:hover, .website-btn:hover {
        transform: none;
    }
    
    .clear-btn:active, .start-btn:active, .restart-btn:active, .website-btn:active {
        transform: scale(0.95);
    }
}

/* スマートフォン対応 */
@media (max-width: 480px) {
.title-screen h1 {
font-size: 28px;
}

.title-screen p {
font-size: 16px;
}

.clear-screen h1, .gameover-screen h1 {
font-size: 24px;
}

.spell-patterns {
grid-template-columns: 1fr;
gap: 3px;
}

.pattern {
font-size: 9px;
padding: 1px;
}
}

.hidden {
    display: none !important;
}