/* City Life Game - 主样式文件 */

/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* 颜色变量 */
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --accent-color: #ff6b6b;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    
    /* 尺寸变量 */
    --header-height: 60px;
    --footer-height: 70px;
    --joystick-size: 120px;
    --button-size: 60px;
    
    /* 字体 */
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* ==================== 屏幕管理 ==================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.screen.active {
    display: flex;
}

/* ==================== 认证界面 ==================== */
#auth-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-container {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease-out;
}

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

.game-logo {
    text-align: center;
    margin-bottom: 30px;
}

.game-logo h1 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.game-logo p {
    color: #7f8c8d;
    font-size: 1.1em;
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    font-size: 1.1em;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tab-btn.active {
    color: var(--primary-color);
    font-weight: bold;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form input {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #ecf0f1;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.4);
}

.auth-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    display: none;
}

.auth-message.success {
    display: block;
    background: #d4edda;
    color: #155724;
}

.auth-message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
}

.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    gap: 10px;
}

#connection-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #95a5a6;
}

#connection-indicator.online {
    background: var(--success-color);
    animation: pulse 2s infinite;
}

#connection-indicator.offline {
    background: var(--danger-color);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ==================== 游戏界面 ==================== */
#game-screen {
    background: #34495e;
}

/* 顶部状态栏 */
.top-bar {
    height: var(--header-height);
    background: rgba(44, 62, 80, 0.95);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: white;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#player-name {
    font-weight: bold;
    font-size: 1.1em;
}

#player-level {
    background: var(--primary-color);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9em;
}

.player-stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-icon {
    font-size: 1.2em;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 10px;
}

/* 游戏画布容器 */
.game-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #2c3e50;
}

/* 移动控制 */
.movement-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 50;
}

.joystick-container {
    pointer-events: auto;
}

.joystick {
    width: var(--joystick-size);
    height: var(--joystick-size);
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    position: relative;
    backdrop-filter: blur(10px);
}

.joystick-knob {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.action-buttons {
    display: flex;
    gap: 15px;
    pointer-events: auto;
    align-items: flex-end;
}

.action-btn {
    width: var(--button-size);
    height: var(--button-size);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.5);
    font-size: 1.5em;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

/* 小地图 */
.minimap {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 150px;
    height: 150px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid white;
    border-radius: 10px;
    overflow: hidden;
    z-index: 50;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
}

/* 底部导航栏 */
.bottom-nav {
    height: var(--footer-height);
    background: rgba(44, 62, 80, 0.95);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.8em;
    cursor: pointer;
    padding: 10px;
    transition: all 0.3s;
    position: relative;
}

.nav-btn:active {
    transform: scale(0.9);
}

.nav-btn.active {
    color: var(--primary-color);
}

/* ==================== 侧边面板 ==================== */
.side-panel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 400px;
    height: 100%;
    background: white;
    z-index: 200;
    transition: left 0.3s ease-out;
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.side-panel.right {
    left: auto;
    right: -100%;
    transition: right 0.3s ease-out;
}

.side-panel.active {
    left: 0;
}

.side-panel.right.active {
    right: 0;
}

.panel-header {
    height: var(--header-height);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.panel-header h2 {
    font-size: 1.3em;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* ==================== 聊天面板 ==================== */
.chat-messages {
    height: calc(100% - 80px);
    overflow-y: auto;
    margin-bottom: 15px;
    -webkit-overflow-scrolling: touch;
}

.chat-message {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.chat-message .sender {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.chat-message .text {
    color: #2c3e50;
}

.chat-message .time {
    font-size: 0.8em;
    color: #95a5a6;
    text-align: right;
    margin-top: 5px;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 10px;
    font-size: 1em;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ==================== 库存面板 ==================== */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.inventory-item {
    aspect-ratio: 1;
    background: #f8f9fa;
    border: 2px solid #ecf0f1;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    padding: 10px;
}

.inventory-item:active {
    transform: scale(0.95);
    background: #ecf0f1;
}

.inventory-item .icon {
    font-size: 2em;
    margin-bottom: 5px;
}

.inventory-item .name {
    font-size: 0.8em;
    text-align: center;
    color: #2c3e50;
}

/* ==================== 社交面板 ==================== */
.social-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.social-tab {
    flex: 1;
    padding: 10px;
    background: #ecf0f1;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
}

.social-tab.active {
    background: var(--primary-color);
    color: white;
}

.social-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
}

.social-item .info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.social-item .avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.social-item .name {
    font-weight: bold;
    color: #2c3e50;
}

.social-item .status {
    font-size: 0.9em;
    color: #7f8c8d;
}

.social-item button {
    padding: 8px 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

/* ==================== 商店面板 ==================== */
.shop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
}

.shop-item .info {
    flex: 1;
}

.shop-item .name {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.shop-item .description {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.shop-item .price {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.1em;
}

.shop-item button {
    padding: 10px 20px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.shop-item button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* ==================== 通知 ==================== */
.notifications {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification.info {
    border-left: 4px solid var(--primary-color);
}

/* ==================== 加载屏幕 ==================== */
#loading-screen {
    background: rgba(44, 62, 80, 0.95);
    justify-content: center;
    align-items: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ecf0f1;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    :root {
        --header-height: 50px;
        --footer-height: 60px;
        --joystick-size: 100px;
        --button-size: 50px;
    }
    
    .game-logo h1 {
        font-size: 2em;
    }
    
    .auth-container {
        padding: 30px 20px;
    }
    
    .side-panel {
        width: 100%;
        max-width: none;
    }
    
    .inventory-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
