/* 自定义工具类 */
.button-primary {
    background-color: #4361ee;
    color: white;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-primary:hover {
    background-color: rgba(67, 97, 238, 0.9);
}

.button-primary:focus {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.5);
}

.button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-secondary {
    background-color: #e5e7eb;
    color: #1f2937;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-secondary:hover {
    background-color: #d1d5db;
}

.button-secondary:focus {
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.5);
}

.button-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-danger {
    background-color: #ef4444;
    color: white;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-danger:hover {
    background-color: #dc2626;
}

.button-danger:focus {
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.5);
}

.button-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 说明文字 */
.help-text {
    background: #eff6ff;
    border-left: 4px solid #4361ee;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: #1e40af;
    line-height: 1.5;
}

.help-text p {
    margin: 0;
}

/* 可视化区域 */
#ringViz {
    position: relative;
    min-height: 420px;
    overflow: hidden;
}

.viz-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#nodesLayer {
    z-index: 10;
}

#arrowsLayer {
    z-index: 5;
}

#pointersLayer {
    z-index: 20;
}

.ring-track {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 280px;
    border: 3px dashed #d1d5db;
    border-radius: 50%;
    pointer-events: none;
}

/* 节点 */
.node-wrapper {
    position: absolute;
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
    transition: all 0.5s ease;
    z-index: 10;
}

.node-box {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    background: linear-gradient(145deg, #60a5fa, #3b82f6);
    border: 3px solid #4361ee;
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.25);
    transition: all 0.4s ease;
}

.node-box.active {
    background: linear-gradient(145deg, #f72585, #d61c77);
    border-color: #b5179e;
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(247, 37, 133, 0.3);
}

.count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    background: #f59e0b;
    color: white;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    z-index: 15;
    animation: popIn 0.3s ease;
}

.node-box.eliminated {
    background: linear-gradient(145deg, #ef4444, #dc2626);
    border-color: #b91c1c;
    animation: eliminate 0.6s ease forwards;
    transition: none;
}

.node-box.visited {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    border-color: #b45309;
    transform: scale(1.08);
}

.node-box.survivor {
    background: linear-gradient(145deg, #2a9d8f, #21867a);
    border-color: #1d6f65;
    transform: scale(1.2);
    box-shadow: 0 0 0 8px rgba(42, 157, 143, 0.3);
}

/* 箭头 */
.arrow-line {
    position: absolute;
    height: 4px;
    background: linear-gradient(90deg, #4361ee 0%, #3a0ca3 100%);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    transform-origin: 0 50%;
    transition: opacity 0.35s ease;
    opacity: 1;
    z-index: 5;
}

.arrow-line.removing {
    opacity: 0 !important;
}

.arrow-line.skip {
    background: linear-gradient(90deg, #f72585 0%, #b5179e 100%);
    height: 5px;
    z-index: 6;
}

.arrow-line .fa-arrow-right {
    color: #3a0ca3;
    font-size: 16px;
    transform: translateX(4px);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.7));
}

.arrow-line.skip .fa-arrow-right {
    color: #f72585;
}

/* 指针 */
.pointer {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    z-index: 20;
    pointer-events: none;
}

.pointer i {
    font-size: 1.2rem;
    margin-bottom: -2px;
}

.pointer-current {
    color: #f72585;
}

.pointer-current i {
    filter: drop-shadow(0 0 3px rgba(247, 37, 133, 0.5));
}

.pointer-prev {
    color: #2a9d8f;
}

.pointer-prev i {
    filter: drop-shadow(0 0 3px rgba(42, 157, 143, 0.5));
}

/* 出列顺序轨道 */
.eliminated-track {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.eliminated-item {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(145deg, #f72585, #d61c77);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    animation: popIn 0.4s ease;
    box-shadow: 0 4px 8px rgba(247, 37, 133, 0.25);
}

.eliminated-arrow {
    color: #9ca3af;
    font-size: 14px;
}

/* 代码面板 */
.code-panel {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 12px;
    padding: 16px 20px;
    font-family: 'Consolas', 'Roboto Mono', monospace;
    font-size: 14px;
    overflow-x: auto;
    line-height: 1.6;
}

.code-line {
    padding: 2px 0;
    padding-left: 12px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-line.active {
    background: rgba(247, 37, 133, 0.2);
    border-left: 3px solid #f72585;
}

.code-kw { color: #c678dd; font-weight: bold; }
.code-fn { color: #61afef; }
.code-var { color: #e06c75; }
.code-num { color: #d19a66; }
.code-cmt { color: #5c6370; font-style: italic; }
.code-class { color: #4ec9b0; }
.code-self { color: #569cd6; }

/* 页脚 */
.page-footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    border-top: 1px solid #e1e4e8;
    font-size: 14px;
    background: #f9fafb;
}

.page-footer a {
    color: #4361ee;
    text-decoration: none;
}

.page-footer a:hover {
    text-decoration: underline;
}

/* 动画 */
@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes eliminate {
    0% { transform: scale(1.15); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
    100% { transform: scale(0); opacity: 0; }
}

/* 响应式 */
@media (max-width: 640px) {
    .ring-track {
        width: 220px;
        height: 220px;
    }
    .node-box {
        width: 48px;
        height: 48px;
        font-size: 14px;
    }
    .node-wrapper {
        width: 48px;
        height: 48px;
        margin-left: -24px;
        margin-top: -24px;
    }
}
