/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-dark: #0a0e17;
    --bg-card: #141b2d;
    --bg-input: #1a2238;
    --border: #2a3a5c;
    --primary: #4a90d9;
    --primary-hover: #5ba0e9;
    --accent: #e8b830;
    --accent-hover: #f0c848;
    --text: #e0e0e0;
    --text-muted: #8892a4;
    --danger: #e74c3c;
    --success: #2ecc71;
    --red: #e74c3c;
    --blue: #3498db;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

.page { display: flex; }
.hidden { display: none !important; }

/* ─── Auth Page ───────────────────────────────────────── */
#auth-page {
    justify-content: center; align-items: center; min-height: 100vh;
    background: linear-gradient(135deg, #0a0e17 0%, #1a1a2e 50%, #16213e 100%);
}
.auth-container {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.game-title {
    text-align: center; font-size: 2rem; color: var(--accent); margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(232,184,48,0.3);
}
.tab-bar {
    display: flex; margin-bottom: 24px; border-radius: var(--radius);
    overflow: hidden; border: 1px solid var(--border);
}
.tab {
    flex: 1; padding: 10px; background: transparent; color: var(--text-muted);
    border: none; cursor: pointer; font-size: 0.95rem; transition: all 0.2s;
}
.tab.active { background: var(--primary); color: #fff; }
.tab:hover:not(.active) { background: var(--bg-input); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; color: var(--text-muted); }
.form-group input {
    padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 0.95rem; outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--primary); }

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-size: 0.9rem; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: #000; font-weight: 600; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-small {
    padding: 6px 14px; font-size: 0.8rem; background: transparent;
    color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius);
}
.btn-small:hover { background: var(--bg-input); color: var(--text); }

/* ─── Messages ────────────────────────────────────────── */
.message { margin-top: 16px; padding: 10px 14px; border-radius: var(--radius); font-size: 0.9rem; text-align: center; }
.message.error { background: rgba(231,76,60,0.15); color: var(--danger); border: 1px solid rgba(231,76,60,0.3); }
.message.success { background: rgba(46,204,113,0.15); color: var(--success); border: 1px solid rgba(46,204,113,0.3); }

/* ─── Top Bar ─────────────────────────────────────────── */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; background: var(--bg-card); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.top-bar h2 { color: var(--accent); font-size: 1.1rem; }
.user-info { display: flex; align-items: center; gap: 12px; }
#lobby-nickname { color: var(--primary); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   LOBBY PAGE
   ═══════════════════════════════════════════════════════════ */
#lobby-page { flex-direction: column; height: 100vh; }
.lobby-main {
    flex: 1; display: flex; gap: 0; overflow: hidden;
}

/* ─── Room List Panel ─────────────────────────────────── */
.lobby-rooms {
    flex: 1; display: flex; flex-direction: column; border-right: 1px solid var(--border);
}
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.panel-header h3 { font-size: 1rem; }
.panel-actions { display: flex; gap: 8px; }
.room-list { flex: 1; overflow-y: auto; padding: 12px; }
.empty-hint { color: var(--text-muted); text-align: center; padding: 40px 20px; }

.room-card {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 8px; transition: border-color 0.2s;
}
.room-card:hover { border-color: var(--primary); }
.room-card-info h4 { font-size: 0.95rem; margin-bottom: 4px; }
.room-card-info span { font-size: 0.8rem; color: var(--text-muted); }
.room-card-status { text-align: right; }
.room-card-status .player-count { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }

/* ─── Chat Panel ──────────────────────────────────────── */
.lobby-chat {
    width: 360px; display: flex; flex-direction: column; flex-shrink: 0;
}
.online-badge {
    font-size: 0.8rem; background: var(--success); color: #000;
    padding: 2px 10px; border-radius: 12px; font-weight: 600;
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 12px; font-size: 0.85rem;
}
.chat-msg { margin-bottom: 8px; line-height: 1.4; }
.chat-msg .chat-nick { font-weight: 600; color: var(--primary); }
.chat-msg.system { color: var(--text-muted); font-style: italic; }
.chat-input-area {
    display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border);
}
.chat-input-area input {
    flex: 1; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); outline: none; font-size: 0.85rem;
}
.chat-input-area input:focus { border-color: var(--primary); }
.chat-input-area .btn { padding: 8px 16px; }

/* ─── Modal ───────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex;
    justify-content: center; align-items: center; z-index: 100;
}
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 30px; width: 100%; max-width: 400px;
}
.modal-content h3 { margin-bottom: 20px; color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ═══════════════════════════════════════════════════════════
   ROOM PAGE
   ═══════════════════════════════════════════════════════════ */
#room-page { flex-direction: column; height: 100vh; }
.room-title-area { display: flex; align-items: center; gap: 12px; }
.room-title-area h3 { color: var(--text); font-size: 1rem; }
.room-main {
    flex: 1; display: flex; justify-content: center; align-items: flex-start;
    gap: 40px; padding: 24px; overflow-y: auto;
}
.team-panel {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 24px; min-width: 200px;
}
.team-panel h4 { margin-bottom: 12px; font-size: 1rem; }
.team-panel ul { list-style: none; }
.team-panel li {
    padding: 8px 0; font-size: 0.9rem; display: flex; align-items: center; gap: 8px;
}
.team-panel li .hero-badge {
    font-size: 0.75rem; padding: 2px 6px; border-radius: 4px;
    background: rgba(255,255,255,0.08); color: var(--text-muted);
}
.team-red { border-left: 3px solid var(--red); }
.team-blue { border-left: 3px solid var(--blue); }
.room-center-area { text-align: center; color: var(--text-muted); max-width: 420px; }
.room-status-text { margin-bottom: 4px; }
.room-hint { font-size: 0.8rem; margin-bottom: 20px; }

/* ── 英雄选择 ── */
#hero-select-area { margin-top: 12px; }
#hero-select-area h4 { color: var(--accent); margin-bottom: 12px; }
.hero-cards {
    display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.hero-card {
    width: 100px; padding: 12px 8px; background: var(--bg-card);
    border: 2px solid var(--border); border-radius: 10px; cursor: pointer;
    text-align: center; transition: all 0.2s;
}
.hero-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.hero-card.selected { border-color: var(--accent); box-shadow: 0 0 12px rgba(232,184,48,0.3); }
.hero-card .hero-avatar {
    width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff; font-weight: bold;
}
.hero-card .hero-card-name { font-size: 0.85rem; color: var(--text); }
.hero-card .hero-card-title { font-size: 0.7rem; color: var(--text-muted); }

/* 英雄详情面板 */
.hero-detail {
    margin-top: 16px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px; text-align: left;
}
.hero-detail h5 { color: var(--accent); margin-bottom: 10px; font-size: 1rem; }
.hero-stats-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
    font-size: 0.8rem; margin-bottom: 12px;
}
.hero-stats-grid .stat-label { color: var(--text-muted); }
.hero-stats-grid .stat-value { color: var(--text); font-weight: 600; }
.hero-skills-list { display: flex; flex-direction: column; gap: 8px; }
.hero-skill-item {
    background: rgba(0,0,0,0.2); padding: 8px 10px; border-radius: 6px;
}
.hero-skill-item .sk-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.hero-skill-item .sk-key {
    background: var(--primary); color: #fff; padding: 2px 8px;
    border-radius: 4px; font-weight: bold; font-size: 0.8rem;
}
.hero-skill-item .sk-name { font-weight: 600; font-size: 0.85rem; }
.hero-skill-item .sk-cd { font-size: 0.75rem; color: var(--text-muted); }
.hero-skill-item .sk-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

/* ═══════════════════════════════════════════════════════════
   GAME PAGE
   ═══════════════════════════════════════════════════════════ */
#game-page {
    flex-direction: column; height: 100vh; background: #0a0e17; position: relative;
}
.game-hud {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 20px; background: rgba(0,0,0,0.6); flex-shrink: 0; z-index: 10;
}
.hud-team { font-size: 1rem; font-weight: 600; }
.hud-red-text { color: var(--red); }
.hud-blue-text { color: var(--blue); }
.hud-center { color: var(--accent); font-size: 0.9rem; }

#game-canvas {
    flex: 1; display: block; width: 100%;
}

/* ── 技能栏 ── */
.skill-bar {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 8px; z-index: 20; pointer-events: none;
}
.skill-slot {
    width: 64px; height: 72px; background: rgba(20,27,45,0.85);
    border: 2px solid rgba(255,255,255,0.15); border-radius: 10px;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; position: relative; overflow: hidden;
    pointer-events: auto; cursor: pointer; transition: border-color 0.2s;
}
.skill-slot:hover { border-color: var(--primary); }
.skill-slot .skill-icon {
    font-size: 1.1rem; font-weight: bold; color: #fff; z-index: 2;
}
.skill-slot .skill-name {
    font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; z-index: 2;
}
.skill-slot .skill-cd-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.6); height: 0%; transition: height 0.1s;
    z-index: 1;
}
.skill-slot .skill-cd-text {
    position: absolute; top: 4px; right: 4px; font-size: 0.7rem;
    color: var(--accent); font-weight: bold; z-index: 3;
}
.skill-slot.on-cd { border-color: rgba(255,255,255,0.05); }
.skill-slot.on-cd .skill-icon { opacity: 0.4; }
.skill-slot.buff-active {
    border-color: #ffb347;
    box-shadow: 0 0 8px rgba(255,179,71,0.6), inset 0 0 6px rgba(255,179,71,0.15);
    animation: buff-pulse 1.2s ease-in-out infinite;
}
.skill-slot.buff-active .skill-cd-text { color: #ffeb3b; }
@keyframes buff-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(255,179,71,0.4); }
    50%      { box-shadow: 0 0 14px rgba(255,179,71,0.7); }
}
.attack-slot { border-color: rgba(231,76,60,0.4); }

/* ─── Game Over Overlay ───────────────────────────────── */
.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex;
    justify-content: center; align-items: center; z-index: 200;
}
.overlay-box {
    background: var(--bg-card); border: 2px solid var(--accent); border-radius: 16px;
    padding: 40px 60px; text-align: center;
}
.overlay-box h2 { font-size: 2rem; margin-bottom: 20px; }

/* ─── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
