/* 平衡小球游戏样式 */

* {
    scroll-behavior: smooth;
}

.game-container {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-canvas-wrapper {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.game-canvas-wrapper:hover {
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    animation: slideInUp 0.5s ease-out;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.info-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.info-value {
    font-size: 24px;
    font-weight: bold;
}

.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.game-btn {
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.game-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.game-btn:active::before {
    width: 300px;
    height: 300px;
}

.game-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-start {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-pause {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-pause:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

.btn-reset {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 172, 254, 0.4);
}

.btn-ai {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(67, 233, 123, 0.4);
}

.btn-ai.loading {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.difficulty-selector {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.difficulty-selector:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.difficulty-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.difficulty-btn {
    padding: 10px 25px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.difficulty-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.difficulty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.difficulty-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #764ba2;
}

.game-instructions {
    background: linear-gradient(to right, #f8f9fa 0%, #ffffff 100%);
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    animation: slideInLeft 0.5s ease-out;
    transition: all 0.3s ease;
}

.game-instructions:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateX(5px);
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.game-instructions h4 {
    color: #667eea;
    margin-top: 0;
    margin-bottom: 10px;
}

.game-instructions ul {
    margin: 10px 0;
    padding-left: 20px;
}

.game-instructions li {
    margin: 8px 0;
    line-height: 1.6;
}

.game-over-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.game-over-modal {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-modal h2 {
    color: #667eea;
    font-size: 32px;
    margin-bottom: 20px;
}

.game-over-modal .final-score {
    font-size: 48px;
    font-weight: bold;
    color: #764ba2;
    margin: 20px 0;
}

.ai-tips {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-top: 15px;
    box-shadow: 0 4px 12px rgba(67, 233, 123, 0.3);
    animation: slideInUp 0.4s ease-out;
}

.ai-tips h5 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
}

.ai-tips ul {
    margin: 5px 0;
    padding-left: 20px;
    text-align: left;
}

.ai-tips ul li {
    margin: 5px 0;
    line-height: 1.6;
}

.ai-tips-loading,
.ai-tips-error {
    margin: 0;
}

.ai-tips-error {
    color: #ffeb3b;
}

/* 难度选择器标题 */
.difficulty-title {
    text-align: center;
    margin-bottom: 10px;
}

.difficulty-title strong {
    color: #667eea;
    font-size: 16px;
}

/* 特殊字体大小 */
.info-value.status-display,
.info-value.difficulty-display {
    font-size: 18px;
}

/* 游戏结束弹窗文本 */
.game-over-text {
    color: #666;
    font-size: 16px;
    margin: 15px 0;
}

.game-over-actions {
    margin-top: 30px;
}

.game-over-actions .game-btn {
    margin-left: 10px;
}

.game-over-actions .game-btn:first-child {
    margin-left: 0;
}

/* Toast消息样式 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: white;
    padding: 14px 18px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    min-width: 250px;
    max-width: 400px;
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(8px);
    border-left: 4px solid #667eea;
    pointer-events: auto;
    font-size: 14px;
    font-weight: 600;
}

.toast.success {
    border-left-color: #43e97b;
}

.toast.error {
    border-left-color: #f5576c;
}

.toast.warning {
    border-left-color: #ffa500;
}

.toast.info {
    border-left-color: #4facfe;
}

@keyframes slideInRight {
    from { 
        opacity: 0; 
        transform: translateX(100px);
    }
    to { 
        opacity: 1; 
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    to { 
        opacity: 0; 
        transform: translateX(100px);
    }
}

.toast.removing {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* 键盘快捷键提示 */
.keyboard-shortcuts {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-top: 15px;
    border-top: 2px solid #667eea;
}

.keyboard-shortcuts h5 {
    color: #667eea;
    margin: 0 0 10px 0;
    font-size: 14px;
}

.shortcut-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
}

.shortcut-key {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 统计卡片增强 */
.info-card .info-value {
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: countUp 0.3s ease-out;
}

@keyframes countUp {
    from { transform: scale(1.2); }
    to { transform: scale(1); }
}

.info-card .info-value.updating {
    animation: countUp 0.3s ease-out;
}

/* Canvas容器增强 */
#gameCanvas {
    cursor: crosshair;
}

.game-canvas-wrapper::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 14px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.game-canvas-wrapper:hover::after {
    opacity: 0.5;
}

/* 得分里程碑提示 */
.milestone-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.5);
    z-index: 100;
    animation: milestonePop 0.6s ease-out;
    pointer-events: none;
}

@keyframes milestonePop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-info {
        grid-template-columns: 1fr 1fr;
    }
    
    .info-value {
        font-size: 20px;
    }
    
    .game-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
    
    #gameCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .game-over-modal {
        margin: 20px;
        padding: 30px 20px;
        max-width: calc(100% - 40px);
    }
    
    .keyboard-shortcuts {
        display: none;
    }
    
    .game-canvas-wrapper {
        padding: 10px;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 640px) {
    .game-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .info-value {
        font-size: 18px;
    }
    
    .game-btn {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .difficulty-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .game-instructions {
        padding: 15px;
    }
    
    .game-instructions h4 {
        font-size: 16px;
    }
    
    .game-instructions li {
        font-size: 14px;
    }
    
    .game-canvas-wrapper {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    #gameCanvas {
        border-radius: 6px;
    }
    
    .game-over-modal h2 {
        font-size: 24px;
    }
    
    .game-over-modal .final-score {
        font-size: 36px;
    }
}
