/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 登录页样式 ========== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 32px;
    color: #667eea;
    margin-bottom: 10px;
}

.login-header p {
    color: #999;
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    background: #ffe0e0;
    color: #d32f2f;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    text-align: center;
}

/* ========== 头部导航 ========== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    animation: slideDown 0.5s ease;
    position: relative;
}

/* 列表页专用header */
.header-list {
    justify-content: flex-end;
}

.header-left {
    flex: 0 0 auto;
    min-width: 100px;
}

.header-right {
    flex: 0 0 auto;
    min-width: 100px;
}

.title {
    font-size: 24px;
    color: #667eea;
    font-weight: 700;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.add-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.back-btn {
    padding: 10px 20px;
    background: #f5f5f5;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.back-btn:hover {
    background: #e0e0e0;
}

/* ========== 游戏卡片网格 ========== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .game-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== 游戏卡片 ========== */
.game-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease;
    overflow: hidden;
    position: relative;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-content {
    margin-bottom: 15px;
}

.game-name {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    word-break: break-all;
}

.game-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #999;
}

.game-time, .game-plays {
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-actions {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.action-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
}

.action-btn:hover {
    background: #e9ecef;
    transform: scale(1.1);
}

.action-btn:active {
    transform: scale(0.95);
}

.play-btn:hover {
    background: #d4edda;
}

.copy-btn:hover {
    background: #cce5ff;
}

.edit-btn:hover {
    background: #fff3cd;
}

/* 删除按钮 */
.delete-btn-wrapper {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: #ff4757;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.delete-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 10px;
}

/* ========== 加载更多 ========== */
.load-more {
    text-align: center;
    padding: 20px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 18px;
}

/* ========== 表单样式 ========== */
.game-form {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-form .form-group {
    margin-bottom: 25px;
}

.game-form label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #555;
}

/* 代码区域头部 */
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.code-actions {
    display: flex;
    gap: 10px;
}

.code-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.code-btn:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-2px);
}

.code-btn:active {
    transform: translateY(0);
}

/* 代码输入框 */
#gameCode {
    width: 100%;
    min-height: 400px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.3s;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#gameCode:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#gameCode::placeholder {
    color: #999;
}

.required {
    color: #ff4757;
}

.game-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
}

.game-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.char-count, .code-size {
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* ========== 按钮样式 ========== */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #ff3838;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 弹窗样式 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 500px;
    width: 100%;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin-bottom: 10px;
    font-size: 16px;
}

.modal-tip {
    font-size: 13px;
    color: #999;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
    border-top: 1px solid #f0f0f0;
}

/* 预览弹窗 */
.preview-content {
    max-width: 90%;
    width: 1000px;
}

.preview-tip {
    background: #fff3cd;
    color: #856404;
    padding: 10px 20px;
    font-size: 14px;
    text-align: center;
}

.preview-wrapper {
    height: 600px;
    padding: 20px;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .preview-content {
        max-width: 100%;
    }
    
    .preview-wrapper {
        height: 400px;
    }
}

/* ========== 提示消息 ========== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: white;
    padding: 15px 30px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 15px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: #d4edda;
    color: #155724;
}

.toast.error {
    background: #f8d7da;
    color: #721c24;
}

/* ========== 动画 ========== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .header {
        padding: 15px;
    }
    
    .header-left {
        min-width: 80px;
    }
    
    .header-right {
        min-width: 80px;
    }
    
    .title {
        font-size: 20px;
    }
    
    .back-btn {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    .add-btn {
        width: 100%;
    }
    
    .game-name {
        font-size: 18px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .code-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .code-actions {
        width: 100%;
    }
    
    .code-btn {
        flex: 1;
        justify-content: center;
    }
}
