@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 で動的に設定 */
}

.debuff-display {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* クリックを透過 */
    z-index: 25;
}

/* 炎魔法のデバフアイコン - 左上 */
.debuff-icon-fire {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 20px;
    animation: debuffPulse 3s infinite;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    transition: transform 0.2s ease;
    opacity: 0.8;
    background: rgba(255, 68, 68, 0.3);
    padding: 6px 8px;
    border-radius: 15px;
    border: 1px solid rgba(255, 68, 68, 0.5);
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.4);
    backdrop-filter: blur(3px);
}

/* 土魔法のデバフアイコン - 右上 */
.debuff-icon-earth {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 20px;
    animation: debuffPulse 3s infinite;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    transition: transform 0.2s ease;
    opacity: 0.8;
    background: rgba(139, 69, 19, 0.3);
    padding: 6px 8px;
    border-radius: 15px;
    border: 1px solid rgba(218, 165, 32, 0.5);
    box-shadow: 0 0 8px rgba(139, 69, 19, 0.4);
    backdrop-filter: blur(3px);
}

/* 氷魔法のデバフアイコン - 右下 */
.debuff-icon-ice {
    position: absolute;
    bottom: 30px; /* より下に移動 */
    right: 15px; /* 右下に変更 */
    font-size: 20px;
    animation: debuffPulse 3s infinite;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    transition: transform 0.2s ease;
    opacity: 0.8;
    background: rgba(0, 191, 255, 0.3);
    padding: 6px 8px;
    border-radius: 15px;
    border: 1px solid rgba(0, 191, 255, 0.5);
    box-shadow: 0 0 8px rgba(0, 191, 255, 0.4);
    backdrop-filter: blur(3px);
}

.debuff-icon-fire:hover,
.debuff-icon-earth:hover, 
.debuff-icon-ice:hover {
    transform: scale(1.2);
}

@keyframes debuffPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.7; /* より控えめに */
    }
    50% {
        transform: scale(1.05); /* 小さなスケール変化 */
        opacity: 0.9;
    }
}

.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);
}

.title-screen {
    padding: 24px 16px;
    box-sizing: border-box;
    overflow-y: auto;
}

.title-screen > * { flex-shrink: 0; }

.battle-settings {
    width: min(420px, 100%);
    box-sizing: border-box;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.2);
    text-align: left;
}

.volume-label { display: flex; justify-content: space-between; font-size: 18px; font-weight: bold; }
#seVolume { width: 100%; height: 36px; margin: 10px 0; accent-color: #ffd700; cursor: pointer; }
.test-sound-btn {
    width: 100%;
    min-height: 50px;
    margin-bottom: 8px;
    padding: 12px 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    background: #315c99;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
}
.test-sound-btn:hover { background: #3d70b5; }
.test-sound-btn:active { background: #244675; }
.test-sound-btn:focus-visible { outline: 3px solid #ffd700; outline-offset: 3px; }
.title-screen .sound-preview-description { font-size: 13px; line-height: 1.6; margin: 0 0 20px; }
.difficulty-options { border: 0; padding: 0; margin: 0; min-width: 0; }
.difficulty-options legend { margin-bottom: 10px; font-size: 18px; font-weight: bold; }
.difficulty-buttons { display: flex; gap: 6px; }
.difficulty-buttons label { flex: 1; position: relative; cursor: pointer; }
.difficulty-buttons input { position: absolute; opacity: 0; }
.difficulty-buttons span {
    display: block;
    padding: 17px 2px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
}
.difficulty-buttons input:checked + span { background: #ffd700; border-color: #ffd700; color: #17294c; font-weight: bold; }
.difficulty-buttons input:focus-visible + span { outline: 3px solid white; outline-offset: 3px; }
.title-screen .difficulty-description { font-size: 13px; line-height: 1.6; margin: 12px 0 0; min-height: 3.2em; }

@media (max-height: 600px) {
    .title-screen { justify-content: flex-start; }
    .title-screen h1 { font-size: 28px; margin-bottom: 10px; }
    .title-screen > p { margin-bottom: 16px; }
    .battle-settings { padding: 14px; margin-bottom: 16px; }
}

.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 {
    width: min(86vw, 430px);
    min-height: 80px;
    padding: 16px 24px;
    border: 3px solid rgba(255,255,255,.95);
    border-radius: 19px;
    background: linear-gradient(135deg, #fff176 0%, #ffca28 46%, #ff8f00 100%);
    color: #351800;
    font-size: clamp(21px, 4.5vw, 29px);
    font-weight: 900;
    text-shadow: 0 1px 0 rgba(255,255,255,.65);
    box-shadow: 0 0 0 7px rgba(255,193,7,.2), 0 18px 42px rgba(0,0,0,.55), 0 0 34px rgba(255,213,79,.85);
    animation: cgButtonPulse 1.25s ease-in-out infinite;
}

.website-btn:hover { animation-play-state: paused; filter: brightness(1.08); }
.website-btn:focus-visible { outline: 4px solid #fff; outline-offset: 5px; }
@keyframes cgButtonPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.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;
}
