/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* 容器样式 */
.container {
    width: 100%;
    max-width: 400px;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 标题样式 */
.card h1 {
    text-align: center;
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 30px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input.error {
    border-color: #ff4757;
}

.error-message {
    color: #ff4757;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.error-message.show {
    display: block;
}

/* 按钮样式 */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 链接样式 */
.links {
    text-align: center;
    margin-top: 20px;
    color: #666;
    font-size: 14px;
}

.links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.links a:hover {
    text-decoration: underline;
}

/* 提示消息 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 15px 30px;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    z-index: 99999;
    transition: transform 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #2ed573;
}

.toast.error {
    background: #ff4757;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 游戏页面样式 */
.game-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 0.5rem;
}

.game-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 0.625rem;
    box-shadow: 0 0.625rem 2.5rem rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-display {
    text-align: right;
}

.score-label {
    font-size: 12px;
    color: #666;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.game-area {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-canvas {
    width: 100%;
    height: 400px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.game-placeholder {
    text-align: center;
    color: #666;
}

.game-placeholder i {
    font-size: 60px;
    margin-bottom: 15px;
    display: block;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.game-controls .btn {
    flex: 1;
}

.btn-secondary {
    background: #f1f2f6;
    color: #333;
}

.btn-secondary:hover {
    background: #dfe4ea;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #ff3838;
}

/* ========== 怪物战斗系统样式 ========== */

/* 战斗区域 */
.battle-section {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-top: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.battle-section h2 {
    text-align: center;
    color: #333;
    font-size: 20px;
    margin-bottom: 20px;
}

/* 怪物遭遇按钮 */
.encounter-btn {
    display: block;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.encounter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(238, 90, 36, 0.4);
}

.encounter-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 战斗场景 */
.battle-scene {
    display: none;
}

.battle-scene.active {
    display: block;
}

/* 怪物卡片 */
.monster-card {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
    position: relative;
    overflow: hidden;
}

.monster-card.boss {
    border: 2px solid #f1c40f;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.3);
}

.monster-card.boss::before {
    content: 'BOSS';
    position: absolute;
    top: 10px;
    right: -25px;
    background: #f1c40f;
    color: #333;
    padding: 3px 30px;
    font-size: 11px;
    font-weight: bold;
    transform: rotate(45deg);
}

.monster-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.monster-emoji {
    font-size: 50px;
    line-height: 1;
}

.monster-details h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.monster-level {
    font-size: 12px;
    color: #bdc3c7;
}

.monster-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.monster-stat {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
}

.monster-stat-label {
    font-size: 11px;
    color: #bdc3c7;
}

.monster-stat-value {
    font-size: 16px;
    font-weight: bold;
    color: #e74c3c;
}

/* 血条 */
.hp-bar-container {
    margin-bottom: 8px;
}

.hp-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
    color: #ecf0f1;
}

.hp-bar {
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}

.hp-bar-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.4s ease;
    position: relative;
}

.hp-bar-fill.high {
    background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.hp-bar-fill.medium {
    background: linear-gradient(90deg, #f39c12, #e67e22);
}

.hp-bar-fill.low {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    animation: hpPulse 0.8s ease-in-out infinite;
}

@keyframes hpPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 玩家状态 */
.player-battle-status {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    color: white;
}

.player-battle-status h4 {
    margin-bottom: 10px;
    font-size: 14px;
}

.player-hp-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
}

.player-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    border-radius: 6px;
    transition: width 0.4s ease;
}

.player-hp-fill.low {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    animation: hpPulse 0.8s ease-in-out infinite;
}

.player-battle-stats {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    font-size: 13px;
}

/* 战斗日志 */
.battle-log {
    background: #1a1a2e;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 15px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.8;
}

.battle-log p {
    color: #ecf0f1;
    margin: 0;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.battle-log p:last-child {
    border-bottom: none;
    color: #f1c40f;
}

.battle-log .damage-text {
    color: #e74c3c;
}

.battle-log .heal-text {
    color: #2ecc71;
}

.battle-log .reward-text {
    color: #f1c40f;
}

/* 战斗按钮组 */
.battle-actions {
    display: flex;
    gap: 10px;
}

.battle-actions .btn {
    flex: 1;
    padding: 12px;
    font-size: 15px;
}

.btn-attack {
    background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
    color: white !important;
}

.btn-attack:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4);
}

.btn-attack:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-flee {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d) !important;
    color: white !important;
}

.btn-flee:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(149, 165, 166, 0.4);
}

.btn-flee:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 战斗结果 */
.battle-result {
    text-align: center;
    padding: 20px;
    display: none;
}

.battle-result.active {
    display: block;
}

.battle-result h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

.battle-result.victory h3 {
    color: #f1c40f;
}

.battle-result.defeat h3 {
    color: #e74c3c;
}

.battle-result .reward-info {
    background: rgba(241, 196, 15, 0.1);
    border: 1px solid rgba(241, 196, 15, 0.3);
    border-radius: 10px;
    padding: 12px;
    margin: 15px 0;
    color: #333;
}

/* 攻击动画 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.4s ease;
}

@keyframes attackFlash {
    0% { filter: brightness(1); }
    50% { filter: brightness(2) saturate(0); }
    100% { filter: brightness(1); }
}

.attack-flash {
    animation: attackFlash 0.3s ease;
}

/* 伤害数字飘动 */
.damage-float {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #e74c3c;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.damage-float.heal {
    color: #2ecc71;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

/* 怪物技能标签 */
.monster-skills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.skill-tag {
    background: rgba(255, 255, 255, 0.15);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    color: #bdc3c7;
}

/* ========== 怪物精灵图样式 ========== */

.monster-sprite-container {
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.monster-sprite-container canvas {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.monster-sprite {
    width: 72px;
    height: 72px;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.monster-sprite.boss {
    width: 88px;
    height: 88px;
    animation: bossGlow 1.5s ease-in-out infinite;
}

@keyframes bossGlow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5)); }
    50% { filter: drop-shadow(0 0 16px rgba(255, 215, 0, 0.8)); }
}

/* ========== 地图卡片图片样式 ========== */

.map-card {
    position: relative;
    overflow: hidden;
    min-height: 110px;
}

.map-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    z-index: 0;
}

.map-card-overlay {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 10px;
}

.map-card-emoji {
    font-size: 28px;
    margin-bottom: 4px;
}

.map-card-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    margin-bottom: 2px;
}

.map-card .map-level {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.map-card.locked .map-card-bg {
    filter: grayscale(100%) brightness(0.5);
}

/* ========== 地图系统样式 ========== */

/* 地图选择区域 */
.map-section {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-top: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.map-section h2 {
    text-align: center;
    color: #333;
    font-size: 20px;
    margin-bottom: 20px;
}

/* 当前地图显示 */
.current-map {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
    text-align: center;
}

.current-map h3 {
    font-size: 24px;
    margin-bottom: 8px;
}

.current-map p {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 15px;
}

.current-map .map-type {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 15px;
}

.current-map .map-type.safe {
    background: #2ecc71;
}

.current-map .map-type.danger {
    background: #e74c3c;
}

.current-map .map-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.current-map .map-actions .btn {
    flex: none;
    width: auto;
    padding: 10px 25px;
}

/* 地图列表 */
.map-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.map-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.map-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.map-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f3ff, #e8ecff);
}

.map-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.map-card.locked:hover {
    transform: none;
    box-shadow: none;
}

.map-card .map-emoji {
    font-size: 36px;
    margin-bottom: 8px;
}

.map-card .map-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.map-card .map-level {
    font-size: 11px;
    color: #666;
}

.map-card .map-type-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.map-card .map-type-badge.safe {
    background: #2ecc71;
}

.map-card .map-type-badge.danger {
    background: #e74c3c;
}

.map-card .map-lock {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #999;
}

/* 进入地图按钮 */
.enter-map-btn {
    display: block;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.enter-map-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.enter-map-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 地图信息面板 */
.map-info-panel {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
}

.map-info-panel h4 {
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
}

.map-info-panel p {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.map-info-panel .map-rewards {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: #667eea;
}

/* ========== 战斗弹窗样式 ========== */

.battle-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.battle-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

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

.battle-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.battle-modal-content {
    position: relative;
    width: 95%;
    max-width: 440px;
    max-height: 90vh;
    background: white;
    border-radius: 20px;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.battle-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px 0;
}

.battle-modal-header h2 {
    font-size: 20px;
    color: #333;
    margin: 0;
}

.battle-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f2f6;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
}

.battle-modal-close:hover {
    background: #ff4757;
    color: white;
}

/* 弹窗内的战斗场景 */
.battle-modal-content .battle-scene {
    padding: 20px 25px 25px;
}

.battle-modal-content .battle-scene.active {
    display: block;
}

.battle-modal-content .battle-log {
    max-height: 150px;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .card {
        padding: 30px 20px;
    }
    
    .card h1 {
        font-size: 24px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .score-display {
        text-align: center;
    }
}
