/* ========================================
   数学クエスト - RPG スタイル
   ======================================== */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --text-color: #ecf0f1;
    --hp-color: #27ae60;
    --mp-color: #3498db;
    --exp-color: #f39c12;
    --danger-color: #e74c3c;
    --border-color: #95a5a6;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'DotGothic16', 'Press Start 2P', monospace;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: var(--text-color);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

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

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ========================================
   タイトル画面
   ======================================== */

#title-screen {
    background: 
        linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600"><rect fill="%231a1a2e" width="800" height="600"/><circle cx="100" cy="100" r="50" fill="%233498db" opacity="0.1"/><circle cx="700" cy="150" r="80" fill="%239b59b6" opacity="0.1"/><circle cx="400" cy="500" r="60" fill="%232ecc71" opacity="0.1"/></svg>');
    background-size: cover;
    justify-content: center;
    align-items: center;
    animation: fadeIn 1s ease-in;
}

.title-content {
    text-align: center;
    animation: slideDown 1s ease-out;
}

.game-title {
    font-size: 3.5rem;
    color: #3498db;
    text-shadow: 
        4px 4px 0 #2c3e50,
        8px 8px 20px rgba(52, 152, 219, 0.5);
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.subtitle {
    font-size: 1.2rem;
    color: #ecf0f1;
    margin-bottom: 3rem;
    letter-spacing: 0.2rem;
}

.pixel-text {
    font-family: 'Press Start 2P', monospace;
}

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.menu-btn, .pixel-btn {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: var(--text-color);
    border: 3px solid var(--border-color);
    padding: 1rem 2rem;
    font-size: 1rem;
    font-family: 'DotGothic16', monospace;
    cursor: pointer;
    min-width: 300px;
    text-align: left;
    transition: all 0.2s;
    box-shadow: 4px 4px 0 var(--shadow-color);
    image-rendering: pixelated;
}

.menu-btn:hover, .pixel-btn:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow-color);
}

.menu-btn:active, .pixel-btn:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

/* ========================================
   ゲーム画面
   ======================================== */

#game-screen {
    flex-direction: column;
    padding: 0;
}

#status-bar {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border-bottom: 4px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.status-section {
    font-size: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.label {
    color: var(--accent-color);
    font-weight: bold;
}

#main-game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* ========================================
   マップビュー
   ======================================== */

#map-view {
    justify-content: center;
    align-items: center;
    background: #0f0f1e;
}

#map-canvas {
    border: 4px solid var(--border-color);
    image-rendering: pixelated;
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.3);
}

#map-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 0.5rem;
}

.control-row {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: var(--text-color);
    border: 3px solid var(--border-color);
    padding: 1rem;
    font-size: 1.2rem;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    width: 60px;
    height: 60px;
    transition: all 0.2s;
    box-shadow: 3px 3px 0 var(--shadow-color);
}

.control-btn:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
}

.control-btn:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

/* ========================================
   戦闘ビュー
   ======================================== */

#battle-view {
    background: linear-gradient(135deg, #2c3e50 0%, #1a1a2e 100%);
    justify-content: space-between;
    padding: 2rem;
    background-size: cover;
    background-position: center;
    position: relative;
}

#battle-view::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

#battle-view > * {
    position: relative;
    z-index: 2;
}

.battle-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 2rem;
}

.enemy-area, .player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.sprite {
    width: 250px;
    height: 250px;
    background-color: transparent;
    border: none;
    image-rendering: pixelated;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.5));
    animation: spriteFloat 3s ease-in-out infinite;
    position: relative;
    z-index: 10;
}

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

.enemy-status, .player-status {
    text-align: center;
    min-width: 250px;
}

.enemy-name, .player-name {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.hp-bar-container {
    background: var(--secondary-color);
    border: 3px solid var(--border-color);
    height: 30px;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.hp-bar {
    background: linear-gradient(90deg, var(--hp-color), #2ecc71);
    height: 100%;
    transition: width 0.5s ease;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.hp-text {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* 問題エリア */
#question-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(44, 62, 80, 0.98);
    border: 4px solid var(--accent-color);
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    box-shadow: 0 0 40px rgba(52, 152, 219, 0.5);
    z-index: 100;
}

#question-area.hidden {
    display: none;
}

.question-title {
    color: var(--accent-color);
    margin-bottom: 1rem;
    text-align: center;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.answer-btn {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: var(--text-color);
    border: 3px solid var(--border-color);
    padding: 1rem;
    font-size: 1rem;
    font-family: 'DotGothic16', monospace;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.answer-btn:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
    transform: translateX(5px);
}

.answer-btn.correct {
    background: linear-gradient(145deg, #27ae60, #229954);
    animation: correctAnswer 0.5s ease;
}

.answer-btn.incorrect {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    animation: shake 0.5s ease;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* メッセージボックス */
.message-box {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 4px solid var(--border-color);
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: 4px;
    min-height: 100px;
    display: flex;
    align-items: center;
}

#battle-text {
    font-size: 1.1rem;
    line-height: 1.6;
}

/* コマンドメニュー */
.command-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.command-btn {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: var(--text-color);
    border: 3px solid var(--border-color);
    padding: 1.5rem;
    font-size: 1rem;
    font-family: 'DotGothic16', monospace;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 3px 3px 0 var(--shadow-color);
}

.command-btn:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
    transform: translate(1px, 1px);
}

.command-btn:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

/* ========================================
   メニュービュー
   ======================================== */

#menu-view {
    justify-content: center;
    align-items: center;
    background: rgba(26, 26, 46, 0.95);
}

.menu-container {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 4px solid var(--border-color);
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    box-shadow: 0 0 40px var(--shadow-color);
}

.menu-title {
    color: var(--accent-color);
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 2rem;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.menu-item {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: var(--text-color);
    border: 3px solid var(--border-color);
    padding: 1.5rem;
    font-size: 1rem;
    font-family: 'DotGothic16', monospace;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 3px 3px 0 var(--shadow-color);
}

.menu-item:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .menu-btn, .pixel-btn {
        min-width: 250px;
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
    
    #map-canvas {
        width: 100%;
        height: auto;
    }
    
    .sprite {
        width: 150px;
        height: 150px;
    }
    
    .command-menu {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   ユーティリティクラス
   ======================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
