/* 一笔画游戏样式 */

* {
    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: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    max-width: 100%;
    height: auto;
    transition: all 0.3s ease;
}

#gameCanvas:active {
    transform: scale(0.995);
}

.canvas-tips {
    text-align: center;
    color: white;
    margin-top: 10px;
    font-size: 14px;
    opacity: 0.9;
    animation: tipBounce 2s ease-in-out infinite;
}

@keyframes tipBounce {
    0%, 100% { transform: translateY(0); opacity: 0.9; }
    50% { transform: translateY(-5px); opacity: 1; }
}

.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-undo {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-undo:hover:not(:disabled) {
    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-hint {
    background: linear-gradient(135deg, #ffa500 0%, #ff6347 100%);
    color: white;
}

.btn-hint:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 165, 0, 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); }
}

.btn-next {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-replay {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-replay:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 172, 254, 0.4);
}

.btn-close {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

.level-selector {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    transition: all 0.3s ease;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.level-selector:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.level-title {
    text-align: center;
    margin-bottom: 15px;
}

.level-title strong {
    color: #667eea;
    font-size: 16px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    justify-items: center;
}

.level-btn {
    width: 70px;
    height: 70px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.level-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
    border-color: #764ba2;
}

.level-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #ccc;
    color: #999;
}

.level-btn.locked {
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    border-color: #bbb;
    color: #999;
    opacity: 0.5;
    cursor: not-allowed;
}

.level-btn.locked:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.level-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #764ba2;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.level-btn.completed {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    border-color: #38f9d7;
    animation: completePulse 2s ease-in-out infinite;
}

@keyframes completePulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(67, 233, 123, 0.3); }
    50% { box-shadow: 0 6px 16px rgba(67, 233, 123, 0.6); }
}

.level-btn.completed::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 14px;
    font-weight: bold;
}

.level-difficulty {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
}

.game-instructions {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    animation: slideInLeft 0.5s ease-out;
    transition: all 0.3s ease;
}

.game-instructions:hover {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
    transform: translateX(3px);
}

@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;
}

.success-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;
}

.success-modal {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    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.5s ease-out;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

@keyframes modalPop {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.success-modal h2 {
    color: #667eea;
    font-size: 32px;
    margin-bottom: 20px;
}

.success-stars {
    font-size: 48px;
    margin: 20px 0;
    animation: starPulse 1s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.success-text {
    color: #666;
    font-size: 16px;
    margin: 15px 0;
}

.success-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.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;
}

.info-value.status-display {
    font-size: 18px;
}

/* Toast消息样式 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    padding: 14px 18px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    margin-bottom: 10px;
    min-width: 250px;
    max-width: 400px;
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 4px solid #667eea;
    pointer-events: auto;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.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: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    margin-top: 15px;
    border-top: 3px solid #667eea;
    transition: all 0.3s ease;
}

.keyboard-shortcuts:hover {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.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);
}

.info-card .info-value.updating {
    animation: countUp 0.3s ease-out;
}

@keyframes countUp {
    from { transform: scale(1.2); }
    to { transform: scale(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%;
        font-size: 13px;
        padding: 12px 14px;
    }
    
    #gameCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .success-modal {
        margin: 20px;
        padding: 30px 20px;
        max-width: calc(100% - 40px);
    }
    
    .keyboard-shortcuts {
        display: none;
    }
    
    .game-canvas-wrapper {
        padding: 10px;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
    }
    
    .level-btn {
        width: 60px;
        height: 60px;
        font-size: 16px;
    }
    
    .canvas-tips {
        font-size: 12px;
    }
}

@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;
    }
    
    .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;
    }
    
    .success-modal h2 {
        font-size: 24px;
    }
    
    .success-stars {
        font-size: 36px;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
    }
    
    .level-btn {
        width: 55px;
        height: 55px;
        font-size: 14px;
    }
    
    .canvas-tips {
        font-size: 11px;
        margin-top: 5px;
    }
    
    .game-canvas-wrapper {
        padding: 8px;
    }
}
