body {
    font-family: Arial, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 20px;
}
.container {
    max-width: 1100px;
    margin: 20px auto;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
h1 {
    text-align: center;
    color: #343a40;
    margin-bottom: 10px;
}
.description {
    text-align: center;
    color: #6c757d;
    margin-bottom: 30px;
    font-size: 1.1em;
}
.simulation-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    gap: 15px;
    flex-wrap: wrap;
}
.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.control-btn {
    padding: 8px 18px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    transition: background-color 0.3s;
}
.control-btn:hover { background-color: #0056b3; }
#reset-btn { background-color: #dc3545; }
#reset-btn:hover { background-color: #c82333; }
select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}
.simulation-area {
    position: relative;
    padding: 20px;
    background-color: #fdfdfd;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    min-height: 500px;
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 20px;
}
.network {
    border: 2px solid #6c757d;
    border-radius: 8px;
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.network-a { background-color: #ffecec; grid-area: 1 / 1 / 2 / 2; }
.network-b { background-color: #ecffec; grid-area: 1 / 2 / 2 / 3; }
.network-c { background-color: #ececff; grid-area: 2 / 1 / 3 / 2; }
.internet { 
    background-color: #f8f9fa; 
    grid-area: 2 / 2 / 3 / 3;
    border: 2px solid #6c757d;
    border-radius: 8px;
    padding: 15px;
    position: relative;
}
.network-title, .internet-title {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #343a40;
    text-align: center;
}
.host, .internet-host {
    background-color: white;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 10px;
    width: 150px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.host-title {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.95em;
    color: #495057;
}
.host-ip, .host-gw {
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 3px;
}
.router {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #e9ecef;
    border: 2px solid #495057;
    border-radius: 10px;
    padding: 15px;
    width: 380px; /* 从280px增加到350px */
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.router-title {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #343a40;
    text-align: center;
}
.router-interfaces {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}
.interface {
    background-color: white;
    border: 1px solid #adb5bd;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 0.85em;
    text-align: center;
    width: 110px;
}
.if-name {
    font-weight: bold;
    color: #495057;
    margin-bottom: 3px;
}
.if-ip {
    color: #6c757d;
}
.table-title {
    font-weight: bold;
    font-size: 0.95em;
    margin-bottom: 5px;
    color: #495057;
    text-align: center;
}
.routing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    table-layout: fixed; /* 添加固定表格布局 */
}

.routing-table th, .routing-table td {
    border: 1px solid #adb5bd;
    padding: 4px 6px;
    text-align: center;
    word-wrap: break-word; /* 允许长文本换行 */
    overflow: hidden; /* 防止内容溢出 */
}
.routing-table th {
    background-color: #dee2e6;
    color: #343a40;
}
.routing-table tr:nth-child(even) {
    background-color: #f8f9fa;
}
.packet {
    position: absolute;
    width: 40px;
    height: 25px;
    background-color: #ffc107;
    border: 2px solid #e0a800;
    border-radius: 6px;
    color: #343a40;
    font-weight: bold;
    font-size: 0.9em;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    text-align: center;
    line-height: 25px;
}
.info-panel, .explanation-card {
    margin-top: 30px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
}
.panel-title, .card-title {
    font-weight: bold;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
    font-size: 1.1em;
    color: #495057;
}
.panel-content, .card-content {
    color: #6c757d;
    font-size: 1em;
}
.panel-content p {
    margin: 5px 0;
}
.card-content ul {
    padding-left: 20px;
    margin: 0;
}
.card-content li {
    margin-bottom: 10px;
}
.card-content strong {
    color: #343a40;
}
.highlight {
    background-color: #fff3cd;
    transition: background-color 0.5s;
}
@media (max-width: 992px) {
    .simulation-area {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, auto);
        min-height: 800px;
    }
    .network-a { grid-area: 1 / 1 / 2 / 2; }
    .network-b { grid-area: 2 / 1 / 3 / 2; }
    .network-c { grid-area: 3 / 1 / 4 / 2; }
    .internet { grid-area: 4 / 1 / 5 / 2; }
    .router {
        position: static;
        transform: none;
        margin: 20px auto;
        grid-area: 5 / 1 / 6 / 2;
    }
}
.network-b, .internet {
    display: flex;
    flex-direction: column;
    align-items: flex-end;  /* 使子元素靠右对齐 */
}

.network-b .network-title, .internet .internet-title {
    width: 100%;  /* 标题仍然居中 */
    text-align: center;
}