* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #2c3e50;
}

.repl {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.memory-container {
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1rem;
}

.stack-visualization {
    width: 100%;
}

#stack-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.heap-visualization {
    width: 100%;
}

#heap-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

#arrows-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.input-area {
    padding: 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

#code-input {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    resize: vertical;
    background: white;
}

#code-input:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}


.output-area {
    padding: 1rem;
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

#output {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    white-space: pre-wrap;
}

.error {
    color: #e53e3e;
}

.success {
    color: #38a169;
}

.stack-visualization {
    padding: 1rem;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.stack-visualization h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

#stack-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.stack-box {
    border: 2px solid #4a9eff;
    border-radius: 4px;
    padding: 0.5rem;
    min-width: 120px;
    background: white;
}

.stack-box-name {
    font-size: 0.9rem;
    color: #2c3e50;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.3rem;
}

.stack-box-value {
    font-size: 0.9rem;
    color: #4299e1;
}

.stack-box-value.heap-reference {
    color: #e53e3e;
}

.heap-visualization {
    padding: 1rem;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
}

.heap-visualization h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

#heap-container {
    position: relative;
    min-height: 60vh;
    padding: 2rem;
    margin-top: 2rem;
    width: 100%;
}

.heap-node {
    border-radius: 16px;
    background: #f8f9fa;
    border: 2px solid #805ad5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: absolute;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    min-width: 120px;
    min-height: 60px;
    cursor: move;
    user-select: none;
    z-index: 2;
}

.heap-node:hover {
    box-shadow: 0 0 0 2px rgba(128, 90, 213, 0.4);
}

.heap-node.dragging {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.memory-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1rem;
    overflow: hidden;
}

.memory-arrow {
    pointer-events: none;
    z-index: 1;
    position: absolute;
    height: 2px;
    background-color: #e53e3e;
}

.memory-arrow::after {
    content: '';
    position: absolute;
    right: -10px;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 12px solid #e53e3e;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.heap-node-content {
    font-size: 0.85rem;
    color: #2c3e50;
    text-align: center;
    overflow-wrap: break-word;
    max-width: 100%;
    max-height: 80px;
    overflow-y: auto;
}

.heap-reference {
    color: #805ad5;
    font-style: italic;
}
