* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Montserrat", sans-serif;
}

body {
    font-family: "Montserrat", sans-serif;
    padding: 20px;
    background-color: #f0f0f0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    min-height: 100vh;
}

.log {
    background: #f4f4f4;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 280px;
    min-width: 280px;
    height: calc(100vh - 40px);
    overflow-y: auto;
    text-align: left;
}

.main-content {
    flex-grow: 1;
    text-align: center;
}

input,
button {
    padding: 10px;
    font-size: 16px;
    margin: 5px;
}

/* Side by Side Layout Containers */
.visualizer-layouts {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    width: 100%;
}

.tree-panel {
    flex: 1;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #ddd;
}

.tree-panel h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #555;
}

.tree-wrapper {
    position: relative;
    min-height: 400px;
    width: 100%;
}

.node {
    position: absolute;
    background-color: #4CAF50;
    color: white;
    border-radius: 50%;
    border: 1px solid #333;
    width: 40px;
    height: 40px;
    line-height: 38px;
    text-align: center;
    transition: all 0.5s ease;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

.balance-factor {
    position: absolute;
    top: -12px;
    right: -12px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    width: 20px;
    height: 20px;
    line-height: 20px;
    border-radius: 50%;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* ==========================================
   4. RULES MODAL SCREEN STYLES
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.modal-content-box {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px 0px 0px 0px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: left;
}

.modal-content-box h2 {
    color: #2c3e50;
    font-size: 24px;
    margin-bottom: 10px;
    text-align: center;
}

.modal-content-box hr {
    border: 0;
    height: 1px;
    background: #ddd;
    margin-bottom: 20px;
}

.rules-body h3 {
    color: #4CAF50;
    font-size: 16px;
    margin-top: 15px;
    margin-bottom: 5px;
}

.rules-body p,
.rules-body li {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

.rules-body ul {
    margin-left: 20px;
    margin-top: 5px;
}

.rules-body li {
    margin-bottom: 8px;
}

.formula-box {
    background-color: #f9f9f9;
    border-left: 4px solid #34495e;
    padding: 12px;
    margin: 15px 0;
    border-radius: 4px;
}

#close-rules-btn {
    display: block;
    width: 100%;
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 6px;
    margin-top: 25px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#close-rules-btn:hover {
    background-color: #45a049;
}